From: Jean-Philippe Bruyère Date: Thu, 17 Jul 2025 20:21:07 +0000 (+0200) Subject: stickedWidget dbg event X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=afc11903ff9018a57aa54ab5339151f0a1a47ead;p=jp%2Fcrow.git stickedWidget dbg event --- diff --git a/Crow/src/DebugUtils/DbgEvent.cs b/Crow/src/DebugUtils/DbgEvent.cs index 20747fb8..cfda1e3d 100644 --- a/Crow/src/DebugUtils/DbgEvent.cs +++ b/Crow/src/DebugUtils/DbgEvent.cs @@ -112,6 +112,8 @@ namespace Crow.DebugLogger case DbgEvtType.IFaceLoad: return Colors.Teal; default: + if (type.HasFlag(DbgEvtType.Focus)) + return Colors.Yellow; if (type.HasFlag(DbgEvtType.Mouse)) return Colors.DeepPink; return Colors.White; diff --git a/Crow/src/DebugUtils/DbgWidgetEvent.cs b/Crow/src/DebugUtils/DbgWidgetEvent.cs index 6f3f1dff..e9e109e7 100644 --- a/Crow/src/DebugUtils/DbgWidgetEvent.cs +++ b/Crow/src/DebugUtils/DbgWidgetEvent.cs @@ -71,6 +71,11 @@ namespace Crow.DebugLogger case DbgEvtType.TGCancelLoadingThread: return Colors.Maroon; default: + if (type.HasFlag(DbgEvtType.Focus)) + return Colors.Yellow; + if (type.HasFlag(DbgEvtType.Mouse)) + return Colors.DeepPink; + return Colors.White; } } diff --git a/Crow/src/Interface.cs b/Crow/src/Interface.cs index 8a56c754..8a713cf7 100644 --- a/Crow/src/Interface.cs +++ b/Crow/src/Interface.cs @@ -84,6 +84,8 @@ namespace Crow public static float WheelIncrement = 1; /// Tabulation size in Text controls public static int TAB_SIZE = 4; + /// Text cursor blinking frequency + public static long TEXT_CURSOR_BLINK_FREQUENCY = 400; [Obsolete]public static string LineBreak = "\n"; /// Allow rendering of interface in development environment public static bool DesignerMode = false; @@ -463,7 +465,6 @@ namespace Crow return null; } - public virtual MethodInfo SearchExtMethod (Type t, string methodName) { string key = t.Name + "." + methodName; if (knownExtMethods.ContainsKey (key)) @@ -694,6 +695,15 @@ namespace Crow public ISurface DragImage = null; public Rectangle DragImageBounds, lastDragImageBounds; public bool DragImageFolowMouse;//prevent dragImg to be moved by mouse + Widget HoverOrDropTarget { + get => DragAndDropInProgress ? dragndropHover : HoverWidget; + set { + if (DragAndDropInProgress) { + dragndropHover = value; + } else + HoverWidget = value; + } + } public void ClearDragImage () { lock (UpdateMutex) { if (DragImage == null) @@ -1245,7 +1255,7 @@ namespace Crow } if (lastDragImageBounds != DragImageBounds) { - ctx.LineWidth = 1; + /*ctx.LineWidth = 1; ctx.SetSource(1,0,0,0.6); ctx.Rectangle(DragImageBounds); ctx.Stroke (); @@ -1253,7 +1263,7 @@ namespace Crow ctx.Rectangle(lastDragImageBounds); ctx.Stroke (); ctx.Arc(lastDragImageBounds.X, lastDragImageBounds.Y, 5,0,Math.PI*2.0); - ctx.Fill (); + ctx.Fill ();*/ DirtyRect += lastDragImageBounds; ctx.Save (); @@ -1311,11 +1321,6 @@ namespace Crow } #region Blinking text cursor - /// - /// Text cursor blinking frequency. - /// - public static long TEXT_CURSOR_BLINK_FREQUENCY = 400; - bool _drawTextCursor = true; public bool drawTextCursor { get => _drawTextCursor; @@ -1389,6 +1394,9 @@ namespace Crow public void ClearInterface() { lock (UpdateMutex) { + HoverWidget = ActiveWidget = FocusedWidget = HoverOrDropTarget = StickedWidget = null; + ClearDragImage(); + resetTooltip(); while (GraphicTree.Count > 0) { //TODO:parent is not reset to null because object will be added //to ObjectToRedraw list, and without parent, it fails @@ -1535,7 +1543,7 @@ namespace Crow public Point MousePosition { get; set; } = default; public bool IsDown (MouseButton button) => Glfw3.GetMouseButton (hWin, button) != InputAction.Release; - public MouseCursor MouseCursor { + public virtual MouseCursor MouseCursor { get => cursor; set { @@ -1569,15 +1577,12 @@ namespace Crow } Point stickyMouseDelta = default; - internal Widget stickedWidget = null; - - Widget HoverOrDropTarget { - get => DragAndDropInProgress ? dragndropHover : HoverWidget; + Widget stickedWidget = null; + internal Widget StickedWidget { + get => stickedWidget; set { - if (DragAndDropInProgress) { - dragndropHover = value; - } else - HoverWidget = value; + stickedWidget = value; + DbgLogger.AddEvent(DbgEvtType.StickedWidget, stickedWidget); } } /// @@ -1601,12 +1606,11 @@ namespace Crow int deltaY = y - MousePosition.Y; if (!DragAndDropInProgress) { - if (stickedWidget != null && ActiveWidget == null) { + if (StickedWidget != null && ActiveWidget == null) { stickyMouseDelta.X += deltaX; stickyMouseDelta.Y += deltaY; - - if (Math.Abs (stickyMouseDelta.X) > stickedWidget.StickyMouse || Math.Abs (stickyMouseDelta.Y) > stickedWidget.StickyMouse) { - stickedWidget = null; + if (Math.Abs (stickyMouseDelta.X) > StickedWidget.StickyMouse || Math.Abs (stickyMouseDelta.Y) > StickedWidget.StickyMouse) { + StickedWidget = null; stickyMouseDelta = default; } else { ForceMousePosition (); diff --git a/Crow/src/Widgets/Widget.cs b/Crow/src/Widgets/Widget.cs index 8c0dfc4f..3fac43e2 100644 --- a/Crow/src/Widgets/Widget.cs +++ b/Crow/src/Widgets/Widget.cs @@ -793,7 +793,7 @@ namespace Crow if (isHover) { if (stickyMouseEnabled && stickyMouse > 0) - IFace.stickedWidget = this; + IFace.StickedWidget = this; Hover.Raise (this, null); } diff --git a/Drawing2D/src/DbgEvtType.cs b/Drawing2D/src/DbgEvtType.cs index e54c5603..d38644c9 100644 --- a/Drawing2D/src/DbgEvtType.cs +++ b/Drawing2D/src/DbgEvtType.cs @@ -42,6 +42,7 @@ namespace Crow FocusedWidget = Focus | Widget | 0x02, ActiveWidget = Focus | Widget | 0x04, UnfocusedWidget = Focus | Widget | 0x08, + StickedWidget = Focus | Widget | 0x10, //10 nth bit set for graphic obj GOClassCreation = Widget | 0x01, diff --git a/Samples/DebugLogViewer/ui/main.crow b/Samples/DebugLogViewer/ui/main.crow index a1f99e19..f0088b3f 100644 --- a/Samples/DebugLogViewer/ui/main.crow +++ b/Samples/DebugLogViewer/ui/main.crow @@ -95,8 +95,8 @@ - + +