Skip to content

Commit

Permalink
c-eyes@anaximeno: Version 2.1.0 (linuxmint#6043)
Browse files Browse the repository at this point in the history
* Update the applet sizing handling
  • Loading branch information
anaximeno authored May 30, 2024
1 parent 7000636 commit 21c26de
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 26 deletions.
51 changes: 37 additions & 14 deletions c-eyes@anaximeno/files/c-eyes@anaximeno/6.2/applet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -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",
Expand All @@ -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);
},
},
{
Expand Down Expand Up @@ -136,18 +138,18 @@ 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),
},
{
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),
}
];
Expand All @@ -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();
}
Expand All @@ -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();
}

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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,
});
Expand Down Expand Up @@ -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);
}
4 changes: 2 additions & 2 deletions c-eyes@anaximeno/files/c-eyes@anaximeno/6.2/eyeModes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down
18 changes: 9 additions & 9 deletions c-eyes@anaximeno/files/c-eyes@anaximeno/6.2/settings-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion c-eyes@anaximeno/files/c-eyes@anaximeno/metadata.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.0.1",
"version": "2.1.0",
"uuid": "c-eyes@anaximeno",
"name": "Cinnamon Eyes",
"multiversion": true,
Expand Down

0 comments on commit 21c26de

Please sign in to comment.