diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-03-14 12:33:40 +0100 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-03-14 12:33:40 +0100 |
| commit | 2c8ebf731af0a626c5d684efc5c2853edd8c3c2d (patch) | |
| tree | 8beeb9d4f53183db21614f0dddc16859d246c339 /src/GraphicObjects | |
| parent | fda39ed7506551ab48dce271cb2d5e9c63f2b00c (diff) | |
dragndrop of GObjs
Diffstat (limited to 'src/GraphicObjects')
| -rw-r--r-- | src/GraphicObjects/GenericStack.cs | 18 | ||||
| -rw-r--r-- | src/GraphicObjects/GraphicObject.cs | 30 | ||||
| -rw-r--r-- | src/GraphicObjects/Group.cs | 2 | ||||
| -rw-r--r-- | src/GraphicObjects/PrivateContainer.cs | 1 |
4 files changed, 36 insertions, 15 deletions
diff --git a/src/GraphicObjects/GenericStack.cs b/src/GraphicObjects/GenericStack.cs index 181c41c2..64841d4b 100644 --- a/src/GraphicObjects/GenericStack.cs +++ b/src/GraphicObjects/GenericStack.cs @@ -227,20 +227,20 @@ namespace Crow public override void RemoveChild (GraphicObject child) { + if (child != stretchedGO) { + if (Orientation == Orientation.Horizontal) + contentSize.Width -= child.LastSlots.Width; + else + contentSize.Height -= child.LastSlots.Height; + } base.RemoveChild (child); if (child == stretchedGO) { - //stretchedGO.LastSlots = default(Rectangle); stretchedGO = null; RegisterForLayouting (LayoutingType.Sizing); - return; - } - if (Orientation == Orientation.Horizontal) { - contentSize.Width -= child.LastSlots.Width; + }else if (Orientation == Orientation.Horizontal) adjustStretchedGo (LayoutingType.Width); - } else { - contentSize.Height -= child.LastSlots.Height; - adjustStretchedGo (LayoutingType.Height); - } + else + adjustStretchedGo (LayoutingType.Height); } } } diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 9e5e4401..2ca07975 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -126,7 +126,24 @@ namespace Crow parentElem.AppendChild (xe); } - + public Surface CreateIcon (int dragIconSize = 32) { + ImageSurface di = new ImageSurface (Format.Argb32, dragIconSize, dragIconSize); + using (Context ctx = new Context (di)) { + double div = Math.Max (LastPaintedSlot.Width, LastPaintedSlot.Height); + double s = (double)dragIconSize / div; + ctx.Scale (s, s); + if (bmp == null) + this.onDraw (ctx); + else { + if (LastPaintedSlot.Width>LastPaintedSlot.Height) + ctx.SetSourceSurface (bmp, 0, (LastPaintedSlot.Width-LastPaintedSlot.Height)/2); + else + ctx.SetSourceSurface (bmp, (LastPaintedSlot.Height-LastPaintedSlot.Width)/2, 0); + ctx.Paint (); + } + } + return di; + } #endif #region IDisposable implementation @@ -337,7 +354,7 @@ namespace Crow parentRWLock.EnterWriteLock(); parent = value; - Slot = default(Rectangle); + Slot = LastSlots = default(Rectangle); parentRWLock.ExitWriteLock(); onParentChanged (this, e); @@ -374,8 +391,13 @@ namespace Crow Parent.ContextCoordinates (r); } public virtual Rectangle ScreenCoordinates (Rectangle r){ - return - Parent.ScreenCoordinates(r) + Parent.getSlot().Position + Parent.ClientRectangle.Position; + try { + return + Parent.ScreenCoordinates(r) + Parent.getSlot().Position + Parent.ClientRectangle.Position; + } catch (Exception ex) { + Debug.WriteLine (ex); + return default(Rectangle); + } } public virtual Rectangle getSlot () { return Slot;} #endregion diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs index 9cedec81..a90947a5 100644 --- a/src/GraphicObjects/Group.cs +++ b/src/GraphicObjects/Group.cs @@ -64,7 +64,7 @@ namespace Crow } #endif - protected ReaderWriterLockSlim childrenRWLock = new ReaderWriterLockSlim(); + protected ReaderWriterLockSlim childrenRWLock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); #region CTOR public Group () : base() {} diff --git a/src/GraphicObjects/PrivateContainer.cs b/src/GraphicObjects/PrivateContainer.cs index 668ba452..d6637247 100644 --- a/src/GraphicObjects/PrivateContainer.cs +++ b/src/GraphicObjects/PrivateContainer.cs @@ -75,7 +75,6 @@ namespace Crow if (child != null) { child.Parent = this; child.LayoutChanged += OnChildLayoutChanges; - child.Slot = child.LastSlots = default(Rectangle); contentSize = child.Slot.Size; child.RegisteredLayoutings = LayoutingType.None; child.RegisterForLayouting (LayoutingType.Sizing); |