[longomatch] Emulate better os x buttons



commit 9080c3b540bc92e0be3cb4c2ae20fbd92031dc20
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Thu Nov 20 19:20:37 2014 +0100

    Emulate better os x buttons
    
    Use meta for multiple selection in our custom widgets
    and make CTRL+Left act as the right button

 LongoMatch.Core/Common/Enums.cs                 |    3 ++-
 LongoMatch.Drawing.Cairo/WidgetWrapper.cs       |    9 +++++++++
 LongoMatch.Drawing/Canvas.cs                    |    4 ++++
 LongoMatch.GUI.Helpers/Misc.cs                  |   11 +++++++++++
 LongoMatch.GUI/Gui/TreeView/FilterBaseView.cs   |    4 ++--
 LongoMatch.GUI/Gui/TreeView/PlayListTreeView.cs |    3 ++-
 LongoMatch.GUI/Gui/TreeView/PlayersTreeView.cs  |    3 ++-
 LongoMatch.GUI/Gui/TreeView/PlaysTreeView.cs    |    3 ++-
 8 files changed, 34 insertions(+), 6 deletions(-)
---
diff --git a/LongoMatch.Core/Common/Enums.cs b/LongoMatch.Core/Common/Enums.cs
index bdf47e7..490a572 100644
--- a/LongoMatch.Core/Common/Enums.cs
+++ b/LongoMatch.Core/Common/Enums.cs
@@ -209,7 +209,8 @@ namespace LongoMatch.Core.Common
        public enum ButtonModifier {
                None,
                Shift,
-               Control
+               Control,
+               Meta
        }
        
        public enum CursorType {
diff --git a/LongoMatch.Drawing.Cairo/WidgetWrapper.cs b/LongoMatch.Drawing.Cairo/WidgetWrapper.cs
index cb18d3e..136e7f4 100644
--- a/LongoMatch.Drawing.Cairo/WidgetWrapper.cs
+++ b/LongoMatch.Drawing.Cairo/WidgetWrapper.cs
@@ -247,9 +247,18 @@ namespace LongoMatch.Drawing.Cairo
                        ButtonModifier bm;
                        
                        switch (modifier) {
+#if OSTYPE_OS_X
+                       case ModifierType.MetaMask:
+                               bm = ButtonModifier.Control;
+                               break;
+                       case ModifierType.ControlMask:
+                               bm = ButtonModifier.Meta;
+                               break;
+#else
                        case ModifierType.ControlMask:
                                bm = ButtonModifier.Control;
                                break;
+#endif
                        case ModifierType.ShiftMask:
                                bm = ButtonModifier.Shift;
                                break;
diff --git a/LongoMatch.Drawing/Canvas.cs b/LongoMatch.Drawing/Canvas.cs
index 0749469..316d851 100644
--- a/LongoMatch.Drawing/Canvas.cs
+++ b/LongoMatch.Drawing/Canvas.cs
@@ -408,6 +408,10 @@ namespace LongoMatch.Drawing
                        }
                        coords = ToUserCoords (coords); 
                        if (type == ButtonType.Left) {
+                               /* For OS X CTRL+Left emulating right click */
+                               if (modifier == ButtonModifier.Meta) {
+                                       HandleRightButton (coords, modifier);
+                               }
                                HandleLeftButton (coords, modifier);
                        } else if (type == ButtonType.Right) {
                                HandleRightButton (coords, modifier);
diff --git a/LongoMatch.GUI.Helpers/Misc.cs b/LongoMatch.GUI.Helpers/Misc.cs
index 5c15fcf..9cf01c5 100644
--- a/LongoMatch.GUI.Helpers/Misc.cs
+++ b/LongoMatch.GUI.Helpers/Misc.cs
@@ -324,6 +324,17 @@ namespace LongoMatch.Gui.Helpers
                        
                        return mediaFile;
                }
+
+               public static bool RightButtonClicked (Gdk.EventButton evnt)
+               {
+                       if (evnt.Type != Gdk.EventType.ButtonPress)
+                               return false;
+#if OSTYPE_OS_X
+                       return evnt.Button == 3 || (evnt.Button == 1 && evnt.State == 
ModifierType.ControlMask);
+#else
+                       return evnt.Button == 3;
+#endif
+               }
        }
 }
 
