diff options
author | Philipp Gesang <phg@phi-gamma.net> | 2022-08-19 07:33:22 +0200 |
---|---|---|
committer | Philipp Gesang <phg@phi-gamma.net> | 2022-08-19 07:33:22 +0200 |
commit | a1f457d71622649a1b1a84c00d200c8f1e315ab4 (patch) | |
tree | d66355a81b61415d4a920e379f90a4b4707e20a3 /src | |
parent | 30b5a3c67f640563460dc5d61e11d24721d66a11 (diff) | |
download | vtcol-a1f457d71622649a1b1a84c00d200c8f1e315ab4.tar.gz |
edit: add setter for palette colors
Diffstat (limited to 'src')
-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 |