[gnome-shell/wip/jimmac/dash-icon-spacing: 30/72] overviewControls: Limit Dash height to 15% of the overview's




commit 641c49d0cc10496176582c64b452e7acabaee969
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Fri Jan 22 10:36:37 2021 -0300

    overviewControls: Limit Dash height to 15% of the overview's
    
    [WIP: write commit message]

 js/ui/dash.js             | 22 ++++++++++++++++++++++
 js/ui/overviewControls.js | 12 +++++++++++-
 2 files changed, 33 insertions(+), 1 deletion(-)
---
diff --git a/js/ui/dash.js b/js/ui/dash.js
index bbf3baa182..a92fa7563b 100644
--- a/js/ui/dash.js
+++ b/js/ui/dash.js
@@ -349,6 +349,7 @@ var Dash = GObject.registerClass({
 }, class Dash extends St.Bin {
     _init() {
         this._maxWidth = -1;
+        this._maxHeight = -1;
         this.iconSize = 64;
         this._shownInitially = false;
 
@@ -605,6 +606,19 @@ var Dash = GObject.registerClass({
 
         let availSize = availWidth / iconChildren.length;
 
+        if (this._maxHeight !== -1) {
+            const [, iconHeight] = firstIcon.icon.get_preferred_height(-1);
+            const [, buttonHeight] = firstButton.get_preferred_height(-1);
+
+            let availHeight = this._maxHeight;
+            availHeight -= this.get_theme_node().get_vertical_padding();
+            availHeight -= themeNode.get_margin(St.Side.TOP) + themeNode.get_margin(St.Side.BOTTOM);
+            availHeight -= themeNode.get_vertical_padding();
+            availHeight -= buttonHeight - iconHeight;
+
+            availSize = Math.min(availSize, availHeight);
+        }
+
         let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
         let iconSizes = baseIconSizes.map(s => s * scaleFactor);
 
@@ -924,4 +938,12 @@ var Dash = GObject.registerClass({
 
         return true;
     }
+
+    setMaxHeight(maxHeight) {
+        if (this._maxHeight === maxHeight)
+            return;
+
+        this._maxHeight = maxHeight;
+        this._queueRedisplay();
+    }
 });
diff --git a/js/ui/overviewControls.js b/js/ui/overviewControls.js
index 634244115a..4c315ce316 100644
--- a/js/ui/overviewControls.js
+++ b/js/ui/overviewControls.js
@@ -10,6 +10,8 @@ const Overview = imports.ui.overview;
 
 var SIDE_CONTROLS_ANIMATION_TIME = Overview.ANIMATION_TIME;
 
+const DASH_HEIGHT_PERCENTAGE = 0.15;
+
 var DashFader = GObject.registerClass(
 class DashFader extends St.Bin {
     _init(dash) {
@@ -41,6 +43,10 @@ class DashFader extends St.Bin {
             mode: Clutter.AnimationMode.EASE_IN_QUAD,
         });
     }
+
+    setMaxHeight(maxHeight) {
+        this._dash.setMaxHeight(maxHeight);
+    }
 });
 
 var ControlsManagerLayout = GObject.registerClass(
@@ -74,7 +80,11 @@ class ControlsManagerLayout extends Clutter.BinLayout {
         availableHeight -= searchHeight + spacing;
 
         // Dash
-        const [, dashHeight] = this._dash.get_preferred_height(width);
+        const maxDashHeight = Math.round(box.get_height() * DASH_HEIGHT_PERCENTAGE);
+        this._dash.setMaxHeight(maxDashHeight);
+
+        let [, dashHeight] = this._dash.get_preferred_height(width);
+        dashHeight = Math.min(dashHeight, maxDashHeight);
         childBox.set_origin(0, height - dashHeight);
         childBox.set_size(width, dashHeight);
         this._dash.allocate(childBox);


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