[longomatch] Add new buttons to control Dashboard's fit/fill/1:1 and edition mode



commit d6816f3f0cba4f56a3d503ae54ec8a4cde36e491
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Fri Aug 29 13:31:55 2014 +0200

    Add new buttons to control Dashboard's fit/fill/1:1 and edition mode

 LongoMatch.Drawing/Widgets/Dashboard.cs            |   16 +++-
 LongoMatch.GUI/Gui/Component/CodingWidget.cs       |    1 +
 LongoMatch.GUI/Gui/Component/DashboardWidget.cs    |   70 ++++++++++++-
 .../LongoMatch.Gui.Component.DashboardWidget.cs    |  105 ++++++++++++++++++--
 LongoMatch.GUI/gtk-gui/gui.stetic                  |  105 +++++++++++++++++++-
 5 files changed, 279 insertions(+), 18 deletions(-)
---
diff --git a/LongoMatch.Drawing/Widgets/Dashboard.cs b/LongoMatch.Drawing/Widgets/Dashboard.cs
index 02322a4..d2c7bde 100644
--- a/LongoMatch.Drawing/Widgets/Dashboard.cs
+++ b/LongoMatch.Drawing/Widgets/Dashboard.cs
@@ -57,6 +57,9 @@ namespace LongoMatch.Drawing.Widgets
                                template = value;
                                LoadTemplate ();
                        }
+                       get {
+                               return template;
+                       }
                }
 
                public Tag AddTag {
@@ -96,10 +99,14 @@ namespace LongoMatch.Drawing.Widgets
                        get;
                }
 
