From 5106bb5a41779a2897903fd41b4053e95ce9bff9 Mon Sep 17 00:00:00 2001 From: Austin Thibodeaux Date: Fri, 21 Jan 2022 23:34:01 -0600 Subject: [PATCH 01/10] Panels now change color according to the dominant color of the focused app icon. Still working on ability to turn this feature on and off. --- Settings.ui | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ appIcons.js | 4 ++++ taskbar.js | 27 ++++++++++++++++++++++---- transparency.js | 9 +++++++-- 4 files changed, 84 insertions(+), 6 deletions(-) diff --git a/Settings.ui b/Settings.ui index ed7ef905..6b8a29e8 100644 --- a/Settings.ui +++ b/Settings.ui @@ -5455,6 +5455,56 @@ + + + True + True + + + True + False + 12 + 12 + 12 + 12 + 32 + + + True + False + True + Override panel theme background color with dominant icon color + True + 0 + + 0 + 0 + + + + + + True + False + 6 + + + True + True + end + center + + + + 0 + 1 + + + + + + + True diff --git a/appIcons.js b/appIcons.js index e79eae89..da7d5ef2 100644 --- a/appIcons.js +++ b/appIcons.js @@ -604,6 +604,10 @@ var taskbarAppIcon = Utils.defineClass({ } let highlightColor = this._getFocusHighlightColor(); + if (this.parentPanelColor != highlightColor){ + global.log('Emitting "changed::focus-highlight-color" with value ' + highlightColor); + global.dashToPanel.emit('changed::focus-highlight-color', highlightColor); + } inlineStyle += "background-color: " + cssHexTocssRgba(highlightColor, Me.settings.get_int('focus-highlight-opacity') * 0.01); } diff --git a/taskbar.js b/taskbar.js index 4f74d1ef..976ef799 100644 --- a/taskbar.js +++ b/taskbar.js @@ -391,6 +391,13 @@ var taskbar = Utils.defineClass({ 'notify::pageSize' ], () => this._onScrollSizeChange(adjustment) + ], + [ + global.dashToPanel, + 'changed::focus-highlight-color', + Lang.bind(this, function(_, color){ + this._updatePanelAppColor(color); + }) ] ); @@ -689,9 +696,9 @@ var taskbar = Utils.defineClass({ } appIcon.connect('menu-state-changed', - Lang.bind(this, function(appIcon, opened) { - this._itemMenuStateChanged(item, opened); - })); + Lang.bind(this, function(appIcon, opened) { + this._itemMenuStateChanged(item, opened); + })); let item = new TaskbarItemContainer(); @@ -700,6 +707,11 @@ var taskbar = Utils.defineClass({ item.setChild(appIcon.actor); appIcon._dashItemContainer = item; + this._signalsHandler.add( + global.dashToPanel, + 'changed::focus-highlight-color', + (_, color) => appIcon.parentPanelColor = this.dtpPanel.dynamicTransparency.currentBackgroundAppColor + ); appIcon.actor.connect('notify::hover', Lang.bind(this, function() { if (appIcon.actor.hover){ @@ -739,7 +751,7 @@ var taskbar = Utils.defineClass({ appIcon._menu._boxPointer.yOffset = -y_shift; } })); - + // Override default AppIcon label_actor, now the // accessible_name is set at DashItemContainer.setLabelText appIcon.actor.label_actor = null; @@ -751,6 +763,13 @@ var taskbar = Utils.defineClass({ return item; }, + _updatePanelAppColor: function (color){ + global.log('color: ' + color); + if (color){ + this.dtpPanel.dynamicTransparency.setBackgroundColorToAppColor(color); + } + }, + // Return an array with the "proper" appIcons currently in the taskbar _getAppIcons: function() { // Only consider children which are "proper" icons and which are not diff --git a/transparency.js b/transparency.js index aa86d7ac..c8485824 100644 --- a/transparency.js +++ b/transparency.js @@ -214,12 +214,17 @@ var DynamicTransparency = Utils.defineClass({ } }, + setBackgroundColorToAppColor: function(color){ + this.currentBackgroundAppColor = Utils.getrgbaColor(color, this.alpha); + this._setBackground(); + }, + _setBackground: function() { - this.currentBackgroundColor = Utils.getrgbaColor(this.backgroundColorRgb, this.alpha); + this.currentBackgroundColor = this.currentBackgroundAppColor || Utils.getrgbaColor(this.backgroundColorRgb, this.alpha); let transition = 'transition-duration:' + this.animationDuration; let cornerStyle = '-panel-corner-background-color: ' + this.currentBackgroundColor + transition; - + // global.log('panel background-color: ' + this.currentBackgroundColor); this._dtpPanel.set_style('background-color: ' + this.currentBackgroundColor + transition + this._complementaryStyles); if (this._dtpPanel.geom.position == St.Side.TOP) { From 53ae70d4db012710b328a0f6f189789599b3f605 Mon Sep 17 00:00:00 2001 From: Austin Thibodeaux Date: Sat, 22 Jan 2022 01:28:12 -0600 Subject: [PATCH 02/10] Dominant color panel background is now attached to settings. Can be turned on and off now. --- prefs.js | 5 +++++ ...shell.extensions.dash-to-panel.gschema.xml | 5 +++++ transparency.js | 20 +++++++++++++------ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/prefs.js b/prefs.js index 30407876..c22cd892 100644 --- a/prefs.js +++ b/prefs.js @@ -965,6 +965,11 @@ const Preferences = new Lang.Class({ this._builder.get_object('trans_bg_color_colorbutton'), 'sensitive', Gio.SettingsBindFlags.DEFAULT); + + this._settings.bind('trans-use-dominant-icon-color', + this._builder.get_object('trans_bg_icon_switch'), + 'active', + Gio.SettingsBindFlags.DEFAULT); let rgba = new Gdk.RGBA(); rgba.parse(this._settings.get_string('trans-bg-color')); diff --git a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml index 7e8ea3a9..4c475f76 100644 --- a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml +++ b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml @@ -239,6 +239,11 @@ Override theme background color Replace current theme background color for the panel + + false + Override panel theme background color with dominant icon color + Replace current theme background color for the panel with the dominant color of the focused app icon. Falls back to overridden background color or theme color if no app is focused or if the Activities overlay is opened. + "#000" Custom background color diff --git a/transparency.js b/transparency.js index c8485824..0e98f5cf 100644 --- a/transparency.js +++ b/transparency.js @@ -87,7 +87,8 @@ var DynamicTransparency = Utils.defineClass({ Me.settings, [ 'changed::trans-use-custom-bg', - 'changed::trans-bg-color' + 'changed::trans-bg-color', + 'changed::trans-use-dominant-icon-color' ], () => this._updateColorAndSet() ], @@ -187,9 +188,16 @@ var DynamicTransparency = Utils.defineClass({ }, _updateColor: function(themeBackground) { - this.backgroundColorRgb = Me.settings.get_boolean('trans-use-custom-bg') ? - Me.settings.get_string('trans-bg-color') : - (themeBackground || this._getThemeBackground()); + this.backgroundColorRgb = (themeBackground || this._getThemeBackground()); + if (Me.settings.get_boolean('trans-use-custom-bg')){ + this.backgroundColorRgb = Me.settings.get_string('trans-bg-color'); + } + if (Me.settings.get_boolean('trans-use-dominant-icon-color')){ + this.backgroundColorRgb = this.currentBackgroundAppColor; + } + // this.backgroundColorRgb = Me.settings.get_boolean('trans-use-custom-bg') ? + // Me.settings.get_string('trans-bg-color') : + // (themeBackground || this._getThemeBackground()); }, _updateAlpha: function(themeBackground) { @@ -216,11 +224,11 @@ var DynamicTransparency = Utils.defineClass({ setBackgroundColorToAppColor: function(color){ this.currentBackgroundAppColor = Utils.getrgbaColor(color, this.alpha); - this._setBackground(); + this._updateColorAndSet(); }, _setBackground: function() { - this.currentBackgroundColor = this.currentBackgroundAppColor || Utils.getrgbaColor(this.backgroundColorRgb, this.alpha); + this.currentBackgroundColor = Utils.getrgbaColor(this.backgroundColorRgb, this.alpha); let transition = 'transition-duration:' + this.animationDuration; let cornerStyle = '-panel-corner-background-color: ' + this.currentBackgroundColor + transition; From 0532ddd422e40e6fa88f990957165de208e3ee26 Mon Sep 17 00:00:00 2001 From: Austin Thibodeaux Date: Sun, 23 Jan 2022 19:27:47 -0600 Subject: [PATCH 03/10] Implemented ability to change dominant color brightness (linear light formula). Still a bug where brightness value gets set to 0.5 when user sets to 0 in settings. --- Settings.ui | 49 +++++++++++++++++++ appIcons.js | 29 +++++++---- prefs.js | 5 ++ ...shell.extensions.dash-to-panel.gschema.xml | 5 ++ taskbar.js | 4 +- transparency.js | 40 ++++++++++++--- 6 files changed, 114 insertions(+), 18 deletions(-) diff --git a/Settings.ui b/Settings.ui index 6b8a29e8..a07bc7f3 100644 --- a/Settings.ui +++ b/Settings.ui @@ -4331,6 +4331,11 @@ 5 10 + + 100 + 5 + 10 + 100 5 @@ -5501,6 +5506,50 @@ + + + True + False + 12 + 12 + 12 + 12 + 32 + + + True + False + True + Panel dominant color brightness (%) + True + 0 + + 0 + 0 + + + + + + True + True + end + center + 0 + trans_bg_icon_brightness_adjustment + + 0 + 1 + + + + + 1 + 0 + 2 + + + diff --git a/appIcons.js b/appIcons.js index da7d5ef2..1584d512 100644 --- a/appIcons.js +++ b/appIcons.js @@ -249,7 +249,7 @@ var taskbarAppIcon = Utils.defineClass({ Me.settings.connect('changed::dot-color-unfocused-4', Lang.bind(this, this._settingsChangeRefresh)), Me.settings.connect('changed::focus-highlight', Lang.bind(this, this._settingsChangeRefresh)), Me.settings.connect('changed::focus-highlight-dominant', Lang.bind(this, this._settingsChangeRefresh)), - Me.settings.connect('changed::focus-highlight-color', Lang.bind(this, this._settingsChangeRefresh)), + Me.settings.connect('changed::focus-dominant-color', Lang.bind(this, this._settingsChangeRefresh)), Me.settings.connect('changed::focus-highlight-opacity', Lang.bind(this, this._settingsChangeRefresh)), Me.settings.connect('changed::group-apps-label-font-size', Lang.bind(this, this._updateWindowTitleStyle)), Me.settings.connect('changed::group-apps-label-font-weight', Lang.bind(this, this._updateWindowTitleStyle)), @@ -604,13 +604,18 @@ var taskbarAppIcon = Utils.defineClass({ } let highlightColor = this._getFocusHighlightColor(); - if (this.parentPanelColor != highlightColor){ - global.log('Emitting "changed::focus-highlight-color" with value ' + highlightColor); - global.dashToPanel.emit('changed::focus-highlight-color', highlightColor); - } inlineStyle += "background-color: " + cssHexTocssRgba(highlightColor, Me.settings.get_int('focus-highlight-opacity') * 0.01); } - + + if (this._checkIfFocusedApp() && !this.isLauncher && + (!this.window || isFocused) && !this._isThemeProvidingIndicator() && this._checkIfMonitorHasFocus()){ + let dominantColor = this._getFocusedAppDominantColor(); + if (dominantColor && this.parentPanelColor != dominantColor){ + global.log('Emitting "changed::focus-dominant-color" with value ' + dominantColor); + global.dashToPanel.emit('changed::focus-dominant-color', dominantColor); + } + + } if(this._dotsContainer.get_style() != inlineStyle && this._dotsContainer.mapped) { if (!this._isGroupApps) { //when the apps are ungrouped, set the style synchronously so the icons don't jump around on taskbar redraw @@ -1087,11 +1092,17 @@ var taskbarAppIcon = Utils.defineClass({ return color; }, + _getFocusedAppDominantColor: function() { + let dce = new Utils.DominantColorExtractor(this.app); + let palette = dce._getColorPalette(); + if (palette) return palette.original; + return undefined; + }, + _getFocusHighlightColor: function() { if (Me.settings.get_boolean('focus-highlight-dominant')) { - let dce = new Utils.DominantColorExtractor(this.app); - let palette = dce._getColorPalette(); - if (palette) return palette.original; + let domColor = this._getFocusedAppDominantColor(); + if (domColor !== undefined) return domColor; } return Me.settings.get_string('focus-highlight-color'); }, diff --git a/prefs.js b/prefs.js index c22cd892..56c03e69 100644 --- a/prefs.js +++ b/prefs.js @@ -1002,6 +1002,11 @@ const Preferences = new Lang.Class({ this._settings.set_double('trans-panel-opacity', widget.get_value() * 0.01); })); + this._builder.get_object('trans_bg_icon_brightness_spinbutton').set_value(this._settings.get_double('trans-panel-dominant-color-brightness') * 100); + this._builder.get_object('trans_bg_icon_brightness_spinbutton').connect('value-changed', Lang.bind(this, function (widget) { + this._settings.set_double('trans-panel-dominant-color-brightness', widget.get_value() * 0.01); + })); + this._settings.bind('trans-use-dynamic-opacity', this._builder.get_object('trans_dyn_switch'), 'active', diff --git a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml index 4c475f76..5249a82c 100644 --- a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml +++ b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml @@ -264,6 +264,11 @@ Panel opacity Custom opacity for the panel + + 0.5 + Panel dominant color brightness + Modify brightness of dominant color of app icon used as panel background color + 'ALL_WINDOWS' Dynamic opacity behavior diff --git a/taskbar.js b/taskbar.js index 976ef799..5e2024ca 100644 --- a/taskbar.js +++ b/taskbar.js @@ -394,7 +394,7 @@ var taskbar = Utils.defineClass({ ], [ global.dashToPanel, - 'changed::focus-highlight-color', + 'changed::focus-dominant-color', Lang.bind(this, function(_, color){ this._updatePanelAppColor(color); }) @@ -709,7 +709,7 @@ var taskbar = Utils.defineClass({ appIcon._dashItemContainer = item; this._signalsHandler.add( global.dashToPanel, - 'changed::focus-highlight-color', + 'changed::focus-dominant-color', (_, color) => appIcon.parentPanelColor = this.dtpPanel.dynamicTransparency.currentBackgroundAppColor ); diff --git a/transparency.js b/transparency.js index 0e98f5cf..bd987080 100644 --- a/transparency.js +++ b/transparency.js @@ -88,7 +88,8 @@ var DynamicTransparency = Utils.defineClass({ [ 'changed::trans-use-custom-bg', 'changed::trans-bg-color', - 'changed::trans-use-dominant-icon-color' + 'changed::trans-use-dominant-icon-color', + 'changed::trans-panel-dominant-color-brightness' ], () => this._updateColorAndSet() ], @@ -187,17 +188,42 @@ var DynamicTransparency = Utils.defineClass({ this._complementaryStyles = 'border-radius: ' + panelThemeNode.get_border_radius(0) + 'px;'; }, + _linearLight: function(color, value){ + let applyBlend = function(comp){ + let comp01 = comp/256; // Scale from 0-256 to 0-1 + global.log('comp: ' + comp + ', comp01: ' + comp01); + return ((value > 0.5)*(comp01 + 2*(value-0.5)) + (value <= 0.5)*(comp01 + 2*value-1))*256 + } + return { + red: applyBlend(color.red), + green: applyBlend(color.green), + blue: applyBlend(color.blue) + } + }, + + _modifyColorToDominantAppColor: function(inputColor){ + let outputColor = inputColor; + if (Me.settings.get_boolean('trans-use-dominant-icon-color') && this.currentBackgroundAppColor){ + outputColor = this.currentBackgroundAppColor; + outputColor = Utils.getrgbColor(outputColor) // Convert to RGB object + + let blendValue = Me.settings.get_double('trans-panel-dominant-color-brightness') || 0.5; + + // Apply Linear Light blending (black if value is 0, white if value is 1, same color as input if value is 0.5) + + global.log('outputColor BEFORE linearlight: r: ' + outputColor.red + ", g: " + outputColor.green + ", b: " + outputColor.blue + ", blendValue: " + blendValue); + outputColor = this._linearLight(outputColor, blendValue); + global.log('outputColor AFTER linearlight: r: ' + outputColor.red + ", g: " + outputColor.green + ", b: " + outputColor.blue + ", blendValue: " + blendValue); + } + return outputColor; + }, + _updateColor: function(themeBackground) { this.backgroundColorRgb = (themeBackground || this._getThemeBackground()); if (Me.settings.get_boolean('trans-use-custom-bg')){ this.backgroundColorRgb = Me.settings.get_string('trans-bg-color'); } - if (Me.settings.get_boolean('trans-use-dominant-icon-color')){ - this.backgroundColorRgb = this.currentBackgroundAppColor; - } - // this.backgroundColorRgb = Me.settings.get_boolean('trans-use-custom-bg') ? - // Me.settings.get_string('trans-bg-color') : - // (themeBackground || this._getThemeBackground()); + this.backgroundColorRgb = this._modifyColorToDominantAppColor(this.backgroundColorRgb); }, _updateAlpha: function(themeBackground) { From ac5d608b81c03fea5d02c92d55f86eba2e3ddd78 Mon Sep 17 00:00:00 2001 From: Austin Thibodeaux Date: Sun, 23 Jan 2022 19:31:14 -0600 Subject: [PATCH 04/10] Renamed _getFocusedAppDominantColor() to _getAppDominantColor() because it doesn't care if the app is focused or not. --- appIcons.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/appIcons.js b/appIcons.js index 1584d512..18866240 100644 --- a/appIcons.js +++ b/appIcons.js @@ -609,7 +609,7 @@ var taskbarAppIcon = Utils.defineClass({ if (this._checkIfFocusedApp() && !this.isLauncher && (!this.window || isFocused) && !this._isThemeProvidingIndicator() && this._checkIfMonitorHasFocus()){ - let dominantColor = this._getFocusedAppDominantColor(); + let dominantColor = this._getAppDominantColor(); if (dominantColor && this.parentPanelColor != dominantColor){ global.log('Emitting "changed::focus-dominant-color" with value ' + dominantColor); global.dashToPanel.emit('changed::focus-dominant-color', dominantColor); @@ -1092,7 +1092,7 @@ var taskbarAppIcon = Utils.defineClass({ return color; }, - _getFocusedAppDominantColor: function() { + _getAppDominantColor: function() { let dce = new Utils.DominantColorExtractor(this.app); let palette = dce._getColorPalette(); if (palette) return palette.original; @@ -1101,7 +1101,7 @@ var taskbarAppIcon = Utils.defineClass({ _getFocusHighlightColor: function() { if (Me.settings.get_boolean('focus-highlight-dominant')) { - let domColor = this._getFocusedAppDominantColor(); + let domColor = this._getAppDominantColor(); if (domColor !== undefined) return domColor; } return Me.settings.get_string('focus-highlight-color'); From 20dac20894903ee42de87cb25284108c9f26acf5 Mon Sep 17 00:00:00 2001 From: Austin Thibodeaux Date: Sun, 23 Jan 2022 22:25:24 -0600 Subject: [PATCH 05/10] Added ability to apply dominant color optionally to window preview as well as choose its brightness --- Settings.ui | 170 ++++++++++++------ appIcons.js | 1 - prefs.js | 10 ++ ...shell.extensions.dash-to-panel.gschema.xml | 10 ++ taskbar.js | 1 - transparency.js | 35 ++-- windowPreview.js | 8 +- 7 files changed, 166 insertions(+), 69 deletions(-) diff --git a/Settings.ui b/Settings.ui index a07bc7f3..09b45bb2 100644 --- a/Settings.ui +++ b/Settings.ui @@ -4336,6 +4336,11 @@ 5 10 + + 100 + 5 + 10 + 100 5 @@ -5465,49 +5470,12 @@ True True - + True False - 12 - 12 - 12 - 12 - 32 - - - True - False - True - Override panel theme background color with dominant icon color - True - 0 - - 0 - 0 - - - - - - True - False - 6 - - - True - True - end - center - - - - 0 - 1 - - - + vertical - + True False 12 @@ -5516,11 +5484,11 @@ 12 32 - + True False True - Panel dominant color brightness (%) + Override panel theme background color with dominant icon color True 0 @@ -5530,24 +5498,120 @@ - + True - True - end - center - 0 - trans_bg_icon_brightness_adjustment + False + 6 + + + True + True + end + center + + 0 1 - - 1 - 0 - 2 - + + + True + False + 12 + 12 + 6 + + + True + False + True + Panel dominant color brightness (%) + True + 0 + + 0 + 0 + + + + + + True + True + end + center + 0 + trans_bg_icon_brightness_adjustment + + 0 + 1 + + + + + + True + False + True + Apply to window preview + True + 0 + + 1 + 0 + + + + + + True + True + end + center + + 1 + 1 + + + + + + True + False + True + Window preview brightness (%) + True + 0 + + 2 + 0 + + + + + + True + True + end + center + 0 + trans_bg_icon_preview_brightness_adjustment + + 2 + 1 + + + + + 1 + 0 + 2 + + + diff --git a/appIcons.js b/appIcons.js index 18866240..d72faf7b 100644 --- a/appIcons.js +++ b/appIcons.js @@ -611,7 +611,6 @@ var taskbarAppIcon = Utils.defineClass({ (!this.window || isFocused) && !this._isThemeProvidingIndicator() && this._checkIfMonitorHasFocus()){ let dominantColor = this._getAppDominantColor(); if (dominantColor && this.parentPanelColor != dominantColor){ - global.log('Emitting "changed::focus-dominant-color" with value ' + dominantColor); global.dashToPanel.emit('changed::focus-dominant-color', dominantColor); } diff --git a/prefs.js b/prefs.js index 56c03e69..06e118ac 100644 --- a/prefs.js +++ b/prefs.js @@ -970,6 +970,11 @@ const Preferences = new Lang.Class({ this._builder.get_object('trans_bg_icon_switch'), 'active', Gio.SettingsBindFlags.DEFAULT); + + this._settings.bind('trans-apply-dominant-color-to-preview', + this._builder.get_object('trans_bg_icon_preview_switch'), + 'active', + Gio.SettingsBindFlags.DEFAULT); let rgba = new Gdk.RGBA(); rgba.parse(this._settings.get_string('trans-bg-color')); @@ -1007,6 +1012,11 @@ const Preferences = new Lang.Class({ this._settings.set_double('trans-panel-dominant-color-brightness', widget.get_value() * 0.01); })); + this._builder.get_object('trans_bg_icon_preview_brightness_spinbutton').set_value(this._settings.get_double('trans-preview-dominant-color-brightness') * 100); + this._builder.get_object('trans_bg_icon_preview_brightness_spinbutton').connect('value-changed', Lang.bind(this, function (widget) { + this._settings.set_double('trans-preview-dominant-color-brightness', widget.get_value() * 0.01); + })); + this._settings.bind('trans-use-dynamic-opacity', this._builder.get_object('trans_dyn_switch'), 'active', diff --git a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml index 5249a82c..397ffb43 100644 --- a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml +++ b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml @@ -244,6 +244,11 @@ Override panel theme background color with dominant icon color Replace current theme background color for the panel with the dominant color of the focused app icon. Falls back to overridden background color or theme color if no app is focused or if the Activities overlay is opened. + + false + Apply to window preview + Apply dominant color to window preview + "#000" Custom background color @@ -269,6 +274,11 @@ Panel dominant color brightness Modify brightness of dominant color of app icon used as panel background color + + 0.5 + Window preview dominant color brightness + Modify brightness of dominant color of app icon used as window preview background color + 'ALL_WINDOWS' Dynamic opacity behavior diff --git a/taskbar.js b/taskbar.js index 5e2024ca..5f4b702f 100644 --- a/taskbar.js +++ b/taskbar.js @@ -764,7 +764,6 @@ var taskbar = Utils.defineClass({ }, _updatePanelAppColor: function (color){ - global.log('color: ' + color); if (color){ this.dtpPanel.dynamicTransparency.setBackgroundColorToAppColor(color); } diff --git a/transparency.js b/transparency.js index bd987080..afe7da37 100644 --- a/transparency.js +++ b/transparency.js @@ -89,7 +89,9 @@ var DynamicTransparency = Utils.defineClass({ 'changed::trans-use-custom-bg', 'changed::trans-bg-color', 'changed::trans-use-dominant-icon-color', - 'changed::trans-panel-dominant-color-brightness' + 'changed::trans-panel-dominant-color-brightness', + 'changed::trans-apply-dominant-color-to-preview', + 'changed::trans-preview-dominant-color-brightness' ], () => this._updateColorAndSet() ], @@ -191,7 +193,6 @@ var DynamicTransparency = Utils.defineClass({ _linearLight: function(color, value){ let applyBlend = function(comp){ let comp01 = comp/256; // Scale from 0-256 to 0-1 - global.log('comp: ' + comp + ', comp01: ' + comp01); return ((value > 0.5)*(comp01 + 2*(value-0.5)) + (value <= 0.5)*(comp01 + 2*value-1))*256 } return { @@ -201,29 +202,36 @@ var DynamicTransparency = Utils.defineClass({ } }, - _modifyColorToDominantAppColor: function(inputColor){ + _modifyColorToDominantAppColor: function(inputColor, overrideValue){ let outputColor = inputColor; if (Me.settings.get_boolean('trans-use-dominant-icon-color') && this.currentBackgroundAppColor){ outputColor = this.currentBackgroundAppColor; outputColor = Utils.getrgbColor(outputColor) // Convert to RGB object - let blendValue = Me.settings.get_double('trans-panel-dominant-color-brightness') || 0.5; + let blendValue = overrideValue || Me.settings.get_double('trans-panel-dominant-color-brightness') || 0.5; // Apply Linear Light blending (black if value is 0, white if value is 1, same color as input if value is 0.5) - - global.log('outputColor BEFORE linearlight: r: ' + outputColor.red + ", g: " + outputColor.green + ", b: " + outputColor.blue + ", blendValue: " + blendValue); + log('outputColor BEFORE linearlight: r: ' + outputColor.red + ", g: " + outputColor.green + ", b: " + outputColor.blue + ", blendValue: " + blendValue); outputColor = this._linearLight(outputColor, blendValue); - global.log('outputColor AFTER linearlight: r: ' + outputColor.red + ", g: " + outputColor.green + ", b: " + outputColor.blue + ", blendValue: " + blendValue); + log('outputColor AFTER linearlight: r: ' + outputColor.red + ", g: " + outputColor.green + ", b: " + outputColor.blue + ", blendValue: " + blendValue); } return outputColor; }, _updateColor: function(themeBackground) { this.backgroundColorRgb = (themeBackground || this._getThemeBackground()); + this.backgroundColorRgbPreview = this.backgroundColorRgb; if (Me.settings.get_boolean('trans-use-custom-bg')){ this.backgroundColorRgb = Me.settings.get_string('trans-bg-color'); + this.backgroundColorRgbPreview = this.backgroundColorRgb; + } + if (Me.settings.get_boolean('trans-apply-dominant-color-to-preview')){ + this.backgroundColorRgb = this._modifyColorToDominantAppColor(this.backgroundColorRgb); + this.backgroundColorRgbPreview = this._modifyColorToDominantAppColor( + this.backgroundColorRgb, + Me.settings.get_double('trans-preview-dominant-color-brightness') + ); } - this.backgroundColorRgb = this._modifyColorToDominantAppColor(this.backgroundColorRgb); }, _updateAlpha: function(themeBackground) { @@ -254,11 +262,18 @@ var DynamicTransparency = Utils.defineClass({ }, _setBackground: function() { - this.currentBackgroundColor = Utils.getrgbaColor(this.backgroundColorRgb, this.alpha); + + if (Me.settings.get_boolean('trans-apply-dominant-color-to-preview')){ + this.currentBackgroundColor = Utils.getrgbaColor(this.backgroundColorRgb, this.alpha); + } + else + { + this.currentBackgroundColor = this._modifyColorToDominantAppColor(this.backgroundColorRgb); + this.currentBackgroundColor = Utils.getrgbaColor(this.currentBackgroundColor, this.alpha); + } let transition = 'transition-duration:' + this.animationDuration; let cornerStyle = '-panel-corner-background-color: ' + this.currentBackgroundColor + transition; - // global.log('panel background-color: ' + this.currentBackgroundColor); this._dtpPanel.set_style('background-color: ' + this.currentBackgroundColor + transition + this._complementaryStyles); if (this._dtpPanel.geom.position == St.Side.TOP) { diff --git a/windowPreview.js b/windowPreview.js index 45d08a04..ebf87dbb 100644 --- a/windowPreview.js +++ b/windowPreview.js @@ -193,7 +193,7 @@ var PreviewMenu = Utils.defineClass({ this.set_height(this.clipHeight); this.menu.show(); - setStyle(this.menu, 'background: ' + Utils.getrgbaColor(this.panel.dynamicTransparency.backgroundColorRgb, alphaBg)); + setStyle(this.menu, 'background: ' + Utils.getrgbaColor(this.panel.dynamicTransparency.backgroundColorRgbPreview, alphaBg)); } this._mergeWindows(appIcon); @@ -519,8 +519,8 @@ var PreviewMenu = Utils.defineClass({ _getFadeWidget: function(end) { let x = 0, y = 0; - let startBg = Utils.getrgbaColor(this.panel.dynamicTransparency.backgroundColorRgb, Math.min(alphaBg + .1, 1)); - let endBg = Utils.getrgbaColor(this.panel.dynamicTransparency.backgroundColorRgb, 0) + let startBg = Utils.getrgbaColor(this.panel.dynamicTransparency.backgroundColorRgbPreview, Math.min(alphaBg + .1, 1)); + let endBg = Utils.getrgbaColor(this.panel.dynamicTransparency.backgroundColorRgbPreview, 0) let fadeStyle = 'background-gradient-start:' + startBg + 'background-gradient-end:' + endBg + 'background-gradient-direction:' + this.panel.getOrientation(); @@ -997,7 +997,7 @@ var Preview = Utils.defineClass({ alpha = alphaBg; } - return Utils.getrgbaColor(this._previewMenu.panel.dynamicTransparency.backgroundColorRgb, alpha, offset); + return Utils.getrgbaColor(this._previewMenu.panel.dynamicTransparency.backgroundColorRgbPreview, alpha, offset); }, _addClone: function(newCloneBin, animateSize) { From 9da5ad192f3f9c493e7d57669b97614a74289b29 Mon Sep 17 00:00:00 2001 From: Austin Thibodeaux Date: Sun, 23 Jan 2022 22:39:48 -0600 Subject: [PATCH 06/10] Fixed issue where window preview brightness adds upon brightness of panel. Not seperate like it's supposed to be. --- schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml | 2 +- transparency.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml index 397ffb43..2fb33ad2 100644 --- a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml +++ b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml @@ -275,7 +275,7 @@ Modify brightness of dominant color of app icon used as panel background color - 0.5 + 0.15 Window preview dominant color brightness Modify brightness of dominant color of app icon used as window preview background color diff --git a/transparency.js b/transparency.js index afe7da37..f72141fa 100644 --- a/transparency.js +++ b/transparency.js @@ -226,9 +226,10 @@ var DynamicTransparency = Utils.defineClass({ this.backgroundColorRgbPreview = this.backgroundColorRgb; } if (Me.settings.get_boolean('trans-apply-dominant-color-to-preview')){ + let prevBgColor = this.backgroundColorRgb; this.backgroundColorRgb = this._modifyColorToDominantAppColor(this.backgroundColorRgb); this.backgroundColorRgbPreview = this._modifyColorToDominantAppColor( - this.backgroundColorRgb, + prevBgColor, Me.settings.get_double('trans-preview-dominant-color-brightness') ); } From b00b0eceaa714bfa55c92f644d82f3691b0168f3 Mon Sep 17 00:00:00 2001 From: Austin Thibodeaux Date: Sun, 23 Jan 2022 22:40:16 -0600 Subject: [PATCH 07/10] Removed some logs --- transparency.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/transparency.js b/transparency.js index f72141fa..a470febc 100644 --- a/transparency.js +++ b/transparency.js @@ -211,9 +211,7 @@ var DynamicTransparency = Utils.defineClass({ let blendValue = overrideValue || Me.settings.get_double('trans-panel-dominant-color-brightness') || 0.5; // Apply Linear Light blending (black if value is 0, white if value is 1, same color as input if value is 0.5) - log('outputColor BEFORE linearlight: r: ' + outputColor.red + ", g: " + outputColor.green + ", b: " + outputColor.blue + ", blendValue: " + blendValue); outputColor = this._linearLight(outputColor, blendValue); - log('outputColor AFTER linearlight: r: ' + outputColor.red + ", g: " + outputColor.green + ", b: " + outputColor.blue + ", blendValue: " + blendValue); } return outputColor; }, From df69b958ce46dee2a88de739930a6b6bf245c90f Mon Sep 17 00:00:00 2001 From: Austin Thibodeaux Date: Sun, 23 Jan 2022 23:09:31 -0600 Subject: [PATCH 08/10] Fixed bug where when dominant color brightness is set to 0 it resets to default brightness. --- prefs.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/prefs.js b/prefs.js index 06e118ac..ec9a701a 100644 --- a/prefs.js +++ b/prefs.js @@ -1009,12 +1009,26 @@ const Preferences = new Lang.Class({ this._builder.get_object('trans_bg_icon_brightness_spinbutton').set_value(this._settings.get_double('trans-panel-dominant-color-brightness') * 100); this._builder.get_object('trans_bg_icon_brightness_spinbutton').connect('value-changed', Lang.bind(this, function (widget) { - this._settings.set_double('trans-panel-dominant-color-brightness', widget.get_value() * 0.01); + if (widget.get_value() < 1){ + // Somehow fixes bug that resets brightness to 0.5 when user sets to 0 + this._settings.set_double('trans-panel-dominant-color-brightness', 0.001); + } + else + { + this._settings.set_double('trans-panel-dominant-color-brightness', widget.get_value() * 0.01); + } })); this._builder.get_object('trans_bg_icon_preview_brightness_spinbutton').set_value(this._settings.get_double('trans-preview-dominant-color-brightness') * 100); this._builder.get_object('trans_bg_icon_preview_brightness_spinbutton').connect('value-changed', Lang.bind(this, function (widget) { - this._settings.set_double('trans-preview-dominant-color-brightness', widget.get_value() * 0.01); + if (widget.get_value() < 1){ + // Somehow fixes bug that resets brightness to 0.5 when user sets to 0 + this._settings.set_double('trans-preview-dominant-color-brightness', 0.001); + } + else + { + this._settings.set_double('trans-preview-dominant-color-brightness', widget.get_value() * 0.01); + } })); this._settings.bind('trans-use-dynamic-opacity', From 69cea48e2a4ddd43bb0b1e727195c076029527c2 Mon Sep 17 00:00:00 2001 From: Austin Thibodeaux Date: Sun, 23 Jan 2022 23:30:04 -0600 Subject: [PATCH 09/10] Panel dominant color will now be turned off when there is no apps in focus. --- transparency.js | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/transparency.js b/transparency.js index a470febc..308cec26 100644 --- a/transparency.js +++ b/transparency.js @@ -26,6 +26,9 @@ const Me = imports.misc.extensionUtils.getCurrentExtension(); const Panel = Me.imports.panel; const Proximity = Me.imports.proximity; const Utils = Me.imports.utils; +const Shell = imports.gi.Shell; + +let tracker = Shell.WindowTracker.get_default(); var DynamicTransparency = Utils.defineClass({ Name: 'DashToPanel.DynamicTransparency', @@ -49,6 +52,18 @@ var DynamicTransparency = Utils.defineClass({ this._updateAnimationDuration(); this._updateAllAndSet(); this._updateProximityWatch(); + + this._focusWindowChangedId = global.display.connect('notify::focus-window', + Lang.bind(this, this._onFocusAppChanged)); + }, + + _onDestroy: function(){ + if(this._focusWindowChangedId) + global.display.disconnect(this._focusWindowChangedId); + }, + + _onFocusAppChanged: function(){ + this._updateColorAndSet(); }, destroy: function() { @@ -223,7 +238,7 @@ var DynamicTransparency = Utils.defineClass({ this.backgroundColorRgb = Me.settings.get_string('trans-bg-color'); this.backgroundColorRgbPreview = this.backgroundColorRgb; } - if (Me.settings.get_boolean('trans-apply-dominant-color-to-preview')){ + if (Me.settings.get_boolean('trans-apply-dominant-color-to-preview') && tracker.focus_app){ let prevBgColor = this.backgroundColorRgb; this.backgroundColorRgb = this._modifyColorToDominantAppColor(this.backgroundColorRgb); this.backgroundColorRgbPreview = this._modifyColorToDominantAppColor( @@ -231,6 +246,10 @@ var DynamicTransparency = Utils.defineClass({ Me.settings.get_double('trans-preview-dominant-color-brightness') ); } + else if (tracker.focus_app) + { + this.backgroundColorRgb = this._modifyColorToDominantAppColor(this.backgroundColorRgb); + } }, _updateAlpha: function(themeBackground) { @@ -261,15 +280,7 @@ var DynamicTransparency = Utils.defineClass({ }, _setBackground: function() { - - if (Me.settings.get_boolean('trans-apply-dominant-color-to-preview')){ - this.currentBackgroundColor = Utils.getrgbaColor(this.backgroundColorRgb, this.alpha); - } - else - { - this.currentBackgroundColor = this._modifyColorToDominantAppColor(this.backgroundColorRgb); - this.currentBackgroundColor = Utils.getrgbaColor(this.currentBackgroundColor, this.alpha); - } + this.currentBackgroundColor = Utils.getrgbaColor(this.backgroundColorRgb, this.alpha); let transition = 'transition-duration:' + this.animationDuration; let cornerStyle = '-panel-corner-background-color: ' + this.currentBackgroundColor + transition; From 4307680900157239781acb3da25a4d3d178319a6 Mon Sep 17 00:00:00 2001 From: Austin Thibodeaux Date: Thu, 27 Jan 2022 20:03:25 -0600 Subject: [PATCH 10/10] Added back changed::focus-highlight-color settings bind that was removed by mistake. --- appIcons.js | 1 + 1 file changed, 1 insertion(+) diff --git a/appIcons.js b/appIcons.js index d72faf7b..469ed525 100644 --- a/appIcons.js +++ b/appIcons.js @@ -249,6 +249,7 @@ var taskbarAppIcon = Utils.defineClass({ Me.settings.connect('changed::dot-color-unfocused-4', Lang.bind(this, this._settingsChangeRefresh)), Me.settings.connect('changed::focus-highlight', Lang.bind(this, this._settingsChangeRefresh)), Me.settings.connect('changed::focus-highlight-dominant', Lang.bind(this, this._settingsChangeRefresh)), + Me.settings.connect('changed::focus-highlight-color', Lang.bind(this, this._settingsChangeRefresh)), Me.settings.connect('changed::focus-dominant-color', Lang.bind(this, this._settingsChangeRefresh)), Me.settings.connect('changed::focus-highlight-opacity', Lang.bind(this, this._settingsChangeRefresh)), Me.settings.connect('changed::group-apps-label-font-size', Lang.bind(this, this._updateWindowTitleStyle)),