aboutsummaryrefslogtreecommitdiffstatsci
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-09-22 06:19:43 +0000
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-09-22 06:19:43 +0000
commit2d7bdc87db703becd689d5f84cb90b3501f0a0a3 (patch)
treef4edce84e56ac9da1c8ada73fae872abcf416b9d
parent25abdf909b7ff86d82205f6f267c1abe8405cc30 (diff)
test clipping and text cursor blinking redraw in drawing loop
-rw-r--r--Crow/src/2d/Measure.cs6
-rw-r--r--Crow/src/Interface.cs91
-rw-r--r--Crow/src/Widgets/Widget.cs4
3 files changed, 51 insertions, 50 deletions
diff --git a/Crow/src/2d/Measure.cs b/Crow/src/2d/Measure.cs
index b5f475f5..4b66a975 100644
--- a/Crow/src/2d/Measure.cs
+++ b/Crow/src/2d/Measure.cs
@@ -53,8 +53,8 @@ namespace Crow
public bool IsRelativeToParent { get { return Value >= 0 && Units == Unit.Percent; }}
#region Operators
public static implicit operator int(Measure m) => m.Value;
- public static implicit operator Measure(int i) => new Measure(i);
- public static implicit operator string(Measure m) => m.ToString();
+ public static implicit operator Measure(int i) => new Measure(i);
+ public static implicit operator string(Measure m) => m.ToString();
public static implicit operator Measure(string s) => Measure.Parse(s);
public static bool operator ==(Measure m1, Measure m2) => m1.Equals (m2);
@@ -87,7 +87,7 @@ namespace Crow
else if (string.Equals ("Fit", st, StringComparison.Ordinal))
return Measure.Fit;
else if (string.Equals ("Stretched", s, StringComparison.Ordinal))
- return Measure.Stretched;
+ return Measure.Stretched;
else {
if (st.EndsWith ("%", StringComparison.Ordinal)) {
if (int.TryParse (s.Substring(0, st.Length - 1), out tmp))
diff --git a/Crow/src/Interface.cs b/Crow/src/Interface.cs
index 250d2fb1..c177cd1b 100644
--- a/Crow/src/Interface.cs
+++ b/Crow/src/Interface.cs
@@ -1073,9 +1073,6 @@ namespace Crow
}
_hoverWidget = value;
- if (_hoverWidget.ToString() == "HelloWorld.Program.vs2.Border12")
- Debugger.Break();
-
NotifyValueChanged ("HoverWidget", _hoverWidget);
DbgLogger.AddEvent (DbgEvtType.HoverWidget, _hoverWidget);
@@ -1176,7 +1173,7 @@ namespace Crow
clipping.UnionRectangle(lastDragImageBounds);
}
- if (!clipping.IsEmpty) {
+ if (!clipping.IsEmpty || shouldDrawTextCursor) {
if (ctx == null) {
using (ctx = new Context (surf))
processDrawing (ctx);
@@ -1190,7 +1187,6 @@ namespace Crow
ProcessResize (new Rectangle (0,0,(int)vkCtx.width, (int)vkCtx.height));
}
#endif
-
} finally {
PerformanceMeasure.End (PerformanceMeasure.Kind.Update);
@@ -1285,67 +1281,68 @@ namespace Crow
DbgLogger.StartEvent (DbgEvtType.ProcessDrawing);
PerformanceMeasure.Begin (PerformanceMeasure.Kind.Drawing);
-
+ if (!clipping.IsEmpty) {
#if VKVG
- clear (ctx);
+ clear (ctx);
#else
- ctx.PushGroup ();
+ ctx.PushGroup ();
- if (SolidBackground)
- clear (ctx);
+ if (SolidBackground)
+ clear (ctx);
#endif
- for (int i = GraphicTree.Count -1; i >= 0 ; i--){
- Widget p = GraphicTree[i];
- if (!p.IsVisible)
- continue;
- if (clipping.OverlapOut (p.Slot))
- continue;
+ for (int i = GraphicTree.Count -1; i >= 0 ; i--){
+ Widget p = GraphicTree[i];
+ if (!p.IsVisible)
+ continue;
+ if (clipping.OverlapOut (p.Slot))
+ continue;
- ctx.Save ();
- p.Paint (ctx);
- ctx.Restore ();
- }
+ ctx.Save ();
+ p.Paint (ctx);
+ ctx.Restore ();
+ }
- if (lastDragImageBounds != DragImageBounds) {
- DirtyRect += lastDragImageBounds;
- ctx.Save ();
- ctx.ResetClip ();
- ctx.SetSource (DragImage, DragImageBounds.X, DragImageBounds.Y);
- ctx.PaintWithAlpha (0.8);
- ctx.Restore ();
- DirtyRect += DragImageBounds;
- IsDirty = true;
- }
+ if (lastDragImageBounds != DragImageBounds) {
+ DirtyRect += lastDragImageBounds;
+ ctx.Save ();
+ ctx.ResetClip ();
+ ctx.SetSource (DragImage, DragImageBounds.X, DragImageBounds.Y);
+ ctx.PaintWithAlpha (0.8);
+ ctx.Restore ();
+ DirtyRect += DragImageBounds;
+ IsDirty = true;
+ }
#if DEBUG_CLIP_RECTANGLE
- ctx.LineWidth = 1;
- ctx.SetSource(1,1,0,0.5);
- for (int i = 0; i < clipping.NumRectangles; i++)
- ctx.Rectangle(clipping.GetRectangle(i));
- ctx.Stroke ();
+ ctx.LineWidth = 1;
+ ctx.SetSource(1,1,0,0.5);
+ for (int i = 0; i < clipping.NumRectangles; i++)
+ ctx.Rectangle(clipping.GetRectangle(i));
+ ctx.Stroke ();
#endif
#if VKVG
- ctx.Flush();
+ ctx.Flush();
#else
- ctx.PopGroupToSource ();
+ ctx.PopGroupToSource ();
- if (!SolidBackground)
- clear (ctx);
+ if (!SolidBackground)
+ clear (ctx);
- ctx.Paint ();
+ ctx.Paint ();
- surf.Flush ();
+ surf.Flush ();
#endif
- clipping.Reset ();
+ clipping.Reset ();
- PerformanceMeasure.End (PerformanceMeasure.Kind.Drawing);
- IsDirty = true;
+ PerformanceMeasure.End (PerformanceMeasure.Kind.Drawing);
+ IsDirty = true;
+ }
#if !VKVG
drawTextCursor (ctx);
@@ -1417,6 +1414,8 @@ namespace Crow
}
}
#endregion
+ bool shouldDrawTextCursor => forceTextCursor || (blinkingCursor.ElapsedMilliseconds > TEXT_CURSOR_BLINK_FREQUENCY &&
+ (FocusedWidget is IEditableTextWidget || textCursor != null));
#region GraphicTree handling
/// <summary>Add widget to the Graphic tree of this interface and register it for layouting</summary>
@@ -2113,8 +2112,10 @@ namespace Crow
ctxMenuContainer.Top = MousePosition.Y - 5;
//OnMouseMove (MousePosition.X, MousePosition.Y);
- HoverWidget = ctxMenuContainer;
+ //
+ //
ctxMenuContainer.onMouseEnter (ctxMenuContainer, new MouseMoveEventArgs (MousePosition.X, MousePosition.Y, 0, 0));
+ HoverWidget = ctxMenuContainer;
}
#endregion
diff --git a/Crow/src/Widgets/Widget.cs b/Crow/src/Widgets/Widget.cs
index da4d7c35..a7f50e78 100644
--- a/Crow/src/Widgets/Widget.cs
+++ b/Crow/src/Widgets/Widget.cs
@@ -1823,9 +1823,9 @@ namespace Crow
if (isVisible) {
if (Width.IsFixed)
Slot.Width = Width;
- else if (Width == Measure.Fit) {
+ else if (Width == Measure.Fit)
Slot.Width = measureRawSize (LayoutingType.Width);
- } else if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Width))
+ else if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Width))
return false;
else if (Width == Measure.Stretched)
Slot.Width = Parent.GetClientRectangleForChild(this).Width;