diff --git a/panel-tweaks@anaximeno/files/panel-tweaks@anaximeno/5.4/constants.js b/panel-tweaks@anaximeno/files/panel-tweaks@anaximeno/5.4/constants.js index e3e3b0b3300..f9eb1f1a2d7 100644 --- a/panel-tweaks@anaximeno/files/panel-tweaks@anaximeno/5.4/constants.js +++ b/panel-tweaks@anaximeno/files/panel-tweaks@anaximeno/5.4/constants.js @@ -1,2 +1,2 @@ var UUID = "panel-tweaks@anaximeno"; -var STYLE_UNSET_KEY = "##unset##"; \ No newline at end of file +var STYLE_TWEAK_UNSET_KEY = "##tweak-unset##"; \ No newline at end of file diff --git a/panel-tweaks@anaximeno/files/panel-tweaks@anaximeno/5.4/helpers.js b/panel-tweaks@anaximeno/files/panel-tweaks@anaximeno/5.4/helpers.js index bff854bc236..00adb090e7d 100644 --- a/panel-tweaks@anaximeno/files/panel-tweaks@anaximeno/5.4/helpers.js +++ b/panel-tweaks@anaximeno/files/panel-tweaks@anaximeno/5.4/helpers.js @@ -17,7 +17,7 @@ */ 'use strict'; -const { STYLE_UNSET_KEY } = require("./constants.js"); +const { STYLE_TWEAK_UNSET_KEY } = require("./constants.js"); function basicStylesDecoder(stylesText) { let stylesObject = {}; @@ -40,8 +40,13 @@ function basicStylesEncoder(stylesObject) { if (stylesObject) for (let [key, value] of Object.entries(stylesObject)) - if (value && value !== STYLE_UNSET_KEY) + if (value && value !== STYLE_TWEAK_UNSET_KEY) stylesEncoded += `${key}: ${value}; `; return stylesEncoded.trimEnd(); +} + +function round(value, nplaces = 0) { + let multDiv = 10 ** nplaces; + return Math.round(value * multDiv) / multDiv; } \ No newline at end of file diff --git a/panel-tweaks@anaximeno/files/panel-tweaks@anaximeno/5.4/settings-schema.json b/panel-tweaks@anaximeno/files/panel-tweaks@anaximeno/5.4/settings-schema.json index 648b5f30d39..c411e6d3198 100644 --- a/panel-tweaks@anaximeno/files/panel-tweaks@anaximeno/5.4/settings-schema.json +++ b/panel-tweaks@anaximeno/files/panel-tweaks@anaximeno/5.4/settings-schema.json @@ -19,42 +19,42 @@ "description": "Tweak Panel Shadow", "default": false }, - "panel-shadow-x-axis-shift": { + "panel-shadow-color": { + "type": "colorchooser", + "description": "Panel Shadow Color", + "dependency": "enable-panel-shadow-tweak", + "default": "#010101" + }, + "panel-shadow-bluriness": { "type": "spinbutton", "units": "px", "dependency": "enable-panel-shadow-tweak", - "description": "Shadow X-Axis Shift", + "description": "Shadow Bluriness", "default": 0.0, - "min": -10.0, - "max": 10.0, + "min": 0.0, + "max": 16.0, "step": 0.05 }, - "panel-shadow-y-axis-shift": { + "panel-shadow-x-axis-shift": { "type": "spinbutton", "units": "px", "dependency": "enable-panel-shadow-tweak", - "description": "Shadow Y-Axis Shift", + "description": "Shadow X-Axis Shift", "default": 0.0, "min": -10.0, "max": 10.0, "step": 0.05 }, - "panel-shadow-bluriness": { + "panel-shadow-y-axis-shift": { "type": "spinbutton", "units": "px", "dependency": "enable-panel-shadow-tweak", - "description": "Shadow Bluriness", + "description": "Shadow Y-Axis Shift", "default": 0.0, - "min": 0.0, - "max": 16.0, + "min": -10.0, + "max": 10.0, "step": 0.05 }, - "panel-shadow-color": { - "type": "colorchooser", - "description": "Panel Shadow Color", - "dependency": "enable-panel-shadow-tweak", - "default": "#010101" - }, "enable-panel-border-tweak": { "type": "switch", "description": "Tweak Panel Border", diff --git a/panel-tweaks@anaximeno/files/panel-tweaks@anaximeno/5.4/settingsController.js b/panel-tweaks@anaximeno/files/panel-tweaks@anaximeno/5.4/settingsController.js index 3fa2883bd80..98884d9cae2 100644 --- a/panel-tweaks@anaximeno/files/panel-tweaks@anaximeno/5.4/settingsController.js +++ b/panel-tweaks@anaximeno/files/panel-tweaks@anaximeno/5.4/settingsController.js @@ -18,8 +18,8 @@ 'use strict'; const Params = imports.misc.params; -const { basicStylesEncoder, basicStylesDecoder } = require("./helpers.js"); -const { STYLE_UNSET_KEY } = require("./constants.js"); +const { basicStylesEncoder, basicStylesDecoder, round } = require("./helpers.js"); +const { STYLE_TWEAK_UNSET_KEY } = require("./constants.js"); var PanelTweakController = class PanelTweakController { @@ -30,12 +30,14 @@ var PanelTweakController = class PanelTweakController { this.enablerKey = enablerKey; if (enablerKey) { - this.settings.bind(enablerKey, enablerKey.replaceAll('-', '_'), this.on_enabler_switched.bind(this)); + this.settings.bind( + this.enablerKey, + this.enablerKey.replaceAll('-', '_'), + this.on_enabler_switched.bind(this), + ); } - if (this.enabled) { - this.start(); - } + if (this.enabled) this.start(); } get values() { @@ -72,8 +74,13 @@ var PanelTweakController = class PanelTweakController { } start() { - for (const key of this.keys) - this.settings.bind(key, key.replaceAll('-', '_'), this.on_changed.bind(this)); + for (const key of this.keys) { + this.settings.bind( + key, + key.replaceAll('-', '_'), + this.on_changed.bind(this), + ); + } this.on_changed(); } @@ -88,10 +95,6 @@ var PanelTweakController = class PanelTweakController { var PanelColorTweakController = class PanelColorTweakController extends PanelTweakController { - constructor(applet, settings, key, enablerKey) { - super(applet, settings, key, enablerKey); - } - on_changed() { let [value] = this.values; this.set_panel_style({ @@ -103,44 +106,36 @@ var PanelColorTweakController = class PanelColorTweakController extends PanelTwe finalize() { this.set_panel_style({ - "background-color": STYLE_UNSET_KEY, - "background-gradient-end": STYLE_UNSET_KEY, - "background-gradient-start": STYLE_UNSET_KEY, + "background-color": STYLE_TWEAK_UNSET_KEY, + "background-gradient-end": STYLE_TWEAK_UNSET_KEY, + "background-gradient-start": STYLE_TWEAK_UNSET_KEY, }); } } var PanelShadowTweakController = class PanelShadowTweakController extends PanelTweakController { - constructor(applet, settings, key, enablerKey) { - super(applet, settings, key, enablerKey); - } - on_changed() { let values = this.valuesKeysMapped; - let x = values["panel-shadow-x-axis-shift"]; - let y = values["panel-shadow-y-axis-shift"]; - let bluriness = values["panel-shadow-bluriness"]; + let x = round(values["panel-shadow-x-axis-shift"], 2); + let y = round(values["panel-shadow-y-axis-shift"], 2); + let bluriness = round(values["panel-shadow-bluriness"], 2); let color = values["panel-shadow-color"]; let shadow = `${x}px ${y}px ${bluriness}px ${color}`; this.set_panel_style({ "box-shadow": shadow }); } finalize() { - this.set_panel_style({ "box-shadow": STYLE_UNSET_KEY }); + this.set_panel_style({ "box-shadow": STYLE_TWEAK_UNSET_KEY }); } } var PanelBorderTweakController = class PanelBorderTweakController extends PanelTweakController { - constructor(applet, settings, key, enablerKey) { - super(applet, settings, key, enablerKey); - } - on_changed() { let values = this.valuesKeysMapped; - let top = values["panel-border-top-thickness"]; - let right = values["panel-border-right-thickness"]; - let bottom = values["panel-border-bottom-thickness"]; - let left = values["panel-border-left-thickness"]; + let top = round(values["panel-border-top-thickness"], 2); + let right = round(values["panel-border-right-thickness"], 2); + let bottom = round(values["panel-border-bottom-thickness"], 2); + let left = round(values["panel-border-left-thickness"], 2); let color = values["panel-border-color"]; this.set_panel_style({ "border-top": `${top}px`, @@ -153,11 +148,11 @@ var PanelBorderTweakController = class PanelBorderTweakController extends PanelT finalize() { this.set_panel_style({ - "border-top": STYLE_UNSET_KEY, - "border-right": STYLE_UNSET_KEY, - "border-bottom": STYLE_UNSET_KEY, - "border-left": STYLE_UNSET_KEY, - "border-color": STYLE_UNSET_KEY, + "border-top": STYLE_TWEAK_UNSET_KEY, + "border-right": STYLE_TWEAK_UNSET_KEY, + "border-bottom": STYLE_TWEAK_UNSET_KEY, + "border-left": STYLE_TWEAK_UNSET_KEY, + "border-color": STYLE_TWEAK_UNSET_KEY, }); } } \ No newline at end of file diff --git a/panel-tweaks@anaximeno/files/panel-tweaks@anaximeno/metadata.json b/panel-tweaks@anaximeno/files/panel-tweaks@anaximeno/metadata.json index fc6c8713d0e..961e9d11782 100644 --- a/panel-tweaks@anaximeno/files/panel-tweaks@anaximeno/metadata.json +++ b/panel-tweaks@anaximeno/files/panel-tweaks@anaximeno/metadata.json @@ -1,5 +1,5 @@ { - "version": "0.1.1", + "version": "0.1.2", "uuid": "panel-tweaks@anaximeno", "name": "Cinnamon Panel Tweaker", "multiversion": true,