]> O.S.I.I.S - jp/crow.git/commitdiff
Add PopDirection to Popper Class
authorjpbruyere <jp.bruyere@hotmail.com>
Mon, 8 Feb 2016 17:35:00 +0000 (18:35 +0100)
committerjpbruyere <jp.bruyere@hotmail.com>
Mon, 8 Feb 2016 17:35:00 +0000 (18:35 +0100)
Tests/GOLIBTests.cs
Tests/Interfaces/testPopper.goml
src/Enums.cs
src/GraphicObjects/Popper.cs

index f6c333946a69cbfe20dfc3ce97f3eaacb35ed642..56275a3a9b6d57b8e67b84d56e8f0805a076476d 100644 (file)
@@ -37,6 +37,8 @@ namespace test
                int frameCpt = 0;
                int idx = 0;
                string[] testFiles = {
+                       "testPopper.goml",
+                       "testTextBox.crow",
                        "testColorList.crow",
                        "0.crow",
                        "testExpandable.goml",
@@ -52,7 +54,6 @@ namespace test
 //                     "testButton2.crow",
                        "test2WayBinding.crow",
                        "fps.goml",
-                       "testTextBox.crow",
                        "testImage.crow",
                        "test4.goml",
                        "2.crow",
@@ -62,15 +63,14 @@ namespace test
                        "testWindow3.goml",
                        "testWindow.goml",
                        "testCheckbox.goml",
-                       "testPopper.goml",
                        "testLabel.goml",
                        "testAll.goml",
 //                     "testSpinner.goml",
-                       "testRadioButton2.goml",
+//                     "testRadioButton2.goml",
                        "testContainer.goml",
                        "testRadioButton.goml",
                        "testMsgBox.goml",
-                       "testMeter.goml",
+//                     "testMeter.goml",
                };
 
                #region FPS
@@ -116,6 +116,7 @@ namespace test
                public string update = "";
                public string drawing = "";
                public string layouting = "";
+               public Alignment alignment = Alignment.Left;
                #endregion
 
                public int intValue = 25;
@@ -134,6 +135,12 @@ namespace test
                                return;
                        intValue = Convert.ToInt32(e.NewValue);
                }
