-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[ui] Graph Editor Update: Quick Node Coloring with the Color Selector Tool #2604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
58a9b74
[core] Coloring a Node: Exposed the Node Color to be set externally
waaake d77b7a3
[ui] Coloring a Node: Added ColorSelector to the Graph Editor
waaake 418bd63
[ui] ColorSelector: Update the color palette with darker shades
waaake 233bbb7
[ui] Graph: Updating the way how color gets set on the selected nodes
waaake 225f4dc
[ui] Color Selector Shortcut Fix: Fixed the shortcut clash with node …
waaake File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.