mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-05 22:48:11 +08:00
Migrate node graph UI interaction from frontend to backend (#1768)
* Click node using click targets based * Display graph transform based on state stored in Rust, fix zoom and pan. * Migrate node selection logic * Move click targets and transform to NodeNetwork * Keep click targets in sync with changes to node shape * Click targets for import/export, add dragging * Basic wire dragging * complete wire dragging * Add node selection box when dragging * Fix zoom operations and dragging nodes * Remove click targets from serialized data, fix EnterNestedNetwork * WIP: Auto connect node when dragged on wire * Finish auto connect node when dragged on wire * Add context menus * Improve layer width calculations and state * Improve context menu state, various other improvements * Close menu on escape * Cleanup Graph.svelte * Fix lock/hide tool tip shortcuts * Clean up editor_api.rs, fix lock/hide layers * Start transferring network and node metadata from NodeNetwork to the editor * Transfer click targets to NodeGraphMessageHandler * Fix infinite canvas * Fix undo/redo, scrollbars, and fix warnings * Unicode-3.0 license and code cleanup * License fix * formatting issue * Enable DomRect * Fix layer move crash * Remove tests * Ignore test * formatting * remove white dot --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
co-authored by
Keavon Chambers
parent
cf01f522a8
commit
02360c7bc8
@@ -6,20 +6,26 @@ use crate::messages::prelude::*;
|
||||
pub struct MenuBarMessageData {
|
||||
pub has_active_document: bool,
|
||||
pub rulers_visible: bool,
|
||||
pub node_graph_open: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct MenuBarMessageHandler {
|
||||
has_active_document: bool,
|
||||
rulers_visible: bool,
|
||||
node_graph_open: bool,
|
||||
}
|
||||
|
||||
impl MessageHandler<MenuBarMessage, MenuBarMessageData> for MenuBarMessageHandler {
|
||||
fn process_message(&mut self, message: MenuBarMessage, responses: &mut VecDeque<Message>, data: MenuBarMessageData) {
|
||||
let MenuBarMessageData { has_active_document, rulers_visible } = data;
|
||||
|
||||
let MenuBarMessageData {
|
||||
has_active_document,
|
||||
rulers_visible,
|
||||
node_graph_open,
|
||||
} = data;
|
||||
self.has_active_document = has_active_document;
|
||||
self.rulers_visible = rulers_visible;
|
||||
self.node_graph_open = node_graph_open;
|
||||
|
||||
match message {
|
||||
MenuBarMessage::SendLayout => self.send_layout(responses, LayoutTarget::MenuBar),
|
||||
@@ -34,6 +40,7 @@ impl MessageHandler<MenuBarMessage, MenuBarMessageData> for MenuBarMessageHandle
|
||||
impl LayoutHolder for MenuBarMessageHandler {
|
||||
fn layout(&self) -> Layout {
|
||||
let no_active_document = !self.has_active_document;
|
||||
let node_graph_open = self.node_graph_open;
|
||||
|
||||
let menu_bar_entries = vec![
|
||||
MenuBarEntry {
|
||||
@@ -271,14 +278,14 @@ impl LayoutHolder for MenuBarMessageHandler {
|
||||
label: "Tilt".into(),
|
||||
shortcut: action_keys!(NavigationMessageDiscriminant::BeginCanvasTilt),
|
||||
action: MenuBarEntry::create_action(|_| NavigationMessage::BeginCanvasTilt { was_dispatched_from_menu: true }.into()),
|
||||
disabled: no_active_document,
|
||||
disabled: no_active_document || node_graph_open,
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
MenuBarEntry {
|
||||
label: "Reset Tilt".into(),
|
||||
shortcut: action_keys!(NavigationMessageDiscriminant::CanvasTiltSet),
|
||||
action: MenuBarEntry::create_action(|_| NavigationMessage::CanvasTiltSet { angle_radians: 0.into() }.into()),
|
||||
disabled: no_active_document,
|
||||
disabled: no_active_document || node_graph_open,
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user