-               public void Refresh (TaggerButton b)
+               public void Refresh (TaggerButton b = null)
                {
                        TaggerObject to;
                        
+                       if (Template == null) {
+                               return;
+                       }
+                       
                        LoadTemplate ();
                        to = (TaggerObject)Objects.FirstOrDefault (o => (o as TaggerObject).Tagger == b);
                        if (to != null) {
@@ -231,14 +238,17 @@ namespace LongoMatch.Drawing.Widgets
 
                void SizeChanged ()
                {
-                       templateHeight = template.CanvasHeight;
-                       templateWidth = template.CanvasWidth;
+                       templateHeight = template.CanvasHeight + 10;
+                       templateWidth = template.CanvasWidth + 10;
                        if (FitMode == FitMode.Original) {
                                widget.Width = templateWidth;
                                widget.Height = templateHeight;
+                               scaleX = scaleY = 1;
+                               translation = new Point (0, 0);
                        } else if (FitMode == FitMode.Fill) {
                                scaleX = (double)widget.Width / templateWidth;
                                scaleY = (double)widget.Height / templateHeight;
+                               translation = new Point (0, 0);
                        } else if (FitMode == FitMode.Fit) {
                                Image.ScaleFactor (templateWidth, templateHeight,
                                                   (int)widget.Width, (int)widget.Height,
diff --git a/LongoMatch.GUI/Gui/Component/CodingWidget.cs b/LongoMatch.GUI/Gui/Component/CodingWidget.cs
index cac0724..ab93a30 100644
--- a/LongoMatch.GUI/Gui/Component/CodingWidget.cs
+++ b/LongoMatch.GUI/Gui/Component/CodingWidget.cs
@@ -75,6 +75,7 @@ namespace LongoMatch.Gui.Component
                        
                        buttonswidget.Mode = TagMode.Free;
                        buttonswidget.FitMode = FitMode.Fit;
+                       buttonswidget.ButtonsVisible = true;
                        buttonswidget.NewTagEvent += HandleNewTagEvent;
                }
 
diff --git a/LongoMatch.GUI/Gui/Component/DashboardWidget.cs b/LongoMatch.GUI/Gui/Component/DashboardWidget.cs
index c82e60d..bccba45 100644
--- a/LongoMatch.GUI/Gui/Component/DashboardWidget.cs
+++ b/LongoMatch.GUI/Gui/Component/DashboardWidget.cs
@@ -44,21 +44,18 @@ namespace LongoMatch.Gui.Component
                Dashboard tagger;
                Categories template;
                TaggerButton selected;
-               bool internalButtons;
-               bool edited;
+               bool internalButtons, edited, inFitModeChange;
 
                public DashboardWidget()
                {
                        this.Build();
                        tagger = new Dashboard (new WidgetWrapper (drawingarea));
-                       tagger.FitMode = FitMode.Original;
                        tagger.TaggersSelectedEvent += HandleTaggersSelectedEvent;
                        tagger.ShowMenuEvent += HandleShowMenuEvent;
                        tagger.NewTagEvent += HandleNewTagEvent;
                        tagger.AddNewTagEvent += HandleAddNewTagEvent;
                        drawingarea.CanFocus = true;
                        drawingarea.KeyPressEvent += HandleKeyPressEvent;
-                       Mode = TagMode.Predefined;
                        fieldeventbox.ButtonPressEvent += HandleFieldButtonPressEvent;
                        hfieldeventbox.ButtonPressEvent += HandleFieldButtonPressEvent;
                        goaleventbox.ButtonPressEvent += HandleFieldButtonPressEvent;
@@ -71,7 +68,20 @@ namespace LongoMatch.Gui.Component
                        addscorebutton.Clicked += HandleAddClicked;
                        addtagbutton.Clicked += HandleAddClicked;
                        addcardbutton.Clicked += HandleAddClicked;
+                       editbutton.Clicked += HandleClicked;
+
+                       fitbutton.Toggled += HandleFitModeToggled;
+                       fillbutton.Toggled += HandleFitModeToggled;
+                       d11button.Toggled += HandleFitModeToggled;
+                       fitimage.Pixbuf = IconTheme.Default.LoadIcon ("longomatch-dash-fit",
+                                                                     22, IconLookupFlags.ForceSvg);
+                       fillimage.Pixbuf = IconTheme.Default.LoadIcon ("longomatch-dash-fill",
+                                                                      22, IconLookupFlags.ForceSvg);
+                       d11image.Pixbuf = IconTheme.Default.LoadIcon ("longomatch-dash-11",
+                                                                     22, IconLookupFlags.ForceSvg);
                        Edited = false;
+                       Mode = TagMode.Predefined;
+                       FitMode = FitMode.Original;
                }
 
                protected override void OnDestroyed ()
@@ -88,7 +98,22 @@ namespace LongoMatch.Gui.Component
                
                public FitMode FitMode {
                        set {
+                               inFitModeChange = true;
+                               fillbutton.Active = value == FitMode.Fill;
+                               fitbutton.Active = value == FitMode.Fit;
+                               d11button.Active = value == FitMode.Original;
+                               inFitModeChange = false;
+                               if (value == FitMode.Original) {
+                                       dashscrolledwindow.HscrollbarPolicy = PolicyType.Automatic;
+                                       dashscrolledwindow.VscrollbarPolicy = PolicyType.Automatic;
+                               } else {
+                                       drawingarea.WidthRequest = -1;
+                                       drawingarea.HeightRequest = -1;
+                                       dashscrolledwindow.HscrollbarPolicy = PolicyType.Never;
+                                       dashscrolledwindow.VscrollbarPolicy = PolicyType.Never;
+                               }
                                tagger.FitMode = value;
+                               tagger.Refresh ();
                        }
                }
 
@@ -120,6 +145,16 @@ namespace LongoMatch.Gui.Component
                                rightbox.Visible = tagMode == TagMode.Edit;
                                // Add buttons for cards/tags/etc.. can be handled remotely.
                                hbuttonbox2.Visible = tagMode == TagMode.Edit && internalButtons;
+                               if (Mode == TagMode.Edit) {
+                                       editimage.Pixbuf = IconTheme.Default.LoadIcon 
("longomatch-dash-edit_active",
+                                                                                      22, 
IconLookupFlags.ForceSvg);
+                               } else {
+                                       editimage.Pixbuf = IconTheme.Default.LoadIcon ("longomatch-dash-edit",
+                                                                                      22, 
IconLookupFlags.ForceSvg);
+                               }
+                       }
+                       get {
+                               return tagMode;
                        }
                }
 
@@ -294,7 +329,16 @@ namespace LongoMatch.Gui.Component
                                tagger.Refresh (null);
                        }
                }
-               
+
+               void HandleClicked (object sender, EventArgs e)
+               {
+                       if (Mode == TagMode.Edit) {
+                               Mode = TagMode.Predefined;
+                       } else {
+                               Mode = TagMode.Edit;
+                       }
+               }
+
                void HandleResetField (object sender, EventArgs e)
                {
                        if (sender == resetfieldbutton) {
@@ -306,5 +350,21 @@ namespace LongoMatch.Gui.Component
                        }
                }
 
