<Compile Include="src\GraphicObjects\Slider.cs" />
<Compile Include="src\GraphicObjects\NumericControl.cs" />
<Compile Include="src\GraphicObjects\Scroller.cs" />
- <Compile Include="src\GraphicObjects\ILayoutable.cs" />
<Compile Include="src\Enums.cs" />
<Compile Include="src\GraphicObjects\GenericStack.cs" />
<Compile Include="src\CompilerServices\CompilerServices.cs" />
<?xml version="1.0"?>
<Border Background="{./Background}" BorderWidth="1" Foreground="{./Foreground}" Height="Fit">
- <HorizontalStack Spacing="1" Height="Fit">
+ <HorizontalStack Spacing="1">
<Image Style="Icon" Margin="2"
Path="#Crow.Images.Icons.expandable.svg" SvgSub="{./IsPopped}"/>
<Label Text="{./Caption}" />
namespace Crow
{
- public class GraphicObject : IXmlSerializable, ILayoutable, IValueChange, ICloneable
+ public class GraphicObject : IXmlSerializable, IValueChange, ICloneable
{
internal static ulong currentUid = 0;
internal ulong uid = 0;
}
#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;
#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)
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);
}
}
}
}
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);
}
[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)
[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)
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){
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);
#if DEBUG_LAYOUTING
CurrentInterface.currentLQI.Slot = LastSlots;
CurrentInterface.currentLQI.NewSlot = Slot;
+ Debug.WriteLine ("\t{0} => {1}",LastSlots,Slot);
#endif
switch (layoutType) {
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;
}
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);
}
}
}
//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);
}
}
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);
}
+++ /dev/null
-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);
-
- }
-}
-
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);
}
#region GraphicObject override
- public override ILayoutable Parent {
+ public override GraphicObject Parent {
get { return base.Parent; }
set {
if (value != null) {
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;
//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;
}
/// - helpers to load XML interfaces files
/// - global constants and variables of CROW
/// </summary>
- public class Interface : ILayoutable
+ public class Interface : GraphicObject
{
#region CTOR
static Interface(){
//check topmost graphicobject first
GraphicObject tmp = HoverWidget;
GraphicObject topc = null;
- while (tmp is GraphicObject) {
+ while (!(tmp is Interface)) {
topc = tmp;
- tmp = tmp.LogicalParent as GraphicObject;
+ tmp = tmp.LogicalParent;
}
int idxhw = GraphicTree.IndexOf (topc);
if (idxhw != 0) {
if (GraphicTree [i].MouseIsIn (e.Position)) {
while (HoverWidget != null) {
HoverWidget.onMouseLeave (HoverWidget, e);
- HoverWidget = HoverWidget.LogicalParent as GraphicObject;
+ HoverWidget = HoverWidget.LogicalParent;
}
GraphicTree [i].checkHoverWidget (e);
} else {
HoverWidget.onMouseLeave (HoverWidget, e);
//seek upward from last focused graph obj's
- while (HoverWidget.LogicalParent as GraphicObject != null) {
- HoverWidget = HoverWidget.LogicalParent as GraphicObject;
+ while (!(HoverWidget.LogicalParent is Interface)) {
+ HoverWidget = HoverWidget.LogicalParent;
if (HoverWidget.MouseIsIn (e.Position)) {
HoverWidget.checkHoverWidget (e);
return true;
HoverWidget.onMouseWheel (this, e);
return true;
}
+
+
+ public override void onMouseMove (object sender, MouseMoveEventArgs e)
+ {
+ }
+ public override void onMouseUp (object sender, MouseButtonEventArgs e)
+ {
+ }
+ public override void onMouseDown (object sender, MouseButtonEventArgs e)
+ {
+ }
+ public override void onMouseClick (object sender, MouseButtonEventArgs e)
+ {
+ }
+ public override void onMouseDoubleClick (object sender, MouseButtonEventArgs e)
+ {
+ }
+ public override void onMouseWheel (object sender, MouseWheelEventArgs e)
+ {
+ }
#endregion
#region Keyboard
#endregion
#region ILayoutable implementation
- public void RegisterClip(Rectangle r){
- clipping.AddRectangle (r);
- }
- public bool ArrangeChildren { get { return false; }}
- public int LayoutingTries {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
- public LayoutingType RegisteredLayoutings {
+ public override void RegisterClip(Rectangle r){ clipping.AddRectangle (r); }
+ public override LayoutingType RegisteredLayoutings {
get { return LayoutingType.None; }
set { throw new NotImplementedException (); }
}
- public void RegisterForLayouting (LayoutingType layoutType) { throw new NotImplementedException (); }
- public bool UpdateLayout (LayoutingType layoutType) { throw new NotImplementedException (); }
- public Rectangle ContextCoordinates (Rectangle r) { return r;}
- public Rectangle ScreenCoordinates (Rectangle r) { return r; }
-
- public ILayoutable Parent {
- get { return null; }
- set { throw new NotImplementedException (); }
- }
- public ILayoutable LogicalParent {
- get { return null; }
- set { throw new NotImplementedException (); }
- }
-
- public Rectangle ClientRectangle {
- get { return clientRectangle; }
- }
- public Interface HostContainer {
- get { return this; }
+ public override Rectangle ContextCoordinates (Rectangle r) { return r;}
+ public override Rectangle ScreenCoordinates (Rectangle r) { return r; }
+ public override Rectangle ClientRectangle { get { return clientRectangle; }}
+ public override Rectangle getSlot () { return ClientRectangle; }
+ public override Measure WidthPolicy { get { return Measure.Stretched; }}
+ public override Measure HeightPolicy { get { return Measure.Stretched; }}
+ public override Measure Width {
+ get { return clientRectangle.Width; }
+ set {}
+ }
+ public override Measure Height {
+ get { return clientRectangle.Height; }
+ set {}
+ }
+ public override bool MouseIsIn (Point m){ return true; }
+ public override void RegisterForLayouting (LayoutingType layoutType)
+ {
+ //base.RegisterForLayouting (layoutType);
+ return;
}
- public Rectangle getSlot () { return ClientRectangle; }
#endregion
}
}
public struct LayoutingQueueItem
{
/// <summary> Instance of widget to be layouted</summary>
- public ILayoutable Layoutable;
+ public GraphicObject Layoutable;
/// <summary> Bitfield containing the element of the layout to performs (x|y|width|height)</summary>
public LayoutingType LayoutType;
/// <summary> Unsuccessfull UpdateLayout and requeueing count </summary>
#endif
#region CTOR
- public LayoutingQueueItem (LayoutingType _layoutType, ILayoutable _graphicObject)
+ public LayoutingQueueItem (LayoutingType _layoutType, GraphicObject _graphicObject)
{
LayoutType = _layoutType;
Layoutable = _graphicObject;
}
#if DEBUG_LAYOUTING
LQITime.Start();
+ Debug.WriteLine ("LAYOUTING: " + this.ToString ());
#endif
LayoutingTries++;
if (!Layoutable.UpdateLayout (LayoutType)) {
if (LayoutingTries < Interface.MaxLayoutingTries) {
Layoutable.RegisteredLayoutings |= LayoutType;
- (Layoutable as GraphicObject).CurrentInterface.LayoutingQueue.Enqueue (this);
+ Layoutable.CurrentInterface.LayoutingQueue.Enqueue (this);
} else if (DiscardCount < Interface.MaxDiscardCount) {
LayoutingTries = 0;
DiscardCount++;
Layoutable.RegisteredLayoutings |= LayoutType;
- (Layoutable as GraphicObject).CurrentInterface.DiscardQueue.Enqueue (this);
+ Layoutable.CurrentInterface.DiscardQueue.Enqueue (this);
}
#if DEBUG_LAYOUTING
else