Skip to content

Commit

Permalink
c-eyes@anaximeno: Use a better eye base color for light and dark them…
Browse files Browse the repository at this point in the history
…es of mint (linuxmint#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
  • Loading branch information
anaximeno authored May 28, 2024
1 parent 7bd920a commit f4e9f1c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 22 deletions.
45 changes: 26 additions & 19 deletions c-eyes@anaximeno/files/c-eyes@anaximeno/6.2/applet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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),
}
];

Expand All @@ -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();
}

Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"margin": {
"type": "spinbutton",
"default": 8,
"min": -6,
"min": -10,
"max": 32,
"step": 2,
"units": "px",
Expand Down Expand Up @@ -85,7 +85,7 @@

"base-color": {
"type": "colorchooser",
"default": "#EFEDEA",
"default": "#BBBBBB",
"description": "Base Color"
},
"iris-color": {
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.0",
"version": "2.0.1",
"uuid": "c-eyes@anaximeno",
"name": "Cinnamon Eyes",
"multiversion": true,
Expand Down

0 comments on commit f4e9f1c

Please sign in to comment.