From 2d1fd70ffa422dfdcf25a8c39ae9f4806c57c6ed Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Mon, 30 Jan 2017 12:09:57 +0100 Subject: [PATCH] make publi Initialize func of GraphicObj, test logical parent in popper to allow shared content, test parent == null on visible changed --- Default.style | 1 + src/GraphicObjects/GraphicObject.cs | 13 ++++++++++--- src/GraphicObjects/Popper.cs | 2 ++ src/GraphicObjects/TemplatedContainer.cs | 2 +- src/GraphicObjects/TemplatedControl.cs | 4 ++-- src/GraphicObjects/TemplatedGroup.cs | 2 +- 6 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Default.style b/Default.style index 62618b17..5b39bc02 100644 --- a/Default.style +++ b/Default.style @@ -23,6 +23,7 @@ Menu { } MenuItem { Width = Stretched; + Height = Fit; Background = Transparent; Foreground = LightGray; MouseEnter = {Background = vgradient|0:UnitedNationsBlue|1:Onyx;Foreground=White;} diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 574870f8..f7e193e1 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -23,7 +23,7 @@ namespace Crow get { if (currentInterface == null) { currentInterface = Interface.CurrentInterface; - initialize (); + Initialize (); } return currentInterface; } @@ -53,7 +53,13 @@ namespace Crow #endif } #endregion - internal protected virtual void initialize(){ + + /// + /// Initialize this Graphic object instance by setting style and default values and loading template if required + /// + public virtual void Initialize(){ + if (currentInterface == null) + currentInterface = Interface.CurrentInterface; loadDefaultValues (); } #region private fields @@ -513,7 +519,8 @@ namespace Crow LayoutChanged.Raise (this, new LayoutingEventArgs (LayoutingType.Width)); Slot.Height = 0; LayoutChanged.Raise (this, new LayoutingEventArgs (LayoutingType.Height)); - CurrentInterface.EnqueueForRepaint (this); + if (this.parent != null) + CurrentInterface.EnqueueForRepaint (this); LastSlots.Width = LastSlots.Height = 0; } diff --git a/src/GraphicObjects/Popper.cs b/src/GraphicObjects/Popper.cs index 8c79ce24..0b022842 100644 --- a/src/GraphicObjects/Popper.cs +++ b/src/GraphicObjects/Popper.cs @@ -229,6 +229,8 @@ namespace Crow Content.Visible = true; if (Content.Parent == null) CurrentInterface.AddWidget (Content, true); + if (Content.LogicalParent != this) + Content.LogicalParent = this; CurrentInterface.PutOnTop (Content, true); _content_LayoutChanged (this, new LayoutingEventArgs (LayoutingType.Sizing)); } diff --git a/src/GraphicObjects/TemplatedContainer.cs b/src/GraphicObjects/TemplatedContainer.cs index f4243588..44f2ca7c 100644 --- a/src/GraphicObjects/TemplatedContainer.cs +++ b/src/GraphicObjects/TemplatedContainer.cs @@ -31,7 +31,7 @@ namespace Crow public TemplatedContainer () : base(){} #endregion - [XmlIgnore]public abstract GraphicObject Content{ get; set;} + [XmlAttributeAttribute]public virtual GraphicObject Content{ get; set;} #region GraphicObject overrides public override GraphicObject FindByName (string nameToFind) diff --git a/src/GraphicObjects/TemplatedControl.cs b/src/GraphicObjects/TemplatedControl.cs index 4a3a2507..cd645dd3 100644 --- a/src/GraphicObjects/TemplatedControl.cs +++ b/src/GraphicObjects/TemplatedControl.cs @@ -39,10 +39,10 @@ namespace Crow } #endregion - internal protected override void initialize () + public override void Initialize () { loadTemplate (); - base.initialize (); + base.Initialize (); } string _template; diff --git a/src/GraphicObjects/TemplatedGroup.cs b/src/GraphicObjects/TemplatedGroup.cs index 4c35197f..fbb3c4bd 100644 --- a/src/GraphicObjects/TemplatedGroup.cs +++ b/src/GraphicObjects/TemplatedGroup.cs @@ -330,7 +330,7 @@ namespace Crow }else if (typeof(GenericStack).IsAssignableFrom (items.GetType ())) { GenericStack gs = new GenericStack (); gs.CurrentInterface = items.CurrentInterface; - gs.initialize (); + gs.Initialize (); gs.Orientation = (items as GenericStack).Orientation; gs.Width = items.Width; gs.Height = items.Height; -- 2.47.3