+               void HandleFitModeToggled (object sender, EventArgs e)
+               {
+                       if (inFitModeChange || !(sender as ToggleButton).Active) {
+                               return;
+                       }
+                       
+                       if (sender == fitbutton) {
+                               FitMode = FitMode.Fit;
+                       } else if (sender == fillbutton) {
+                               FitMode = FitMode.Fill;
+                       } else if (sender == d11button) {
+                               FitMode = FitMode.Original;
+                       }
+                       
+               }
+
        }
 }
diff --git a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.DashboardWidget.cs 
b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.DashboardWidget.cs
index 799b1ef..0241628 100644
--- a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.DashboardWidget.cs
+++ b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.DashboardWidget.cs
@@ -12,7 +12,7 @@ namespace LongoMatch.Gui.Component
                private global::Gtk.Button addscorebutton;
                private global::Gtk.Button addcardbutton;
                private global::Gtk.Button addtagbutton;
-               private global::Gtk.ScrolledWindow scrolledwindow4;
+               private global::Gtk.ScrolledWindow dashscrolledwindow;
                private global::Gtk.DrawingArea drawingarea;
                private global::Gtk.VBox rightbox;
                private global::Gtk.Frame propertiesframe;
@@ -48,6 +48,16 @@ namespace LongoMatch.Gui.Component
                private global::Gtk.Button resetgoalbutton;
                private global::Gtk.ScrolledWindow propertiesscrolledwindow;
                private global::LongoMatch.Gui.Component.CategoryProperties tagproperties;