diff --git a/LongoMatch.GUI/Gui/TreeView/FilterBaseView.cs b/LongoMatch.GUI/Gui/TreeView/FilterBaseView.cs
index e9cf5c3..609e85e 100644
--- a/LongoMatch.GUI/Gui/TreeView/FilterBaseView.cs
+++ b/LongoMatch.GUI/Gui/TreeView/FilterBaseView.cs
@@ -22,7 +22,7 @@ using Mono.Unix;
 
 using LongoMatch.Core.Common;
 using LongoMatch.Core.Store;
-using LongoMatch.Core.Store.Templates;
+using Misc = LongoMatch.Gui.Helpers.Misc;
 
 namespace LongoMatch.Gui.Component
 {
@@ -107,7 +107,7 @@ namespace LongoMatch.Gui.Component
 
                protected override bool OnButtonPressEvent (Gdk.EventButton evnt)
                {
-                       if((evnt.Type == Gdk.EventType.ButtonPress) && (evnt.Button == 3))
+                       if(Misc.RightButtonClicked (evnt))
                                playersMenu.Popup();
                        return base.OnButtonPressEvent (evnt);
                }
diff --git a/LongoMatch.GUI/Gui/TreeView/PlayListTreeView.cs b/LongoMatch.GUI/Gui/TreeView/PlayListTreeView.cs
index bad880d..200e281 100644
--- a/LongoMatch.GUI/Gui/TreeView/PlayListTreeView.cs
+++ b/LongoMatch.GUI/Gui/TreeView/PlayListTreeView.cs
@@ -25,6 +25,7 @@ using LongoMatch.Core.Store.Playlists;
 using LongoMatch.Core.Interfaces;
 using LongoMatch.Gui.Dialog;
 using LongoMatch.Core.Store;
+using Misc = LongoMatch.Gui.Helpers.Misc;
 
 namespace LongoMatch.Gui.Component
 {
@@ -202,7 +203,7 @@ namespace LongoMatch.Gui.Component
 
                protected override bool OnButtonPressEvent (Gdk.EventButton evnt)
                {
-                       if ((evnt.Type == Gdk.EventType.ButtonPress) && (evnt.Button == 3)) {
+                       if (Misc.RightButtonClicked (evnt)) {
                                TreePath path;
                                GetPathAtPos ((int)evnt.X, (int)evnt.Y, out path);
                                if (path != null) {
diff --git a/LongoMatch.GUI/Gui/TreeView/PlayersTreeView.cs b/LongoMatch.GUI/Gui/TreeView/PlayersTreeView.cs
index a399af7..dbc496e 100644
--- a/LongoMatch.GUI/Gui/TreeView/PlayersTreeView.cs
+++ b/LongoMatch.GUI/Gui/TreeView/PlayersTreeView.cs
@@ -20,6 +20,7 @@ using Gdk;
 using Gtk;
 using LongoMatch.Core.Common;
 using LongoMatch.Core.Store;
+using Misc = LongoMatch.Gui.Helpers.Misc;
 
 namespace LongoMatch.Gui.Component
 {
@@ -64,7 +65,7 @@ namespace LongoMatch.Gui.Component
                {
                        TreePath[] paths = Selection.GetSelectedRows();
 
-                       if((evnt.Type == Gdk.EventType.ButtonPress) && (evnt.Button == 3))
+                       if (Misc.RightButtonClicked (evnt))
                        {
                                // We don't want to unselect the play when several
                                // plays are selected and we clik the right button
diff --git a/LongoMatch.GUI/Gui/TreeView/PlaysTreeView.cs b/LongoMatch.GUI/Gui/TreeView/PlaysTreeView.cs
index b9db7de..012931d 100644
--- a/LongoMatch.GUI/Gui/TreeView/PlaysTreeView.cs
+++ b/LongoMatch.GUI/Gui/TreeView/PlaysTreeView.cs
@@ -24,6 +24,7 @@ using LongoMatch.Core.Common;
 using LongoMatch.Core.Handlers;
 using LongoMatch.Core.Store;
 using EventType = LongoMatch.Core.Store.EventType;
+using Misc = LongoMatch.Gui.Helpers.Misc;
 
 namespace LongoMatch.Gui.Component
 {
@@ -268,7 +269,7 @@ namespace LongoMatch.Gui.Component
                                return true;
                        }
                
-                       if ((evnt.Type == Gdk.EventType.ButtonPress) && (evnt.Button == 3)) {
+                       if (Misc.RightButtonClicked (evnt)) {
                                // We don't want to unselect the play when several
                                // plays are selected and we clik the right button
                                // For multiedition


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