]> O.S.I.I.S - jp/crow.git/commitdiff
combo popup sizing, binding creation in code
authorjpbruyere <jp.bruyere@hotmail.com>
Tue, 8 Mar 2016 06:29:36 +0000 (07:29 +0100)
committerjpbruyere <jp.bruyere@hotmail.com>
Tue, 8 Mar 2016 06:29:36 +0000 (07:29 +0100)
.gitignore
Templates/ComboBox.goml
Tests/GOLIBTestsOTK.cs
Tests/Interfaces/testColorList.crow
Tests/Interfaces/testCombobox.goml
src/CompilerServices/CompilerServices.cs
src/GraphicObjects/ComboBox.cs
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/ListBox.cs

index 27a2e1e444d6339b7bb2fd6c1c136c7b4cb76202..7aa58178d1c0f0f90390f5a6e1378d038148de82 100644 (file)
@@ -9,6 +9,7 @@ packages
 /obj/*
 /GOLib.userprefs
 /Tests/obj/*
+/OTKCrow/obj
 /Tests/bin/*
 /UnitTest/obj
 /UnitTest/bin
index 8c5782fc6ea5c4b0793ba74ab4453b1f0b6a22af..a114bed8d696ab708523b621f268c33cc7b59733 100755 (executable)
                        </HorizontalStack>
                </Border>
        </Template>
-       <Border Background="DimGray" BorderWidth="1" Margin="1"
-               MinimumSize="{../../MinimumPopupSize}" MaximumSize="0;400"
-               Height="400" Width="-1">
-               <Scroller  Name="scroller1" Margin="1" VerticalScrolling="true"
-                       Height="{../HeightPolicy}" Width="{../WidthPolicy}"
+       <Border Background="DimGray" BorderWidth="1" Margin="1"         
+               Fit="true">
+               <Scroller  Name="scroller1" Margin="2" VerticalScrolling="true"
+                       MinimumSize="{../../../MinimumPopupSize}" MaximumSize="0;400"
+                       Fit="true"
+                       HorizontalAlignment="Left"
                        ValueChanged="../../../_scroller_ValueChanged">
                        <VerticalStack LayoutChanged="../../../../_list_LayoutChanged"
-                               Height="-1" Width="{../../WidthPolicy}" Name="List" Margin="0" VerticalAlignment="Top"/>
+                               Height="-1" Width="{../WidthPolicy}" Name="List" Margin="0"
+                               HorizontalAlignment="Left"
+                               VerticalAlignment="Top"/>
                </Scroller>
        </Border>
 </Popper>
index feacdd86b8a3cd8b524b25f5b91bb0f62414c4b9..9c522b32169d0b892f246a6fc3576115d5a01e8e 100644 (file)
@@ -29,8 +29,9 @@ namespace testOTK
                int frameCpt = 0;
                int idx = 0;
                string[] testFiles = {
-                       "0.crow",
                        "testColorList.crow",
+                       "testCombobox.goml",
+                       "0.crow",
                        "testCheckbox.goml",
                        "testWindow.goml",
                        "fps.goml",
index 054c4c1a598839f68f53306a27360aaafc09b2ea..f98ef1348ecfe4a2c7b9cbc08a806b5aff798daf 100755 (executable)
@@ -2,7 +2,7 @@
 <Border BorderWidth="2" Fit="true">
        <VerticalStack Fit="true" Margin="5">
                <ListBox Data="{TestList}" Background="0,5;0,5;0,5;0,7"
-                                        HorizontalAlignment="Center" Width="300" Height="350" Margin="5"
+                                        HorizontalAlignment="Center" Width="200" Height="200" Margin="5"
                                         ItemTemplate="#Tests.Interfaces.colorItem.crow">
                        <Template>
                                <Border BorderWidth="1" Height="{../HeightPolicy}" Width="{../WidthPolicy}">
@@ -11,7 +11,9 @@
                                                                Margin="2" VerticalScrolling="true" ScrollY="{../scrollbar1.Value}"
                                                                ValueChanged="../../../_scroller_ValueChanged">
                                                        <VerticalStack Width="{../../../../WidthPolicy}" Height="-1" MinimumSize="10;10"
-                                                               Name="List" Margin="0" VerticalAlignment="Top"
+                                                               Name="List" Margin="0"
+                                                               VerticalAlignment="Top"
+                                                               HorizontalAlignment="Left"
                                                                LayoutChanged="../../../../_list_LayoutChanged"/>
                                                </Scroller>
                                                <ScrollBar Name="scrollbar1" Value="{../scroller1.ScrollY}" 
index 73007079237d0d20fa6e5d5814bd3f32d67deb23..5d84ca3adbdb9db2d4ad8e4d41d0968d1e102492 100755 (executable)
@@ -1,5 +1,5 @@
 <?xml version="1.0"?>
-<VerticalStack>
-       <ComboBox Width="250" Data="{TestList}" SelectedIndex="0"
+<VerticalStack Width="200">
+       <ComboBox Width="0" Data="{TestList}" SelectedIndex="0"
                ItemTemplate="#Tests.Interfaces.colorItem.crow"/>
 </VerticalStack>
\ No newline at end of file
index bdfe362e4ed25d2bf356337174a1088746e86cdb..aea199f42fdabc944a391fc985194c46ba2e565f 100644 (file)
@@ -93,6 +93,11 @@ namespace Crow
                        Target = _source;
                        Expression = _expression;
                }
+               public Binding(object _source, string _member, string _expression)
+               {
+                       Target = new MemberReference (_source, _source.GetType().GetMember (_member) [0]);
+                       Expression = _expression;
+               }
                #endregion
 
                public bool FindTarget(){
index 019d8c9c9369db3a70f2a673b0adc196411cbb19..8888696db78ffb7309576bf51db081f84c666f02 100644 (file)
@@ -11,7 +11,7 @@ namespace Crow
                public ComboBox() : base(){     }       
                #endregion
 
-               Size minimumPopupSize = "100;100";
+               Size minimumPopupSize = "10;10";
                [XmlIgnore]public Size MinimumPopupSize{
                        get { return minimumPopupSize; }
                        set {
index 8b6ea18fd82d7733d592d6abb413255d583422de..cddc918a54afe7a857e83e3eaf24d1f758d5ba6f 100644 (file)
@@ -117,7 +117,7 @@ namespace Crow
                        set { _parent = value; }
                }
 
-               public ILayoutable LogicalParent {
+               [XmlIgnore]public ILayoutable LogicalParent {
                        get { return logicalParent == null ? Parent : logicalParent; }
                        set { logicalParent = value; }
                }
@@ -793,16 +793,19 @@ namespace Crow
                                        Slot.Width = Width;
                                else if (Width < 0) {
                                        Slot.Width = measureRawSize (LayoutingType.Width);
-                               }else if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Width))
+                               } else if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Width))
                                        return false;
                                else
                                        Slot.Width = Parent.ClientRectangle.Width;
 
                                //size constrain
-                               if (Slot.Width < MinimumSize.Width)
+                               if (Slot.Width < MinimumSize.Width) {
                                        Slot.Width = MinimumSize.Width;
-                               else if (Slot.Width > MaximumSize.Width && MaximumSize.Width > 0)
+                                       NotifyValueChanged ("WidthPolicy", 0);
+                               } else if (Slot.Width > MaximumSize.Width && MaximumSize.Width > 0) {
                                        Slot.Width = MaximumSize.Width;
+                                       NotifyValueChanged ("WidthPolicy", 0);
+                               }
 
                                if (LastSlots.Width == Slot.Width)
                                        break;
@@ -816,18 +819,21 @@ namespace Crow
                        case LayoutingType.Height:
                                if (Height > 0)
                                        Slot.Height = Height;
-                               else if (Height < 0){
+                               else if (Height < 0) {
                                        Slot.Height = measureRawSize (LayoutingType.Height);
-                               }else if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Height))
+                               } else if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Height))
                                        return false;
                                else
                                        Slot.Height = Parent.ClientRectangle.Height;
 
                                //size constrain
-                               if (Slot.Height < MinimumSize.Height)
+                               if (Slot.Height < MinimumSize.Height) {
                                        Slot.Height = MinimumSize.Height;
-                               else if (Slot.Height > MaximumSize.Height && MaximumSize.Height > 0)
+                                       NotifyValueChanged ("HeightPolicy", 0);
+                               } else if (Slot.Height > MaximumSize.Height && MaximumSize.Height > 0) {
                                        Slot.Height = MaximumSize.Height;
+                                       NotifyValueChanged ("HeightPolicy", 0);
+                               }
 
                                if (LastSlots.Height == Slot.Height)
                                        break;
@@ -1039,6 +1045,9 @@ namespace Crow
                }
 
                #region Binding
+               public void BindMember(string _member, string _expression){
+                       Bindings.Add(new Binding (this, _member, _expression));
+               }
                public virtual void ResolveBindings()
                {
                        if (Bindings.Count == 0)
index b6e174859ee2c31d95a52b526d9b5749a4e0ea35..c0f16d655467c48f3ed5637a328e714627dffff6 100644 (file)
@@ -124,7 +124,7 @@ namespace Crow
                                SelectedItemChanged.Raise (this, new SelectionChangeEventArgs (SelectedItem));
                        }
                }
-               int itemPerPage = 100;
+               int itemPerPage = 50;
                MemoryStream templateStream = null;
                Type templateBaseType = null;
 
@@ -144,33 +144,37 @@ namespace Crow
                                templateBaseType = Interface.GetTopContainerOfGOMLStream (templateStream);
                        }
 
-                       Group page = _list.Clone () as Group;
-                       page.Name = "page" + pageNum;
+                       lock (Interface.CurrentInterface.UpdateMutex) {
+                               
+                               Group page = _list.Clone () as Group;
+                               page.Name = "page" + pageNum;
+                               page.Background = Color.Transparent;
 
-                       //reset size to fit in the dir of the stacking
-                       //because _list total size is forced to approx size
-                       if (_gsList.Orientation == Orientation.Horizontal) {
-                               page.Width = -1;
-                               page.Height = 0;
-                       } else {
-                               page.Height = -1;
-                               page.Width = 0;
-                       }
+                               //reset size to fit in the dir of the stacking
+                               //because _list total size is forced to approx size
+                               if (_gsList.Orientation == Orientation.Horizontal) {
+                                       page.Width = -1;
+                               } else {
+                                       page.Height = -1;
+//                                     Bindings.Add(new Binding 
+//                                             (new MemberReference (page, typeof(GraphicObject).GetMember ("Width")[0]), "../../WidthPolicy"));
+                                       //page.Bindings.Add(new Binding (page, "Width", "../../WidthPolicy"));
+                                       page.BindMember("Width", "../../WidthPolicy");
+                               }
 
+                               for (int i = (pageNum - 1) * itemPerPage; i < pageNum * itemPerPage; i++) {
+                                       if (i >= data.Count)
+                                               break;
+                                       templateStream.Seek (0, SeekOrigin.Begin);
+                                       GraphicObject g = Interface.Load (templateStream, templateBaseType);
+                                       g.MouseClick += itemClick;
+                                       page.AddChild (g);
+                                       g.DataSource = data [i];
+                                       //g.LogicalParent = this;
+                               }
 
-                       for (int i = (pageNum - 1) * itemPerPage; i < pageNum * itemPerPage; i++) {
-                               if (i >= data.Count)
-                                       break;
-                               templateStream.Seek(0,SeekOrigin.Begin);
-                               GraphicObject g = Interface.Load (templateStream, templateBaseType);
-                               g.MouseClick += itemClick;
-                               page.AddChild (g);
-                               g.DataSource = data [i];
-                               //g.LogicalParent = this;
+                               _list.AddChild (page);
                        }
-
-                       _list.AddChild (page);
-
                        #if DEBUG_LOAD
                        loadingTime.Stop ();
                        Debug.WriteLine("Listbox {2} Loading: {0} ticks \t, {1} ms",