Skip to content

Commit

Permalink
#238 Test new group header layout + new group dnd policy... WIP.
Browse files Browse the repository at this point in the history
Signed-off-by: cneben <benoit@destrat.io>
  • Loading branch information
cneben committed Aug 11, 2024
1 parent c0a19f2 commit af33391
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 74 deletions.
18 changes: 9 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ add_subdirectory(src)

option(QUICK_QANAVA_BUILD_SAMPLES "Build QuickQanava samples" OFF)
if (${QUICK_QANAVA_BUILD_SAMPLES})
add_subdirectory(samples/advanced)
add_subdirectory(samples/connector)
add_subdirectory(samples/cpp)
add_subdirectory(samples/dataflow)
add_subdirectory(samples/edges)
#add_subdirectory(samples/advanced)
#add_subdirectory(samples/connector)
#add_subdirectory(samples/cpp)
#add_subdirectory(samples/dataflow)
#add_subdirectory(samples/edges)
add_subdirectory(samples/groups)
add_subdirectory(samples/navigable)
#add_subdirectory(samples/navigable)
add_subdirectory(samples/nodes)
add_subdirectory(samples/selection)
add_subdirectory(samples/style)
add_subdirectory(samples/topology)
#add_subdirectory(samples/selection)
#add_subdirectory(samples/style)
#add_subdirectory(samples/topology)
endif()
141 changes: 76 additions & 65 deletions src/RectGroupTemplate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -70,80 +70,91 @@ Item {

RectGradientBackground { // Node background and shadow with backOpacity and backRadius support
id: groupBackground
anchors.fill: content // Note 20160328: Do not set as content child to avoid interferring
//anchors.fill: content // Note 20160328: Do not set as content child to avoid interferring
anchors.fill: parent
style: template.groupItem ? template.groupItem.style: undefined // with content.childrenRect
visible: !groupItem.collapsed
}
Item {
id: content

ColumnLayout {
anchors.fill: parent
z: 3
visible: !groupItem.collapsed
enabled: !groupItem.collapsed
}
RowLayout {
id: headerLayout
x: 0
y: -2 - Math.max(collapser.height, // Shift header by the size of collapser button or the label
groupLabel.contentHeight, labelEditor.height) // height (for large font size) plus 2px margin
z: 2
width: content.width; height: collapser.height
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
spacing: 0
ToolButton {
id: collapser
padding: 0
Layout.preferredWidth: 32
Layout.preferredHeight: 32
text: groupItem ? (groupItem.collapsed ? "+" : "-") : "-"
font.pixelSize: 13
font.bold: true
onClicked: groupItem.collapsed = !groupItem.collapsed
}
Item {
id: labelEditorControl
clip: false
RowLayout {
id: headerLayout
Layout.fillWidth: true
Layout.fillHeight: true
property int fontPointSize : groupItem.style.fontPointSize // Do not set pointSize for -1 value
onFontPointSizeChanged: {
if (fontPointSize != -1)
labelEditor.pixelSize = fontPointSize
groupLabel.font.pointSize = fontPointSize
Layout.fillHeight: false
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
// x: 0
// y: -2 - Math.max(collapser.height, // Shift header by the size of collapser button or the label
// groupLabel.contentHeight, labelEditor.height) // height (for large font size) plus 2px margin
// z: 2
//width: content.width; height: collapser.height
//Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
spacing: 0
ToolButton {
id: collapser
padding: 0
Layout.preferredWidth: 32
Layout.preferredHeight: 32
text: groupItem ? (groupItem.collapsed ? "+" : "-") : "-"
font.pixelSize: 13
font.bold: true
onClicked: groupItem.collapsed = !groupItem.collapsed
}
LabelEditor {
Item {
id: labelEditorControl
clip: false
id: labelEditor
anchors.top: parent.top; anchors.left: parent.left; anchors.right: parent.right
target: groupItem && groupItem.group ? groupItem.group : undefined
visible: false
bold: groupItem.style.fontBold
}
Label {
id: groupLabel
anchors.fill: parent
text: groupItem &&
groupItem.group ? groupItem.group.label :
" "
visible: !labelEditor.visible
verticalAlignment: Text.AlignVCenter
font.bold: groupItem.style.fontBold
color: groupItem &&
groupItem.style &&
groupItem.style.labelColor ? groupItem.style.labelColor : "black"
elide: Text.ElideRight
MouseArea {
Layout.fillWidth: true
Layout.fillHeight: true
property int fontPointSize : groupItem.style.fontPointSize // Do not set pointSize for -1 value
onFontPointSizeChanged: {
if (fontPointSize != -1)
labelEditor.pixelSize = fontPointSize
groupLabel.font.pointSize = fontPointSize
}
LabelEditor {
clip: false
id: labelEditor
anchors.top: parent.top; anchors.left: parent.left; anchors.right: parent.right
target: groupItem && groupItem.group ? groupItem.group : undefined
visible: false
bold: groupItem.style.fontBold
}
Label {
id: groupLabel
anchors.fill: parent
enabled: !groupItem.group.isProtected &&
!groupItem.group.locked // Do not allow dragging of locked groups
preventStealing: true
propagateComposedEvents: true // Ensure event are forwarded to collapserArea
drag.target: groupItem.draggable ? groupItem : null
onDoubleClicked: labelEditor.visible = true
text: groupItem &&
groupItem.group ? groupItem.group.label :
" "
visible: !labelEditor.visible
verticalAlignment: Text.AlignVCenter
font.bold: groupItem.style.fontBold
color: groupItem &&
groupItem.style &&
groupItem.style.labelColor ? groupItem.style.labelColor : "black"
elide: Text.ElideRight
MouseArea {
anchors.fill: parent
enabled: !groupItem.group.isProtected &&
!groupItem.group.locked // Do not allow dragging of locked groups
preventStealing: true
propagateComposedEvents: true // Ensure event are forwarded to collapserArea
drag.target: groupItem.draggable ? groupItem : null
onDoubleClicked: labelEditor.visible = true
}
}
}
} // labelEditor Item
} // RowLayout: collapser + label
} // labelEditor Item
} // RowLayout: collapser + label
Item {
id: content
Layout.fillWidth: true
Layout.fillHeight: true
//anchors.fill: parent
z: 3
visible: !groupItem.collapsed
enabled: !groupItem.collapsed
}
}


// Emitted by qan::GroupItem when node dragging start
function onNodeDragEnter() { /*groupBackground.backColor = Qt.binding( function() { return Qt.darker( template.groupItem.style.backColor, 1.05 ) } ) */}
Expand Down

0 comments on commit af33391

Please sign in to comment.