From 21c26de1d86668cbbddcbe9b0ecf7c3faadf8391 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anax=C3=ADmeno=20Brito?= Date: Thu, 30 May 2024 20:32:31 -0100 Subject: [PATCH] c-eyes@anaximeno: Version 2.1.0 (#6043) * Update the applet sizing handling --- .../files/c-eyes@anaximeno/6.2/applet.js | 51 ++++++++++++++----- .../files/c-eyes@anaximeno/6.2/eyeModes.js | 4 +- .../c-eyes@anaximeno/6.2/settings-schema.json | 18 +++---- .../files/c-eyes@anaximeno/metadata.json | 2 +- 4 files changed, 49 insertions(+), 26 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 1cc6c3efb42..d2ac47f9a77 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 @@ -31,6 +31,7 @@ const { Debouncer } = require("./helpers.js"); const UUID = "c-eyes@anaximeno"; const LOC_DIR = GLib.get_home_dir() + "/.local/share/locale"; +const AREA_DEFAULT_WIDTH = 28; Gettext.bindtextdomain(UUID, LOC_DIR); @@ -41,11 +42,11 @@ function _(text) { class Eye extends Applet.Applet { - constructor(metadata, orientation, panelHeight, instanceId, areaHeight, areaWidth) { + constructor(metadata, orientation, panelHeight, instanceId, areaWidth) { super(orientation, panelHeight, instanceId); this.settings = this._setup_settings(metadata.uuid, instanceId); + this.orientation = orientation; this.metadata = metadata; - this.area_height = areaHeight; this.area_width = areaWidth; this.setAllowedLayout(Applet.AllowedLayout.BOTH); @@ -57,6 +58,7 @@ class Eye extends Applet.Applet { this.signals = new SignalManager.SignalManager(null); this.signals.connect(global.screen, 'in-fullscreen-changed', this.on_fullscreen_changed, this); + this.signals.connect(Main.layoutManager, 'monitors-changed', this.on_property_updated, this); this._last_mouse_x = undefined; this._last_mouse_y = undefined; @@ -71,7 +73,7 @@ class Eye extends Applet.Applet { { key: "repaint-interval", value: "repaint_interval", - cb: d.debounce(() => this.set_active(true), 300), + cb: d.debounce((value) => this.set_active(true), 300), }, { key: "repaint-angle", @@ -81,9 +83,9 @@ class Eye extends Applet.Applet { { key: "mode", value: "mode", - cb: () => { + cb: (value) => { this.on_eye_mode_update(); - this.on_property_updated(); + this.on_property_updated(value); }, }, { @@ -136,8 +138,8 @@ class Eye extends Applet.Applet { cb: this.on_property_updated, }, { - key: "vertical-padding", - value: "vertical_padding", + key: "padding", + value: "padding", cb: d.debounce( this.on_property_updated.bind(this), 300), @@ -145,9 +147,9 @@ class Eye extends Applet.Applet { { key: "tooltip-message", value: "tooltip_message", - cb: d.debounce(() => { + cb: d.debounce((value) => { this.update_tooltip(); - this.on_property_updated(); + this.on_property_updated(value); }, 100), } ]; @@ -163,6 +165,11 @@ class Eye extends Applet.Applet { return settings; } + on_orientation_changed(orientation) { + this.orientation = orientation; + this.update_sizes(); + } + on_applet_removed_from_panel(deleteConfig) { this.destroy(); } @@ -171,9 +178,8 @@ class Eye extends Applet.Applet { this.area.queue_repaint(); } - 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); + on_property_updated(value = null) { + this.update_sizes(); this.area.queue_repaint(); } @@ -211,6 +217,23 @@ class Eye extends Applet.Applet { this.settings.finalize(); } + update_sizes() { + let width = 1, height = 1; + + if (this.orientation == St.Side.LEFT || this.orientation == St.Side.RIGHT) { + this.actor.set_style("padding-top: 0px; padding-bottom: 0px; margin-top: 0px; margin-bottom: 0px;"); + height = (this.area_width + 2 * this.margin) * global.ui_scale; + width = this.panel.height; + } else { + this.actor.set_style("padding-left: 0px; padding-right: 0px; margin-left: 0px; margin-right: 0px;"); + width = (this.area_width + 2 * this.margin) * global.ui_scale; + height = this.panel.height; + } + + this.area.set_width(width); + this.area.set_height(height); + } + set_active(enabled) { this.on_property_updated(); @@ -288,7 +311,7 @@ class Eye extends Applet.Applet { iris_color: iris_color, pupil_color: pupil_color, line_width: (this.line_width * global.ui_scale), - padding: (this.vertical_padding * global.ui_scale), + padding: (this.padding * global.ui_scale), lids_fill: this.fill_lids_color_painting && this.use_alternative_colors, bulb_fill: this.fill_bulb_color_painting && this.use_alternative_colors, }); @@ -328,5 +351,5 @@ class Eye extends Applet.Applet { } function main(metadata, orientation, panelHeight, instanceId) { - return new Eye(metadata, orientation, panelHeight, instanceId, 16, 28); + return new Eye(metadata, orientation, panelHeight, instanceId, AREA_DEFAULT_WIDTH); } diff --git a/c-eyes@anaximeno/files/c-eyes@anaximeno/6.2/eyeModes.js b/c-eyes@anaximeno/files/c-eyes@anaximeno/6.2/eyeModes.js index f798c12b16d..61ecde54f08 100644 --- a/c-eyes@anaximeno/files/c-eyes@anaximeno/6.2/eyeModes.js +++ b/c-eyes@anaximeno/files/c-eyes@anaximeno/6.2/eyeModes.js @@ -49,7 +49,7 @@ class EyelidMode extends EyeMode { const mouse_ang = Math.atan2(mouse_y, mouse_x); let mouse_rad = Math.sqrt(mouse_x * mouse_x + mouse_y * mouse_y); - const eye_rad = (area_height - options.padding) / 2; + const eye_rad = (Math.min(area_height, area_width) - options.padding) / 2; const iris_rad = eye_rad * 0.5; const pupil_rad = iris_rad * 0.4; @@ -147,7 +147,7 @@ class BulbMode extends EyeMode { let mouse_rad = Math.sqrt(mouse_x * mouse_x + mouse_y * mouse_y); const mouse_ang = Math.atan2(mouse_y, mouse_x); - const eye_rad = (area_height - options.padding) / 2.3; + const eye_rad = (Math.min(area_height, area_width) - options.padding) / 2.3; const iris_rad = eye_rad * 0.6; const pupil_rad = iris_rad * 0.4; 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 f9af91f4a68..3a16508ce75 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 @@ -24,19 +24,19 @@ }, "margin": { "type": "spinbutton", - "default": 8, - "min": -10, - "max": 32, - "step": 2, + "default": 8.0, + "min": 0.0, + "max": 32.0, + "step": 0.5, "units": "px", "description": "Margin" }, - "vertical-padding": { + "padding": { "type": "spinbutton", - "default": 2, - "min": 0, - "max": 20, - "step": 2, + "default": 4.0, + "min": 0.0, + "max": 24.0, + "step": 0.5, "units": "px", "description": "Padding" }, diff --git a/c-eyes@anaximeno/files/c-eyes@anaximeno/metadata.json b/c-eyes@anaximeno/files/c-eyes@anaximeno/metadata.json index 1659b146b11..9b7c2acf18f 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.1", + "version": "2.1.0", "uuid": "c-eyes@anaximeno", "name": "Cinnamon Eyes", "multiversion": true,