Skip to content

Commit db64642

Browse files
committed
widgets/wrapper: add WrapperMouseArea
1 parent 7a60ef7 commit db64642

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

src/widgets/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ qt_add_qml_module(quickshell-widgets
1111
IconImage.qml
1212
ClippingRectangle.qml
1313
WrapperItem.qml
14+
WrapperMouseArea.qml
1415
WrapperRectangle.qml
1516
ClippingWrapperRectangle.qml
1617
)

src/widgets/WrapperMouseArea.qml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import QtQuick
2+
3+
///! MouseArea wrapper item.
4+
/// This component is useful for wrapping a single component in
5+
/// a mouse area. It works the same as @@WrapperItem, but with a @@QtQuick.MouseArea.
6+
///
7+
/// > [!NOTE] WrapperMouseArea is a @@MarginWrapperManager based component.
8+
/// > See its documentation for information on how margins and sizes are calculated.
9+
///
10+
/// > [!NOTE] The child item can be specified by writing it inline in the wrapper,
11+
/// > as in the example above, or by using the @@child property. See
12+
/// > @@WrapperManager.child for details.
13+
///
14+
/// > [!WARNING] You should not set @@Item.x, @@Item.y, @@Item.width,
15+
/// > @@Item.height or @@Item.anchors on the child item, as they are used
16+
/// > by WrapperItem to position it. Instead set @@Item.implicitWidth and
17+
/// > @@Item.implicitHeight.
18+
///
19+
/// [QtQuick.Layouts]: https://doc.qt.io/qt-6/qtquicklayouts-index.html
20+
MouseArea {
21+
/// The default for @@topMargin, @@bottomMargin, @@leftMargin and @@rightMargin.
22+
/// Defaults to 0.
23+
property /*real*/alias margin: manager.margin
24+
/// An extra margin applied in addition to @@topMargin, @@bottomMargin,
25+
/// @@leftMargin, and @@rightMargin. Defaults to 0.
26+
property /*real*/alias extraMargin: manager.extraMargin
27+
/// The requested top margin of the content item, not counting @@extraMargin.
28+
///
29+
/// Defaults to @@margin, and may be reset by assigning `undefined`.
30+
property /*real*/alias topMargin: manager.topMargin
31+
/// The requested bottom margin of the content item, not counting @@extraMargin.
32+
///
33+
/// Defaults to @@margin, and may be reset by assigning `undefined`.
34+
property /*real*/alias bottomMargin: manager.bottomMargin
35+
/// The requested left margin of the content item, not counting @@extraMargin.
36+
///
37+
/// Defaults to @@margin, and may be reset by assigning `undefined`.
38+
property /*real*/alias leftMargin: manager.leftMargin
39+
/// The requested right margin of the content item, not counting @@extraMargin.
40+
///
41+
/// Defaults to @@margin, and may be reset by assigning `undefined`.
42+
property /*real*/alias rightMargin: manager.rightMargin
43+
/// Determines if child item should be resized larger than its implicit size if
44+
/// the parent is resized larger than its implicit size. Defaults to false.
45+
property /*bool*/alias resizeChild: manager.resizeChild
46+
/// See @@WrapperManager.child for details.
47+
property /*Item*/alias child: manager.child
48+
49+
MarginWrapperManager { id: manager }
50+
}

src/widgets/module.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ qml_files = [
1010
"IconImage.qml",
1111
"ClippingRectangle.qml",
1212
"WrapperItem.qml",
13+
"WrapperMouseArea.qml",
1314
"WrapperRectangle.qml",
1415
"ClippingWrapperRectangle.qml",
1516
]

0 commit comments

Comments
 (0)