mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-29 07:18:12 +08:00
Improve hotkeys with canonical flag, more industry-standard mappings, and fix GRS menu bar labels (#2827)
This commit is contained in:
@@ -80,12 +80,12 @@ pub enum ToolMessage {
|
||||
Redo,
|
||||
RefreshToolOptions,
|
||||
ResetColors,
|
||||
SelectPrimaryColor {
|
||||
SelectWorkingColor {
|
||||
color: Color,
|
||||
primary: bool,
|
||||
},
|
||||
SelectRandomPrimaryColor,
|
||||
SelectSecondaryColor {
|
||||
color: Color,
|
||||
SelectRandomWorkingColor {
|
||||
primary: bool,
|
||||
},
|
||||
SwapColors,
|
||||
Undo,
|
||||
|
||||
@@ -240,14 +240,8 @@ impl MessageHandler<ToolMessage, ToolMessageData<'_>> for ToolMessageHandler {
|
||||
|
||||
document_data.update_working_colors(responses); // TODO: Make this an event
|
||||
}
|
||||
ToolMessage::SelectPrimaryColor { color } => {
|
||||
let document_data = &mut self.tool_state.document_tool_data;
|
||||
document_data.primary_color = color;
|
||||
|
||||
document_data.update_working_colors(responses); // TODO: Make this an event
|
||||
}
|
||||
ToolMessage::SelectRandomPrimaryColor => {
|
||||
// Select a random primary color (rgba) based on an UUID
|
||||
ToolMessage::SelectRandomWorkingColor { primary } => {
|
||||
// Select a random working color (RGBA) based on an UUID
|
||||
let document_data = &mut self.tool_state.document_tool_data;
|
||||
|
||||
let random_number = generate_uuid();
|
||||
@@ -255,13 +249,23 @@ impl MessageHandler<ToolMessage, ToolMessageData<'_>> for ToolMessageHandler {
|
||||
let g = (random_number >> 8) as u8;
|
||||
let b = random_number as u8;
|
||||
let random_color = Color::from_rgba8_srgb(r, g, b, 255);
|
||||
document_data.primary_color = random_color;
|
||||
|
||||
if primary {
|
||||
document_data.primary_color = random_color;
|
||||
} else {
|
||||
document_data.secondary_color = random_color;
|
||||
}
|
||||
|
||||
document_data.update_working_colors(responses); // TODO: Make this an event
|
||||
}
|
||||
ToolMessage::SelectSecondaryColor { color } => {
|
||||
ToolMessage::SelectWorkingColor { color, primary } => {
|
||||
let document_data = &mut self.tool_state.document_tool_data;
|
||||
document_data.secondary_color = color;
|
||||
|
||||
if primary {
|
||||
document_data.primary_color = color;
|
||||
} else {
|
||||
document_data.secondary_color = color;
|
||||
}
|
||||
|
||||
document_data.update_working_colors(responses); // TODO: Make this an event
|
||||
}
|
||||
@@ -340,7 +344,7 @@ impl MessageHandler<ToolMessage, ToolMessageData<'_>> for ToolMessageHandler {
|
||||
|
||||
ActivateToolBrush,
|
||||
|
||||
SelectRandomPrimaryColor,
|
||||
SelectRandomWorkingColor,
|
||||
ResetColors,
|
||||
SwapColors,
|
||||
Undo,
|
||||
|
||||
@@ -12,10 +12,11 @@ pub enum TransformLayerMessage {
|
||||
|
||||
// Messages
|
||||
ApplyTransformOperation { final_transform: bool },
|
||||
BeginTransformOperation { operation: TransformType },
|
||||
BeginGrab,
|
||||
BeginRotate,
|
||||
BeginScale,
|
||||
BeginGRS { transform_type: TransformType },
|
||||
BeginGRS { operation: TransformType },
|
||||
BeginGrabPen { last_point: DVec2, handle: DVec2 },
|
||||
BeginRotatePen { last_point: DVec2, handle: DVec2 },
|
||||
BeginScalePen { last_point: DVec2, handle: DVec2 },
|
||||
|
||||
@@ -368,6 +368,15 @@ impl MessageHandler<TransformLayerMessage, TransformData<'_>> for TransformLayer
|
||||
responses.add(OverlaysMessage::RemoveProvider(TRANSFORM_GRS_OVERLAY_PROVIDER));
|
||||
}
|
||||
}
|
||||
TransformLayerMessage::BeginTransformOperation { operation } => {
|
||||
begin_operation(self.transform_operation, &mut self.typing, &mut self.mouse_position, &mut self.start_mouse, &mut self.initial_transform);
|
||||
self.transform_operation = match operation {
|
||||
TransformType::Grab => TransformOperation::Grabbing(Default::default()),
|
||||
TransformType::Rotate => TransformOperation::Rotating(Default::default()),
|
||||
TransformType::Scale => TransformOperation::Scaling(Default::default()),
|
||||
};
|
||||
self.layer_bounding_box = selected.bounding_box();
|
||||
}
|
||||
TransformLayerMessage::BeginGrabPen { last_point, handle } | TransformLayerMessage::BeginRotatePen { last_point, handle } | TransformLayerMessage::BeginScalePen { last_point, handle } => {
|
||||
self.typing.clear();
|
||||
|
||||
@@ -402,9 +411,10 @@ impl MessageHandler<TransformLayerMessage, TransformData<'_>> for TransformLayer
|
||||
increments_key: INCREMENTS_KEY,
|
||||
});
|
||||
}
|
||||
TransformLayerMessage::BeginGRS { transform_type } => {
|
||||
TransformLayerMessage::BeginGRS { operation: transform_type } => {
|
||||
let selected_points: Vec<&ManipulatorPointId> = shape_editor.selected_points().collect();
|
||||
let selected_segments = shape_editor.selected_segments().collect::<Vec<_>>();
|
||||
|
||||
if (using_path_tool && selected_points.is_empty() && selected_segments.is_empty())
|
||||
|| (!using_path_tool && !using_select_tool && !using_pen_tool && !using_shape_tool)
|
||||
|| selected_layers.is_empty()
|
||||
@@ -439,42 +449,24 @@ impl MessageHandler<TransformLayerMessage, TransformData<'_>> for TransformLayer
|
||||
}
|
||||
}
|
||||
|
||||
self.local = false;
|
||||
self.operation_count += 1;
|
||||
|
||||
let chain_operation = self.transform_operation != TransformOperation::None;
|
||||
if chain_operation {
|
||||
responses.add(TransformLayerMessage::ApplyTransformOperation { final_transform: false });
|
||||
} else {
|
||||
responses.add(OverlaysMessage::AddProvider(TRANSFORM_GRS_OVERLAY_PROVIDER));
|
||||
}
|
||||
|
||||
let response = match transform_type {
|
||||
TransformType::Grab => TransformLayerMessage::BeginGrab,
|
||||
TransformType::Rotate => TransformLayerMessage::BeginRotate,
|
||||
TransformType::Scale => TransformLayerMessage::BeginScale,
|
||||
};
|
||||
|
||||
self.local = false;
|
||||
self.operation_count += 1;
|
||||
responses.add(response);
|
||||
responses.add(TransformLayerMessage::BeginTransformOperation { operation: transform_type });
|
||||
responses.add(TransformLayerMessage::PointerMove {
|
||||
slow_key: SLOW_KEY,
|
||||
increments_key: INCREMENTS_KEY,
|
||||
});
|
||||
}
|
||||
TransformLayerMessage::BeginGrab => {
|
||||
begin_operation(self.transform_operation, &mut self.typing, &mut self.mouse_position, &mut self.start_mouse, &mut self.initial_transform);
|
||||
self.transform_operation = TransformOperation::Grabbing(Default::default());
|
||||
self.layer_bounding_box = selected.bounding_box();
|
||||
}
|
||||
TransformLayerMessage::BeginRotate => {
|
||||
begin_operation(self.transform_operation, &mut self.typing, &mut self.mouse_position, &mut self.start_mouse, &mut self.initial_transform);
|
||||
self.transform_operation = TransformOperation::Rotating(Default::default());
|
||||
self.layer_bounding_box = selected.bounding_box();
|
||||
}
|
||||
TransformLayerMessage::BeginScale => {
|
||||
begin_operation(self.transform_operation, &mut self.typing, &mut self.mouse_position, &mut self.start_mouse, &mut self.initial_transform);
|
||||
self.transform_operation = TransformOperation::Scaling(Default::default());
|
||||
self.layer_bounding_box = selected.bounding_box();
|
||||
}
|
||||
TransformLayerMessage::BeginGrab => responses.add_front(TransformLayerMessage::BeginGRS { operation: TransformType::Grab }),
|
||||
TransformLayerMessage::BeginRotate => responses.add_front(TransformLayerMessage::BeginGRS { operation: TransformType::Rotate }),
|
||||
TransformLayerMessage::BeginScale => responses.add_front(TransformLayerMessage::BeginGRS { operation: TransformType::Scale }),
|
||||
TransformLayerMessage::CancelTransformOperation => {
|
||||
if using_pen_tool {
|
||||
self.typing.clear();
|
||||
@@ -707,7 +699,9 @@ impl MessageHandler<TransformLayerMessage, TransformData<'_>> for TransformLayer
|
||||
|
||||
fn actions(&self) -> ActionList {
|
||||
let mut common = actions!(TransformLayerMessageDiscriminant;
|
||||
BeginGRS,
|
||||
BeginGrab,
|
||||
BeginRotate,
|
||||
BeginScale,
|
||||
);
|
||||
|
||||
if self.transform_operation != TransformOperation::None {
|
||||
|
||||
Reference in New Issue
Block a user