Skip to content

Commit e4073a1

Browse files
RustyNixieTubeKeavon
authored andcommitted
Implement update_colors (#43)
Co-authored-by: RustyNixieTube <RustyNixieTube@users.noreply.github.com>
1 parent 543fc4f commit e4073a1

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

client/web/wasm/src/viewport.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,7 @@ pub fn on_mouse_move(x: u32, y: u32) {
2424
/// Update working colors
2525
#[wasm_bindgen]
2626
pub fn update_colors(primary_color: Color, secondary_color: Color) {
27-
todo!()
27+
let tool_state = unsafe { &mut TOOL_STATE };
28+
tool_state.set_primary_color(primary_color.get_inner_color());
29+
tool_state.set_secondary_color(secondary_color.get_inner_color());
2830
}

client/web/wasm/src/wrappers.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ impl Color {
1313
}
1414
}
1515

16+
impl Color {
17+
pub fn get_inner_color(&self) -> InnerColor {
18+
self.0
19+
}
20+
}
21+
1622
pub fn translate_tool(name: &str) -> Option<ToolType> {
1723
match name {
1824
"Select" => Some(ToolType::Select),

core/editor/src/tools/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ impl ToolState {
2222
pub fn select_tool(&mut self, tool: ToolType) {
2323
self.active_tool = tool
2424
}
25+
pub fn set_primary_color<T: Into<Color>>(&mut self, primary_color: T) {
26+
self.primary_color = primary_color.into();
27+
}
28+
pub fn set_secondary_color<T: Into<Color>>(&mut self, secondary_color: T) {
29+
self.secondary_color = secondary_color.into();
30+
}
2531
}
2632

2733
#[repr(usize)]

0 commit comments

Comments
 (0)