From f4e9f1c1ac8a18bfbfe7dcf67e35b5143a234b3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anax=C3=ADmeno=20Brito?= Date: Tue, 28 May 2024 08:05:05 -0100 Subject: [PATCH] c-eyes@anaximeno: Use a better eye base color for light and dark themes of mint (#6039) * Use a base color that adapts better to light and dark themes of mint for the eye * Also made some refactoring and improvements of the code: * Bind this on debounced callbacks * Update margin limits * Bump version --- .../files/c-eyes@anaximeno/6.2/applet.js | 45 +++++++++++-------- .../c-eyes@anaximeno/6.2/settings-schema.json | 4 +- .../files/c-eyes@anaximeno/metadata.json | 2 +- 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/c-eyes@anaximeno/files/c-eyes@anaximeno/6.2/applet.js b/c-eyes@anaximeno/files/c-eyes@anaximeno/6.2/applet.js index af221b28f4e..1cc6c3efb42 100644 --- a/c-eyes@anaximeno/files/c-eyes@anaximeno/6.2/applet.js +++ b/c-eyes@anaximeno/files/c-eyes@anaximeno/6.2/applet.js @@ -71,7 +71,7 @@ class Eye extends Applet.Applet { { key: "repaint-interval", value: "repaint_interval", - cb: d.debounce(e => this.set_active(true), 300), + cb: d.debounce(() => this.set_active(true), 300), }, { key: "repaint-angle", @@ -81,17 +81,24 @@ class Eye extends Applet.Applet { { key: "mode", value: "mode", - cb: this.on_property_updated, + cb: () => { + this.on_eye_mode_update(); + this.on_property_updated(); + }, }, { key: "line-width", value: "line_width", - cb: d.debounce(e => this.on_property_updated(e), 300), + cb: d.debounce( + this.on_property_updated.bind(this), + 300), }, { key: "margin", value: "margin", - cb: d.debounce(e => this.on_property_updated(e), 300), + cb: d.debounce( + this.on_property_updated.bind(this), + 300), }, { key: "base-color", @@ -131,12 +138,17 @@ class Eye extends Applet.Applet { { key: "vertical-padding", value: "vertical_padding", - cb: d.debounce(e => this.on_property_updated(e), 300), + cb: d.debounce( + this.on_property_updated.bind(this), + 300), }, { key: "tooltip-message", value: "tooltip_message", - cb: d.debounce(e => this.update_tooltip(), 100), + cb: d.debounce(() => { + this.update_tooltip(); + this.on_property_updated(); + }, 100), } ]; @@ -157,19 +169,11 @@ class Eye extends Applet.Applet { on_applet_clicked(event) { this.area.queue_repaint(); - this.update_tooltip(); } - on_property_updated(event) { - this.update_tooltip(); - + on_property_updated() { this.area.set_width((this.area_width + 2 * this.margin) * global.ui_scale); this.area.set_height(this.area_height * global.ui_scale); - - if (this.eye_painter.mode != this.mode) { - this.eye_painter = EyeModeFactory.createEyeMode(this.mode); - } - this.area.queue_repaint(); } @@ -194,6 +198,12 @@ class Eye extends Applet.Applet { return true; } + on_eye_mode_update() { + if (this.eye_painter && this.eye_painter.mode != this.mode) { + this.eye_painter = EyeModeFactory.createEyeMode(this.mode); + } + } + destroy() { this.set_active(false); this.signals.disconnectAllSignals(); @@ -249,6 +259,7 @@ class Eye extends Applet.Applet { } paint_eye(area) { + this.on_eye_mode_update(); const theme_node = this.area.get_theme_node(); const [mouse_x, mouse_y, _] = global.get_pointer(); const [area_x, area_y] = this.get_area_position(); @@ -268,10 +279,6 @@ class Eye extends Applet.Applet { pupil_color = ok ? color : pupil_color; } - if (this.eye_painter.mode != this.mode) { - this.eye_painter = EyeModeFactory.createEyeMode(this.mode); - } - this.eye_painter.drawEye(area, { area_x: area_x, area_y: area_y, diff --git a/c-eyes@anaximeno/files/c-eyes@anaximeno/6.2/settings-schema.json b/c-eyes@anaximeno/files/c-eyes@anaximeno/6.2/settings-schema.json index b9525d20aa5..f9af91f4a68 100644 --- a/c-eyes@anaximeno/files/c-eyes@anaximeno/6.2/settings-schema.json +++ b/c-eyes@anaximeno/files/c-eyes@anaximeno/6.2/settings-schema.json @@ -25,7 +25,7 @@ "margin": { "type": "spinbutton", "default": 8, - "min": -6, + "min": -10, "max": 32, "step": 2, "units": "px", @@ -85,7 +85,7 @@ "base-color": { "type": "colorchooser", - "default": "#EFEDEA", + "default": "#BBBBBB", "description": "Base Color" }, "iris-color": { diff --git a/c-eyes@anaximeno/files/c-eyes@anaximeno/metadata.json b/c-eyes@anaximeno/files/c-eyes@anaximeno/metadata.json index 0127a01efbf..1659b146b11 100644 --- a/c-eyes@anaximeno/files/c-eyes@anaximeno/metadata.json +++ b/c-eyes@anaximeno/files/c-eyes@anaximeno/metadata.json @@ -1,5 +1,5 @@ { - "version": "2.0.0", + "version": "2.0.1", "uuid": "c-eyes@anaximeno", "name": "Cinnamon Eyes", "multiversion": true,