+               private global::Gtk.VBox vbox4;
+               private global::Gtk.ToggleButton editbutton;
+               private global::Gtk.Image editimage;
+               private global::Gtk.HSeparator hseparator1;
+               private global::Gtk.ToggleButton fitbutton;
+               private global::Gtk.Image fitimage;
+               private global::Gtk.ToggleButton fillbutton;
+               private global::Gtk.Image fillimage;
+               private global::Gtk.ToggleButton d11button;
+               private global::Gtk.Image d11image;
 
                protected virtual void Build ()
                {
@@ -203,10 +213,10 @@ namespace LongoMatch.Gui.Component
                        w46.Expand = false;
                        w46.Fill = false;
                        // Container child vbox2.Gtk.Box+BoxChild
-                       this.scrolledwindow4 = new global::Gtk.ScrolledWindow ();
-                       this.scrolledwindow4.CanFocus = true;
-                       this.scrolledwindow4.Name = "scrolledwindow4";
-                       // Container child scrolledwindow4.Gtk.Container+ContainerChild
+                       this.dashscrolledwindow = new global::Gtk.ScrolledWindow ();
+                       this.dashscrolledwindow.CanFocus = true;
+                       this.dashscrolledwindow.Name = "dashscrolledwindow";
+                       // Container child dashscrolledwindow.Gtk.Container+ContainerChild
                        global::Gtk.Viewport w47 = new global::Gtk.Viewport ();
                        w47.ShadowType = ((global::Gtk.ShadowType)(0));
                        // Container child GtkViewport.Gtk.Container+ContainerChild
@@ -214,9 +224,9 @@ namespace LongoMatch.Gui.Component
                        this.drawingarea.CanFocus = true;
                        this.drawingarea.Name = "drawingarea";
                        w47.Add (this.drawingarea);
-                       this.scrolledwindow4.Add (w47);
-                       this.vbox2.Add (this.scrolledwindow4);
-                       global::Gtk.Box.BoxChild w50 = ((global::Gtk.Box.BoxChild)(this.vbox2 
[this.scrolledwindow4]));
+                       this.dashscrolledwindow.Add (w47);
+                       this.vbox2.Add (this.dashscrolledwindow);
+                       global::Gtk.Box.BoxChild w50 = ((global::Gtk.Box.BoxChild)(this.vbox2 
[this.dashscrolledwindow]));
                        w50.Position = 1;
                        this.hbox2.Add (this.vbox2);
                        global::Gtk.Box.BoxChild w51 = ((global::Gtk.Box.BoxChild)(this.hbox2 [this.vbox2]));
@@ -540,6 +550,85 @@ namespace LongoMatch.Gui.Component
                        w111.Position = 1;
                        w111.Expand = false;
                        w111.Fill = false;
+                       // Container child hbox2.Gtk.Box+BoxChild
+                       this.vbox4 = new global::Gtk.VBox ();
+                       this.vbox4.Name = "vbox4";
+                       this.vbox4.Spacing = 6;
+                       // Container child vbox4.Gtk.Box+BoxChild
+                       this.editbutton = new global::Gtk.ToggleButton ();
+                       this.editbutton.CanFocus = true;
+                       this.editbutton.Name = "editbutton";
+                       this.editbutton.Relief = ((global::Gtk.ReliefStyle)(2));
+                       // Container child editbutton.Gtk.Container+ContainerChild
+                       this.editimage = new global::Gtk.Image ();
+                       this.editimage.Name = "editimage";
+                       this.editbutton.Add (this.editimage);
+                       this.editbutton.Label = null;
+                       this.vbox4.Add (this.editbutton);
+                       global::Gtk.Box.BoxChild w113 = ((global::Gtk.Box.BoxChild)(this.vbox4 
[this.editbutton]));
+                       w113.Position = 0;
+                       w113.Expand = false;
+                       w113.Fill = false;
+                       // Container child vbox4.Gtk.Box+BoxChild
+                       this.hseparator1 = new global::Gtk.HSeparator ();
+                       this.hseparator1.Name = "hseparator1";
+                       this.vbox4.Add (this.hseparator1);
+                       global::Gtk.Box.BoxChild w114 = ((global::Gtk.Box.BoxChild)(this.vbox4 
[this.hseparator1]));
+                       w114.Position = 1;
+                       w114.Expand = false;
+                       w114.Fill = false;
+                       // Container child vbox4.Gtk.Box+BoxChild
+                       this.fitbutton = new global::Gtk.ToggleButton ();
+                       this.fitbutton.CanFocus = true;
+                       this.fitbutton.Name = "fitbutton";
+                       this.fitbutton.FocusOnClick = false;
+                       this.fitbutton.Relief = ((global::Gtk.ReliefStyle)(2));
+                       this.fitbutton.Active = true;
+                       // Container child fitbutton.Gtk.Container+ContainerChild
+                       this.fitimage = new global::Gtk.Image ();
+                       this.fitimage.Name = "fitimage";
+                       this.fitbutton.Add (this.fitimage);
+                       this.fitbutton.Label = null;
+                       this.vbox4.Add (this.fitbutton);
+                       global::Gtk.Box.BoxChild w116 = ((global::Gtk.Box.BoxChild)(this.vbox4 
[this.fitbutton]));
+                       w116.Position = 2;
+                       w116.Expand = false;
+                       w116.Fill = false;
+                       // Container child vbox4.Gtk.Box+BoxChild
+                       this.fillbutton = new global::Gtk.ToggleButton ();
+                       this.fillbutton.CanFocus = true;
+                       this.fillbutton.Name = "fillbutton";
+                       this.fillbutton.Relief = ((global::Gtk.ReliefStyle)(2));
+                       // Container child fillbutton.Gtk.Container+ContainerChild
+                       this.fillimage = new global::Gtk.Image ();
+                       this.fillimage.Name = "fillimage";
+                       this.fillbutton.Add (this.fillimage);
+                       this.fillbutton.Label = null;
+                       this.vbox4.Add (this.fillbutton);
+                       global::Gtk.Box.BoxChild w118 = ((global::Gtk.Box.BoxChild)(this.vbox4 
[this.fillbutton]));
+                       w118.Position = 3;
+                       w118.Expand = false;
+                       w118.Fill = false;
+                       // Container child vbox4.Gtk.Box+BoxChild
+                       this.d11button = new global::Gtk.ToggleButton ();
+                       this.d11button.CanFocus = true;
+                       this.d11button.Name = "d11button";
+                       this.d11button.Relief = ((global::Gtk.ReliefStyle)(2));
+                       // Container child d11button.Gtk.Container+ContainerChild
+                       this.d11image = new global::Gtk.Image ();
+                       this.d11image.Name = "d11image";
+                       this.d11button.Add (this.d11image);
+                       this.d11button.Label = null;
+                       this.vbox4.Add (this.d11button);
+                       global::Gtk.Box.BoxChild w120 = ((global::Gtk.Box.BoxChild)(this.vbox4 
[this.d11button]));
+                       w120.Position = 4;
+                       w120.Expand = false;
+                       w120.Fill = false;
+                       this.hbox2.Add (this.vbox4);
+                       global::Gtk.Box.BoxChild w121 = ((global::Gtk.Box.BoxChild)(this.hbox2 [this.vbox4]));
+                       w121.Position = 2;
+                       w121.Expand = false;
+                       w121.Fill = false;
                        this.Add (this.hbox2);
                        if ((this.Child != null)) {
                                this.Child.ShowAll ();
diff --git a/LongoMatch.GUI/gtk-gui/gui.stetic b/LongoMatch.GUI/gtk-gui/gui.stetic
index 9a78bd8..de1fbda 100644
--- a/LongoMatch.GUI/gtk-gui/gui.stetic
+++ b/LongoMatch.GUI/gtk-gui/gui.stetic
@@ -95,7 +95,7 @@
       </widget>
     </child>
   </widget>
-  <widget class="Gtk.Bin" id="LongoMatch.Gui.Component.DashboardWidget" design-size="1668 747">
+  <widget class="Gtk.Bin" id="LongoMatch.Gui.Component.DashboardWidget" design-size="1244 509">
     <property name="MemberName" />
     <child>
       <widget class="Gtk.HBox" id="hbox2">
@@ -194,7 +194,7 @@
               </packing>
             </child>
             <child>
-              <widget class="Gtk.ScrolledWindow" id="scrolledwindow4">
+              <widget class="Gtk.ScrolledWindow" id="dashscrolledwindow">
                 <property name="MemberName" />
                 <property name="CanFocus">True</property>
                 <child>
@@ -595,6 +595,107 @@
             <property name="Fill">False</property>
           </packing>
         </child>
+        <child>
+          <widget class="Gtk.VBox" id="vbox4">
+            <property name="MemberName" />
+            <property name="Spacing">6</property>
+            <child>
+              <widget class="Gtk.ToggleButton" id="editbutton">
+                <property name="MemberName" />
+                <property name="CanFocus">True</property>
+                <property name="Type">Custom</property>
+                <property name="Relief">None</property>
+                <child>
+                  <widget class="Gtk.Image" id="editimage">
+                    <property name="MemberName" />
+                  </widget>
+                </child>
+              </widget>
+              <packing>
+                <property name="Position">0</property>
+                <property name="AutoSize">True</property>
+                <property name="Expand">False</property>
+                <property name="Fill">False</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="Gtk.HSeparator" id="hseparator1">
+                <property name="MemberName" />
+              </widget>
+              <packing>
+                <property name="Position">1</property>
+                <property name="AutoSize">True</property>
+                <property name="Expand">False</property>
+                <property name="Fill">False</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="Gtk.ToggleButton" id="fitbutton">
+                <property name="MemberName" />
+                <property name="CanFocus">True</property>
+                <property name="Type">Custom</property>
+                <property name="FocusOnClick">False</property>
+                <property name="Relief">None</property>
+                <property name="Active">True</property>
+                <child>
+                  <widget class="Gtk.Image" id="fitimage">
+                    <property name="MemberName" />
+                  </widget>
+                </child>
+              </widget>
+              <packing>
+                <property name="Position">2</property>
+                <property name="AutoSize">True</property>
+                <property name="Expand">False</property>
+                <property name="Fill">False</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="Gtk.ToggleButton" id="fillbutton">
+                <property name="MemberName" />
+                <property name="CanFocus">True</property>
+                <property name="Type">Custom</property>
+                <property name="Relief">None</property>
+                <child>
+                  <widget class="Gtk.Image" id="fillimage">
+                    <property name="MemberName" />
+                  </widget>
+                </child>
+              </widget>
+              <packing>
+                <property name="Position">3</property>
+                <property name="AutoSize">True</property>
+                <property name="Expand">False</property>
+                <property name="Fill">False</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="Gtk.ToggleButton" id="d11button">
+                <property name="MemberName" />
+                <property name="CanFocus">True</property>
+                <property name="Type">Custom</property>
+                <property name="Relief">None</property>
+                <child>
+                  <widget class="Gtk.Image" id="d11image">
+                    <property name="MemberName" />
+                  </widget>
+                </child>
+              </widget>
+              <packing>
+                <property name="Position">4</property>
+                <property name="AutoSize">True</property>
+                <property name="Expand">False</property>
+                <property name="Fill">False</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="Position">2</property>
+            <property name="AutoSize">True</property>
+            <property name="Expand">False</property>
+            <property name="Fill">False</property>
+          </packing>
+        </child>
       </widget>
     </child>
   </widget>


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