Implement update_colors (#43)
Co-authored-by: RustyNixieTube <RustyNixieTube@users.noreply.github.com>
This commit is contained in:
parent
543fc4fec1
commit
e4073a112f
|
|
@ -24,5 +24,7 @@ pub fn on_mouse_move(x: u32, y: u32) {
|
|||
/// Update working colors
|
||||
#[wasm_bindgen]
|
||||
pub fn update_colors(primary_color: Color, secondary_color: Color) {
|
||||
todo!()
|
||||
let tool_state = unsafe { &mut TOOL_STATE };
|
||||
tool_state.set_primary_color(primary_color.get_inner_color());
|
||||
tool_state.set_secondary_color(secondary_color.get_inner_color());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,12 @@ impl Color {
|
|||
}
|
||||
}
|
||||
|
||||
impl Color {
|
||||
pub fn get_inner_color(&self) -> InnerColor {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
pub fn translate_tool(name: &str) -> Option<ToolType> {
|
||||
match name {
|
||||
"Select" => Some(ToolType::Select),
|
||||
|
|
|
|||
|
|
@ -22,6 +22,12 @@ impl ToolState {
|
|||
pub fn select_tool(&mut self, tool: ToolType) {
|
||||
self.active_tool = tool
|
||||
}
|
||||
pub fn set_primary_color<T: Into<Color>>(&mut self, primary_color: T) {
|
||||
self.primary_color = primary_color.into();
|
||||
}
|
||||
pub fn set_secondary_color<T: Into<Color>>(&mut self, secondary_color: T) {
|
||||
self.secondary_color = secondary_color.into();
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(usize)]
|
||||
|
|
|
|||
Loading…
Reference in New Issue