Skip to content

Commit

Permalink
Improve the node graph with revamped top bar and disabling tools when…
Browse files Browse the repository at this point in the history
… graph is open (#2093)

* Add "Fade Artwork" slider and disable tools when graph is open

* Add navigation and layer/node management buttons to graph top bar

* Reduce code duplication
  • Loading branch information
Keavon authored Nov 4, 2024
1 parent 12ca060 commit f1b0d8f
Show file tree
Hide file tree
Showing 19 changed files with 479 additions and 284 deletions.
9 changes: 6 additions & 3 deletions editor/src/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,11 @@ impl Dispatcher {
Message::Portfolio(message) => {
let ipp = &self.message_handlers.input_preprocessor_message_handler;
let preferences = &self.message_handlers.preferences_message_handler;
let current_tool = &self.message_handlers.tool_message_handler.tool_state.tool_data.active_tool_type;

self.message_handlers
.portfolio_message_handler
.process_message(message, &mut queue, PortfolioMessageData { ipp, preferences });
.process_message(message, &mut queue, PortfolioMessageData { ipp, preferences, current_tool });
}
Message::Preferences(message) => {
self.message_handlers.preferences_message_handler.process_message(message, &mut queue, ());
Expand Down Expand Up @@ -244,8 +245,10 @@ impl Dispatcher {
list.extend(self.message_handlers.input_preprocessor_message_handler.actions());
list.extend(self.message_handlers.key_mapping_message_handler.actions());
list.extend(self.message_handlers.debug_message_handler.actions());
if self.message_handlers.portfolio_message_handler.active_document().is_some() {
list.extend(self.message_handlers.tool_message_handler.actions());
if let Some(document) = self.message_handlers.portfolio_message_handler.active_document() {
if !document.graph_view_overlay_open {
list.extend(self.message_handlers.tool_message_handler.actions());
}
}
list.extend(self.message_handlers.portfolio_message_handler.actions());
list
Expand Down
9 changes: 6 additions & 3 deletions editor/src/messages/frontend/frontend_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ pub enum FrontendMessage {
#[serde(rename = "isDefault")]
is_default: bool,
},
TriggerGraphViewOverlay {
open: bool,
},
TriggerImport,
TriggerIndexedDbRemoveDocument {
#[serde(rename = "documentId")]
Expand Down Expand Up @@ -153,6 +150,9 @@ pub enum FrontendMessage {
#[serde(rename = "clickTargets")]
click_targets: Option<FrontendClickTargets>,
},
UpdateGraphViewOverlay {
open: bool,
},
UpdateLayerWidths {
#[serde(rename = "layerWidths")]
layer_widths: HashMap<NodeId, u32>,
Expand Down Expand Up @@ -221,6 +221,9 @@ pub enum FrontendMessage {
#[serde(rename = "setColorChoice")]
set_color_choice: Option<String>,
},
UpdateGraphFadeArtwork {
percentage: f64,
},
UpdateInputHints {
#[serde(rename = "hintData")]
hint_data: HintData,
Expand Down
3 changes: 3 additions & 0 deletions editor/src/messages/input_mapper/input_mappings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub fn input_mappings() -> Mapping {
//
// Hack to prevent Left Click + Accel + Z combo (this effectively blocks you from making a double undo with AbortTransaction)
entry!(KeyDown(KeyZ); modifiers=[Accel, MouseLeft], action_dispatch=DocumentMessage::Noop),
//
// NodeGraphMessage
entry!(KeyDown(MouseLeft); action_dispatch=NodeGraphMessage::PointerDown {shift_click: false, control_click: false, alt_click: false, right_click: false}),
entry!(KeyDown(MouseLeft); modifiers=[Shift], action_dispatch=NodeGraphMessage::PointerDown {shift_click: true, control_click: false, alt_click: false, right_click: false}),
Expand All @@ -69,6 +70,8 @@ pub fn input_mappings() -> Mapping {
entry!(KeyDown(KeyX); modifiers=[Accel], action_dispatch=NodeGraphMessage::Cut),
entry!(KeyDown(KeyC); modifiers=[Accel], action_dispatch=NodeGraphMessage::Copy),
entry!(KeyDown(KeyD); modifiers=[Accel], action_dispatch=NodeGraphMessage::DuplicateSelectedNodes),
entry!(KeyDown(KeyH); modifiers=[Accel], action_dispatch=NodeGraphMessage::ToggleSelectedVisibility),
entry!(KeyDown(KeyL); modifiers=[Accel], action_dispatch=NodeGraphMessage::ToggleSelectedLocked),
entry!(KeyDown(KeyL); modifiers=[Alt], action_dispatch=NodeGraphMessage::ToggleSelectedAsLayersOrNodes),
entry!(KeyDown(KeyC); modifiers=[Shift], action_dispatch=NodeGraphMessage::PrintSelectedNodeCoordinates),
entry!(KeyDown(KeyC); modifiers=[Alt], action_dispatch=NodeGraphMessage::SendClickTargets),
Expand Down
3 changes: 3 additions & 0 deletions editor/src/messages/portfolio/document/document_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ pub enum DocumentMessage {
SetBlendModeForSelectedLayers {
blend_mode: BlendMode,
},
SetGraphFadeArtwork {
percentage: f64,
},
SetNodePinned {
node_id: NodeId,
pinned: bool,
Expand Down
Loading

0 comments on commit f1b0d8f

Please sign in to comment.