aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects
diff options
context:
space:
mode:
Diffstat (limited to 'src/GraphicObjects')
-rw-r--r--src/GraphicObjects/ColorPicker.cs6
-rw-r--r--src/GraphicObjects/DockStack.cs299
-rw-r--r--src/GraphicObjects/DockWindow.cs191
-rw-r--r--src/GraphicObjects/Docker.cs191
-rw-r--r--src/GraphicObjects/Expandable.cs2
-rw-r--r--src/GraphicObjects/GenericStack.cs97
-rw-r--r--src/GraphicObjects/GraphicObject.cs186
-rw-r--r--src/GraphicObjects/Group.cs15
-rw-r--r--src/GraphicObjects/PrivateContainer.cs8
-rw-r--r--src/GraphicObjects/TemplatedGroup.cs5
-rw-r--r--src/GraphicObjects/Wrapper.cs14
11 files changed, 672 insertions, 342 deletions
diff --git a/src/GraphicObjects/ColorPicker.cs b/src/GraphicObjects/ColorPicker.cs
index 3a5ec23f..ee0d31da 100644
--- a/src/GraphicObjects/ColorPicker.cs
+++ b/src/GraphicObjects/ColorPicker.cs
@@ -165,7 +165,11 @@ namespace Crow
NotifyValueChanged ("SelectedColorName", n);
else
NotifyValueChanged ("SelectedColorName", "-");
- NotifyValueChanged ("HexColor", ((int)R).ToString ("X2") + ((int)G).ToString ("X2") + ((int)B).ToString ("X2") + ((int)A).ToString ("X2"));
+ NotifyValueChanged ("HexColor",
+ ((int)Math.Round(R)).ToString ("X2") +
+ ((int)Math.Round(G)).ToString ("X2") +
+ ((int)Math.Round(B)).ToString ("X2") +
+ ((int)Math.Round(A)).ToString ("X2"));
}
void notifyRGBAHasChanged(){
NotifyValueChanged ("R", R);
diff --git a/src/GraphicObjects/DockStack.cs b/src/GraphicObjects/DockStack.cs
new file mode 100644
index 00000000..29ebe0ec
--- /dev/null
+++ b/src/GraphicObjects/DockStack.cs
@@ -0,0 +1,299 @@
+//
+// DockStack.cs
+//
+// Author:
+// Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// Copyright (c) 2013-2017 Jean-Philippe Bruyère
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using Crow.IML;
+
+namespace Crow
+{
+ public class DockStack : GenericStack
+ {
+ internal static Instantiator instStack, instSplit, instSpacer;
+
+ int dockingDiv = 5;
+
+ GraphicObject subStack = null;
+ public GraphicObject SubStack {
+ get { return subStack;}
+ set{ subStack=value; }
+ }
+
+ public DockStack () {}
+ public DockStack (Interface iface) : base (iface) {}
+
+ public override bool PointIsIn (ref Point m)
+ {
+ if (!base.PointIsIn(ref m))
+ return false;
+
+ Group p = Parent as Group;
+ if (p != null) {
+ lock (p.Children) {
+ for (int i = p.Children.Count - 1; i >= 0; i--) {
+ if (p.Children [i] == this)
+ break;
+ if (p.Children [i].IsDragged)
+ continue;
+ if (p.Children [i].Slot.ContainsOrIsEqual (m)) {
+ return false;
+ }
+ }
+ }
+ }
+ 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) {
+ DockWindow dw = IFace.DragAndDropOperation.DragSource as DockWindow;
+ if (dw.IsDocked) {
+ if (!dw.CheckUndock (e.Position)) {
+ base.onMouseMove (sender, e);
+ return;
+ }
+ }
+ Point lm = ScreenPointToLocal (e.Position);
+
+ Rectangle r = ClientRectangle;
+ int vTreshold = r.Height / dockingDiv;
+ int hTreshold = r.Width / dockingDiv;
+
+ Alignment curDockPos = dw.DockingPosition;
+
+ if (lm.X < hTreshold)
+ dw.DockingPosition = Alignment.Left;
+ else if (lm.X > r.Right - hTreshold)
+ dw.DockingPosition = Alignment.Right;
+ else if (lm.Y < vTreshold)
+ dw.DockingPosition = Alignment.Top;
+ else if (lm.Y > r.Bottom - vTreshold)
+ dw.DockingPosition = Alignment.Bottom;
+ else
+ dw.DockingPosition = Alignment.Center;
+
+ if (curDockPos != dw.DockingPosition)
+ RegisterForGraphicUpdate ();
+ }
+ base.onMouseMove (sender, e);
+ }
+ static Orientation GetOrientation (Alignment a){
+ return (a==Alignment.Left) ||(a==Alignment.Right) ? Orientation.Horizontal : Orientation.Vertical;
+ }
+ 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)
+ g.Paint (ref gr);
+
+ childrenRWLock.ExitReadLock ();
+
+
+ if (!IsDropTarget) {
+ gr.Restore ();
+ return;
+ }
+
+ DockWindow dw = IFace.DragAndDropOperation.DragSource as DockWindow;
+ if (!dw.IsDocked) {
+
+ Rectangle r;
+
+ if (GetOrientation (dw.DockingPosition) == Orientation || SubStack == null)
+ r = ClientRectangle;
+ else
+ r = SubStack.ClientRectangle + SubStack.Slot.Position + ClientRectangle.TopLeft;
+
+ switch (dw.DockingPosition) {
+ 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 Undock (DockWindow dw){
+ RemoveChild(dw);
+
+ if (dw.DockingPosition == Alignment.Left || dw.DockingPosition == Alignment.Top)
+ RemoveChild (0);
+ else
+ RemoveChild (Children.Count - 1);
+
+ if (Children.Count > 1)
+ return;
+ DockStack dsp = Parent as DockStack;
+ if (dsp == null) {
+ SubStack = null;
+ RemoveChild (0);
+ return;
+ }
+ GraphicObject g = Children [0];
+ RemoveChild (g);
+ int i = dsp.Children.IndexOf (this);
+ dsp.RemoveChild (this);
+ dsp.AddChild (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;
+
+ int vTreshold = r.Height / dockingDiv;
+ int hTreshold = r.Width / dockingDiv;
+
+ DockStack activeStack = this;
+
+ if (SubStack == null) {
+ activeStack = this;
+ SubStack = instSpacer.CreateInstance ();
+ }else if (GetOrientation (dw.DockingPosition) != Orientation) {
+ int i = Children.IndexOf (SubStack);
+ RemoveChild (SubStack);
+ activeStack = instStack.CreateInstance<DockStack> ();
+ activeStack.SubStack = instSpacer.CreateInstance ();
+ SubStack = activeStack;
+ InsertChild(i, activeStack);
+ }
+
+ switch (dw.DockingPosition) {
+ case Alignment.Top:
+ dw.Height = vTreshold;
+ dw.Width = Measure.Stretched;
+ if (activeStack.Children.Count == 0) {
+ activeStack.Orientation = Orientation.Vertical;
+ activeStack.AddChild (dw);
+ activeStack.AddChild (splitter);
+ activeStack.AddChild (activeStack.SubStack);
+ } else {
+ activeStack.InsertChild (0, dw);
+ activeStack.InsertChild (0, splitter);
+ }
+ break;
+ case Alignment.Bottom:
+ dw.Height = vTreshold;
+ dw.Width = Measure.Stretched;
+ if (activeStack.Children.Count == 0) {
+ activeStack.Orientation = Orientation.Vertical;
+ activeStack.AddChild (activeStack.SubStack);
+ activeStack.AddChild (splitter);
+ activeStack.AddChild (dw);
+ } else {
+ activeStack.AddChild (splitter);
+ activeStack.AddChild (dw);
+ }
+ break;
+ case Alignment.Left:
+ dw.Width = hTreshold;
+ dw.Height = Measure.Stretched;
+ if (activeStack.Children.Count == 0) {
+ activeStack.Orientation = Orientation.Horizontal;
+ activeStack.AddChild (dw);
+ activeStack.AddChild (splitter);
+ activeStack.AddChild (activeStack.SubStack);
+ } else {
+ activeStack.InsertChild (0, dw);
+ activeStack.InsertChild (0, splitter);
+ }
+ break;
+ case Alignment.Right:
+ dw.Width = hTreshold;
+ dw.Height = Measure.Stretched;
+ if (activeStack.Children.Count == 0) {
+ activeStack.Orientation = Orientation.Horizontal;
+ activeStack.AddChild (activeStack.SubStack);
+ activeStack.AddChild (splitter);
+ activeStack.AddChild (dw);
+ } else {
+ activeStack.AddChild (splitter);
+ activeStack.AddChild (dw);
+ }
+ break;
+ }
+ }
+
+ void checkInstantiators () {
+ if (instStack != null)
+ return;
+ instStack = IFace.CreateITorFromIMLFragment (@"<DockStack/>");
+ instSplit = IFace.CreateITorFromIMLFragment (@"<Splitter/>");
+ instSpacer = IFace.CreateITorFromIMLFragment (@"<GraphicObject Background='Jet' IsEnabled='false'/>");
+ }
+
+ }
+}
+
diff --git a/src/GraphicObjects/DockWindow.cs b/src/GraphicObjects/DockWindow.cs
index b68a3085..4c71c92d 100644
--- a/src/GraphicObjects/DockWindow.cs
+++ b/src/GraphicObjects/DockWindow.cs
@@ -35,6 +35,7 @@ namespace Crow
}
#endregion
+ int undockThreshold = 10;
bool isDocked = false;
Alignment docking = Alignment.Center;
@@ -43,6 +44,8 @@ namespace Crow
Rectangle savedSlot; //last undocked slot recalled when view is undocked
bool wasResizable;
+ public Docker RootDock { get { return LogicalParent as Docker; }}
+
public bool IsDocked {
get { return isDocked; }
set {
@@ -61,12 +64,7 @@ namespace Crow
NotifyValueChanged ("DockingPosition", DockingPosition);
}
}
- protected override void onDrop (object sender, DragDropEventArgs e)
- {
- base.onDrop (sender, e);
- Docker dv = Parent as Docker;
- dv.Dock (this);
- }
+
public override bool PointIsIn (ref Point m)
{
if (!base.PointIsIn(ref m))
@@ -78,6 +76,8 @@ namespace Crow
for (int i = p.Children.Count - 1; i >= 0; i--) {
if (p.Children [i] == this)
break;
+ if (p.Children [i].IsDragged)
+ continue;
if (p.Children [i].Slot.ContainsOrIsEqual (m)) {
return false;
}
@@ -113,130 +113,75 @@ namespace Crow
// }
// }
//
-// public override void onMouseMove (object sender, MouseMoveEventArgs e)
-// {
-// lastMousePos = e.Position;
-//
-// if (this.HasFocus && e.Mouse.IsButtonDown (MouseButton.Left) && IsDocked) {
-// Docker dv = Parent as Docker;
-// if (docking == Alignment.Left) {
-// if (lastMousePos.X - undockingMousePosOrig.X > dv.DockingThreshold)
-// undock ();
-// } else if (docking == Alignment.Right) {
-// if (undockingMousePosOrig.X - lastMousePos.X > dv.DockingThreshold)
-// undock ();
-// } else if (docking == Alignment.Top) {
-// if (lastMousePos.Y - undockingMousePosOrig.Y > dv.DockingThreshold)
-// undock ();
-// } else if (docking == Alignment.Bottom) {
-// if (undockingMousePosOrig.Y - lastMousePos.Y > dv.DockingThreshold)
-// undock ();
-// }
-// return;
-// }
-//
-// base.onMouseMove (sender, e);
-// }
-// public override void onMouseDown (object sender, MouseButtonEventArgs e)
-// {
-// base.onMouseDown (sender, e);
-//
-// if (this.HasFocus && IsDocked && e.Button == MouseButton.Left)
-// undockingMousePosOrig = lastMousePos;
-// }
+ public override void onMouseMove (object sender, MouseMoveEventArgs e)
+ {
+ lastMousePos = e.Position;
-// protected override void onBorderMouseEnter (object sender, MouseMoveEventArgs e)
-// {
-// base.onBorderMouseEnter (sender, e);
-//
-// if (isDocked) {
-// switch (docking) {
-// case Alignment.Top:
-// if (this.currentDirection != Window.Direction.S)
-// onBorderMouseLeave (this, null);
-// break;
-// case Alignment.Left:
-// if (this.currentDirection != Window.Direction.E)
-// onBorderMouseLeave (this, null);
-// break;
-// case Alignment.TopLeft:
-// break;
-// case Alignment.Right:
-// if (this.currentDirection != Window.Direction.W)
-// onBorderMouseLeave (this, null);
-// break;
-// case Alignment.TopRight:
-// break;
-// case Alignment.Bottom:
-// if (this.currentDirection != Window.Direction.N)
-// onBorderMouseLeave (this, null);
-// break;
-// case Alignment.BottomLeft:
-// break;
-// case Alignment.BottomRight:
-// break;
-// case Alignment.Center:
-// break;
-// default:
-// break;
-// }
-// }
-// }
+ if (this.HasFocus && e.Mouse.IsButtonDown (MouseButton.Left) && IsDocked) {
+ if (Math.Abs (e.Position.X - undockingMousePosOrig.X) > 10 ||
+ Math.Abs (e.Position.X - undockingMousePosOrig.X) > 10)
+ Undock ();
+ }
- void undock () {
- this.Left = savedSlot.Left;
- this.Top = savedSlot.Top;
- this.Width = savedSlot.Width;
- this.Height = savedSlot.Height;
+ base.onMouseMove (sender, e);
+ }
+ public override void onMouseDown (object sender, MouseButtonEventArgs e)
+ {
+ base.onMouseDown (sender, e);
- IsDocked = false;
- Resizable = wasResizable;
+ if (this.HasFocus && IsDocked && e.Button == MouseButton.Left)
+ undockingMousePosOrig = e.Position;
+ }
+ public bool CheckUndock (Point mousePos) {
+ if (Math.Abs (mousePos.X - undockingMousePosOrig.X) < undockThreshold ||
+ Math.Abs (mousePos.X - undockingMousePosOrig.X) < undockThreshold)
+ return false;
+ Undock ();
+ return true;
}
- void dock (Alignment align){
- IsDocked = true;
- docking = align;
- undockingMousePosOrig = lastMousePos;
- savedSlot = this.LastPaintedSlot;
- wasResizable = Resizable;
- Resizable = false;
- this.Left = this.Top = 0;
+ protected override void onStartDrag (object sender, DragDropEventArgs e)
+ {
+ base.onStartDrag (sender, e);
- switch (align) {
- case Alignment.Top:
- this.HorizontalAlignment = HorizontalAlignment.Left;
- this.VerticalAlignment = VerticalAlignment.Top;
- this.Width = Measure.Stretched;
- break;
- case Alignment.Left:
- this.HorizontalAlignment = HorizontalAlignment.Left;
- this.VerticalAlignment = VerticalAlignment.Top;
- this.Height = Measure.Stretched;
- break;
- case Alignment.TopLeft:
- break;
- case Alignment.Right:
- this.HorizontalAlignment = HorizontalAlignment.Right;
- this.VerticalAlignment = VerticalAlignment.Top;
- this.Height = Measure.Stretched;
- break;
- case Alignment.TopRight:
- break;
- case Alignment.Bottom:
- this.HorizontalAlignment = HorizontalAlignment.Left;
- this.VerticalAlignment = VerticalAlignment.Bottom;
- this.Width = Measure.Stretched;
- break;
- case Alignment.BottomLeft:
- break;
- case Alignment.BottomRight:
- break;
- case Alignment.Center:
- break;
- default:
- break;
+ undockingMousePosOrig = IFace.Mouse.Position;
+ }
+ protected override void onDrop (object sender, DragDropEventArgs e)
+ {
+ if (!isDocked && DockingPosition != Alignment.Center)
+ dock (e.DropTarget as DockStack);
+ base.onDrop (sender, e);
+ }
+ public void Undock () {
+ lock (IFace.UpdateMutex) {
+ DockStack ds = Parent as DockStack;
+ ds.Undock (this);
+
+ RootDock.AddChild (this);
+
+ this.Left = savedSlot.Left;
+ this.Top = savedSlot.Top;
+ this.Width = savedSlot.Width;
+ this.Height = savedSlot.Height;
+
+ IsDocked = false;
+ Resizable = wasResizable;
+ }
+ }
+ void dock (DockStack target){
+ lock (IFace.UpdateMutex) {
+ IsDocked = true;
+ undockingMousePosOrig = lastMousePos;
+ savedSlot = this.LastPaintedSlot;
+ wasResizable = Resizable;
+ Resizable = false;
+ LastSlots = LastPaintedSlot = Slot = default(Rectangle);
+ Left = Top = 0;
+
+ RootDock.RemoveChild (this);
+
+ target.Dock (this);
}
-
}
}
}
diff --git a/src/GraphicObjects/Docker.cs b/src/GraphicObjects/Docker.cs
index bb816dd9..dfd386aa 100644
--- a/src/GraphicObjects/Docker.cs
+++ b/src/GraphicObjects/Docker.cs
@@ -27,45 +27,32 @@ using System;
using System.Xml.Serialization;
using System.ComponentModel;
using Crow.IML;
+using System.Collections.Generic;
+using System.Diagnostics;
namespace Crow
{
public class Docker : Group
- {
- static Instantiator instStack, instSplit, instSpacer;
+ {
#region CTOR
static Docker () {
}
public Docker () : base ()
{
- instStack = IFace.CreateITorFromIMLFragment (@"<GenericStack Background='Blue' AllowDrop='true' DragEnter='onStackDragEnter'/>");
- instSplit = IFace.CreateITorFromIMLFragment (@"<Splitter/>");
- instSpacer = IFace.CreateITorFromIMLFragment (@"<GraphicObject Background='Red' IsEnabled='false'/>");
}
#endregion
- GenericStack rootStack = null;
+ //GenericStack rootStack = null;
+ DockStack stack = null;
+ int dockingThreshold;
+
+ List<DockWindow> windows = new List<DockWindow>();
public override void AddChild (GraphicObject g)
- {
- DockWindow dw = g as DockWindow;
- if (dw == null)
- throw new Exception ("Docker accept only DockWindow as child");
-
+ {
base.AddChild (g);
-
- dw.LogicalParent = this;
+ g.LogicalParent = this;
}
- public override void RemoveChild (GraphicObject child)
- {
- child.LogicalParent = null;
-
-
- base.RemoveChild (child);
- }
-
- GenericStack mainStack = null;
- int dockingThreshold;
[XmlAttributeAttribute][DefaultValue(10)]
public virtual int DockingThreshold {
@@ -79,57 +66,39 @@ namespace Crow
}
}
- bool showDockingTarget = false;
- Alignment dockingDirection = Alignment.Center;
- int dockingDiv = 5;
+ //bool showDockingTarget = false;
+ //Alignment dockingDirection = Alignment.Center;
+ //int dockingDiv = 8;
+ //bool showDock = false;
public override void onMouseMove (object sender, MouseMoveEventArgs e)
{
if (IFace.DragAndDropOperation?.DragSource as DockWindow != null) {
- DockWindow dw = IFace.DragAndDropOperation?.DragSource as DockWindow;
- if (IFace.DragAndDropOperation.DragSource.Parent == this && !dw.IsDocked)
+ DockWindow dw = IFace.DragAndDropOperation.DragSource as DockWindow;
+ if (!dw.IsDocked)
dw.MoveAndResize (e.XDelta, e.YDelta);
-
- Rectangle r = ClientRectangle;
- int vTreshold = r.Height / dockingDiv;
- int hTreshold = r.Width / dockingDiv;
-
-
- bool showDock = true;
-
- if (dw.Slot.Left < hTreshold)
- dockingDirection = Alignment.Left;
- else if (dw.Slot.Right > r.Right - hTreshold)
- dockingDirection = Alignment.Right;
- else if (dw.Slot.Top < vTreshold)
- dockingDirection = Alignment.Top;
- else if (dw.Slot.Bottom > r.Bottom - vTreshold)
- dockingDirection = Alignment.Bottom;
- else {
- dockingDirection = Alignment.Center;
- showDock = false;
+ if (stack == null) {
+ stack = new DockStack (IFace);
+ InsertChild (0, stack);
+ stack.LogicalParent = this;
}
-
- showDockingTarget = showDock;
-
- RegisterForGraphicUpdate ();
-
- //System.Diagnostics.Debug.WriteLine ("Dock: {0}", dockingDirection);
- } else
- showDockingTarget = false;
-
+ }
base.onMouseMove (sender, e);
}
+ /*
protected override void onDragEnter (object sender, DragDropEventArgs e)
{
base.onDragEnter (sender, e);
+ showDock = true;
+ Console.WriteLine ("showdock=" + showDock);
}
- void onStackDragEnter (object sender, DragDropEventArgs e)
+ protected override void onDragLeave (object sender, DragDropEventArgs e)
{
- base.onDragEnter (sender, e);
-
- mainStack = sender as GenericStack;
+ base.onDragLeave (sender, e);
+ showDock = false;
+ Console.WriteLine ("showdock=" + showDock);
}
+
protected override void onDraw (Cairo.Context gr)
{
gr.Save ();
@@ -149,8 +118,8 @@ namespace Crow
childrenRWLock.EnterReadLock ();
foreach (GraphicObject g in Children) {
- if (IFace.DragAndDropOperation?.DragSource == g)
- continue;
+// if (IFace.DragAndDropOperation?.DragSource == g)
+// continue;
g.Paint (ref gr);
}
@@ -158,10 +127,10 @@ namespace Crow
if (showDockingTarget) {
Rectangle r;
- if (mainStack == null)
+ if (stack == null)
r = ClientRectangle;
else
- r = mainStack.ClientRectangle;
+ r = stack.ClientRectangle;
switch (dockingDirection) {
case Alignment.Top:
@@ -184,73 +153,83 @@ namespace Crow
gr.Stroke ();
}
- if (IFace.DragAndDropOperation != null)
- IFace.DragAndDropOperation.DragSource.Paint (ref gr);
-
-
gr.Restore ();
}
+*/
+ /*
public void Dock(DockWindow dw){
+ checkInstantiators();
+
if (dockingDirection == Alignment.Center)
return;
+
lock (IFace.UpdateMutex) {
Splitter splitter = instSplit.CreateInstance<Splitter> ();
+ Rectangle r = ClientRectangle;
- dw.Resizable = false;
- dw.Left = dw.Top = 0;
- this.RemoveChild (dw);
-
- Rectangle r;
- if (mainStack == null) {
- mainStack = instStack.CreateInstance<GenericStack> ();
- this.AddChild (mainStack);
- this.putWidgetOnBottom (mainStack);
- r = ClientRectangle;
- } else
- r = mainStack.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.Width = Measure.Stretched;
- mainStack.Orientation = Orientation.Vertical;
- mainStack.AddChild (dw);
- mainStack.AddChild (splitter);
- //mainStack.AddChild (instSpacer.CreateInstance (CurrentInterface));
+ 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.Width = Measure.Stretched;
- mainStack.Orientation = Orientation.Vertical;
- //mainStack.AddChild (instSpacer.CreateInstance (CurrentInterface));
- mainStack.AddChild (splitter);
- mainStack.AddChild (dw);
+ 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.Height = Measure.Stretched;
- mainStack.Orientation = Orientation.Horizontal;
- mainStack.AddChild (dw);
- mainStack.AddChild (splitter);
- //mainStack.AddChild (instSpacer.CreateInstance (CurrentInterface));
+ 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.Height = Measure.Stretched;
- mainStack.Orientation = Orientation.Horizontal;
- //mainStack.AddChild (instSpacer.CreateInstance (CurrentInterface));
- mainStack.AddChild (splitter);
- mainStack.AddChild (dw);
+ 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;
}
-
}
- }
- protected override void onDrop (object sender, DragDropEventArgs e)
- {
- base.onDrop (sender, e);
- }
+ }*/
}
}
diff --git a/src/GraphicObjects/Expandable.cs b/src/GraphicObjects/Expandable.cs
index aff804f8..83d91956 100644
--- a/src/GraphicObjects/Expandable.cs
+++ b/src/GraphicObjects/Expandable.cs
@@ -77,7 +77,7 @@ namespace Crow
NotifyValueChanged ("Image", image);
}
}
- [XmlAttributeAttribute][DefaultValue(false)]
+ [DefaultValue(false)]
public bool IsExpanded
{
get { return _isExpanded; }
diff --git a/src/GraphicObjects/GenericStack.cs b/src/GraphicObjects/GenericStack.cs
index 3d6884e1..2df681e4 100644
--- a/src/GraphicObjects/GenericStack.cs
+++ b/src/GraphicObjects/GenericStack.cs
@@ -136,6 +136,46 @@ namespace Crow
return base.UpdateLayout(layoutType);
}
+ void adjustStretchedGo (LayoutingType lt){
+ if (stretchedGO == null)
+ return;
+ if (lt == LayoutingType.Width) {
+ int newW = Math.Max (
+ this.ClientRectangle.Width - contentSize.Width - Spacing * (Children.Count - 1),
+ stretchedGO.MinimumSize.Width);
+ if (stretchedGO.MaximumSize.Width > 0)
+ newW = Math.Min (newW, stretchedGO.MaximumSize.Width);
+ if (newW != stretchedGO.Slot.Width) {
+ stretchedGO.Slot.Width = newW;
+ stretchedGO.IsDirty = true;
+ #if DEBUG_LAYOUTING
+ Debug.WriteLine ("\tAdjusting Width of " + stretchedGO.ToString());
+ #endif
+ stretchedGO.LayoutChanged -= OnChildLayoutChanges;
+ stretchedGO.OnLayoutChanges (LayoutingType.Width);
+ stretchedGO.LayoutChanged += OnChildLayoutChanges;
+ stretchedGO.LastSlots.Width = stretchedGO.Slot.Width;
+ }
+ } else {
+ int newH = Math.Max (
+ this.ClientRectangle.Height - contentSize.Height - Spacing * (Children.Count - 1),
+ stretchedGO.MinimumSize.Height);
+ if (stretchedGO.MaximumSize.Height > 0)
+ newH = Math.Min (newH, stretchedGO.MaximumSize.Height);
+ if (newH != stretchedGO.Slot.Height) {
+ stretchedGO.Slot.Height = newH;
+ stretchedGO.IsDirty = true;
+ #if DEBUG_LAYOUTING
+ Debug.WriteLine ("\tAdjusting Height of " + stretchedGO.ToString());
+ #endif
+ stretchedGO.LayoutChanged -= OnChildLayoutChanges;
+ stretchedGO.OnLayoutChanges (LayoutingType.Height);
+ stretchedGO.LayoutChanged += OnChildLayoutChanges;
+ stretchedGO.LastSlots.Height = stretchedGO.Slot.Height;
+ }
+ }
+ }
+
public override void OnChildLayoutChanges (object sender, LayoutingEventArgs arg)
{
GraphicObject go = sender as GraphicObject;
@@ -154,24 +194,7 @@ namespace Crow
} else
contentSize.Width += go.Slot.Width - go.LastSlots.Width;
- if (stretchedGO != null) {
- int newW = Math.Max (
- this.ClientRectangle.Width - contentSize.Width - Spacing * (Children.Count - 1),
- stretchedGO.MinimumSize.Width);
- if (stretchedGO.MaximumSize.Width > 0)
- newW = Math.Min (newW, stretchedGO.MaximumSize.Width);
- if (newW != stretchedGO.Slot.Width) {
- stretchedGO.Slot.Width = newW;
- stretchedGO.IsDirty = true;
-#if DEBUG_LAYOUTING
- Debug.WriteLine ("\tAdjusting Width of " + stretchedGO.ToString());
-#endif
- stretchedGO.LayoutChanged -= OnChildLayoutChanges;
- stretchedGO.OnLayoutChanges (LayoutingType.Width);
- stretchedGO.LayoutChanged += OnChildLayoutChanges;
- stretchedGO.LastSlots.Width = stretchedGO.Slot.Width;
- }
- }
+ adjustStretchedGo (LayoutingType.Width);
if (Width == Measure.Fit)
this.RegisterForLayouting (LayoutingType.Width);
@@ -193,24 +216,7 @@ namespace Crow
} else
contentSize.Height += go.Slot.Height - go.LastSlots.Height;
- if (stretchedGO != null) {
- int newH = Math.Max (
- this.ClientRectangle.Height - contentSize.Height - Spacing * (Children.Count - 1),
- stretchedGO.MinimumSize.Height);
- if (stretchedGO.MaximumSize.Height > 0)
- newH = Math.Min (newH, stretchedGO.MaximumSize.Height);
- if (newH != stretchedGO.Slot.Height) {
- stretchedGO.Slot.Height = newH;
- stretchedGO.IsDirty = true;
-#if DEBUG_LAYOUTING
- Debug.WriteLine ("\tAdjusting Height of " + stretchedGO.ToString());
-#endif
- stretchedGO.LayoutChanged -= OnChildLayoutChanges;
- stretchedGO.OnLayoutChanges (LayoutingType.Height);
- stretchedGO.LayoutChanged += OnChildLayoutChanges;
- stretchedGO.LastSlots.Height = stretchedGO.Slot.Height;
- }
- }
+ adjustStretchedGo (LayoutingType.Height);
if (Height == Measure.Fit)
this.RegisterForLayouting (LayoutingType.Height);
@@ -224,6 +230,23 @@ namespace Crow
}
#endregion
-
+ public override void RemoveChild (GraphicObject child)
+ {
+ base.RemoveChild (child);
+ if (child == stretchedGO) {
+ stretchedGO = null;
+ return;
+ }
+ if (Orientation == Orientation.Horizontal) {
+ contentSize.Width -= child.LastSlots.Width;
+ adjustStretchedGo (LayoutingType.Width);
+ } else {
+ contentSize.Height -= child.LastSlots.Height;
+ adjustStretchedGo (LayoutingType.Height);
+ }
+
+
+// RegisterForLayouting (LayoutingType.ArrangeChildren);
+ }
}
}
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs
index adb29e54..db49832e 100644
--- a/src/GraphicObjects/GraphicObject.cs
+++ b/src/GraphicObjects/GraphicObject.cs
@@ -52,24 +52,37 @@ namespace Crow
internal ReaderWriterLockSlim parentRWLock = new ReaderWriterLockSlim();
#if DESIGN_MODE
- static MethodInfo miDesignAddDefLoc = typeof(GraphicObject).GetMethod("design_add_default_location",
+ static MethodInfo miDesignAddDefLoc = typeof(GraphicObject).GetMethod("design_add_style_location",
BindingFlags.Instance | BindingFlags.NonPublic);
- public volatile bool HasChanged = false;
+ static MethodInfo miDesignAddValLoc = typeof(GraphicObject).GetMethod("design_add_iml_location",
+ BindingFlags.Instance | BindingFlags.NonPublic);
+
+ public volatile bool design_HasChanged = false;
public string design_id;
public int design_line;
public int design_column;
public string design_imlPath;
- public Dictionary<string,string> design_members = new Dictionary<string, string>();
- public Dictionary<string,FileLocation> design_defaults = new Dictionary<string, FileLocation>();
- internal void design_add_default_location (string memberName, string path, int line, int col) {
- if (design_defaults.ContainsKey(memberName)){
+ public bool design_isTGItem = false;//true if this is a templated item's root
+ public Dictionary<string,string> design_iml_values = new Dictionary<string, string>();
+ public Dictionary<string,string> design_style_values = new Dictionary<string, string>();
+ //public Dictionary<string,FileLocation> design_iml_locations = new Dictionary<string, FileLocation>();
+ public Dictionary<string,FileLocation> design_style_locations = new Dictionary<string, FileLocation>();
+
+ internal void design_add_style_location (string memberName, string path, int line, int col) {
+ if (design_style_locations.ContainsKey(memberName)){
Console.WriteLine ("default value localtion already set for {0}{1}.{2}", this.GetType().Name, this.design_id, memberName);
return;
}
- design_defaults.Add(memberName, new FileLocation(path,line,col));
+ design_style_locations.Add(memberName, new FileLocation(path,line,col));
}
- public bool design_isTGItem = false;
-
+// internal void design_add_iml_location (string memberName, string path, int line, int col) {
+// if (design_iml_locations.ContainsKey(memberName)){
+// Console.WriteLine ("IML value localtion already set for {0}{1}.{2}", this.GetType().Name, this.design_id, memberName);
+// return;
+// }
+// design_iml_locations.Add(memberName, new FileLocation(path,line,col));
+// }
+
public virtual bool FindByDesignID(string designID, out GraphicObject go){
go = null;
if (this.design_id == designID){
@@ -94,7 +107,7 @@ namespace Crow
getIML (doc, (XmlNode)doc);
doc.WriteTo (xtw);
}
- this.HasChanged = false;
+ this.design_HasChanged = false;
return sw.ToString ();
}
}
@@ -105,7 +118,7 @@ namespace Crow
XmlElement xe = doc.CreateElement(this.GetType().Name);
- foreach (KeyValuePair<string,string> kv in design_members) {
+ foreach (KeyValuePair<string,string> kv in design_iml_values) {
XmlAttribute xa = doc.CreateAttribute (kv.Key);
xa.Value = kv.Value;
xe.Attributes.Append (xa);
@@ -257,6 +270,7 @@ namespace Crow
bool focusable = false;
bool hasFocus = false;
bool isActive = false;
+ bool isHover = false;
bool mouseRepeat;
protected bool isVisible = true;
bool isEnabled = true;
@@ -307,6 +321,9 @@ 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
@@ -364,6 +381,14 @@ namespace Crow
}
public virtual Rectangle getSlot () { return Slot;}
#endregion
+ public Point ScreenPointToLocal(Point p){
+ Point pt = p - ScreenCoordinates(Slot).TopLeft - ClientRectangle.TopLeft;
+ if (pt.X < 0)
+ pt.X = 0;
+ if (pt.Y < 0)
+ pt.Y = 0;
+ return pt;
+ }
#region EVENT HANDLERS
/// <summary>Occurs when mouse wheel is rolled in this object. It bubbles to the root</summary>
@@ -392,7 +417,11 @@ namespace Crow
public event EventHandler Focused;
/// <summary>Occurs when this object loose focus</summary>
public event EventHandler Unfocused;
- /// <summary>Occurs when the enabled state this object is set to true</summary>
+ /// <summary>Occurs when mouse is over</summary>
+ public event EventHandler Hover;
+ /// <summary>Occurs when this control is no longer the Hover one</summary>
+ public event EventHandler UnHover;
+ /// <summary>Occurs when this object loose focus</summary>
public event EventHandler Enabled;
/// <summary>Occurs when the enabled state this object is set to false</summary>
public event EventHandler Disabled;
@@ -413,7 +442,7 @@ namespace Crow
#region public properties
/// <summary>Random value placeholder</summary>
- [XmlAttributeAttribute]
+ [DesignCategory ("Divers")]
public object Tag {
get { return tag; }
set {
@@ -427,7 +456,7 @@ namespace Crow
/// If enabled, resulting bitmap of graphic object is cached
/// speeding up rendering of complex object. Default is enabled.
/// </summary>
- [XmlAttributeAttribute][DefaultValue(true)]
+ [DesignCategory ("Behavior")][DefaultValue(true)]
public virtual bool CacheEnabled {
get { return cacheEnabled; }
set {
@@ -440,7 +469,7 @@ namespace Crow
/// <summary>
/// If true, rendering of GraphicObject is clipped inside client rectangle
/// </summary>
- [XmlAttributeAttribute][DefaultValue(true)]
+ [DesignCategory ("Appearance")][DefaultValue(true)]
public virtual bool ClipToClientRect {
get { return clipToClientRect; }
set {
@@ -461,7 +490,7 @@ namespace Crow
/// and by template controls to find special element in their template implementation such
/// as a container or a group to put children in.
/// </summary>
- [XmlAttributeAttribute][DefaultValue(null)]
+ [DesignCategory ("Divers")][DefaultValue(null)]
public virtual string Name {
get {
#if DEBUG
@@ -481,7 +510,7 @@ namespace Crow
/// Vertical alignment inside parent, disabled if height is stretched
/// or top coordinate is not null
/// </summary>
- [XmlAttributeAttribute ()][DefaultValue(VerticalAlignment.Center)]
+ [DesignCategory ("Layout")][DefaultValue(VerticalAlignment.Center)]
public virtual VerticalAlignment VerticalAlignment {
get { return verticalAlignment; }
set {
@@ -497,7 +526,7 @@ namespace Crow
/// Horizontal alignment inside parent, disabled if width is stretched
/// or left coordinate is not null
/// </summary>
- [XmlAttributeAttribute()][DefaultValue(HorizontalAlignment.Center)]
+ [DesignCategory ("Layout")][DefaultValue(HorizontalAlignment.Center)]
public virtual HorizontalAlignment HorizontalAlignment {
get { return horizontalAlignment; }
set {
@@ -511,7 +540,7 @@ namespace Crow
/// <summary>
/// x position inside parent
/// </summary>
- [XmlAttributeAttribute()][DefaultValue(0)]
+ [DesignCategory ("Layout")][DefaultValue(0)]
public virtual int Left {
get { return left; }
set {
@@ -525,7 +554,7 @@ namespace Crow
/// <summary>
/// y position inside parent
/// </summary>
- [XmlAttributeAttribute()][DefaultValue(0)]
+ [DesignCategory ("Layout")][DefaultValue(0)]
public virtual int Top {
get { return top; }
set {
@@ -539,7 +568,7 @@ namespace Crow
/// <summary>
/// Helper property used to set width and height to fit in one call
/// </summary>
- [XmlAttributeAttribute()][DefaultValue(false)]
+ [DesignCategory ("Layout")][DefaultValue(false)]
public virtual bool Fit {
get { return Width == Measure.Fit && Height == Measure.Fit ? true : false; }
set {
@@ -553,7 +582,7 @@ namespace Crow
/// Width of this control, by default inherited from parent. May have special values
/// such as Stretched or Fit. It may be proportionnal or absolute.
/// </summary>
- [XmlAttributeAttribute()][DefaultValue("Inherit")]
+ [DesignCategory ("Layout")][DefaultValue("Inherit")]
public virtual Measure Width {
get {
return width.Units == Unit.Inherit ?
@@ -593,7 +622,7 @@ namespace Crow
/// Height of this control, by default inherited from parent. May have special values
/// such as Stretched or Fit. It may be proportionnal or absolute.
/// </summary>
- [XmlAttributeAttribute()][DefaultValue("Inherit")]
+ [DesignCategory ("Layout")][DefaultValue("Inherit")]
public virtual Measure Height {
get {
return height.Units == Unit.Inherit ?
@@ -641,7 +670,7 @@ namespace Crow
/// Indicate that this object may received focus or not, if not focusable all the descendants are
/// affected.
/// </summary>
- [XmlAttributeAttribute()][DefaultValue(false)]
+ [DesignCategory ("Behaviour")][DefaultValue(false)]
public virtual bool Focusable {
get { return focusable; }
set {
@@ -683,9 +712,28 @@ namespace Crow
}
}
/// <summary>
+ /// true if this control has the pointer hover
+ /// </summary>
+ [XmlIgnore]public virtual bool IsHover {
+ get { return isHover; }
+ set {
+ if (value == isHover)
+ return;
+
+ isHover = value;
+
+ if (isHover)
+ onHover (this, null);
+ else
+ onUnHover (this, null);
+
+ NotifyValueChanged ("IsHover", isHover);
+ }
+ }
+ /// <summary>
/// true if holding mouse button down should trigger multiple click events
/// </summary>
- [XmlAttributeAttribute()][DefaultValue(false)]
+ [DesignCategory ("Behaviour")][DefaultValue(false)]
public virtual bool MouseRepeat {
get { return mouseRepeat; }
set {
@@ -699,7 +747,7 @@ namespace Crow
/// <summary>
/// background fill of the control, maybe solid color, gradient, image, or svg
/// </summary>
- [XmlAttributeAttribute()][DefaultValue("Transparent")]
+ [DesignCategory ("Appearance")][DefaultValue("Transparent")]
public virtual Fill Background {
get { return background; }
set {
@@ -720,7 +768,7 @@ namespace Crow
/// <summary>
/// Foreground fill of the control, usage may be different among derived controls
/// </summary>
- [XmlAttributeAttribute()][DefaultValue("White")]
+ [DesignCategory ("Appearance")][DefaultValue("White")]
public virtual Fill Foreground {
get { return foreground; }
set {
@@ -734,7 +782,7 @@ namespace Crow
/// <summary>
/// Font being used in many controls, it is defined in the base GraphicObject class.
/// </summary>
- [XmlAttributeAttribute()][DefaultValue("sans,10")]
+ [DesignCategory ("Appearance")][DefaultValue("sans,10")]
public virtual Font Font {
get { return font; }
set {
@@ -748,7 +796,7 @@ namespace Crow
/// <summary>
/// to get rounded corners
/// </summary>
- [XmlAttributeAttribute()][DefaultValue(0.0)]
+ [DesignCategory ("Appearance")][DefaultValue(0.0)]
public virtual double CornerRadius {
get { return cornerRadius; }
set {
@@ -763,7 +811,7 @@ namespace Crow
/// This is a single integer for the 4 direction, a gap between the control and it's container,
/// by default it is filled with the background.
/// </summary>
- [XmlAttributeAttribute()][DefaultValue(0)]
+ [DesignCategory ("Layout")][DefaultValue(0)]
public virtual int Margin {
get { return margin; }
set {
@@ -777,7 +825,7 @@ namespace Crow
/// <summary>
/// set the visible state of the control, invisible controls does reserve space in the layouting system.
/// </summary>
- [XmlAttributeAttribute][DefaultValue(true)]
+ [DesignCategory ("Appearance")][DefaultValue(true)]
public virtual bool Visible {
get { return isVisible; }
set {
@@ -798,7 +846,7 @@ namespace Crow
/// get or set the enabled state, disabling a control will affect focuability and
/// also it's rendering which will be grayed
/// </summary>
- [XmlAttributeAttribute][DefaultValue(true)]
+ [DesignCategory ("Behaviour")][DefaultValue(true)]
public virtual bool IsEnabled {
get { return isEnabled; }
set {
@@ -819,7 +867,7 @@ namespace Crow
/// <summary>
/// Minimal width and height for this control
/// </summary>
- [XmlAttributeAttribute()][DefaultValue("1,1")]
+ [DesignCategory ("Layout")][DefaultValue("1,1")]
public virtual Size MinimumSize {
get { return minimumSize; }
set {
@@ -835,7 +883,7 @@ namespace Crow
/// <summary>
/// Maximum width and height for this control, unlimited if null.
/// </summary>
- [XmlAttributeAttribute()][DefaultValue("0,0")]
+ [DesignCategory ("Layout")][DefaultValue("0,0")]
public virtual Size MaximumSize {
get { return maximumSize; }
set {
@@ -852,7 +900,7 @@ namespace Crow
/// Seek first logical tree upward if logicalParent is set, or seek graphic tree for
/// a not null dataSource that will be active for all descendants having dataSource=null
/// </summary>
- [XmlAttributeAttribute]
+ [DesignCategory ("Data")]
public virtual object DataSource {
set {
if (DataSource == value)
@@ -893,7 +941,7 @@ namespace Crow
/// <summary>
/// Style key to use for this control
/// </summary>
- [XmlAttributeAttribute]
+ [DesignCategory ("Appearance")]
public virtual string Style {
get { return style; }
set {
@@ -905,7 +953,7 @@ namespace Crow
NotifyValueChanged ("Style", style);
}
}
- [XmlAttributeAttribute]
+ [DesignCategory ("Divers")]
public virtual string Tooltip {
get { return tooltip; }
set {
@@ -915,7 +963,7 @@ namespace Crow
NotifyValueChanged("Tooltip", tooltip);
}
}
- [XmlAttributeAttribute]
+ [DesignCategory ("Divers")]
public IList<Command> ContextCommands {
get { return contextCommands; }
set {
@@ -1040,7 +1088,9 @@ namespace Crow
name = pi.Name;
else
name = xaa.AttributeName;
- }
+ }else
+ name = pi.Name;
+
int styleIndex = -1;
if (styling.Count > 0){
for (int i = 0; i < styling.Count; i++) {
@@ -1057,13 +1107,21 @@ namespace Crow
defaultValue = styling[styleIndex] [name];
#if DESIGN_MODE
- FileLocation fl = styling[styleIndex].Locations[name];
- il.Emit (OpCodes.Ldloc_0);
- il.Emit (OpCodes.Ldstr, name);
- il.Emit (OpCodes.Ldstr, fl.FilePath);
- il.Emit (OpCodes.Ldc_I4, fl.Line);
- il.Emit (OpCodes.Ldc_I4, fl.Column);
- il.Emit (OpCodes.Call, miDesignAddDefLoc);
+ if (defaultValue != null){
+ FileLocation fl = styling[styleIndex].Locations[name];
+ il.Emit (OpCodes.Ldloc_0);
+ il.Emit (OpCodes.Ldstr, name);
+ il.Emit (OpCodes.Ldstr, fl.FilePath);
+ il.Emit (OpCodes.Ldc_I4, fl.Line);
+ il.Emit (OpCodes.Ldc_I4, fl.Column);
+ il.Emit (OpCodes.Call, miDesignAddDefLoc);
+
+ il.Emit (OpCodes.Ldloc_0);
+ il.Emit (OpCodes.Ldfld, typeof(GraphicObject).GetField("design_style_values"));
+ il.Emit (OpCodes.Ldstr, name);
+ il.Emit (OpCodes.Ldstr, defaultValue.ToString());
+ il.Emit (OpCodes.Call, CompilerServices.miDicStrStrAdd);
+ }
#endif
}else {
@@ -1122,7 +1180,7 @@ namespace Crow
}
#region Drag&Drop
- [XmlAttributeAttribute][DefaultValue(false)]
+ [DesignCategory ("DragAndDrop")][DefaultValue(false)]
public virtual bool AllowDrag {
get { return allowDrag; }
set {
@@ -1132,7 +1190,7 @@ namespace Crow
NotifyValueChanged ("AllowDrag", allowDrag);
}
}
- [XmlAttributeAttribute][DefaultValue(false)]
+ [DesignCategory ("DragAndDrop")][DefaultValue(false)]
public virtual bool AllowDrop {
get { return allowDrop; }
set {
@@ -1193,8 +1251,12 @@ namespace Crow
protected virtual void onDrop (object sender, DragDropEventArgs e){
IsDragged = false;
Drop.Raise (this, e);
+ //e.DropTarget.onDragLeave (this, e);//raise drag leave in target
Debug.WriteLine(this.ToString() + " : DROP => " + e.ToString());
}
+ public bool IsDropTarget {
+ get { return IFace.DragAndDropOperation?.DropTarget == this; }
+ }
#endregion
@@ -1314,8 +1376,8 @@ namespace Crow
public virtual void OnLayoutChanges(LayoutingType layoutType)
{
#if DEBUG_LAYOUTING
- CurrentInterface.currentLQI.Slot = LastSlots;
- CurrentInterface.currentLQI.NewSlot = Slot;
+ IFace.currentLQI.Slot = LastSlots;
+ IFace.currentLQI.NewSlot = Slot;
Debug.WriteLine ("\t\t{0} => {1}",LastSlots,Slot);
#endif
@@ -1717,26 +1779,38 @@ namespace Crow
#if DEBUG_FOCUS
Debug.WriteLine("MouseEnter => " + this.ToString());
#endif
-
+ MouseEnter.Raise (this, e);
+ }
+ public virtual void onMouseLeave(object sender, MouseMoveEventArgs e)
+ {
+ #if DEBUG_FOCUS
+ Debug.WriteLine("MouseLeave => " + this.ToString());
+ #endif
+ MouseLeave.Raise (this, e);
+ }
+ public virtual void onHover(object sender, EventArgs e)
+ {
+ #if DEBUG_FOCUS
+ Debug.WriteLine("MouseHover => " + this.ToString());
+ #endif
if (IFace.DragAndDropOperation != null) {
if (this.AllowDrop) {
if (IFace.DragAndDropOperation.DragSource != this && IFace.DragAndDropOperation.DropTarget != this)
onDragEnter (this, IFace.DragAndDropOperation);
}
}
-
- MouseEnter.Raise (this, e);
+ Hover.Raise (this, e);
}
- public virtual void onMouseLeave(object sender, MouseMoveEventArgs e)
+ public virtual void onUnHover(object sender, EventArgs e)
{
#if DEBUG_FOCUS
- Debug.WriteLine("MouseLeave => " + this.ToString());
+ Debug.WriteLine("MouseUnHover => " + this.ToString());
#endif
if (IFace.DragAndDropOperation != null) {
if (IFace.DragAndDropOperation.DropTarget == this)
onDragLeave (this, IFace.DragAndDropOperation);
}
- MouseLeave.Raise (this, e);
+ UnHover.Raise (this, e);
}
#endregion
diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs
index 0eb1ece2..11bf16fb 100644
--- a/src/GraphicObjects/Group.cs
+++ b/src/GraphicObjects/Group.cs
@@ -114,6 +114,8 @@ namespace Crow
childrenRWLock.EnterWriteLock ();
Children.Remove(child);
+ child.Parent = null;
+ //child.ResetSlots ();
childrenRWLock.ExitWriteLock ();
@@ -142,6 +144,9 @@ namespace Crow
g.LayoutChanged += OnChildLayoutChanges;
g.RegisterForLayouting (LayoutingType.Sizing | LayoutingType.ArrangeChildren);
}
+ public virtual void RemoveChild (int idx) {
+ RemoveChild (children[idx]);
+ }
public virtual void DeleteChild (int idx) {
DeleteChild (children[idx]);
}
@@ -263,7 +268,7 @@ namespace Crow
switch (layoutType) {
case LayoutingType.Width:
foreach (GraphicObject c in Children) {
- if (c.Width.Units == Unit.Percent)
+ if (c.Width.IsRelativeToParent)
c.RegisterForLayouting (LayoutingType.Width);
else
c.RegisterForLayouting (LayoutingType.X);
@@ -271,7 +276,7 @@ namespace Crow
break;
case LayoutingType.Height:
foreach (GraphicObject c in Children) {
- if (c.Height.Units == Unit.Percent)
+ if (c.Height.IsRelativeToParent)
c.RegisterForLayouting (LayoutingType.Height);
else
c.RegisterForLayouting (LayoutingType.Y);
@@ -294,9 +299,9 @@ namespace Crow
childrenRWLock.EnterReadLock ();
- foreach (GraphicObject g in Children) {
- g.Paint (ref gr);
- }
+ foreach (GraphicObject g in Children) {
+ g.Paint (ref gr);
+ }
childrenRWLock.ExitReadLock ();
gr.Restore ();
diff --git a/src/GraphicObjects/PrivateContainer.cs b/src/GraphicObjects/PrivateContainer.cs
index 81017a7e..b0719ef0 100644
--- a/src/GraphicObjects/PrivateContainer.cs
+++ b/src/GraphicObjects/PrivateContainer.cs
@@ -108,11 +108,11 @@ namespace Crow
//force sizing to fit if sizing on children and child has stretched size
switch (layoutType) {
case LayoutingType.Width:
- if (Width == Measure.Fit && child.Width.Units == Unit.Percent)
+ if (Width == Measure.Fit && child.Width.IsRelativeToParent)
child.Width = Measure.Fit;
break;
case LayoutingType.Height:
- if (Height == Measure.Fit && child.Height.Units == Unit.Percent)
+ if (Height == Measure.Fit && child.Height.IsRelativeToParent)
child.Height = Measure.Fit;
break;
}
@@ -129,14 +129,14 @@ namespace Crow
LayoutingType ltChild = LayoutingType.None;
if (layoutType == LayoutingType.Width) {
- if (child.Width.Units == Unit.Percent) {
+ if (child.Width.IsRelativeToParent) {
ltChild |= LayoutingType.Width;
if (child.Width.Value < 100 && child.Left == 0)
ltChild |= LayoutingType.X;
} else if (child.Left == 0)
ltChild |= LayoutingType.X;
} else if (layoutType == LayoutingType.Height) {
- if (child.Height.Units == Unit.Percent) {
+ if (child.Height.IsRelativeToParent) {
ltChild |= LayoutingType.Height;
if (child.Height.Value < 100 && child.Top == 0)
ltChild |= LayoutingType.Y;
diff --git a/src/GraphicObjects/TemplatedGroup.cs b/src/GraphicObjects/TemplatedGroup.cs
index 42ffa51c..f7c93763 100644
--- a/src/GraphicObjects/TemplatedGroup.cs
+++ b/src/GraphicObjects/TemplatedGroup.cs
@@ -457,8 +457,9 @@ namespace Crow
}
if (iTemp.Expand != null && g is Expandable) {
- (g as Expandable).Expand += iTemp.Expand;
- (g as Expandable).GetIsExpandable = iTemp.HasSubItems;
+ Expandable e = g as Expandable;
+ e.Expand += iTemp.Expand;
+ e.GetIsExpandable = iTemp.HasSubItems;
}
g.DataSource = o;
diff --git a/src/GraphicObjects/Wrapper.cs b/src/GraphicObjects/Wrapper.cs
index 3f5dfdf0..a7f5f73b 100644
--- a/src/GraphicObjects/Wrapper.cs
+++ b/src/GraphicObjects/Wrapper.cs
@@ -104,7 +104,7 @@ namespace Crow
this.RegisterForLayouting (LayoutingType.Width);
break;
case LayoutingType.Height:
- if (Orientation == Orientation.Vertical && go.Height.Units == Unit.Percent) {
+ if (Orientation == Orientation.Vertical && go.Height.IsRelativeToParent) {
go.Height = Measure.Fit;
return;
}
@@ -137,7 +137,7 @@ namespace Crow
foreach (GraphicObject c in Children) {
if (!c.Visible)
continue;
- if (c.Height.Units == Unit.Percent &&
+ if (c.Height.IsRelativeToParent &&
c.RegisteredLayoutings.HasFlag (LayoutingType.Height)) {
childrenRWLock.ExitReadLock();
return -1;
@@ -172,7 +172,7 @@ namespace Crow
foreach (GraphicObject c in Children) {
if (!c.Visible)
continue;
- if (c.Width.Units == Unit.Percent &&
+ if (c.Width.IsRelativeToParent &&
c.RegisteredLayoutings.HasFlag (LayoutingType.Width)) {
childrenRWLock.ExitReadLock();
return -1;
@@ -217,13 +217,13 @@ namespace Crow
public override void OnLayoutChanges (LayoutingType layoutType)
{
#if DEBUG_LAYOUTING
- CurrentInterface.currentLQI.Slot = LastSlots;
- CurrentInterface.currentLQI.Slot = Slot;
+ IFace.currentLQI.Slot = LastSlots;
+ IFace.currentLQI.Slot = Slot;
#endif
switch (layoutType) {
case LayoutingType.Width:
foreach (GraphicObject c in Children) {
- if (c.Width.Units == Unit.Percent)
+ if (c.Width.IsRelativeToParent)
c.RegisterForLayouting (LayoutingType.Width);
}
if (Height == Measure.Fit)
@@ -232,7 +232,7 @@ namespace Crow
break;
case LayoutingType.Height:
foreach (GraphicObject c in Children) {
- if (c.Height.Units == Unit.Percent)
+ if (c.Height.IsRelativeToParent)
c.RegisterForLayouting (LayoutingType.Height);
}
if (Width == Measure.Fit)