diff options
Diffstat (limited to 'src/GraphicObjects')
| -rw-r--r-- | src/GraphicObjects/GraphicObject.cs | 74 | ||||
| -rw-r--r-- | src/GraphicObjects/ILayoutable.cs | 29 | ||||
| -rw-r--r-- | src/GraphicObjects/Popper.cs | 2 | ||||
| -rw-r--r-- | src/GraphicObjects/Splitter.cs | 2 | ||||
| -rw-r--r-- | src/GraphicObjects/TabView.cs | 2 | ||||
| -rw-r--r-- | src/GraphicObjects/TreeView.cs | 2 |
6 files changed, 33 insertions, 78 deletions
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 25332832..3c9cb061 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -12,7 +12,7 @@ using System.IO; namespace Crow { - public class GraphicObject : IXmlSerializable, ILayoutable, IValueChange, ICloneable + public class GraphicObject : IXmlSerializable, IValueChange, ICloneable { internal static ulong currentUid = 0; internal ulong uid = 0; @@ -58,8 +58,8 @@ namespace Crow } #region private fields LayoutingType registeredLayoutings = LayoutingType.All; - ILayoutable logicalParent; - ILayoutable parent; + GraphicObject logicalParent; + GraphicObject parent; string name; Fill background = Color.Transparent; Fill foreground = Color.White; @@ -118,13 +118,13 @@ namespace Crow #endregion #region ILayoutable - [XmlIgnore]public LayoutingType RegisteredLayoutings { get { return registeredLayoutings; } set { registeredLayoutings = value; } } + [XmlIgnore]public virtual 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 // or we could add to the interface the mouse events /// <summary> /// Parent in the graphic tree, used for rendering and layouting /// </summary> - [XmlIgnore]public virtual ILayoutable Parent { + [XmlIgnore]public virtual GraphicObject Parent { get { return parent; } set { if (parent == value) @@ -135,18 +135,18 @@ namespace Crow onParentChanged (this, e); } } - [XmlIgnore]public ILayoutable LogicalParent { + [XmlIgnore]public GraphicObject LogicalParent { get { return logicalParent == null ? Parent : logicalParent; } set { if (logicalParent == value) return; if (logicalParent != null) - (logicalParent as GraphicObject).DataSourceChanged -= onLogicalParentDataSourceChanged; + logicalParent.DataSourceChanged -= onLogicalParentDataSourceChanged; DataSourceChangeEventArgs dsce = new DataSourceChangeEventArgs (LogicalParent, null); logicalParent = value; dsce.NewDataSource = LogicalParent; if (logicalParent != null) - (logicalParent as GraphicObject).DataSourceChanged += onLogicalParentDataSourceChanged; + logicalParent.DataSourceChanged += onLogicalParentDataSourceChanged; onLogicalParentChanged (this, dsce); } } @@ -158,10 +158,9 @@ namespace Crow } } public virtual Rectangle ContextCoordinates(Rectangle r){ - GraphicObject go = Parent as GraphicObject; - if (go == null) + if (Parent is Interface) return r + Parent.ClientRectangle.Position; - return go.CacheEnabled ? + return Parent.CacheEnabled ? r + Parent.ClientRectangle.Position : Parent.ContextCoordinates (r); } @@ -296,9 +295,7 @@ namespace Crow [XmlAttributeAttribute()][DefaultValue("Inherit")] public virtual Measure Width { get { - return width.Units == Unit.Inherit ? - Parent is GraphicObject ? (Parent as GraphicObject).WidthPolicy : - Measure.Stretched : width; + return width.Units == Unit.Inherit ? Parent == null ? Measure.Stretched : Parent.WidthPolicy : width; } set { if (width == value) @@ -332,9 +329,7 @@ namespace Crow [XmlAttributeAttribute()][DefaultValue("Inherit")] public virtual Measure Height { get { - return height.Units == Unit.Inherit ? - Parent is GraphicObject ? (Parent as GraphicObject).HeightPolicy : - Measure.Stretched : height; + return height.Units == Unit.Inherit ? Parent == null ? Measure.Stretched :Parent.HeightPolicy : height; } set { if (height == value) @@ -573,8 +568,7 @@ namespace Crow get { return dataSource == null ? LogicalParent == null ? null : - LogicalParent is GraphicObject ? (LogicalParent as GraphicObject).DataSource : null : - dataSource; + LogicalParent.DataSource : dataSource; } } protected virtual void onLogicalParentDataSourceChanged(object sender, DataSourceChangeEventArgs e){ @@ -843,8 +837,7 @@ namespace Crow layoutType &= (~LayoutingType.ArrangeChildren); //apply constraints depending on parent type - if (Parent is GraphicObject) - (Parent as GraphicObject).ChildrenLayoutingConstraints (ref layoutType); + Parent.ChildrenLayoutingConstraints (ref layoutType); // //prevent queueing same LayoutingType for this // layoutType &= (~RegisteredLayoutings); @@ -872,6 +865,7 @@ namespace Crow #if DEBUG_LAYOUTING CurrentInterface.currentLQI.Slot = LastSlots; CurrentInterface.currentLQI.NewSlot = Slot; + Debug.WriteLine ("\t{0} => {1}",LastSlots,Slot); #endif switch (layoutType) { @@ -1147,11 +1141,8 @@ namespace Crow return false; if (ScreenCoordinates (Slot).ContainsOrIsEqual (m)) { Scroller scr = Parent as Scroller; - if (scr == null) { - if (Parent is GraphicObject) - return (Parent as GraphicObject).MouseIsIn (m); - else return true; - } + if (scr == null) + return Parent.MouseIsIn (m); return scr.MouseIsIn (scr.savedMousePos); } return false; @@ -1167,10 +1158,8 @@ namespace Crow } public virtual void onMouseMove(object sender, MouseMoveEventArgs e) { - //bubble event to the top - GraphicObject p = Parent as GraphicObject; - if (p != null) - p.onMouseMove(sender,e); + if (Parent != null) + Parent.onMouseMove(sender,e); MouseMove.Raise (sender, e); } @@ -1191,17 +1180,15 @@ namespace Crow } } //bubble event to the top - GraphicObject p = Parent as GraphicObject; - if (p != null) - p.onMouseDown(sender,e); + if (Parent != null) + Parent.onMouseDown(sender,e); MouseDown.Raise (this, e); } public virtual void onMouseUp(object sender, MouseButtonEventArgs e){ //bubble event to the top - GraphicObject p = Parent as GraphicObject; - if (p != null) - p.onMouseUp(sender,e); + if (Parent != null) + Parent.onMouseUp(sender,e); MouseUp.Raise (this, e); @@ -1212,21 +1199,18 @@ namespace Crow } } public virtual void onMouseClick(object sender, MouseButtonEventArgs e){ - GraphicObject p = Parent as GraphicObject; - if (p != null) - p.onMouseClick(sender,e); + if (Parent != null) + Parent.onMouseClick(sender,e); MouseClick.Raise (this, e); } public virtual void onMouseDoubleClick(object sender, MouseButtonEventArgs e){ - GraphicObject p = Parent as GraphicObject; - if (p != null) - p.onMouseDoubleClick(sender,e); + if (Parent != null) + Parent.onMouseDoubleClick(sender,e); MouseDoubleClick.Raise (this, e); } public virtual void onMouseWheel(object sender, MouseWheelEventArgs e){ - GraphicObject p = Parent as GraphicObject; - if (p != null) - p.onMouseWheel(sender,e); + if (Parent != null) + Parent.onMouseWheel(sender,e); MouseWheelChanged.Raise (this, e); } diff --git a/src/GraphicObjects/ILayoutable.cs b/src/GraphicObjects/ILayoutable.cs deleted file mode 100644 index 33153935..00000000 --- a/src/GraphicObjects/ILayoutable.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Crow -{ - public interface ILayoutable - { - /// <summary> Parent in the graphic tree </summary> - ILayoutable Parent { get; set; } - /// <summary> The logical parent (used mainly for bindings) as opposed - /// to the parent in the graphic tree </summary> - ILayoutable LogicalParent { get; set; } - - Rectangle ClientRectangle { get; } - Rectangle getSlot(); - - bool ArrangeChildren { get; } - LayoutingType RegisteredLayoutings { get; set; } - void RegisterForLayouting(LayoutingType layoutType); - void RegisterClip(Rectangle clip); - bool UpdateLayout(LayoutingType layoutType); - - - Rectangle ContextCoordinates(Rectangle r); - Rectangle ScreenCoordinates (Rectangle r); - - } -} - diff --git a/src/GraphicObjects/Popper.cs b/src/GraphicObjects/Popper.cs index 38621337..e9887d94 100644 --- a/src/GraphicObjects/Popper.cs +++ b/src/GraphicObjects/Popper.cs @@ -119,7 +119,7 @@ namespace Crow protected void _content_LayoutChanged (object sender, LayoutingEventArgs e) { - ILayoutable tc = Content.Parent; + GraphicObject tc = Content.Parent; if (tc == null) return; Rectangle r = this.ScreenCoordinates (this.Slot); diff --git a/src/GraphicObjects/Splitter.cs b/src/GraphicObjects/Splitter.cs index 220fc476..6d4f494e 100644 --- a/src/GraphicObjects/Splitter.cs +++ b/src/GraphicObjects/Splitter.cs @@ -64,7 +64,7 @@ namespace Crow } #region GraphicObject override - public override ILayoutable Parent { + public override GraphicObject Parent { get { return base.Parent; } set { if (value != null) { diff --git a/src/GraphicObjects/TabView.cs b/src/GraphicObjects/TabView.cs index 1debfedc..b79f41eb 100644 --- a/src/GraphicObjects/TabView.cs +++ b/src/GraphicObjects/TabView.cs @@ -179,7 +179,7 @@ namespace Crow if (SelectedTab > Children.Count - 1) return; - if (((Children[SelectedTab] as TabItem).Content.Parent as GraphicObject).MouseIsIn(e.Position)) + if ((Children[SelectedTab] as TabItem).Content.Parent.MouseIsIn(e.Position)) { Children[SelectedTab].checkHoverWidget (e); return; diff --git a/src/GraphicObjects/TreeView.cs b/src/GraphicObjects/TreeView.cs index 4fa881b4..ee73ed19 100644 --- a/src/GraphicObjects/TreeView.cs +++ b/src/GraphicObjects/TreeView.cs @@ -61,7 +61,7 @@ namespace Crow //register ItemClick on the Root node TreeView tv = this as TreeView; while (!tv.IsRoot) { - ILayoutable tmp = tv.Parent; + GraphicObject tmp = tv.Parent; while (!(tmp is TreeView)) { tmp = tmp.Parent; } |