File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,5 +24,7 @@ pub fn on_mouse_move(x: u32, y: u32) {
2424/// Update working colors
2525#[ wasm_bindgen]
2626pub 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}
Original file line number Diff line number Diff 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+
1622pub fn translate_tool ( name : & str ) -> Option < ToolType > {
1723 match name {
1824 "Select" => Some ( ToolType :: Select ) ,
Original file line number Diff line number Diff 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 ) ]
You can’t perform that action at this time.
0 commit comments