]> O.S.I.I.S - jp/crow.git/commitdiff
Added Hoverable prop to GraphicObject, still have problem in tabview when hover anoth...
authorjpbruyere <jp.bruyere@hotmail.com>
Mon, 15 Feb 2016 14:39:16 +0000 (15:39 +0100)
committerjpbruyere <jp.bruyere@hotmail.com>
Mon, 15 Feb 2016 14:39:16 +0000 (15:39 +0100)
Templates/TabItem.crow
Tests/Interfaces/testTabView.crow
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/Group.cs
src/GraphicObjects/PrivateContainer.cs
src/GraphicObjects/TabItem.cs
src/GraphicObjects/TabView.cs

index 6f8bfe8e43cd48b75691c5daff3aa96648fb6473..8026c216ea72436c030cefe9b87d63da706efc32 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<GenericStack Orientation="Vertical" Spacing="0"
+<GenericStack Orientation="Vertical" Spacing="0" Hoverable="false"
                Width="{../../WidthPolicy}" Height="{../../HeightPolicy}">
        <Label Margin="5" Name="TabTitle" Width="-1"
                HorizontalAlignment="Left"
@@ -7,7 +7,7 @@
                Height="{../../../TabThickness}"
                Left="{../../TabOffset}"
                LayoutChanged="../../../TabTitleLayoutChanged"/>
-       <Container Background="LightGray"
+       <Container
                Name="Content" Width="{../../../WidthPolicy}" Height="{../../../HeightPolicy}"/>
 </GenericStack>
 
index 0e2d565803b4f9a0993a60f95b125791e9d80100..5edad7a29710a4cc4c73ac4fd805e666b42fc003 100644 (file)
@@ -1,15 +1,44 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<TabView Orientation="Horizontal" Spacing="20" Margin="0">
-       <TabItem Name="TabItem1" Caption="tab 1" Width="0" Height="0" Margin="0" Background="Gray"
-               MouseEnter="{Background=Red}"
-               MouseLeave="{Background=Gray}">
-               <Label Text="tab content test 1"/>
-       </TabItem>
-       <TabItem Name="TabItem2" Caption="tab 2" Width="0" Height="0" Margin="0" Background="Gray"
-               MouseEnter="{Background=Red}"
-               MouseLeave="{Background=Gray}">
-               <Label Text="tab content test 2"/>
-       </TabItem>
-
-</TabView>
+<HorizontalStack>
+       <TabView CacheEnabled="false" Width="200" Height="200" Orientation="Horizontal" Spacing="20" Margin="0">
+               <TabItem Hoverable="false" Name="TabItem1" Caption="tab 1" Width="0" Height="0" Margin="0" Background="Gray">
+                       <VerticalStack Fit="true">
+                               <CheckBox/>
+                               <CheckBox/>
+                               <CheckBox/>
+                               <CheckBox/>
+                               <Label Text="tab content test 1"/>
+                       </VerticalStack>
+               </TabItem>
+               <TabItem Hoverable="false" Name="TabItem2" Caption="tab 2" Width="0" Height="0" Margin="0" Background="Gray">
+                       <VerticalStack Fit="true">
+                               <RadioButton/>
+                               <RadioButton/>
+                               <RadioButton/>
+                               <RadioButton/>
+                               <Label Text="tab content test 2"/>
+                       </VerticalStack>
+               </TabItem>
+       </TabView>
+       <TabView CacheEnabled="false" Width="200" Height="200" Orientation="Horizontal" Spacing="20" Margin="0">
+               <TabItem Hoverable="false" Name="TabItem1" Caption="tab 1" Width="0" Height="0" Margin="0" Background="Gray">
+                       <VerticalStack Fit="true">
+                               <CheckBox/>
+                               <CheckBox/>
+                               <CheckBox/>
+                               <CheckBox/>
+                               <Label Text="tab content test 1"/>
+                       </VerticalStack>
+               </TabItem>
+               <TabItem Hoverable="false" Name="TabItem2" Caption="tab 2" Width="0" Height="0" Margin="0" Background="Gray">
+                       <VerticalStack Fit="true">
+                               <RadioButton/>
+                               <RadioButton/>
+                               <RadioButton/>
+                               <RadioButton/>
+                               <Label Text="tab content test 2"/>
+                       </VerticalStack>
+               </TabItem>
+       </TabView>
+</HorizontalStack>
 
index 02e5c863da29d95b8029a94917b0bcb44b9cb2e0..d7585d58e1436a88cf1649bca3fb9d96fe8d0056 100644 (file)
@@ -69,6 +69,7 @@ namespace Crow
                double _cornerRadius = 0;
                int _margin = 0;
                bool _focusable = false;
+               bool hoverable = true;
                bool _hasFocus = false;
                bool _isActive = false;
                bool _mouseRepeat;
@@ -272,6 +273,19 @@ namespace Crow
                                Bounds.Width = Bounds.Height = -1;
                        }
                }
