summaryrefslogtreecommitdiff
path: root/Item Size Position.md
diff options
context:
space:
mode:
Diffstat (limited to 'Item Size Position.md')
-rw-r--r--Item Size Position.md40
1 files changed, 40 insertions, 0 deletions
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