diff options
-rw-r--r-- | src/edit.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/edit.rs b/src/edit.rs index af91c26..de0fa80 100644 --- a/src/edit.rs +++ b/src/edit.rs @@ -12,6 +12,7 @@ slint::slint! { export global Aux := { property<int> selected: 0; callback select(int); + callback set-palette-color(int, color); callback format-rgb-hex(color) -> string; callback format-rgb-component(int) -> string; callback color-of-rgb-component(string, int) -> color; @@ -128,6 +129,7 @@ slint::slint! { set-secondary (colors) => { secondary-colors.colors = colors; } callback get-palette-color(int) -> color; + callback set-palette-color(int, color); callback update-edit <=> edit.update; callback user-quit(); @@ -175,6 +177,14 @@ slint::slint! { : secondary-colors.colors [i - 8] } + set-palette-color (i, col) => { + if (i < 8) { + primary-colors.colors [i] = col; + } else { + secondary-colors.colors [i - 8] = col; + } + } + master := VerticalBox { alignment: start; @@ -270,6 +280,15 @@ impl Edit }); } + { + let guiw = gui.as_weak(); + let npal = pal.len(); + gui.global::<Aux>().on_set_palette_color(move |i, col| { + let i = (i as usize % npal) as i32; + guiw.unwrap().invoke_set_palette_color(i, col); + }); + } + gui.global::<Aux>().on_format_rgb_hex(|col| { let x = (col.red() as u32) << 2 | (col.green() as u32) << 1 |