]> O.S.I.I.S - jp/crow.git/commitdiff
adapt child layout register on group size change depending on units of child measure...
authorjpbruyere <jp.bruyere@hotmail.com>
Mon, 22 Aug 2016 05:10:38 +0000 (07:10 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Thu, 1 Sep 2016 11:24:16 +0000 (13:24 +0200)
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/Group.cs

index 6572ba52b08cd63ca8ceaf40e52f67ff3cbe181d..026c06bd5d2bc16ba382980ab209633f60d03561 100644 (file)
@@ -54,8 +54,10 @@ namespace Crow
                #region CTOR
                public GraphicObject ()
                {
+                       #if DEBUG
                        uid = currentUid;
                        currentUid++;
+                       #endif
                }
                #endregion
                internal protected virtual void initialize(){
@@ -65,7 +67,7 @@ namespace Crow
                LayoutingType registeredLayoutings = LayoutingType.All;
                ILayoutable logicalParent;
                ILayoutable parent;
-               string name = "unamed";
+               string name;
                Fill background = Color.Transparent;
                Fill foreground = Color.White;
                Font font = "droid, 10";
@@ -199,14 +201,20 @@ namespace Crow
                                this.RegisterForRedraw ();
                        }
                }
-               [XmlAttributeAttribute()][DefaultValue("unamed")]
+               [XmlAttributeAttribute()][DefaultValue(null)]
                public virtual string Name {
-                       get { return name; }
+                       get {
+                               #if DEBUG
+                               return string.IsNullOrEmpty(name) ? this.GetType().Name + uid.ToString () : name;
+                               #else
+                               return name;
+                               #endif
+                       }
                        set {
                                if (name == value)
                                        return;
                                name = value;
-                               NotifyValueChanged("Name", verticalAlignment);
+                               NotifyValueChanged("Name", name);
                        }
                }
                [XmlAttributeAttribute  ()][DefaultValue(VerticalAlignment.Center)]
@@ -450,14 +458,17 @@ namespace Crow
                                if (!isVisible && this.Contains (CurrentInterface.HoverWidget))
                                        CurrentInterface.HoverWidget = null;
 
-                               if (Parent is GraphicObject)
-                                       (Parent as GraphicObject).RegisterForLayouting (LayoutingType.Sizing);
-                               if (Parent is GenericStack)
-                                       (Parent as GraphicObject).RegisterForLayouting (LayoutingType.ArrangeChildren);
-
                                if (isVisible)
                                        RegisterForLayouting (LayoutingType.Sizing);
-                               CurrentInterface.EnqueueForRepaint (this);
+                               else {
+                                       Slot.Width = 0;
+                                       LayoutChanged.Raise (this, new LayoutingEventArgs (LayoutingType.Width));
+                                       Slot.Height = 0;
+                                       LayoutChanged.Raise (this, new LayoutingEventArgs (LayoutingType.Height));
+                                       CurrentInterface.EnqueueForRepaint (this);
+                                       LastSlots.Width = LastSlots.Height = 0;
+                               }
+
 
                                NotifyValueChanged ("Visible", isVisible);
                        }
@@ -792,7 +803,7 @@ namespace Crow
                {
                        #if DEBUG_LAYOUTING
                        LayoutingQueueItem.currentLQI.Slot = LastSlots;
-                       LayoutingQueueItem.currentLQI.Slot = Slot;
+                       LayoutingQueueItem.currentLQI.NewSlot = Slot;
                        #endif
 
                        switch (layoutType) {
@@ -1200,18 +1211,6 @@ namespace Crow
                public virtual void onDisable(object sender, EventArgs e){
                        Disabled.Raise (this, e);
                }
-               public override string ToString ()
-               {
-                       string tmp ="";
-
-                       if (Parent != null)
-                               tmp = Parent.ToString () + tmp;
-                       #if DEBUG_LAYOUTING
-                       return Name == "unamed" ? tmp + "." + this.GetType ().Name + uid.ToString(): tmp + "." + Name;
-                       #else
-                       return Name == "unamed" ? tmp + "." + this.GetType ().Name : tmp + "." + Name;
-                       #endif
-               }
 
                #region Binding
                public void BindMember(string _member, string _expression){
@@ -1489,5 +1488,18 @@ namespace Crow
                                tmp.Bindings.Add (new Binding (new MemberReference (tmp, b.Source.Member), b.Expression));
                        return tmp;
                }
+
+               public override string ToString ()
+               {
+                       string tmp ="";
+
+                       if (Parent != null)
+                               tmp = Parent.ToString () + tmp;
+                       #if DEBUG_LAYOUTING
+                       return Name == "unamed" ? tmp + "." + this.GetType ().Name + uid.ToString(): tmp + "." + Name;
+                       #else
+                       return Name == "unamed" ? tmp + "." + this.GetType ().Name : tmp + "." + Name;
+                       #endif
+               }
        }
 }
index 402128b08792b4640019b0f28892117a57cf473e..efe02d95cfd24e9521a0d0717cfdba810ba9a081 100644 (file)
@@ -153,12 +153,20 @@ namespace Crow
                        //position smaller objects in group when group size is fit
                        switch (layoutType) {
                        case LayoutingType.Width:
-                               foreach (GraphicObject c in Children)
-                                       c.RegisterForLayouting (LayoutingType.X | LayoutingType.Width);
+                               foreach (GraphicObject c in Children){
+                                       if (c.Width.Units == Unit.Percent)
+                                               c.RegisterForLayouting (LayoutingType.Width);
+                                       else
+                                               c.RegisterForLayouting (LayoutingType.X);
+                               }
                                break;
                        case LayoutingType.Height:
-                               foreach (GraphicObject c in Children)
-                                       c.RegisterForLayouting (LayoutingType.Y | LayoutingType.Height);
+                               foreach (GraphicObject c in Children) {
+                                       if (c.Height.Units == Unit.Percent)
+                                               c.RegisterForLayouting (LayoutingType.Height);
+                                       else
+                                               c.RegisterForLayouting (LayoutingType.Y);
+                               }
                                break;
                        }
                }