From aabc901083b8c521f34df863c09340570062b1e6 Mon Sep 17 00:00:00 2001 From: jpbruyere Date: Fri, 5 Feb 2016 16:15:25 +0100 Subject: [PATCH] code clean --- src/GraphicObjects/GraphicObject.cs | 60 ++++++++++++++++++----------- src/GraphicObjects/Group.cs | 11 ------ src/Interface.cs | 2 +- 3 files changed, 38 insertions(+), 35 deletions(-) diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index e181fdf7..fe010d6a 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -82,9 +82,30 @@ namespace Crow #endregion #region public fields + /// + /// The logical parent (used mainly for bindings) as opposed to the parent in the graphic tree + /// public GraphicObject LogicalParent; + /// + /// Original size and position 0=Stretched; -1=Fit + /// public Rectangle Bounds; + /// + /// Current size and position computed during layouting pass + /// public Rectangle Slot = new Rectangle (); + /// + /// keep last slot components for each layouting pass to track + /// changes and trigger update of other component accordingly + /// + public Rectangle LastSlots; + /// + /// keep last slot painted on screen to clear traces if moved or resized + /// TODO: we should ensure the whole parsed widget tree is the last painted + /// version to clear effective oldslot if parents have been moved or resized. + /// IDEA is to add a ScreenCoordinates function that use only lastPaintedSlots + /// + public Rectangle LastPaintedSlot; public object Tag; public byte[] bmp; #endregion @@ -94,6 +115,9 @@ namespace Crow public List> RegisteredLQINodes { get; } = new List>(); //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 + /// + /// Parent in the graphic tree, used for rendering and layouting + /// [XmlIgnore]public ILayoutable Parent { get { return _parent; } set { @@ -442,7 +466,13 @@ namespace Crow return false; } - + public virtual void registerClipRect() + { + HostContainer.redrawClip.AddRectangle (ScreenCoordinates(Slot)); + //this clipping should take only last painted slots in ancestor tree which + //is not the case for now. + HostContainer.redrawClip.AddRectangle (ScreenCoordinates(LastPaintedSlot)); + } /// /// Clear chached object and add clipping region in redraw list of interface /// @@ -466,31 +496,12 @@ namespace Crow HostContainer.gobjsToRedraw.Add (this); } - /// - /// keep last slot components for each layouting pass to track - /// changes and trigger update of other component accordingly - /// - public Rectangle LastSlots; - /// - /// keep last slot painted on screen to clear traces if moved or resized - /// TODO: we should ensure the whole parsed widget tree is the last painted - /// version to clear effective oldslot if parents have been moved or resized. - /// IDEA is to add a ScreenCoordinates function that use only lastPaintedSlots - /// - public Rectangle LastPaintedSlot; - - public virtual void registerClipRect() - { - HostContainer.redrawClip.AddRectangle (ScreenCoordinates(Slot)); - //this clipping should take only last painted slots in ancestor tree which - //is not the case for now. - HostContainer.redrawClip.AddRectangle (ScreenCoordinates(LastPaintedSlot)); - } + #region Layouting /// return size of content + margins - protected virtual Size measureRawSize () - { + protected virtual Size measureRawSize () { return Bounds.Size; } + void deleteLQI(int lt){ LinkedListNode[] lqis = this.RegisteredLQINodes.Where (n => (lt & (int)n.Value.LayoutType) > 0).ToArray (); for (int i = 0; i < lqis.Length; i++) { @@ -712,7 +723,9 @@ namespace Crow if (this.RegisteredLQINodes.Count () <= 0 && bmp == null) this.RegisterForRedraw (); } + #endregion + #region Rendering /// This is the common overridable drawing routine to create new widget protected virtual void onDraw(Context gr) { @@ -772,6 +785,7 @@ namespace Crow ctx.Paint (); } } + #endregion #region Keyboard handling public virtual void onKeyDown(object sender, KeyboardKeyEventArgs e){ diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs index 14142e0d..7f952ac1 100644 --- a/src/GraphicObjects/Group.cs +++ b/src/GraphicObjects/Group.cs @@ -129,17 +129,6 @@ namespace Crow } protected override Size measureRawSize () { -// Size tmp = new Size (); -// -// foreach (GraphicObject c in Children.Where(ch=>ch.Visible)) { -// tmp.Width = Math.Max (tmp.Width, c.Slot.Right); -// tmp.Height = Math.Max (tmp.Height, c.Slot.Bottom); -// } -// -// tmp.Width += 2*Margin; -// tmp.Height += 2*Margin; -// -// return tmp; return new Size(maxChildrenWidth + 2 * Margin, maxChildrenHeight + 2 * Margin); } diff --git a/src/Interface.cs b/src/Interface.cs index e6be4220..c96dffa0 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -44,7 +44,7 @@ namespace Crow public static string LineBreak = "\r\n"; public static bool FocusOnHover = false; /// Time to wait in millisecond before starting repeat loop - public static int DeviceRepeatDelay = 1000; + public static int DeviceRepeatDelay = 600; /// Time interval in millisecond between device event repeat public static int DeviceRepeatInterval = 100; public static bool ReplaceTabsWithSpace = false; -- 2.47.3