Skip to content

Commit

Permalink
WIP: GzSplit
Browse files Browse the repository at this point in the history
Signed-off-by: Addisu Z. Taddese <[email protected]>
  • Loading branch information
azeey committed Aug 9, 2024
1 parent 96d791a commit 872ea46
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 181 deletions.
51 changes: 32 additions & 19 deletions include/gz/gui/qml/GzCard.qml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import "qrc:/gz/gui/qml"

// TODO: don't use "parent"
Pane {
clip: true
/**
* Minimum length of each dimension
*/
Expand Down Expand Up @@ -157,6 +158,8 @@ Pane {
*/
objectName: "plugin" + Math.floor(Math.random() * 100000);

anchors.fill: parent

// Stop scroll propagation to widgets below
MouseArea {
anchors.fill: parent
Expand All @@ -173,9 +176,9 @@ Pane {
return;

// Bind anchors
anchors.fill = Qt.binding(function() {return parent})
parent.height = Qt.binding(function() {return height})
parent.width = Qt.binding(function() {return width})
// anchors.fill = Qt.binding(function() {return parent})
// parent.height = Qt.binding(function() {return height})
// parent.width = Qt.binding(function() {return width})

// Keep a reference to the background
// TODO(louise) This feels hacky, the card shouldn't care about the background,
Expand All @@ -195,16 +198,16 @@ Pane {
* any knowledge of splits
*/
function syncTheFamily() {
var parentSplit = helpers.ancestorByName(cardPane, /^split_item/);

if (undefined == parentSplit)
return;

if (content.children.length != 1)
return;

parentSplit.Layout.minimumWidth = content.children[0].Layout.minimumWidth;
parentSplit.Layout.minimumHeight = content.children[0].Layout.minimumHeight;
// var parentSplit = helpers.ancestorByName(cardPane, /^split_item/);
//
// if (undefined == parentSplit)
// return;
//
// if (content.children.length != 1)
// return;
//
// parentSplit.Layout.minimumWidth = content.children[0].Layout.minimumWidth;
// parentSplit.Layout.minimumHeight = content.children[0].Layout.minimumHeight;
}

/**
Expand Down Expand Up @@ -415,7 +418,7 @@ Pane {
{
const collapsed = cardPane.parent.Layout.minimumHeight === 50;
// Reparent to main window's background
cardPane.parent = backgroundItem
cardPane.parent = backgroundItem.contentChildren[0]

// Resize to minimum size
cardPane.clearAnchors();
Expand Down Expand Up @@ -449,7 +452,7 @@ Pane {
*/
function recalculateSplitSizes()
{
backgroundItem.recalculateMinimumSizes();
// backgroundItem.recalculateMinimumSizes();
}

// TODO(louise): re-enable window state support
Expand Down Expand Up @@ -669,21 +672,31 @@ Pane {
Rectangle {
objectName: "content"
id: content
// anchors.horizontalCenter: parent.horizontalCenter

anchors.fill: parent
anchors.topMargin: cardPane.showTitleBar ? 50 : 0
// height: 100
// implicitHeight: 123
clip: true
color: cardBackground

onChildrenChanged: {
// Set the height and width of the cardPane when child plugin is attached
// if (children.length > 0) {
// cardMinimumWidth = content.children[0].Layout.minimumWidth;
// cardMinimumHeight = content.children[0].Layout.minimumHeight;
// cardPane.width = cardMinimumWidth
// cardPane.height = cardMinimumHeight
// }
//
// cardPane.syncTheFamily()
if (children.length > 0) {
cardMinimumWidth = content.children[0].Layout.minimumWidth;
cardMinimumHeight = content.children[0].Layout.minimumHeight;
cardPane.width = cardMinimumWidth
cardPane.height = cardMinimumHeight
cardPane.Layout.minimumWidth = cardMinimumWidth
cardPane.Layout.minimumHeight = cardMinimumHeight
}

cardPane.syncTheFamily()
}

/**
Expand Down
9 changes: 9 additions & 0 deletions include/gz/gui/qml/GzHelpers.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import QtQuick

Item {
visible: false
/**
* Helper function to get an item's ancestor by name.
* @param _item Item whose parent we're looking for.
Expand Down Expand Up @@ -56,4 +57,12 @@ Item {

return 4
}
function dump(object, indent, depth) {
console.log(indent + object)
if (depth > 0) {
for (const i in object.children)
dump(object.children[i], indent + " ", depth - 1)
}
}

}
Loading

0 comments on commit 872ea46

Please sign in to comment.