[gnome-shell] overviewControls: Use adjustment to control layout



commit 3887253823b9ff6e86cc0da191863c12fff79d7b
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Dec 30 17:32:03 2020 -0300

    overviewControls: Use adjustment to control layout
    
    Right now, the adjustment is fixed at ControlsState.WINDOW_PICKER,
    but soon it will be propagated to ViewSelector to control the
    transitions.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1624>

 js/ui/overviewControls.js | 31 ++++++++++++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)
---
diff --git a/js/ui/overviewControls.js b/js/ui/overviewControls.js
index d31c5b96ca..4f0751d45f 100644
--- a/js/ui/overviewControls.js
+++ b/js/ui/overviewControls.js
@@ -6,14 +6,23 @@ const { Clutter, GObject, St } = imports.gi;
 const Dash = imports.ui.dash;
 const ViewSelector = imports.ui.viewSelector;
 
+var ControlsState = {
+    HIDDEN: 0,
+    WINDOW_PICKER: 1,
+    APP_GRID: 2,
+};
+
 var ControlsManagerLayout = GObject.registerClass(
 class ControlsManagerLayout extends Clutter.BoxLayout {
-    _init(searchEntry, viewSelector, dash) {
+    _init(searchEntry, viewSelector, dash, stateAdjustment) {
         super._init({ orientation: Clutter.Orientation.VERTICAL });
 
+        this._stateAdjustment = stateAdjustment;
         this._searchEntry = searchEntry;
         this._viewSelector = viewSelector;
         this._dash = dash;
+
+        stateAdjustment.connect('notify::value', () => this.layout_changed());
     }
 
     vfunc_set_container(container) {
@@ -46,9 +55,18 @@ class ControlsManagerLayout extends Clutter.BoxLayout {
         availableHeight -= dashHeight + spacing;
 
         // ViewSelector
+        const initialBox = new Clutter.ActorBox();
+        initialBox.set_origin(0, 0);
+        initialBox.set_size(width, height);
+
         childBox.set_origin(0, searchHeight + spacing);
         childBox.set_size(width, availableHeight);
-        this._viewSelector.allocate(childBox);
+
+        const page = this._viewSelector.getActivePage();
+        const progress = page === ViewSelector.ViewPage.SEARCH
+            ? 1 : Math.min(this._stateAdjustment.value, 1);
+        const viewSelectorBox = initialBox.interpolate(childBox, progress);
+        this._viewSelector.allocate(viewSelectorBox);
     }
 });
 
@@ -93,6 +111,13 @@ class ControlsManager extends St.Widget {
             upper: workspaceManager.n_workspaces,
         });
 
+        this._stateAdjustment = new St.Adjustment({
+            actor: this,
+            value: ControlsState.WINDOW_PICKER,
+            lower: ControlsState.HIDDEN,
+            upper: ControlsState.APP_GRID,
+        });
+
         this._nWorkspacesNotifyId =
             workspaceManager.connect('notify::n-workspaces',
                 this._updateAdjustment.bind(this));
@@ -105,7 +130,7 @@ class ControlsManager extends St.Widget {
         this.add_child(this.viewSelector);
 
         this.layout_manager = new ControlsManagerLayout(searchEntryBin,
-            this.viewSelector, this.dash);
+            this.viewSelector, this.dash, this._stateAdjustment);
 
         this.connect('destroy', this._onDestroy.bind(this));
     }


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