+               void change_alignment(object sender, EventArgs e){
+                       RadioButton rb = sender as RadioButton;
+                       if (rb == null)
+                               return;
+                       NotifyValueChanged ("alignment", Enum.Parse(typeof(Alignment), rb.Caption));
+               }
                IList<Color> testList = null;
                public IList<Color> TestList {
                        set{
index 362972e7a7474f79f6eb6a799b89d83cf031843e..2e6cb1735ce6794a36eb01ca7bab4fc59adace50 100755 (executable)
@@ -1,16 +1,26 @@
 <?xml version="1.0"?>
-<Popper Caption="TestPopper" Width="100" Background="DimGray">
-       <Border Fit="True" Background="ArmyGreen">
-<!--           <Image Fit="true" Path="#go.Images.Icons.tetra.png" Margin="10"/>-->
-               <VerticalStack Fit="true" Margin="10" Background="CornflowerBlue">
-                       <CheckBox Name="chk1" Background="Red"/>
-                       <CheckBox Name="chk2" IsChecked="true"/>
-                       <CheckBox Name="chk3"/>
-                       <CheckBox Name="chk4"/>
-                       <HorizontalStack Fit="true" Margin="20">
-                               <Label Name="captionFps" Text="Fps:" Width="50" TextAlignment="Right"/>
-                               <Label Name="valueFps" Text="{fps}" Font="droid , 12" Width="50" TextAlignment="Center" Background="AoEnglish"/>
-                       </HorizontalStack>
-               </VerticalStack>        
+<VerticalStack>
+       <Border Fit="true" Margin="10">
+               <VerticalStack Width="150" Height="-1">
+                       <RadioButton Width="0" Caption="Left" IsChecked="true" Checked="change_alignment"/>
+                       <RadioButton Width="0" Caption="Right" Checked="change_alignment"/>
+                       <RadioButton Width="0" Caption="Top" Checked="change_alignment"/>
+                       <RadioButton Width="0" Caption="Bottom" Checked="change_alignment"/>
+               </VerticalStack>
        </Border>
-</Popper>
+       <Popper Caption="TestPopper" Width="100" Background="DimGray" PopDirection="{alignment}">
+               <Border Fit="True" Background="ArmyGreen">
+       <!--            <Image Fit="true" Path="#go.Images.Icons.tetra.png" Margin="10"/>-->
+                       <VerticalStack Fit="true" Margin="10" Background="CornflowerBlue">
+                               <CheckBox Name="chk1" Background="Red"/>
+                               <CheckBox Name="chk2" IsChecked="true"/>
+                               <CheckBox Name="chk3"/>
+                               <CheckBox Name="chk4"/>
+                               <HorizontalStack Fit="true" Margin="20">
+                                       <Label Name="captionFps" Text="Fps:" Width="50" TextAlignment="Right"/>
+                                       <Label Name="valueFps" Text="{fps}" Font="droid , 12" Width="50" TextAlignment="Center" Background="AoEnglish"/>
+                               </HorizontalStack>
+                       </VerticalStack>
+               </Border>
+       </Popper>
+</VerticalStack>
index 6cde0b34e1fbcd80e76a13cbcbec0bd19bc29934..aac12e16c2dfb9f73d9c965851c5d06ea51f6f82 100644 (file)
@@ -11,17 +11,17 @@ namespace Crow
         Vertical
     }
 
-    public enum Alignment
+       public enum Alignment : byte
     {
-        Top,
-        Left,
-        Right,
-        Bottom,
-        TopLeft,
-        TopRight,
-        BottomLeft,
-        BottomRight,
-               Center
+        Top = 0x01,
+        Left = 0x02,
+               TopLeft = 0x03,
+               Right = 0x04,
+               TopRight = 0x05,
+               Bottom = 0x08,
+        BottomLeft = 0x0a,
+        BottomRight = 0x0c,
+               Center = 0x10
     }
     public enum HorizontalAlignment
     {
index 528022e74a6406a2fa8d22bba008ea03bb7208e8..66cb4884cb317e0ee1aa79752a1f6c741f238dea 100644 (file)
@@ -55,11 +55,6 @@ namespace Crow
                        }
                }
 
-               void _content_MouseLeave (object sender, MouseMoveEventArgs e)
-               {
-                       IsPopped = false;
-               }
-
                void _content_LayoutChanged (object sender, LayoutingEventArgs e)
                {
                        ILayoutable tc = Content.Parent as ILayoutable;
@@ -67,24 +62,52 @@ namespace Crow
                                return;
                        Rectangle r = this.ScreenCoordinates (this.Slot);
                        if (e.LayoutType.HasFlag(LayoutingType.Width)) {
-                               if (Content.Slot.Width < tc.ClientRectangle.Width) {
-                                       if (r.Left + Content.Slot.Width > tc.ClientRectangle.Right)
-                                               Content.Left = tc.ClientRectangle.Right - Content.Slot.Width;
+                               if (popDirection.HasFlag (Alignment.Right)) {
+                                       if (r.Right + Content.Slot.Width > tc.ClientRectangle.Right)
+                                               Content.Left = r.Left - Content.Slot.Width;
+                                       else
+                                               Content.Left = r.Right;
+                               } else if (popDirection.HasFlag (Alignment.Left)) {
+                                       if (r.Left - Content.Slot.Width < tc.ClientRectangle.Left)
+                                               Content.Left = r.Right;
                                        else
-                                               Content.Left = r.Left;
-                               } else
-                                       Content.Left = 0;
+                                               Content.Left = r.Left - Content.Slot.Width;
+                               } else {
+                                       if (Content.Slot.Width < tc.ClientRectangle.Width) {
+                                               if (r.Left + Content.Slot.Width > tc.ClientRectangle.Right)
+                                                       Content.Left = tc.ClientRectangle.Right - Content.Slot.Width;
+                                               else
+                                                       Content.Left = r.Left;
+                                       } else
+                                               Content.Left = 0;
+                               }
                        }
                        if (e.LayoutType.HasFlag(LayoutingType.Height)) {
                                if (Content.Slot.Height < tc.ClientRectangle.Height) {
-                                       if (r.Bottom + Content.Slot.Height > tc.ClientRectangle.Bottom)
-                                               Content.Top = r.Top - Content.Slot.Height;
-                                       else
-                                               Content.Top = r.Bottom;
+                                       if (PopDirection.HasFlag (Alignment.Bottom)) {
+                                               if (r.Bottom + Content.Slot.Height > tc.ClientRectangle.Bottom)
+                                                       Content.Top = r.Top - Content.Slot.Height;
+                                               else
+                                                       Content.Top = r.Bottom;
+                                       } else if (PopDirection.HasFlag (Alignment.Top)) {
+                                               if (r.Top - Content.Slot.Height < tc.ClientRectangle.Top)
+                                                       Content.Top = r.Bottom;
+                                               else
+                                                       Content.Top = r.Top - Content.Slot.Height;
+                                       } else
+                                               Content.Top = r.Top;
                                }else
                                        Content.Top = 0;
                        }
                }
