Add a hotkey to select a random primary color (#622)
* Add shortcut to select a random primary color (#549) * Rename random primary color message and reduce the number of calls to generate_uuid * Add documentation for SelectRandomPrimaryColor message * Set the alpha value to 255 instead of a random value #622 Co-authored-by: Florent Collin <florentcollin23@gmail.com>
This commit is contained in:
parent
07736a9fca
commit
c65c33243b
|
|
@ -142,7 +142,8 @@ impl Default for Mapping {
|
||||||
// Colors
|
// Colors
|
||||||
entry! {action=ToolMessage::ResetColors, key_down=KeyX, modifiers=[KeyShift, KeyControl]},
|
entry! {action=ToolMessage::ResetColors, key_down=KeyX, modifiers=[KeyShift, KeyControl]},
|
||||||
entry! {action=ToolMessage::SwapColors, key_down=KeyX, modifiers=[KeyShift]},
|
entry! {action=ToolMessage::SwapColors, key_down=KeyX, modifiers=[KeyShift]},
|
||||||
// Editor actions
|
entry! {action=ToolMessage::SelectRandomPrimaryColor, key_down=KeyC, modifiers=[KeyAlt]},
|
||||||
|
// Editor Actions
|
||||||
entry! {action=FrontendMessage::TriggerFileUpload, key_down=KeyO, modifiers=[KeyControl]},
|
entry! {action=FrontendMessage::TriggerFileUpload, key_down=KeyO, modifiers=[KeyControl]},
|
||||||
// Document actions
|
// Document actions
|
||||||
entry! {action=DocumentMessage::Redo, key_down=KeyZ, modifiers=[KeyControl, KeyShift]},
|
entry! {action=DocumentMessage::Redo, key_down=KeyZ, modifiers=[KeyControl, KeyShift]},
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,7 @@ pub enum ToolMessage {
|
||||||
SelectPrimaryColor {
|
SelectPrimaryColor {
|
||||||
color: Color,
|
color: Color,
|
||||||
},
|
},
|
||||||
|
SelectRandomPrimaryColor,
|
||||||
SelectSecondaryColor {
|
SelectSecondaryColor {
|
||||||
color: Color,
|
color: Color,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,19 @@ impl MessageHandler<ToolMessage, (&DocumentMessageHandler, &InputPreprocessorMes
|
||||||
|
|
||||||
update_working_colors(&self.tool_state.document_tool_data, responses);
|
update_working_colors(&self.tool_state.document_tool_data, responses);
|
||||||
}
|
}
|
||||||
|
SelectRandomPrimaryColor => {
|
||||||
|
// Select a random primary color (rgba) based on an UUID
|
||||||
|
let document_data = &mut self.tool_state.document_tool_data;
|
||||||
|
|
||||||
|
let random_number = generate_uuid();
|
||||||
|
let r = (random_number >> 16) as u8;
|
||||||
|
let g = (random_number >> 8) as u8;
|
||||||
|
let b = random_number as u8;
|
||||||
|
let random_color = Color::from_rgba8(r, g, b, 255);
|
||||||
|
document_data.primary_color = random_color;
|
||||||
|
|
||||||
|
update_working_colors(document_data, responses);
|
||||||
|
}
|
||||||
SelectSecondaryColor { color } => {
|
SelectSecondaryColor { color } => {
|
||||||
let document_data = &mut self.tool_state.document_tool_data;
|
let document_data = &mut self.tool_state.document_tool_data;
|
||||||
document_data.secondary_color = color;
|
document_data.secondary_color = color;
|
||||||
|
|
@ -137,7 +150,7 @@ impl MessageHandler<ToolMessage, (&DocumentMessageHandler, &InputPreprocessorMes
|
||||||
}
|
}
|
||||||
|
|
||||||
fn actions(&self) -> ActionList {
|
fn actions(&self) -> ActionList {
|
||||||
let mut list = actions!(ToolMessageDiscriminant; ResetColors, SwapColors, ActivateTool);
|
let mut list = actions!(ToolMessageDiscriminant; SelectRandomPrimaryColor, ResetColors, SwapColors, ActivateTool);
|
||||||
list.extend(self.tool_state.tool_data.active_tool().actions());
|
list.extend(self.tool_state.tool_data.active_tool().actions());
|
||||||
|
|
||||||
list
|
list
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue