Skip to content
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

Show the open hand cursor when space bar is held #2173

Closed
wants to merge 16 commits into from
Prev Previous commit
Next Next commit
fixed the cursor change on different tool
  • Loading branch information
Pratik Agrawal authored and Pratik Agrawal committed Jan 17, 2025
commit a035f49df145d4d0101c4ae8fdc6efbcb4a5b617
2 changes: 2 additions & 0 deletions editor/src/messages/input_mapper/input_mappings.rs
Original file line number Diff line number Diff line change
@@ -160,6 +160,8 @@ pub fn input_mappings() -> Mapping {
entry!(KeyDown(MouseRight); action_dispatch=TextToolMessage::CommitText),
entry!(KeyDown(Escape); action_dispatch=TextToolMessage::CommitText),
entry!(KeyDown(Enter); modifiers=[Accel], action_dispatch=TextToolMessage::CommitText),
// entry!(KeyDownNoRepeat(Space); action_dispatch=NavigationMessage::SetCursorState { is_active: true }),
// entry!(KeyUp(Space); action_dispatch=NavigationMessage::SetCursorState { is_active: false }),
//
// GradientToolMessage
entry!(KeyDown(MouseLeft); action_dispatch=GradientToolMessage::PointerDown),
Original file line number Diff line number Diff line change
@@ -174,6 +174,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
// Sub-messages
DocumentMessage::Navigation(message) => {
let data = NavigationMessageData {
tool_type: *current_tool,
network_interface: &mut self.network_interface,
breadcrumb_network_path: &self.breadcrumb_network_path,
ipp,
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ use crate::messages::portfolio::document::navigation::utility_types::NavigationO
use crate::messages::portfolio::document::utility_types::misc::PTZ;
use crate::messages::portfolio::document::utility_types::network_interface::NodeNetworkInterface;
use crate::messages::prelude::*;
use crate::messages::tool::utility_types::{HintData, HintGroup, HintInfo};
use crate::messages::tool::utility_types::{HintData, HintGroup, HintInfo, ToolData, ToolType};

use graph_craft::document::NodeId;

@@ -22,6 +22,7 @@ pub struct NavigationMessageData<'a> {
pub selection_bounds: Option<[DVec2; 2]>,
pub document_ptz: &'a mut PTZ,
pub graph_view_overlay_open: bool,
pub tool_type: ToolType,
}

#[derive(Debug, Clone, PartialEq, Default)]
@@ -40,6 +41,7 @@ impl MessageHandler<NavigationMessage, NavigationMessageData<'_>> for Navigation
selection_bounds,
document_ptz,
graph_view_overlay_open,
tool_type,
} = data;

fn get_ptz<'a>(document_ptz: &'a PTZ, network_interface: &'a NodeNetworkInterface, graph_view_overlay_open: bool, breadcrumb_network_path: &[NodeId]) -> Option<&'a PTZ> {
@@ -88,7 +90,12 @@ impl MessageHandler<NavigationMessage, NavigationMessageData<'_>> for Navigation
if is_active {
responses.add(FrontendMessage::UpdateMouseCursor { cursor: MouseCursorIcon::Grab });
} else {
responses.add(FrontendMessage::UpdateMouseCursor { cursor: MouseCursorIcon::Default });
if tool_type != ToolType::Select {
log::info!("ToolType is not Select, so we are not updating the cursor");
responses.add(ToolMessage::UpdateCursor);
} else {
responses.add(FrontendMessage::UpdateMouseCursor { cursor: MouseCursorIcon::Default });
}
}
}
NavigationMessage::BeginCanvasTilt { was_dispatched_from_menu } => {
3 changes: 2 additions & 1 deletion editor/src/messages/portfolio/portfolio_message_handler.rs
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ use crate::messages::portfolio::document::node_graph::document_node_definitions:
use crate::messages::portfolio::document::utility_types::clipboards::{Clipboard, CopyBufferEntry, INTERNAL_CLIPBOARD_COUNT};
use crate::messages::portfolio::document::DocumentMessageData;
use crate::messages::prelude::*;
use crate::messages::tool::utility_types::{HintData, HintGroup, ToolType};
use crate::messages::tool::utility_types::{HintData, HintGroup, ToolData, ToolType};
use crate::node_graph_executor::{ExportConfig, NodeGraphExecutor};

use graph_craft::document::value::TaggedValue;
@@ -79,6 +79,7 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageData<'_>> for PortfolioMes
let document_inputs = DocumentMessageData {
document_id,
ipp,

persistent_data: &self.persistent_data,
executor: &mut self.executor,
current_tool,
15 changes: 14 additions & 1 deletion editor/src/messages/tool/tool_messages/text_tool.rs
Original file line number Diff line number Diff line change
@@ -638,7 +638,20 @@ impl Fsm for TextToolFsmState {

responses.add(FrontendMessage::UpdateInputHints { hint_data });
}

fn standard_tool_messages(&self, message: &ToolMessage, responses: &mut VecDeque<Message>, _tool_data: &mut Self::ToolData) -> bool {
// Check for standard hits or cursor events
match message {
ToolMessage::UpdateHints => {
self.update_hints(responses);
true
}
ToolMessage::UpdateCursor => {
self.update_cursor(responses);
true
}
_ => false,
}
}
fn update_cursor(&self, responses: &mut VecDeque<Message>) {
let cursor = match self {
TextToolFsmState::Dragging => MouseCursorIcon::Crosshair,