}
public void OnChanged (object obj)
{
- (obj as GraphicObject).registerForGraphicUpdate ();
+ (obj as GraphicObject).RegisterForGraphicUpdate ();
QueueDraw ();
}
#endregion
}
//Debug.WriteLine ("======= Layouting queue start =======");
- while (Interface.LayoutingQueue.Count > 0) {
- LayoutingQueueItem lqi = Interface.LayoutingQueue.Dequeue ();
+ while (Interface.CurrentInterface.LayoutingQueue.Count > 0) {
+ LayoutingQueueItem lqi = Interface.CurrentInterface.LayoutingQueue.Dequeue ();
lqi.ProcessLayouting ();
}
set { throw new NotImplementedException (); }
}
- public void RegisterForLayouting (int layoutType)
+ public void EnqueueForLayouting (int layoutType)
{
throw new NotImplementedException ();
}
};
- volatile public int intValue = 25;
+ public int intValue = 25;
public int IntValue {
get {
return;
NotifyValueChanged ("alignment", Enum.Parse(typeof(Alignment), rb.Caption));
}
- volatile public IList<String> List2 = new List<string>(new string[]
+ public IList<String> List2 = new List<string>(new string[]
{
"string1",
"string2",
"string9"
}
);
- volatile IList<Color> testList = Color.ColorDic.ToList();
+ IList<Color> testList = Color.ColorDic.ToList();
public IList<Color> TestList {
set{
testList = value;
//this.AddWidget(new test4());
KeyboardKeyDown += GOLIBTests_KeyboardKeyDown1;;
- CrowInterface.LoadInterfaceDelegate.Invoke ("Interfaces/" + testFiles [idx]);
- //GraphicObject obj = CrowInterface.LoadInterface("Interfaces/" + testFiles[idx]);
- //obj.DataSource = this;
+ GraphicObject obj = CrowInterface.LoadInterface("Interfaces/" + testFiles[idx]);
+ obj.DataSource = this;
}
void GOLIBTests_KeyboardKeyDown1 (object sender, OpenTK.Input.KeyboardKeyEventArgs e)
{
GraphicObjects.Remove(g);
GraphicObjects.Insert(0, g);
- g.RegisterForRedraw ();
+ g.AddToRedrawList ();
}
}
public void Quit ()
//Debug.WriteLine ("======= Layouting queue start =======");
- while (Interface.LayoutingQueue.Count > 0) {
- LayoutingQueueItem lqi = Interface.LayoutingQueue.Dequeue ();
+ while (Interface.CurrentInterface.LayoutingQueue.Count > 0) {
+ LayoutingQueueItem lqi = Interface.CurrentInterface.LayoutingQueue.Dequeue ();
lqi.ProcessLayouting ();
}
gobjsToRedraw.CopyTo (gotr);
gobjsToRedraw.Clear ();
foreach (GraphicObject p in gotr) {
- p.IsQueuedForRedraw = false;
+ p.IsInRedrawList = false;
p.Parent.RegisterClip (p.LastPaintedSlot);
p.Parent.RegisterClip (p.getSlot());
}
public void RegisterClip(Rectangle r){
clipping.AddRectangle (r);
}
- public void RegisterForLayouting (LayoutingType layoutType)
+ public void EnqueueForLayouting (LayoutingType layoutType)
{
throw new NotImplementedException ();
}
get { return null; }
set { throw new NotImplementedException (); }
}
- public LayoutingType RegisteredLayoutings {
+ public LayoutingType QueuedLayoutings {
get { return LayoutingType.None; }
set { throw new NotImplementedException (); }
}
- public void RegisterForLayouting (int layoutType) { throw new NotImplementedException (); }
+ public void EnqueueForLayouting (int layoutType) { throw new NotImplementedException (); }
public bool UpdateLayout (LayoutingType layoutType) { throw new NotImplementedException (); }
public Rectangle ContextCoordinates (Rectangle r) => r;
public Rectangle ScreenCoordinates (Rectangle r) => r;
get { return _borderWidth; }
set {
_borderWidth = value;
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
}
}
[XmlAttributeAttribute()][DefaultValue("White")]
foreach (GraphicObject c in Children) {
if (!c.Visible)
continue;
- if (c.RegisteredLayoutings.HasFlag (LayoutingType.Width))
+ if (c.QueuedLayoutings.HasFlag (LayoutingType.Width))
return -1;
tmp += c.Slot.Width + Spacing;
}
foreach (GraphicObject c in Children) {
if (!c.Visible)
continue;
- if (c.RegisteredLayoutings.HasFlag (LayoutingType.Height))
+ if (c.QueuedLayoutings.HasFlag (LayoutingType.Height))
return -1;
tmp += c.Slot.Height + Spacing;
}
continue;
c.Slot.X = d;
d += c.Slot.Width + Spacing;
- c.RegisterForLayouting (LayoutingType.Y);
+ c.EnqueueForLayouting (LayoutingType.Y);
}
} else {
foreach (GraphicObject c in Children) {
continue;
c.Slot.Y = d;
d += c.Slot.Height + Spacing;
- c.RegisterForLayouting (LayoutingType.X);
+ c.EnqueueForLayouting (LayoutingType.X);
}
}
bmp = null;
public override bool UpdateLayout (LayoutingType layoutType)
{
- RegisteredLayoutings &= (~layoutType);
+ QueuedLayoutings &= (~layoutType);
if (layoutType == LayoutingType.ArrangeChildren) {
//allow 1 child to have size to 0 if stack has fixed or streched size policy,
if (!Children [i].Visible)
continue;
//requeue Positionning if child is not layouted
- if (Children [i].RegisteredLayoutings.HasFlag (LayoutingType.Width))
+ if (Children [i].QueuedLayoutings.HasFlag (LayoutingType.Width))
return false;
cptChildren++;
if (Children [i].Width == 0) {
for (int i = 0; i < Children.Count; i++) {
if (!Children [i].Visible)
continue;
- if (Children [i].RegisteredLayoutings.HasFlag (LayoutingType.Height))
+ if (Children [i].QueuedLayoutings.HasFlag (LayoutingType.Height))
return false;
cptChildren++;
if (Children [i].Height == 0) {
ComputeChildrenPositions ();
//if no layouting remains in queue for item, registre for redraw
- if (RegisteredLayoutings == LayoutingType.None && bmp==null)
- this.RegisterForRedraw ();
+ if (QueuedLayoutings == LayoutingType.None && bmp==null)
+ this.AddToRedrawList ();
return true;
}
case LayoutingType.Width:
if (Orientation == Orientation.Horizontal) {
if (this.Bounds.Width < 0)
- this.RegisterForLayouting (LayoutingType.Width);
- this.RegisterForLayouting (LayoutingType.ArrangeChildren);
+ this.EnqueueForLayouting (LayoutingType.Width);
+ this.EnqueueForLayouting (LayoutingType.ArrangeChildren);
}
break;
case LayoutingType.Height:
if (Orientation == Orientation.Vertical) {
if (this.Bounds.Height < 0)
- this.RegisterForLayouting (LayoutingType.Height);
- this.RegisterForLayouting (LayoutingType.ArrangeChildren);
+ this.EnqueueForLayouting (LayoutingType.Height);
+ this.EnqueueForLayouting (LayoutingType.ArrangeChildren);
}
break;
}
#endregion
#region private fields
- LayoutingType registeredLayoutings = LayoutingType.None;
+ LayoutingType queuedLayoutings = LayoutingType.None;
ILayoutable logicalParent;
ILayoutable _parent;
string _name = "unamed";
/// IDEA is to add a ScreenCoordinates function that use only lastPaintedSlots
/// </summary>
public Rectangle LastPaintedSlot;
+ public LayoutingType RegisteredLayoutings = LayoutingType.None;
public object Tag;
public byte[] bmp;
#endregion
#region ILayoutable
- [XmlIgnore]public LayoutingType RegisteredLayoutings { get { return registeredLayoutings; } set { registeredLayoutings = value; } }
+ [XmlIgnore]public LayoutingType QueuedLayoutings { get { return queuedLayoutings; } set { queuedLayoutings = 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>
return;
_background = value;
NotifyValueChanged ("Background", _background);
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
}
}
[XmlAttributeAttribute()][DefaultValue("White")]
return;
_foreground = value;
NotifyValueChanged ("Foreground", _foreground);
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
}
}
[XmlAttributeAttribute()][DefaultValue("droid,10")]
return;
_font = value;
NotifyValueChanged ("Font", _font);
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
}
}
[XmlAttributeAttribute()][DefaultValue(0.0)]
return;
_cornerRadius = value;
NotifyValueChanged ("CornerRadius", _cornerRadius);
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
}
}
[XmlAttributeAttribute()][DefaultValue(0)]
return;
_margin = value;
NotifyValueChanged ("Margin", _margin);
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
}
}
[XmlAttributeAttribute()][DefaultValue(true)]
Interface.CurrentInterface.hoverWidget = null;
if (Parent is GraphicObject)
- Parent.RegisterForLayouting (LayoutingType.Sizing);
+ (Parent as GraphicObject).RegisterForLayouting (LayoutingType.Sizing);
if (Parent is GenericStack)
- Parent.RegisterForLayouting (LayoutingType.ArrangeChildren);
- RegisterForLayouting (LayoutingType.Sizing);
+ (Parent as GraphicObject).RegisterForLayouting (LayoutingType.ArrangeChildren);
- RegisterForRedraw ();
+ RegisterForLayouting (LayoutingType.Sizing);
+ RegisterForGraphicUpdate ();
NotifyValueChanged ("Visible", _isVisible);
}
Clipping.AddRectangle (clip + ClientRectangle.Position);
Parent.RegisterClip (clip + Slot.Position + ClientRectangle.Position);
}
+ public bool IsQueueForGraphicUpdate = false;
/// <summary>
/// Clear chached object and add clipping region in redraw list of interface
/// </summary>
- public virtual void registerForGraphicUpdate ()
+ public void RegisterForGraphicUpdate ()
{
- bmp = null;
- RegisterForRedraw ();
+ Interface.RegisterForGraphicUpdate (this);
}
- public bool IsQueuedForRedraw = false;
+ public void RegisterForLayouting(LayoutingType lt)
+ {
+ Interface.RegisterForLayouting (this, lt);
+ }
+ internal bool IsInRedrawList = false;
/// <summary>
/// Add clipping region in redraw list of interface, dont update cached object content
/// </summary>
- public virtual void RegisterForRedraw ()
+ internal void AddToRedrawList ()
{
- if (IsQueuedForRedraw)
- return;
- if (Interface.CurrentInterface == null)
- return;
- lock(Interface.CurrentInterface.RenderMutex)
- Interface.CurrentInterface.gobjsToRedraw.Add (this);
- IsQueuedForRedraw = true;
+ Interface.AddToRedrawList (this);
}
#region Layouting
}
public virtual bool ArrangeChildren { get { return false; } }
- public virtual void RegisterForLayouting(LayoutingType layoutType){
+ public virtual void EnqueueForLayouting(LayoutingType layoutType){
if (Parent == null)
return;
//dont set position for stretched item
(Parent as GraphicObject).ChildrenLayoutingConstraints (ref layoutType);
//prevent queueing same LayoutingType for this
- layoutType &= (~RegisteredLayoutings);
+ layoutType &= (~QueuedLayoutings);
if (layoutType == LayoutingType.None)
return;
Debug.WriteLine ("REGLayout => {1}->{0}", layoutType, this.ToString());
#endif
- lock (Interface.LayoutingQueue) {
- //enqueue LQI LayoutingTypes separately
- if (layoutType.HasFlag (LayoutingType.Width))
- Interface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Width, this));
- if (layoutType.HasFlag (LayoutingType.Height))
- Interface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Height, this));
- if (layoutType.HasFlag (LayoutingType.X))
- Interface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.X, this));
- if (layoutType.HasFlag (LayoutingType.Y))
- Interface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Y, this));
- if (layoutType.HasFlag (LayoutingType.ArrangeChildren))
- Interface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.ArrangeChildren, this));
- }
+ //enqueue LQI LayoutingTypes separately
+ if (layoutType.HasFlag (LayoutingType.Width))
+ Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Width, this));
+ if (layoutType.HasFlag (LayoutingType.Height))
+ Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Height, this));
+ if (layoutType.HasFlag (LayoutingType.X))
+ Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.X, this));
+ if (layoutType.HasFlag (LayoutingType.Y))
+ Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Y, this));
+ if (layoutType.HasFlag (LayoutingType.ArrangeChildren))
+ Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.ArrangeChildren, this));
}
/// <summary> trigger dependant sizing component update </summary>
switch (layoutType) {
case LayoutingType.Width:
- this.RegisterForLayouting (LayoutingType.X);
+ EnqueueForLayouting (LayoutingType.X);
break;
case LayoutingType.Height:
- this.RegisterForLayouting (LayoutingType.Y);
+ EnqueueForLayouting (LayoutingType.Y);
break;
}
LayoutChanged.Raise (this, new LayoutingEventArgs (layoutType));
public virtual bool UpdateLayout (LayoutingType layoutType)
{
//unset bit, it would be reset if LQI is re-queued
- registeredLayoutings &= (~layoutType);
+ queuedLayoutings &= (~layoutType);
switch (layoutType) {
case LayoutingType.X:
if (Bounds.X == 0) {
- if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Width) ||
- RegisteredLayoutings.HasFlag (LayoutingType.Width))
+ if (Parent.QueuedLayoutings.HasFlag (LayoutingType.Width) ||
+ QueuedLayoutings.HasFlag (LayoutingType.Width))
return false;
switch (HorizontalAlignment) {
case LayoutingType.Y:
if (Bounds.Y == 0) {
- if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Height) ||
- RegisteredLayoutings.HasFlag (LayoutingType.Height))
+ if (Parent.QueuedLayoutings.HasFlag (LayoutingType.Height) ||
+ QueuedLayoutings.HasFlag (LayoutingType.Height))
return false;
switch (VerticalAlignment) {
Slot.Width = Width;
else if (Width < 0) {
Slot.Width = measureRawSize (LayoutingType.Width);
- }else if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Width))
+ }else if (Parent.QueuedLayoutings.HasFlag (LayoutingType.Width))
return false;
else
Slot.Width = Parent.ClientRectangle.Width;
Slot.Height = Height;
else if (Height < 0){
Slot.Height = measureRawSize (LayoutingType.Height);
- }else if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Height))
+ }else if (Parent.QueuedLayoutings.HasFlag (LayoutingType.Height))
return false;
else
Slot.Height = Parent.ClientRectangle.Height;
}
//if no layouting remains in queue for item, registre for redraw
- if (this.registeredLayoutings == LayoutingType.None && bmp == null)
- this.RegisterForRedraw ();
+ if (this.queuedLayoutings == LayoutingType.None && bmp == null)
+ this.AddToRedrawList ();
return true;
}
public override bool UpdateLayout (LayoutingType layoutType)
{
- RegisteredLayoutings &= (~layoutType);
+ QueuedLayoutings &= (~layoutType);
if (layoutType == LayoutingType.ArrangeChildren) {
ComputeChildrenPositions ();
//if no layouting remains in queue for item, registre for redraw
- if (RegisteredLayoutings == LayoutingType.None && bmp==null)
- this.RegisterForRedraw ();
+ if (QueuedLayoutings == LayoutingType.None && bmp==null)
+ this.AddToRedrawList ();
return true;
}
foreach (GraphicObject c in Children) {
if (!c.Visible)
continue;
- c.RegisterForLayouting (LayoutingType.X | LayoutingType.Width);
+ c.EnqueueForLayouting (LayoutingType.X | LayoutingType.Width);
}
break;
case LayoutingType.Height:
foreach (GraphicObject c in Children) {
if (!c.Visible)
continue;
- c.RegisterForLayouting (LayoutingType.Y | LayoutingType.Height); }
+ c.EnqueueForLayouting (LayoutingType.Y | LayoutingType.Height); }
break;
}
}
maxChildrenWidth = g.Slot.Width;
largestChild = g;
if (this.Bounds.Width < 0)
- this.RegisterForLayouting (LayoutingType.Width);
+ this.EnqueueForLayouting (LayoutingType.Width);
} else if (g == largestChild) {
largestChild = null;
maxChildrenWidth = 0;
if (this.Bounds.Width < 0)
- this.RegisterForLayouting (LayoutingType.Width);
+ this.EnqueueForLayouting (LayoutingType.Width);
}
break;
case LayoutingType.Height:
maxChildrenHeight = g.Slot.Height;
tallestChild = g;
if (this.Bounds.Height < 0)
- this.RegisterForLayouting (LayoutingType.Height);
+ this.EnqueueForLayouting (LayoutingType.Height);
} else if (g == tallestChild) {
tallestChild = null;
maxChildrenHeight = 0;
if (this.Bounds.Height < 0)
- this.RegisterForLayouting (LayoutingType.Height);
+ this.EnqueueForLayouting (LayoutingType.Height);
}
break;
}
for (int i = 0; i < Children.Count; i++) {
if (!Children [i].Visible)
continue;
- if (children [i].RegisteredLayoutings.HasFlag (LayoutingType.Width))
+ if (children [i].QueuedLayoutings.HasFlag (LayoutingType.Width))
continue;
if (Children [i].Slot.Width > maxChildrenWidth) {
maxChildrenWidth = Children [i].Slot.Width;
for (int i = 0; i < Children.Count; i++) {
if (!Children [i].Visible)
continue;
- if (children [i].RegisteredLayoutings.HasFlag (LayoutingType.Height))
+ if (children [i].QueuedLayoutings.HasFlag (LayoutingType.Height))
continue;
if (Children [i].Slot.Height > maxChildrenHeight) {
maxChildrenHeight = Children [i].Slot.Height;
Rectangle getBounds();
bool ArrangeChildren { get; }
- LayoutingType RegisteredLayoutings { get; set; }
- void RegisterForLayouting(LayoutingType layoutType);
+ LayoutingType QueuedLayoutings { get; set; }
+ void EnqueueForLayouting(LayoutingType layoutType);
void RegisterClip(Rectangle clip);
bool UpdateLayout(LayoutingType layoutType);
if (_pic == null)
return;
_pic.Scaled = scaled;
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
}
}
bool keepProps;
if (_pic == null)
return;
_pic.KeepProportions = keepProps;
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
}
}
[XmlAttributeAttribute("Path")]
get { return _svgSub; }
set {
_svgSub = value;
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
}
}
_pic = new BmpPicture ();
_pic.LoadImage (path);
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
RegisterForLayouting (LayoutingType.Sizing);
}
#endregion
return;
selColor = value;
NotifyValueChanged ("SelectionBackground", selColor);
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
}
}
[XmlAttributeAttribute()][DefaultValue("White")]
return;
selFontColor = value;
NotifyValueChanged ("SelectionForeground", selFontColor);
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
}
}
[XmlAttributeAttribute()][DefaultValue(Alignment.Left)]
if (value == _textAlignment)
return;
_textAlignment = value;
- registerForGraphicUpdate ();
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
NotifyValueChanged ("TextAlignment", _textAlignment);
}
}
if (horizontalStretch == value)
return;
horizontalStretch = value;
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
NotifyValueChanged ("HorizontalStretch", horizontalStretch);
}
}
lines = getLines;
- this.registerForGraphicUpdate ();
+ this.RegisterForGraphicUpdate ();
this.RegisterForLayouting (LayoutingType.Sizing);
NotifyValueChanged ("Text", _text);
}
return;
_multiline = value;
NotifyValueChanged ("Multiline", _multiline);
- registerForGraphicUpdate();
+ RegisterForGraphicUpdate();
}
}
[XmlAttributeAttribute()][DefaultValue(0)]
SelBegin = new Point(0,0);
SelRelease = new Point (lines.LastOrDefault ().Length, lines.Count-1);
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
}
public override void onUnfocused (object sender, EventArgs e)
{
SelBegin = -1;
SelRelease = -1;
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
}
public override void onMouseMove (object sender, MouseMoveEventArgs e)
{
updatemouseLocalPos (e.Position);
- registerForGraphicUpdate();
+ RegisterForGraphicUpdate();
}
public override void onMouseDown (object sender, MouseButtonEventArgs e)
{
SelBegin = -1;
SelRelease = -1;
SelectionInProgress = true;
- registerForGraphicUpdate();//TODO:should put it in properties
+ RegisterForGraphicUpdate();//TODO:should put it in properties
}
//done at the end to set 'hasFocus' value after testing it
updatemouseLocalPos (e.Position);
SelectionInProgress = false;
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
}
#endregion
/// <summary>
minValue = value;
NotifyValueChanged ("Minimum", minValue);
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
}
}
[XmlAttributeAttribute()][DefaultValue(100.0)]
maxValue = value;
NotifyValueChanged ("Maximum", maxValue);
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
}
}
[XmlAttributeAttribute()][DefaultValue(1.0)]
smallStep = value;
NotifyValueChanged ("SmallIncrement", smallStep);
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
}
}
[XmlAttributeAttribute()][DefaultValue(5.0)]
bigStep = value;
NotifyValueChanged ("LargeIncrement", bigStep);
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
}
}
[XmlAttributeAttribute()][DefaultValue(0.0)]
_actualValue = value;
NotifyValueChanged("Value", _actualValue);
- registerForGraphicUpdate();
+ RegisterForGraphicUpdate();
}
}
#endregion
if (child == null)
return base.measureRawSize (lt);
if (lt == LayoutingType.Width)
- return child.RegisteredLayoutings.HasFlag(LayoutingType.Width) ?
+ return child.QueuedLayoutings.HasFlag(LayoutingType.Width) ?
-1 : child.Slot.Size.Width + 2 * Margin;
else
- return child.RegisteredLayoutings.HasFlag(LayoutingType.Height) ?
+ return child.QueuedLayoutings.HasFlag(LayoutingType.Height) ?
-1 : child.Slot.Size.Height + 2 * Margin;
}
public override bool UpdateLayout (LayoutingType layoutType)
case LayoutingType.Width:
if (child != null) {
if (child.Visible)
- child.RegisterForLayouting (LayoutingType.X | LayoutingType.Width);
+ child.EnqueueForLayouting (LayoutingType.X | LayoutingType.Width);
}
break;
case LayoutingType.Height:
if (child != null) {
if (child.Visible)
- child.RegisterForLayouting (LayoutingType.Y | LayoutingType.Height);
+ child.EnqueueForLayouting (LayoutingType.Y | LayoutingType.Height);
}
break;
}
break;
case LayoutingType.Width:
if (this.Bounds.Width < 0)
- this.RegisterForLayouting (LayoutingType.Width);
+ this.EnqueueForLayouting (LayoutingType.Width);
break;
case LayoutingType.Height:
if (this.Bounds.Height < 0)
- this.RegisterForLayouting (LayoutingType.Height);
+ this.EnqueueForLayouting (LayoutingType.Height);
break;
}
}
return;
_orientation = value;
NotifyValueChanged ("Orientation", _orientation);
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
}
}
public void onScrollBack (object sender, MouseButtonEventArgs e)
else
_scrollX = value;
NotifyValueChanged("ScrollX", _scrollX);
- RegisterForRedraw();
+ RegisterForGraphicUpdate ();
}
}
[XmlAttributeAttribute][DefaultValue(0.0)]
else
_scrollY = value;
NotifyValueChanged("ScrollY", _scrollY);
- RegisterForRedraw();
+ RegisterForGraphicUpdate ();
}
}
if (_cursorColor == value)
return;
_cursorColor = value;
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
NotifyValueChanged ("CursorColor", _cursorColor);
}
}
return;
_cursorSize = value;
RegisterForLayouting (LayoutingType.Sizing);
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
NotifyValueChanged ("CursorSize", _cursorSize);
}
}
thickness = value;
NotifyValueChanged ("Thickness", thickness);
RegisterForLayouting (LayoutingType.Sizing);
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
}
}
#region GraphicObject override
NotifyValueChanged ("TabOffset", tabOffset);
RegisterForLayouting (LayoutingType.X);
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
}
}
[XmlAttributeAttribute()][DefaultValue("TabItem")]
(Children [selectedTab] as TabItem).IsSelected = true;
NotifyValueChanged ("SelectedTab", selectedTab);
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
}
}
int tabThickness;
public override bool ArrangeChildren { get { return true; } }
public override bool UpdateLayout (LayoutingType layoutType)
{
- RegisteredLayoutings &= (~layoutType);
+ QueuedLayoutings &= (~layoutType);
if (layoutType == LayoutingType.ArrangeChildren) {
int curOffset = Spacing;
TabItem ti = Children [i] as TabItem;
ti.TabOffset = curOffset;
if (Orientation == Orientation.Horizontal) {
- if (ti.TabTitle.RegisteredLayoutings.HasFlag (LayoutingType.Width))
+ if (ti.TabTitle.QueuedLayoutings.HasFlag (LayoutingType.Width))
return false;
curOffset += ti.TabTitle.Slot.Width + Spacing;
} else {
- if (ti.TabTitle.RegisteredLayoutings.HasFlag (LayoutingType.Height))
+ if (ti.TabTitle.QueuedLayoutings.HasFlag (LayoutingType.Height))
return false;
curOffset += ti.TabTitle.Slot.Height + Spacing;
}
}
//if no layouting remains in queue for item, registre for redraw
- if (RegisteredLayoutings == LayoutingType.None && bmp==null)
- this.RegisterForRedraw ();
+ if (QueuedLayoutings == LayoutingType.None && bmp==null)
+ this.AddToRedrawList ();
return true;
}
set
{
base.HasFocus = value;
- registerForGraphicUpdate();
+ RegisterForGraphicUpdate();
}
}
[XmlAttributeAttribute()][DefaultValue(true)]
RegisterForLayouting (LayoutingType.Width);
if (Height < 0)
RegisterForLayouting (LayoutingType.Height);
- registerForGraphicUpdate();
+ RegisterForGraphicUpdate();
}
#endregion
}
if (horizontalStretch == value)
return;
horizontalStretch = value;
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
NotifyValueChanged ("HorizontalStretch", horizontalStretch);
}
}
if (_text == value)
return;
- registerForGraphicUpdate();
+ RegisterForGraphicUpdate();
this.RegisterForLayouting (LayoutingType.Sizing);
set
{
_multiline = value;
- registerForGraphicUpdate();
+ RegisterForGraphicUpdate();
}
}
[XmlAttributeAttribute()][DefaultValue(false)]
if (wordWrap == value)
return;
wordWrap = value;
- registerForGraphicUpdate();
+ RegisterForGraphicUpdate();
}
}
values.Add (_value);
while (values.Count > nbValues)
values.RemoveAt (0);
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
}
public Trend ()
nbValues = value;
NotifyValueChanged ("NbValues", minValue);
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
}
}
[XmlAttributeAttribute()][DefaultValue(0.0)]
minValue = value;
NotifyValueChanged ("Minimum", minValue);
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
}
}
[XmlAttributeAttribute()][DefaultValue(100.0)]
maxValue = value;
NotifyValueChanged ("Maximum", maxValue);
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
}
}
[XmlAttributeAttribute()][DefaultValue(20.0)]
return;
lowThreshold = value;
NotifyValueChanged ("LowThreshold", lowThreshold);
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
}
}
[XmlAttributeAttribute()][DefaultValue(80.0)]
return;
highThreshold = value;
NotifyValueChanged ("HighThreshold", highThreshold);
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
}
}
[XmlAttributeAttribute()][DefaultValue("DarkRed")]
return;
lowThresholdFill = value;
NotifyValueChanged ("LowThresholdFill", lowThresholdFill);
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
}
}
[XmlAttributeAttribute()][DefaultValue("DarkGreen")]
return;
highThresholdFill = value;
NotifyValueChanged ("HighThresholdFill", highThresholdFill);
- registerForGraphicUpdate ();
+ RegisterForGraphicUpdate ();
}
}
protected override void onDraw (Cairo.Context gr)
public const int MaxLayoutingTries = 50;
#endregion
- public static Queue<LayoutingQueueItem> LayoutingQueue = new Queue<LayoutingQueueItem>();
+ public Queue<LayoutingQueueItem> LayoutingQueue = new Queue<LayoutingQueueItem>();
+ public Queue<GraphicObject> GraphicUpdateQueue = new Queue<GraphicObject>();
+ public Queue<GraphicObject> UpdateLayoutQueue = new Queue<GraphicObject>();
+
+ public static void RegisterForLayouting(GraphicObject g, LayoutingType lt){
+
+ lock (CurrentInterface.UpdateLayoutQueue) {
+ if (CurrentInterface == null)
+ return;
+ if (g.RegisteredLayoutings == LayoutingType.None)
+ CurrentInterface.UpdateLayoutQueue.Enqueue (g);
+ g.RegisteredLayoutings |= lt;
+ }
+ }
+ public static void RegisterForGraphicUpdate(GraphicObject g)
+ {
+ lock (CurrentInterface.GraphicUpdateQueue) {
+ if (g.IsQueueForGraphicUpdate)
+ return;
+ if (CurrentInterface == null)
+ return;
+ CurrentInterface.GraphicUpdateQueue.Enqueue (g);
+ g.IsQueueForGraphicUpdate = true;
+ }
+ }
+ public static void AddToRedrawList(GraphicObject g)
+ {
+ if (g.IsInRedrawList)
+ return;
+ if (Interface.CurrentInterface == null)
+ return;
+ Interface.CurrentInterface.RedrawList.Add (g);
+ g.IsInRedrawList = true;
+ }
+
#region default values loading helpers
public delegate void loadDefaultInvoker(object instance);
public static Dictionary<String, loadDefaultInvoker> DefaultValuesLoader = new Dictionary<string, loadDefaultInvoker>();
}
public GraphicObject LoadInterface (string path)
- {
- lock (RenderMutex) {
+ {
+ lock (this) {
GraphicObject tmp = Interface.Load (path, this);
AddWidget (tmp);
return tmp;
- }
+ }
}
#endregion
updateTime.Restart ();
#endif
+ lock (this) {
+ processLayouting ();
- processLayouting ();
-
- clippingRegistration ();
-
- processDrawing ();
+ clippingRegistration ();
+ processDrawing ();
+ }
#if MEASURE_TIME
updateTime.Stop ();
#endif
#if MEASURE_TIME
layoutTime.Restart();
#endif
-
+ lock (Interface.CurrentInterface.UpdateLayoutQueue) {
+ while(Interface.CurrentInterface.UpdateLayoutQueue.Count>0){
+ GraphicObject g = Interface.CurrentInterface.UpdateLayoutQueue.Dequeue();
+ g.EnqueueForLayouting (g.RegisteredLayoutings);
+ g.RegisteredLayoutings = LayoutingType.None;
+ }
+ }
//Debug.WriteLine ("======= Layouting queue start =======");
- int queueCount = 0;
LayoutingQueueItem lqi = null;
-
- lock (Interface.LayoutingQueue)
- queueCount = Interface.LayoutingQueue.Count;
-
- while (queueCount > 0) {
- lock (Interface.LayoutingQueue)
- lqi = Interface.LayoutingQueue.Dequeue ();
- if (lqi!=null)
+ while (Interface.CurrentInterface.LayoutingQueue.Count > 0) {
+ lqi = Interface.CurrentInterface.LayoutingQueue.Dequeue ();
lqi.ProcessLayouting ();
- lock (Interface.LayoutingQueue)
- queueCount = Interface.LayoutingQueue.Count;
}
#if MEASURE_TIME
layoutTime.Stop ();
#endif
}
void clippingRegistration(){
+ lock (CurrentInterface.GraphicUpdateQueue) {
+ while (CurrentInterface.GraphicUpdateQueue.Count > 0) {
+ GraphicObject g = CurrentInterface.GraphicUpdateQueue.Dequeue ();
+ g.bmp = null;
+ g.IsQueueForGraphicUpdate = false;
+ AddToRedrawList (g);
+ }
+ }
//Debug.WriteLine ("otd:" + gobjsToRedraw.Count.ToString () + "-");
//final redraw clips should be added only when layout is completed among parents,
//that's why it take place in a second pass
- lock (Interface.CurrentInterface.RenderMutex) {
- GraphicObject[] gotr = null;
- gotr = new GraphicObject[gobjsToRedraw.Count];
- gobjsToRedraw.CopyTo (gotr);
- gobjsToRedraw.Clear ();
-
- foreach (GraphicObject p in gotr) {
- try {
- p.IsQueuedForRedraw = false;
- p.Parent.RegisterClip (p.LastPaintedSlot);
- p.Parent.RegisterClip (p.getSlot ());
- } catch (Exception ex) {
- Debug.WriteLine ("Error Register Clip: " + ex.ToString ());
- }
+ foreach (GraphicObject p in RedrawList) {
+ try {
+ p.IsInRedrawList = false;
+ p.Parent.RegisterClip (p.LastPaintedSlot);
+ p.Parent.RegisterClip (p.getSlot ());
+ } catch (Exception ex) {
+ Debug.WriteLine ("Error Register Clip: " + ex.ToString ());
}
}
+ RedrawList.Clear ();
}
void processDrawing(){
#if MEASURE_TIME
DirtyRect.Top = Math.Max (0, DirtyRect.Top);
DirtyRect.Width = Math.Min (ClientRectangle.Width - DirtyRect.Left, DirtyRect.Width);
DirtyRect.Height = Math.Min (ClientRectangle.Height - DirtyRect.Top, DirtyRect.Height);
+ DirtyRect.Width = Math.Max (0, DirtyRect.Width);
+ DirtyRect.Height = Math.Max (0, DirtyRect.Height);
}
clipping.Reset ();
}
get { return _redrawClip; }
set { _redrawClip = value; }
}
- public List<GraphicObject> gobjsToRedraw {
+ public List<GraphicObject> RedrawList {
get { return _gobjsToRedraw; }
set { _gobjsToRedraw = value; }
}
get { throw new NotImplementedException (); }
set { throw new NotImplementedException (); }
}
- public LayoutingType RegisteredLayoutings {
+ public LayoutingType QueuedLayoutings {
get { return LayoutingType.None; }
set { throw new NotImplementedException (); }
}
- public void RegisterForLayouting (LayoutingType layoutType) { throw new NotImplementedException (); }
+ public void EnqueueForLayouting (LayoutingType layoutType) { throw new NotImplementedException (); }
public bool UpdateLayout (LayoutingType layoutType) { throw new NotImplementedException (); }
public Rectangle ContextCoordinates (Rectangle r) => r;
public Rectangle ScreenCoordinates (Rectangle r) => r;
{
LayoutType = _layoutType;
GraphicObject = _graphicObject;
- GraphicObject.RegisteredLayoutings |= LayoutType;
+ GraphicObject.QueuedLayoutings |= LayoutType;
}
public void ProcessLayouting()
#endif
GraphicObject.LayoutingTries ++;
if (GraphicObject.LayoutingTries < Interface.MaxLayoutingTries) {
- GraphicObject.RegisteredLayoutings |= LayoutType;
- Interface.LayoutingQueue.Enqueue (this);
+ GraphicObject.QueuedLayoutings |= LayoutType;
+ Interface.CurrentInterface.LayoutingQueue.Enqueue (this);
}
} else {
GraphicObject.LayoutingTries = 0;