[gnome-shell/wip/jimmac/dash-icon-spacing: 32/72] viewSelector: Use state adjustment for apps page




commit 7823bc06f0271f35df2933af0d9c1f0a9a9f52ac
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Dec 30 17:45:09 2020 -0300

    viewSelector: Use state adjustment for apps page
    
    Currently, AppsPageContainer reacts to showAppsButton and
    transitions between app grid and window picking states on
    its own. In the future, we want full control over this.
    
    ControlsManager already has a state adjustment that represents
    all possible overview states. Progragate this adjustment up
    to AppsPageContainer, and use it to drive the transition.
    
    This requires moving the callback to the showAppsButton to
    ControlsManager, since now it control the state adjustment
    itself, not AppsPageContainer's adjustment.

 js/ui/overviewControls.js | 19 ++++++++++++++++++-
 js/ui/viewSelector.js     | 22 ++++++----------------
 2 files changed, 24 insertions(+), 17 deletions(-)
---
diff --git a/js/ui/overviewControls.js b/js/ui/overviewControls.js
index df03a0dd01..09a616e771 100644
--- a/js/ui/overviewControls.js
+++ b/js/ui/overviewControls.js
@@ -170,7 +170,9 @@ class ControlsManager extends St.Widget {
                 this._updateAdjustment.bind(this));
 
         this.viewSelector = new ViewSelector.ViewSelector(this._searchEntry,
-            this._workspaceAdjustment, this.dash.showAppsButton);
+            this._workspaceAdjustment,
+            this.dash.showAppsButton,
+            this._adjustment);
 
         this.add_child(searchEntryBin);
         this.add_child(this._dashFader);
@@ -179,9 +181,24 @@ class ControlsManager extends St.Widget {
         this.layout_manager = new ControlsManagerLayout(searchEntryBin,
             this.viewSelector, this._dashFader, this._adjustment);
 
+        this.dash.showAppsButton.connect('notify::checked',
+            this._onShowAppsButtonToggled.bind(this));
+
         this.connect('destroy', this._onDestroy.bind(this));
     }
 
+    _onShowAppsButtonToggled() {
+        const checked = this.dash.showAppsButton.checked;
+
+        const value = checked
+            ? ControlsState.APP_GRID : ControlsState.WINDOW_PICKER;
+        this._adjustment.remove_transition('value');
+        this._adjustment.ease(value, {
+            duration: SIDE_CONTROLS_ANIMATION_TIME,
+            mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+        });
+    }
+
     _onDestroy() {
         global.workspace_manager.disconnect(this._nWorkspacesNotifyId);
     }
diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js
index cb293a326b..a5a896a407 100644
--- a/js/ui/viewSelector.js
+++ b/js/ui/viewSelector.js
@@ -122,7 +122,7 @@ var ShowOverviewAction = GObject.registerClass({
 
 var AppsPageContainer = GObject.registerClass(
 class AppsPageContainer extends St.Widget {
-    _init(workspacesDisplay, appDisplay, showAppsButton) {
+    _init(workspacesDisplay, appDisplay, overviewAdjustment) {
         super._init();
 
         // 0 for window picker, 1 for app grid
@@ -137,9 +137,9 @@ class AppsPageContainer extends St.Widget {
             this.queue_relayout();
         });
 
-        this._showAppsButton = showAppsButton;
-        showAppsButton.connect('notify::checked',
-            this._onShowAppsButtonToggled.bind(this));
+        overviewAdjustment.connect('notify::value', () => {
+            this._adjustment.value = Math.max(overviewAdjustment.value - 1, 0);
+        });
 
         this._appDisplay = appDisplay;
         this.add_child(appDisplay);
@@ -154,16 +154,6 @@ class AppsPageContainer extends St.Widget {
         this._update();
     }
 
-    _onShowAppsButtonToggled() {
-        const checked = this._showAppsButton.checked;
-
-        const value = checked ? 1 : 0;
-        this._adjustment.ease(value, {
-            duration: OverviewControls.SIDE_CONTROLS_ANIMATION_TIME,
-            mode: Clutter.AnimationMode.EASE_OUT_QUAD,
-        });
-    }
-
     _update() {
         const progress = this._adjustment.value;
 
@@ -207,7 +197,7 @@ var ViewSelector = GObject.registerClass({
         'page-empty': {},
     },
 }, class ViewSelector extends Shell.Stack {
-    _init(searchEntry, workspaceAdjustment, showAppsButton) {
+    _init(searchEntry, workspaceAdjustment, showAppsButton, overviewAdjustment) {
         super._init({
             name: 'viewSelector',
             x_expand: true,
@@ -256,7 +246,7 @@ var ViewSelector = GObject.registerClass({
         this.appDisplay = new AppDisplay.AppDisplay();
 
         const appsContainer = new AppsPageContainer(
-            this._workspacesDisplay, this.appDisplay, showAppsButton);
+            this._workspacesDisplay, this.appDisplay, overviewAdjustment);
         this._appsPage =
             this._addPage(appsContainer, _('Applications'), 'view-app-grid-symbolic');
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]