Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions meshroom/ui/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,20 @@ def selectFollowing(self, node):
""" Select all the nodes the depend on 'node'. """
self.selectNodes(self._graph.dfsOnDiscover(startNodes=[node], reverse=True, dependenciesOnly=True)[0])

@Slot(str)
def setSelectedNodesColor(self, color: str):
""" Sets the Provided color on the selected Nodes.

Args:
color (str): Hex code of the color to be set on the nodes.
"""
# Update the color attribute of the nodes which are currently selected
with self.groupedGraphModification("Set Nodes Color"):
# For each of the selected nodes -> Check if the node has a color -> Apply the color if it has
for node in self._selectedNodes:
if node.hasInternalAttribute("color"):
self.setAttribute(node.internalAttribute("color"), color)

@Slot(QObject, QObject)
def boxSelect(self, selection, draggable):
"""
Expand Down
133 changes: 133 additions & 0 deletions meshroom/ui/qml/Controls/ColorSelector.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
import QtQuick
import QtQuick.Controls

import Utils 1.0
import MaterialIcons 2.2

/**
* ColorSelector is a color picker based on a set of predefined colors.
* It takes the form of a ToolButton that pops-up its palette when pressed.
*/
MaterialToolButton {
id: root

text: MaterialIcons.palette

// Internal property holding when the popup remains visible and when is it toggled off
property var isVisible: false

property var colors: [
"#E35C03",
"#FFAD7D",
"#D0AE22",
"#C9C770",
"#3D6953",
"#79C62F",
"#02627E",
"#2CB9CC",
"#1453E6",
"#507DD0",
"#4D3E5C",
"#A252BD",
"#B61518",
"#C16162",
]

// When a color gets selected/choosen
signal colorSelected(var color)

// Toggles the visibility of the popup
onPressed: toggle()

function toggle() {
/*
* Toggles the visibility of the color palette.
*/
if (!isVisible) {
palettePopup.open()
isVisible = true
}
else {
palettePopup.close()
isVisible = false
}
}

// Popup for the color palette
Popup {
id: palettePopup

// The popup will not get closed unless explicitly closed
closePolicy: Popup.NoAutoClose

// Bounds
padding: 4
width: (root.height * 4) + (padding * 4)

// center the current color
y: -height
x: -width + root.width + padding

// Layout of the Colors
Grid {
// Allow only 4 columns and all the colors can be adjusted in row multiples of 4
columns: 4

spacing: 2
anchors.centerIn: parent

// Default -- Reset Colour button
ToolButton {
id: defaultButton
padding: 0
width: root.height
height: root.height

// Emit no color so the graph sets None as the color of the Node
onClicked: {
root.colorSelected("")
}

background: Rectangle {
color: "#FFFFFF"
// display border of current/selected item
border.width: defaultButton.hovered ? 1 : 0
border.color: "#000000"

// Another Rectangle
Rectangle {
color: "#FF0000"
width: parent.width + 8
height: 2
anchors.centerIn: parent
rotation: 135 // Diagonally creating a Red line from bottom left to top right
}
}
}

// Colors palette
Repeater {
model: root.colors
// display each color as a ToolButton with a custom background
delegate: ToolButton {
padding: 0
width: root.height
height: root.height

// Emit the model data as the color to update
onClicked: {
colorSelected(modelData)
}

// Model color as the background of the button
background: Rectangle {
color: modelData
// display border of current/selected item
border.width: hovered ? 1 : 0
border.color: "#000000"
}
}
}
}
}
}
1 change: 1 addition & 0 deletions meshroom/ui/qml/Controls/qmldir
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Controls

ColorChart 1.0 ColorChart.qml
ColorSelector 1.0 ColorSelector.qml
ExpandableGroup 1.0 ExpandableGroup.qml
FloatingPane 1.0 FloatingPane.qml
Group 1.0 Group.qml
Expand Down
20 changes: 20 additions & 0 deletions meshroom/ui/qml/GraphEditor/GraphEditor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ Item {
Keys.onPressed: function(event) {
if (event.key === Qt.Key_F) {
fit()
} else if (event.key === Qt.Key_C) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This takes precedence over the copy shortcut (Ctrl+C).
We need better handling of keyboard shortcuts, but in the meantime, this should either test if no modifier are active, or be moved at after the copy action handling.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's my bad, I did not notice something as simple as this. Have updated the code to consider both cases.

colorSelector.toggle()
} else if (event.key === Qt.Key_Delete) {
if (event.modifiers === Qt.AltModifier) {
uigraph.removeNodesFrom(uigraph.selectedNodes)
Expand Down Expand Up @@ -1048,6 +1050,24 @@ Item {
}
}
}

// Separator
Rectangle {
Layout.fillHeight: true
Layout.margins: 2
implicitWidth: 1
color: activePalette.window
}

ColorSelector {
id: colorSelector
Layout.minimumWidth: colorSelector.width

// When a Color is selected
onColorSelected: (color)=> {
uigraph.setSelectedNodesColor(color)
}
}
}
}

Expand Down