]> O.S.I.I.S - jp/crow.git/commitdiff
tabView functionnal, mouse handling is a bit complicated, this should be improved
authorjpbruyere <jp.bruyere@hotmail.com>
Mon, 15 Feb 2016 17:45:11 +0000 (18:45 +0100)
committerjpbruyere <jp.bruyere@hotmail.com>
Mon, 15 Feb 2016 18:00:47 +0000 (19:00 +0100)
Crow.csproj
Tests/Interfaces/testTabView.crow
src/GraphicObjects/TabItem.cs
src/GraphicObjects/TabView.cs

index 8c35fe4ed7dbbc9818b16aaf1b5188f015d92163..6d0c6d3a4a9d7a74aa2ad8b6aa24793d424d160a 100644 (file)
@@ -45,7 +45,7 @@
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <OutputPath>bin\Debug</OutputPath>
-    <DefineConstants>DEBUG_LAYOUTING0;TRACE;DEBUG;__linux__;MEASURE_TIME;DEBUG_LOAD_TIME0;DEBUG_BINDING;DEBUG_CLIP_RECTANGLE0</DefineConstants>
+    <DefineConstants>DEBUG_LAYOUTING0;TRACE;DEBUG;__linux__;MEASURE_TIME;DEBUG_LOAD_TIME0;DEBUG_BINDING0;DEBUG_CLIP_RECTANGLE0</DefineConstants>
   </PropertyGroup>
   <!--  <PropertyGroup Condition=" '$(Platform)' == 'Linux_x86' ">
     <DefineConstants>__linux__</DefineConstants>
index 5edad7a29710a4cc4c73ac4fd805e666b42fc003..f298f529b18f21ba5950227024c4832ed0a3ed69 100644 (file)
@@ -1,42 +1,52 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<HorizontalStack>
+<HorizontalStack Fit="true">
        <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">
+               <TabItem Name="TabItem1" Caption="tab item 1" Width="0" Height="0" Margin="0" Background="Gray"
+                       MouseEnter="{Background=Red}"
+                       MouseLeave="{Background=Gray}">
                        <VerticalStack Fit="true">
                                <CheckBox/>
                                <CheckBox/>
                                <CheckBox/>
                                <CheckBox/>
-                               <Label Text="tab content test 1"/>
+                               <Label Text="{fps}" HorizontalAlignment="Right" Foreground="Black" Background="Yellow"/>
                        </VerticalStack>
                </TabItem>
-               <TabItem Hoverable="false" Name="TabItem2" Caption="tab 2" Width="0" Height="0" Margin="0" Background="Gray">
+               <TabItem Name="TabItem2" Caption="tab item 2" Width="0" Height="0" Margin="0" Background="Gray"
+                       MouseEnter="{Background=BlueCrayola}"
+                       MouseLeave="{Background=Gray}">
                        <VerticalStack Fit="true">
                                <RadioButton/>
                                <RadioButton/>
                                <RadioButton/>
                                <RadioButton/>
-                               <Label Text="tab content test 2"/>
+                               <Label Text="{fps}" HorizontalAlignment="Left" Background="LimeGreen"/>
                        </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">
+               <TabItem
+                       MouseEnter="{Background=BlueCrayola}"
+                       MouseLeave="{Background=Gray}"
+                       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"/>
+                               <Label Text="{fps}" HorizontalAlignment="Right" Foreground="Black" Background="Yellow"/>
                        </VerticalStack>
                </TabItem>
-               <TabItem Hoverable="false" Name="TabItem2" Caption="tab 2" Width="0" Height="0" Margin="0" Background="Gray">
+               <TabItem
+                       MouseEnter="{Background=BlueCrayola}"
+                       MouseLeave="{Background=Gray}"
+                       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"/>
+                               <Label Text="{fps}" HorizontalAlignment="Left" Background="LimeGreen"/>
                        </VerticalStack>
                </TabItem>
        </TabView>
index f54f4fc524f9d4b1de1302b8d61bdd1685d77f90..d59336f9a8748cdc25274d310007df615b8c6792 100644 (file)
@@ -95,25 +95,17 @@ 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;
-//             }
+               bool isSelected;
+               [XmlAttributeAttribute()][DefaultValue(false)]
+               public virtual bool IsSelected {
+                       get { return isSelected; }
+                       set {
+                               if (isSelected == value)
+                                       return;
+                               isSelected = value;
+                               NotifyValueChanged ("IsSelected", isSelected);
+                       }
+               }
                protected override void onDraw (Cairo.Context gr)
                {
                        int spacing = (Parent as TabView).Spacing;
@@ -142,6 +134,17 @@ namespace Crow
                        base.onDraw (gr);
                        gr.Restore ();
                }
+               public override bool MouseIsIn (Point m)
+               {
+                       if (!Visible)
+                               return false;
+
+                       bool mouseIsInTitle = TabTitle.ScreenCoordinates (TabTitle.Slot).ContainsOrIsEqual (m);
+                       if (!IsSelected)
+                               return mouseIsInTitle;
+
+                       return _contentContainer.ScreenCoordinates (_contentContainer.Slot).ContainsOrIsEqual (m) || mouseIsInTitle;
+               }
        }
 }
 
index 21247343c4cfb1731f0fd5c07ce4090cd842a35a..15731b2fc1edb3004c37565b153a6608eeea3b35 100644 (file)
@@ -71,7 +71,13 @@ namespace Crow
                        set {
                                if (selectedTab == value)
                                        return;
+
+                               (Children [selectedTab] as TabItem).IsSelected = false;
+
                                selectedTab = value;
+
+                               (Children [selectedTab] as TabItem).IsSelected = true;
+
                                NotifyValueChanged ("SelectedTab", selectedTab);
                                Debug.WriteLine ("selected tab: " + (selectedTab + 1).ToString ());
                                registerForGraphicUpdate ();
@@ -96,8 +102,21 @@ namespace Crow
 
                        ti.MouseDown += Ti_MouseDown;
 
+                       if (Children.Count == 0) {
+                               ti.IsSelected = true;
+                               SelectedTab = 0;
+                       }
+
                        return base.AddChild (child);
                }
+               public override void RemoveChild (GraphicObject child)
+               {
+                       TabItem ti = child as TabItem;
+                       base.RemoveChild (child);
+                       if (ti.IsSelected)
+                               SelectedTab = Math.Min(0, Children.Count - 1);
+
+               }
                public override bool ArrangeChildren { get { return true; } }
                public override bool UpdateLayout (LayoutingType layoutType)
                {
@@ -162,21 +181,21 @@ namespace Crow
                                HostContainer.hoverWidget = this;
                                onMouseEnter (this, e);
                        }
-                       if (Children[SelectedTab].MouseIsIn(e.Position))
+                       if (((Children[SelectedTab] as TabItem).Content.Parent as GraphicObject).MouseIsIn(e.Position))
                        {
+                               Debug.WriteLine ("Mouse is in selected tab: {0}", selectedTab + 1);
                                Children[SelectedTab].checkHoverWidget (e);
                                return;
                        }
                        for (int i = Children.Count - 1; i >= 0; i--) {
-                               if (i == SelectedTab)
-                                       continue;
-                               if (Children[i].MouseIsIn(e.Position))
+                               TabItem ti = Children [i] as TabItem;
+                               if (ti.TabTitle.MouseIsIn(e.Position))
                                {
+                                       Debug.WriteLine ("Mouse is in tab title: {0}", i + 1);
                                        Children[i].checkHoverWidget (e);
                                        return;
                                }
                        }
-                       base.checkHoverWidget (e);
                }
                #endregion