+               /// <summary>
+               /// used to handle mouse hover in children instead of the whole container
+               /// </summary>
+               [XmlAttributeAttribute()][DefaultValue(true)]
+               public virtual bool Hoverable {
+                       get { return hoverable; }
+                       set {
+                               if (hoverable == value)
+                                       return;
+                               hoverable = value; 
+                               NotifyValueChanged ("Hoverable", hoverable);
+                       }
+               } 
                [XmlAttributeAttribute()][DefaultValue(false)]
                public virtual bool Focusable {
                        get { return _focusable; }
@@ -916,7 +930,7 @@ namespace Crow
                        if (ScreenCoordinates (Slot).ContainsOrIsEqual (m)) {
                                Scroller scr = Parent as Scroller;
                                if (scr == null)
-                                       return true;
+                                       return Hoverable;
                                return scr.MouseIsIn (scr.savedMousePos);
                        }
                        return false; 
index 12d8c7058dea884b3bca000874c0bee09a9e9b8d..68c92e2aa09934c08f9b420ed3c1867b65eb3f34 100644 (file)
@@ -268,6 +268,16 @@ namespace Crow
 
        
                #region Mouse handling
+               public override bool MouseIsIn (Point m)
+               {
+                       if (Hoverable)
+                               return base.MouseIsIn (m);
+                       for (int i = Children.Count - 1; i >= 0; i--) {
+                               if (Children[i].MouseIsIn(m))
+                                       return true;
+                       }
+                       return false;
+               }
                public override void checkHoverWidget (MouseMoveEventArgs e)
                {
                        if (HostContainer.hoverWidget != this) {
index 5a680da09ffe71ab9ba24190e0094ab0e762134b..7bc62cb89e09242068fa4fad75260bc2d783ac80 100644 (file)
@@ -225,12 +225,18 @@ namespace Crow
                #endregion
 
                #region Mouse handling
+               public override bool MouseIsIn (Point m)
+               {
+                       if (Hoverable || child == null)
+                               return base.MouseIsIn (m);
+                       return child.MouseIsIn (m);
+               }
                public override void checkHoverWidget (MouseMoveEventArgs e)
                {
                        base.checkHoverWidget (e);
                        if (child != null) 
-                       if (child.MouseIsIn (e.Position)) 
-                               child.checkHoverWidget (e);
+                               if (child.MouseIsIn (e.Position)) 
+                                       child.checkHoverWidget (e);
                }
                #endregion
 
index 3ecce21744392f80132010f7182215d7e2e41e9c..f54f4fc524f9d4b1de1302b8d61bdd1685d77f90 100644 (file)
@@ -95,25 +95,25 @@ namespace Crow
                                NotifyValueChanged ("Caption", caption);
                        }
                }
-               public override bool MouseIsIn (Point m)
-               {
-                       if (!Visible)
-                               return false;
-
-                       Debug.WriteLine ("Mouse Testing " + this.ToString ());
-
-                       if (TabTitle.MouseIsIn (m)){
-                               Debug.WriteLine ("Mouse is in title of " + this.ToString ());
-                               return true;
-                       }
-                       if (Content.MouseIsIn (m)){
-                               Debug.WriteLine ("Mouse is in content of " + this.ToString ());
-                               return true;
-                       }
-
-                       Debug.WriteLine ("Mouse is not in " + this.ToString ());
-                       return false;
-               }
+//             public override bool MouseIsIn (Point m)
+//             {
+//                     if (!Visible)
+//                             return false;
+//
+//                     Debug.WriteLine ("Mouse Testing " + this.ToString ());
+//
+//                     if (TabTitle.MouseIsIn (m)){
+//                             Debug.WriteLine ("Mouse is in title of " + this.ToString ());
+//                             return true;
+//                     }
+//                     if (Content.MouseIsIn (m)){
+//                             Debug.WriteLine ("Mouse is in content of " + this.ToString ());
+//                             return true;
+//                     }
+//
+//                     Debug.WriteLine ("Mouse is not in " + this.ToString ());
+//                     return false;
+//             }
                protected override void onDraw (Cairo.Context gr)
                {
                        int spacing = (Parent as TabView).Spacing;
index ab7806736e604a4ab6519391beefb5563e572235..21247343c4cfb1731f0fd5c07ce4090cd842a35a 100644 (file)
@@ -73,6 +73,7 @@ namespace Crow
                                        return;
                                selectedTab = value;
                                NotifyValueChanged ("SelectedTab", selectedTab);
+                               Debug.WriteLine ("selected tab: " + (selectedTab + 1).ToString ());
                                registerForGraphicUpdate ();
                        }
                }
@@ -187,7 +188,6 @@ namespace Crow
                void Ti_MouseDown (object sender, OpenTK.Input.MouseButtonEventArgs e)
                {
                        SelectedTab = Children.IndexOf (sender as GraphicObject);
-                       Debug.WriteLine ("selected tab: " + (selectedTab + 1).ToString ());
                }
        }
 }