diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-03-04 14:46:02 +0100 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-03-04 14:46:02 +0100 |
| commit | 4492fa1bccc93616831ddeec76e8c26116d183e4 (patch) | |
| tree | 8ecec7b8eaa2e3db641855aec2b36b3d698bfa1a /src/GraphicObjects | |
| parent | 90a024039580f2c097f727a277166582bf4abf7f (diff) | |
docker wip
Diffstat (limited to 'src/GraphicObjects')
| -rw-r--r-- | src/GraphicObjects/DockStack.cs | 90 | ||||
| -rw-r--r-- | src/GraphicObjects/Docker.cs | 171 | ||||
| -rw-r--r-- | src/GraphicObjects/GenericStack.cs | 1 | ||||
| -rw-r--r-- | src/GraphicObjects/GraphicObject.cs | 21 | ||||
| -rw-r--r-- | src/GraphicObjects/Group.cs | 1 |
5 files changed, 76 insertions, 208 deletions
diff --git a/src/GraphicObjects/DockStack.cs b/src/GraphicObjects/DockStack.cs index bb5bf3a4..7d5baf32 100644 --- a/src/GraphicObjects/DockStack.cs +++ b/src/GraphicObjects/DockStack.cs @@ -30,18 +30,41 @@ namespace Crow { public class DockStack : GenericStack { - internal static Instantiator instStack, instSplit, instSpacer; + internal static Instantiator instStack, instSplit;//, instSpacer; int dockingDiv = 5; - GraphicObject subStack = null; + + Docker rootDock { get { return LogicalParent as Docker; }} + public GraphicObject SubStack { get { return subStack;} set{ subStack=value; } } + #region CTor public DockStack () {} public DockStack (Interface iface) : base (iface) {} + #endregion + + protected override void onInitialized (object sender, EventArgs e) + { + base.onInitialized (sender, e); + instStack = IFace.CreateITorFromIMLFragment (@"<DockStack/>"); + instSplit = IFace.CreateITorFromIMLFragment (@"<Splitter/>"); + //instSpacer = IFace.CreateITorFromIMLFragment (@"<GraphicObject Background='Transparent' IsEnabled='false'/>"); + } + + public override void AddChild (GraphicObject g) + { + base.AddChild (g); + g.LogicalParent = this.LogicalParent; + } + public override void InsertChild (int idx, GraphicObject g) + { + base.InsertChild (idx, g); + g.LogicalParent = this.LogicalParent; + } public override bool PointIsIn (ref Point m) { @@ -64,16 +87,6 @@ namespace Crow } return Slot.ContainsOrIsEqual(m); } -// protected override void onDragEnter (object sender, DragDropEventArgs e) -// { -// base.onDragEnter (sender, e); -// showDock = true; -// } -// protected override void onDragLeave (object sender, DragDropEventArgs e) -// { -// base.onDragLeave (sender, e); -// showDock = false; -// } public override void onMouseMove (object sender, MouseMoveEventArgs e) { if (IsDropTarget) { @@ -108,9 +121,18 @@ namespace Crow } base.onMouseMove (sender, e); } - static Orientation GetOrientation (Alignment a){ - return (a==Alignment.Left) ||(a==Alignment.Right) ? Orientation.Horizontal : Orientation.Vertical; + + protected override void onDragEnter (object sender, DragDropEventArgs e) + { + base.onDragEnter (sender, e); + RegisterForGraphicUpdate (); } + protected override void onDragLeave (object sender, DragDropEventArgs e) + { + base.onDragLeave (sender, e); + RegisterForGraphicUpdate (); + } + protected override void onDraw (Cairo.Context gr) { gr.Save (); @@ -145,7 +167,7 @@ namespace Crow Rectangle r; - if (GetOrientation (dw.DockingPosition) == Orientation || SubStack == null) + if (dw.DockingPosition.GetOrientation() == Orientation || SubStack == null) r = ClientRectangle; else r = SubStack.ClientRectangle + SubStack.Slot.Position + ClientRectangle.TopLeft; @@ -172,13 +194,16 @@ namespace Crow } gr.Restore (); } + public void Undock (DockWindow dw){ + int dwIdx = Children.IndexOf(dw); + RemoveChild(dw); if (dw.DockingPosition == Alignment.Left || dw.DockingPosition == Alignment.Top) - RemoveChild (0); + RemoveChild (dwIdx); else - RemoveChild (Children.Count - 1); + RemoveChild (dwIdx - 1); if (Children.Count > 1) return; @@ -200,22 +225,8 @@ namespace Crow dsp.RemoveChild (this); dsp.InsertChild (i, g); dsp.SubStack = g; -// if (SubStack is DockStack) { -// -// } else { -// int i = p.Children.IndexOf (this); -// p.RemoveChild (this); -// if (p is DockStack) { -// DockStack dsp = p as DockStack; -// dsp.SubStack = instSpacer.CreateInstance (); -// dsp.AddChild (dsp.SubStack); -// } -// } - } public void Dock(DockWindow dw){ - checkInstantiators(); - Splitter splitter = instSplit.CreateInstance<Splitter> (); Rectangle r = ClientRectangle; @@ -226,12 +237,12 @@ namespace Crow if (SubStack == null) { activeStack = this; - SubStack = instSpacer.CreateInstance (); - }else if (GetOrientation (dw.DockingPosition) != Orientation) { + SubStack = rootDock.CenterDockedObj; + }else if (dw.DockingPosition.GetOrientation() != Orientation) { int i = Children.IndexOf (SubStack); RemoveChild (SubStack); activeStack = instStack.CreateInstance<DockStack> (); - activeStack.SubStack = instSpacer.CreateInstance (); + activeStack.SubStack = rootDock.CenterDockedObj; SubStack = activeStack; InsertChild(i, activeStack); } @@ -247,7 +258,7 @@ namespace Crow activeStack.AddChild (activeStack.SubStack); } else { activeStack.InsertChild (0, dw); - activeStack.InsertChild (0, splitter); + activeStack.InsertChild (1, splitter); } break; case Alignment.Bottom: @@ -291,15 +302,6 @@ namespace Crow break; } } - - void checkInstantiators () { - if (instStack != null) - return; - instStack = IFace.CreateITorFromIMLFragment (@"<DockStack/>"); - instSplit = IFace.CreateITorFromIMLFragment (@"<Splitter/>"); - instSpacer = IFace.CreateITorFromIMLFragment (@"<GraphicObject Background='Transparent' IsEnabled='false'/>"); - } - } } diff --git a/src/GraphicObjects/Docker.cs b/src/GraphicObjects/Docker.cs index f61269d3..a14d70be 100644 --- a/src/GraphicObjects/Docker.cs +++ b/src/GraphicObjects/Docker.cs @@ -42,17 +42,10 @@ namespace Crow } #endregion - //GenericStack rootStack = null; - public DockStack SubStack = null; int dockingThreshold; - List<DockWindow> windows = new List<DockWindow>(); - - public override void AddChild (GraphicObject g) - { - base.AddChild (g); - g.LogicalParent = this; - } + public DockStack SubStack = null; + public GraphicObject CenterDockedObj = null; [XmlAttributeAttribute][DefaultValue(10)] public virtual int DockingThreshold { @@ -66,10 +59,17 @@ namespace Crow } } - //bool showDockingTarget = false; - //Alignment dockingDirection = Alignment.Center; - //int dockingDiv = 8; - //bool showDock = false; + protected override void onInitialized (object sender, EventArgs e) + { + base.onInitialized (sender, e); + CenterDockedObj = new GraphicObject (IFace) { IsEnabled = false }; + } + + public override void AddChild (GraphicObject g) + { + base.AddChild (g); + g.LogicalParent = this; + } public override void onMouseMove (object sender, MouseMoveEventArgs e) { @@ -85,151 +85,6 @@ namespace Crow } base.onMouseMove (sender, e); } - /* - protected override void onDragEnter (object sender, DragDropEventArgs e) - { - base.onDragEnter (sender, e); - showDock = true; - Console.WriteLine ("showdock=" + showDock); - } - protected override void onDragLeave (object sender, DragDropEventArgs e) - { - base.onDragLeave (sender, e); - showDock = false; - Console.WriteLine ("showdock=" + showDock); - } - - protected override void onDraw (Cairo.Context gr) - { - gr.Save (); - - Rectangle rBack = new Rectangle (Slot.Size); - - Background.SetAsSource (gr, rBack); - CairoHelpers.CairoRectangle (gr, rBack, CornerRadius); - gr.Fill (); - - if (ClipToClientRect) { - //clip to client zone - CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius); - gr.Clip (); - } - - childrenRWLock.EnterReadLock (); - - foreach (GraphicObject g in Children) { -// if (IFace.DragAndDropOperation?.DragSource == g) -// continue; - g.Paint (ref gr); - } - - childrenRWLock.ExitReadLock (); - - if (showDockingTarget) { - Rectangle r; - if (stack == null) - r = ClientRectangle; - else - r = stack.ClientRectangle; - - switch (dockingDirection) { - case Alignment.Top: - gr.Rectangle (r.Left, r.Top, r.Width, r.Height / dockingDiv); - break; - case Alignment.Bottom: - gr.Rectangle (r.Left, r.Bottom - r.Height / dockingDiv, r.Width, r.Height / dockingDiv); - break; - case Alignment.Left: - gr.Rectangle (r.Left, r.Top, r.Width / dockingDiv, r.Height); - break; - case Alignment.Right: - gr.Rectangle (r.Right - r.Width / dockingDiv, r.Top, r.Width / dockingDiv, r.Height); - break; - } - gr.LineWidth = 1; - gr.SetSourceRGBA (0.4, 0.4, 0.9, 0.4); - gr.FillPreserve (); - gr.SetSourceRGBA (0.9, 0.9, 1.0, 0.8); - gr.Stroke (); - } - - gr.Restore (); - } -*/ - - /* - public void Dock(DockWindow dw){ - checkInstantiators(); - - if (dockingDirection == Alignment.Center) - return; - - lock (IFace.UpdateMutex) { - - Splitter splitter = instSplit.CreateInstance<Splitter> (); - Rectangle r = ClientRectangle; - - if (stack == null) { - stack = instStack.CreateInstance<GenericStack> (); - this.AddChild (stack); - this.putWidgetOnBottom (stack); - } - - int vTreshold = r.Height / dockingDiv; - int hTreshold = r.Width / dockingDiv; - - switch (dockingDirection) { - case Alignment.Top: - dw.Height = vTreshold; - stack.Orientation = Orientation.Vertical; - if (stack.Children.Count == 0) { - stack.AddChild (dw); - stack.AddChild (splitter); - stack.AddChild (instSpacer.CreateInstance ()); - } else { - stack.AddChild (splitter); - stack.AddChild (dw); - } - break; - case Alignment.Bottom: - dw.Height = vTreshold; - stack.Orientation = Orientation.Vertical; - if (stack.Children.Count == 0) { - stack.AddChild (instSpacer.CreateInstance ()); - stack.AddChild (splitter); - stack.AddChild (dw); - } else { - stack.InsertChild (0, dw); - stack.InsertChild (0, splitter); - } - break; - case Alignment.Left: - dw.Width = hTreshold; - stack.Orientation = Orientation.Horizontal; - if (stack.Children.Count == 0) { - stack.AddChild (dw); - stack.AddChild (splitter); - stack.AddChild (instSpacer.CreateInstance ()); - } else { - stack.AddChild (splitter); - stack.AddChild (dw); - } - break; - case Alignment.Right: - dw.Width = hTreshold; - stack.Orientation = Orientation.Horizontal; - if (stack.Children.Count == 0) { - stack.AddChild (instSpacer.CreateInstance ()); - stack.AddChild (splitter); - stack.AddChild (dw); - } else { - stack.InsertChild (0, dw); - stack.InsertChild (0, splitter); - } - break; - } - } - }*/ } } diff --git a/src/GraphicObjects/GenericStack.cs b/src/GraphicObjects/GenericStack.cs index 0dbaedd1..19c70076 100644 --- a/src/GraphicObjects/GenericStack.cs +++ b/src/GraphicObjects/GenericStack.cs @@ -234,6 +234,7 @@ namespace Crow { base.RemoveChild (child); if (child == stretchedGO) { + stretchedGO.LastSlots = default(Rectangle); stretchedGO = null; RegisterForLayouting (LayoutingType.Sizing); return; diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index a70f04a1..8ba8788d 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -247,13 +247,13 @@ namespace Crow Initialize (); } #endregion - internal bool initialized = false; + //internal bool initialized = false; /// <summary> /// Initialize this Graphic object instance by setting style and default values and loading template if required /// </summary> public virtual void Initialize(){ loadDefaultValues (); - initialized = true; + //initialized = true; } #region private fields LayoutingType registeredLayoutings = LayoutingType.All; @@ -321,9 +321,6 @@ namespace Crow internal Size contentSize; #endregion - public void ResetSlots () { - LastSlots = LastPaintedSlot = Slot = default(Rectangle); - } #region ILayoutable [XmlIgnore]public LayoutingType RegisteredLayoutings { get { return registeredLayoutings; } set { registeredLayoutings = value; } } //TODO: it would save the recurent cost of a cast in event bubbling if parent type was GraphicObject @@ -426,11 +423,21 @@ namespace Crow public event EventHandler Enabled; /// <summary>Occurs when the enabled state this object is set to false</summary> public event EventHandler Disabled; + + #region DragAndDrop Events public event EventHandler StartDrag; public event EventHandler DragEnter; public event EventHandler DragLeave; public event EventHandler EndDrag; public event EventHandler Drop; + #endregion + + /// <summary> + /// Occurs when default value and styling are loaded, and for templated control, + /// template is also loaded. Bindings should be functionnal as well. + /// </summary> + public event EventHandler Initialized; + /// <summary>Occurs when one part of the rendering slot changed</summary> public event EventHandler<LayoutingEventArgs> LayoutChanged; /// <summary>Occurs when DataSource changed</summary> @@ -1143,6 +1150,10 @@ namespace Crow } catch (Exception ex) { throw new Exception ("Error applying style <" + styleKey + ">:", ex); } + onInitialized (this, null); + } + protected virtual void onInitialized (object sender, EventArgs e){ + Initialized.Raise(sender, e); } bool getDefaultEvent(EventInfo ei, List<Style> styling, out string expression){ diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs index 11bf16fb..43f08198 100644 --- a/src/GraphicObjects/Group.cs +++ b/src/GraphicObjects/Group.cs @@ -115,7 +115,6 @@ namespace Crow Children.Remove(child); child.Parent = null; - //child.ResetSlots (); childrenRWLock.ExitWriteLock (); |