+
+               #region GraphicObject overrides
+               [XmlAttributeAttribute()][DefaultValue(true)]//overiden to get default to true
+               public override bool Focusable
+               {
+                       get { return base.Focusable; }
+                       set { base.Focusable = value; }
+               }
                public override void ClearBinding ()
                {
                        //ensure popped window is cleared
@@ -104,18 +127,19 @@ namespace Crow
                                Content.ResolveBindings ();
                }
 
-               [XmlAttributeAttribute()][DefaultValue(true)]//overiden to get default to true
-               public override bool Focusable
+               public override void onMouseClick (object sender, MouseButtonEventArgs e)
                {
-                       get { return base.Focusable; }
-                       set { base.Focusable = value; }
+                       IsPopped = !IsPopped;
+                       base.onMouseClick (sender, e);
                }
-               [XmlAttributeAttribute()][DefaultValue(-1)]
-               public override int Height {
-                       get { return base.Height; }
-                       set { base.Height = value; }
+               public override void onMouseLeave (object sender, MouseMoveEventArgs e)
+               {
+                       base.onMouseLeave (sender, e);
+                       IsPopped = false;
                }
+               #endregion
 
+               #region Public Properties
                [XmlAttributeAttribute()][DefaultValue("Popper")]
                public string Caption {
                        get { return caption; } 
@@ -136,7 +160,6 @@ namespace Crow
                                NotifyValueChanged ("Image", image);
                        }
                } 
-
                [XmlAttributeAttribute()][DefaultValue(false)]
         public bool IsPopped
         {
@@ -155,6 +178,18 @@ namespace Crow
                                NotifyValueChanged ("SvgSub", "collapsed");
             }
         }
+               Alignment popDirection;
+               [XmlAttributeAttribute()][DefaultValue(Alignment.Bottom)]
+               public virtual Alignment PopDirection {
+                       get { return popDirection; }
+                       set {
+                               if (popDirection == value)
+                                       return;
+                               popDirection = value;
+                               NotifyValueChanged ("PopDirection", popDirection);
+                       }
+               }
+               #endregion
                        
                public virtual void onPop(object sender, EventArgs e)
                {
@@ -178,11 +213,5 @@ namespace Crow
                        Content.Visible = false;
                        Unpop.Raise (this, e);
                }
-                       
-               public override void onMouseClick (object sender, MouseButtonEventArgs e)
-               {
-                       IsPopped = !IsPopped;
-                       base.onMouseClick (sender, e);
-               }
        }
 }