From 8bde51ba29aa23d1b6e01826b6af720b4256bd78 Mon Sep 17 00:00:00 2001 From: Jasper Ras Date: Thu, 24 Jul 2025 21:24:53 +0200 Subject: quickshell --- Item Size Position.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Item Size Position.md (limited to 'Item Size Position.md') diff --git a/Item Size Position.md b/Item Size Position.md new file mode 100644 index 0000000..2479688 --- /dev/null +++ b/Item Size Position.md @@ -0,0 +1,40 @@ +[[Quickshell]] + +--- + +# Item Size Position + +`Item` type is the base type for "visual items". It has two properties: +- actual size ( width, height ) +- implicit/desired size ( implicitWidth, implicitHeight ) + +Implicit size is used by containers to determine their own. + +## Container items + +Container (ie. `Item`): +```qml +implicitWidth: child.implicitWidth + margin * 2 +implicitHeight: child.implicitHeight + margin * 2 +``` + +^ `WrapperItem` does this margin for us. + +Child (ie. `Rectangle`): +```qml +x: parent.margin +y: parent.margin +width: parent.width - parent.margin * 2 +height: parent.height - parent.margin * 2 +implicitWidth: 50 +implicitHeight: 50 +``` +[Binding](https://doc.qt.io/qt-6/qml-qtqml-binding.html) can be used to map any property +[Anchors](https://doc.qt.io/qt-6/qtquick-positioning-anchors.html) are a shorthand way to achieve many common position and size bindings. + +Using a containers' Item.childrenRect to determine size of children is a mistake. +Item.childrenRect represents the actual geometry of all child items, not the mplicit one. + +Use [MarginWrapperManager](https://quickshell.org/docs/types/Quickshell.Widgets/MarginWrapperManager) to handle size and position of container and a single child item. + +## Layouts -- cgit v1.2.3