[gnome-shell] Add "precision" to boxpointer alignment



commit 8f3376ce62de2ac5a42ea06f251900b21e578bf0
Author: Sardem FF7 <sardemff7 pub gmail com>
Date:   Wed Feb 9 18:27:00 2011 +0100

    Add "precision" to boxpointer alignment
    
    Allows the boxpointer arrow to be at a fixed percentage of the bubble
    
    https://bugzilla.gnome.org/show_bug.cgi?id=642031

 js/ui/appDisplay.js  |    2 +-
 js/ui/boxpointer.js  |   30 ++++++------------------------
 js/ui/dateMenu.js    |    2 +-
 js/ui/messageTray.js |    2 +-
 js/ui/panel.js       |    2 +-
 js/ui/panelMenu.js   |    2 +-
 js/ui/statusMenu.js  |    2 +-
 7 files changed, 12 insertions(+), 30 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index e39d399..a2286d0 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -505,7 +505,7 @@ AppIconMenu.prototype = {
         if (St.Widget.get_default_direction() == St.TextDirection.RTL)
             side = St.Side.RIGHT;
 
-        PopupMenu.PopupMenu.prototype._init.call(this, source.actor, St.Align.MIDDLE, side, 0);
+        PopupMenu.PopupMenu.prototype._init.call(this, source.actor, 0.5, side, 0);
 
         this._source = source;
 
diff --git a/js/ui/boxpointer.js b/js/ui/boxpointer.js
index 887f4a7..99de6f1 100644
--- a/js/ui/boxpointer.js
+++ b/js/ui/boxpointer.js
@@ -320,9 +320,11 @@ BoxPointer.prototype = {
         // separated from its sourceActor
         let primary = global.get_primary_monitor();
         let themeNode = this.actor.get_theme_node();
-        let halfBorder = themeNode.get_length('-arrow-border-width') / 2;
-        let halfBase = themeNode.get_length('-arrow-base') / 2;
+        let borderWidth = themeNode.get_length('-arrow-border-width');
+        let arrowBase = themeNode.get_length('-arrow-base');
         let borderRadius = themeNode.get_length('-arrow-border-radius');
+        let margin = (4 * borderRadius + borderWidth + arrowBase);
+        let halfMargin = margin / 2;
 
         let resX, resY;
 
@@ -346,17 +348,7 @@ BoxPointer.prototype = {
         switch (this._arrowSide) {
         case St.Side.TOP:
         case St.Side.BOTTOM:
-            switch (alignment) {
-            case St.Align.START:
-                resX = sourceCenterX - (halfBase + borderRadius + halfBorder);
-                break;
-            case St.Align.MIDDLE:
-                resX = sourceCenterX - (natWidth / 2);
-                break;
-            case St.Align.END:
-                resX = sourceCenterX - natWidth + (halfBase + borderRadius + halfBorder);
-                break;
-            }
+            resX = sourceCenterX - (halfMargin + (natWidth - margin) * alignment);
 
             resX = Math.max(resX, primary.x + 10);
             resX = Math.min(resX, primary.x + primary.width - (10 + natWidth));
@@ -365,17 +357,7 @@ BoxPointer.prototype = {
 
         case St.Side.LEFT:
         case St.Side.RIGHT:
-            switch (alignment) {
-            case St.Align.START:
-                resY = sourceCenterY - (halfBase + borderRadius + halfBorder);
-                break;
-            case St.Align.MIDDLE:
-                resY = sourceCenterY - (natHeight / 2);
-                break;
-            case St.Align.END:
-                resY = sourceCenterY - natHeight + (halfBase + borderRadius + halfBorder);
-                break;
-            }
+            resY = sourceCenterY - (halfMargin + (natHeight - margin) * alignment);
 
             resY = Math.max(resY, primary.y + 10);
             resY = Math.min(resY, primary.y + primary.height - (10 + natHeight));
diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js
index f22cfd5..e37b4af 100644
--- a/js/ui/dateMenu.js
+++ b/js/ui/dateMenu.js
@@ -56,7 +56,7 @@ DateMenuButton.prototype = {
         //this._eventSource = new Calendar.FakeEventSource();
         this._eventSource = new Calendar.EvolutionEventSource();
 
-        PanelMenu.Button.prototype._init.call(this, St.Align.START);
+        PanelMenu.Button.prototype._init.call(this, 0.0);
 
         this._clock = new St.Label();
         this.actor.set_child(this._clock);
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index 3450b19..38598fb 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -1802,7 +1802,7 @@ MessageTray.prototype = {
         if (!this._clickedSummaryItem)
             return;
 
-        this._summaryNotificationBoxPointer.setPosition(this._clickedSummaryItem.actor, 0, St.Align.MIDDLE);
+        this._summaryNotificationBoxPointer.setPosition(this._clickedSummaryItem.actor, 0, 0.5);
     },
 
     _unsetClickedSummaryItem: function() {
diff --git a/js/ui/panel.js b/js/ui/panel.js
index 5389b88..1c32e86 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -195,7 +195,7 @@ AppMenuButton.prototype = {
     __proto__: PanelMenu.Button.prototype,
 
     _init: function() {
-        PanelMenu.Button.prototype._init.call(this, St.Align.START);
+        PanelMenu.Button.prototype._init.call(this, 0.0);
         this._metaDisplay = global.screen.get_display();
         this._startingApps = [];
 
diff --git a/js/ui/panelMenu.js b/js/ui/panelMenu.js
index 6248264..a3e9e8c 100644
--- a/js/ui/panelMenu.js
+++ b/js/ui/panelMenu.js
@@ -68,7 +68,7 @@ SystemStatusButton.prototype = {
     __proto__: Button.prototype,
 
     _init: function(iconName,tooltipText) {
-        Button.prototype._init.call(this, St.Align.START);
+        Button.prototype._init.call(this, 0.0);
         this._iconActor = new St.Icon({ icon_name: iconName,
                                         icon_type: St.IconType.SYMBOLIC,
                                         style_class: 'system-status-icon' });
diff --git a/js/ui/statusMenu.js b/js/ui/statusMenu.js
index e09c851..ecc12b0 100644
--- a/js/ui/statusMenu.js
+++ b/js/ui/statusMenu.js
@@ -27,7 +27,7 @@ StatusMenuButton.prototype = {
     __proto__: PanelMenu.Button.prototype,
 
     _init: function() {
-        PanelMenu.Button.prototype._init.call(this, St.Align.START);
+        PanelMenu.Button.prototype._init.call(this, 0.0);
         let box = new St.BoxLayout({ name: 'panelStatusMenu' });
         this.actor.set_child(box);
 



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