]> O.S.I.I.S - jp/crow.git/commitdiff
stickedWidget dbg event
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Thu, 17 Jul 2025 20:21:07 +0000 (22:21 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Thu, 17 Jul 2025 20:21:07 +0000 (22:21 +0200)
Crow/src/DebugUtils/DbgEvent.cs
Crow/src/DebugUtils/DbgWidgetEvent.cs
Crow/src/Interface.cs
Crow/src/Widgets/Widget.cs
Drawing2D/src/DbgEvtType.cs
Samples/DebugLogViewer/ui/main.crow

index 20747fb876d662fd8a3b1fc85c6058e75f24bc3b..cfda1e3d1d78107077e0d212db0c2040082c8518 100644 (file)
@@ -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;
index 6f3f1dff6be2d8a9b60764afb8e6fb2493ca1186..e9e109e7925144db885dbc928cd35e6b04cd4201 100644 (file)
@@ -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;
                                }
                        }
index 8a56c754d04a0b759ae5848a50409b6dcf2ecd8c..8a713cf713f1ec96fbc1f4142686756ce51f35ee 100644 (file)
@@ -84,6 +84,8 @@ namespace Crow
                public static float WheelIncrement = 1;
                /// <summary>Tabulation size in Text controls</summary>
                public static int TAB_SIZE = 4;
+               /// <summary>Text cursor blinking frequency</summary>
+               public static long TEXT_CURSOR_BLINK_FREQUENCY = 400;
                [Obsolete]public static string LineBreak = "\n";
                /// <summary> Allow rendering of interface in development environment </summary>
                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
-               /// <summary>
-               /// Text cursor blinking frequency.
-               /// </summary>
-               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);
                        }
                }
                /// <summary>
@@ -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 ();
index 8c0dfc4f6f0af00c5b5c13cae52b0f500510a957..3fac43e268f10251562de75281683708555703b6 100644 (file)
@@ -793,7 +793,7 @@ namespace Crow
 
                                if (isHover) {
                                        if (stickyMouseEnabled && stickyMouse > 0)
-                                               IFace.stickedWidget = this;
+                                               IFace.StickedWidget = this;
                                        Hover.Raise (this, null);
                                }
 
index e54c5603205cecc46e4b58dc7e89b227f32eef68..d38644c9913d391cab0de0fb166d3a8df8cdbb2d 100644 (file)
@@ -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,
index a1f99e1941d04657b0b3fbfc55a59cd84fbf3de7..f0088b3fc4fe890cce043fa9731c6e2749e8b4ab 100644 (file)
@@ -95,8 +95,8 @@
                        <ListBox Height="Stretched" Data="{CurrentWidgetEvents}" SelectedItem="{²CurrentEvent}" Background="DarkGrey"
                                                ItemTemplate="#ui.DbgWidgetEventListItems.itemp"/>
                </VerticalStack>
-               <!--<Splitter/>
-               <DbgEventView Template="#ui.DbgEventView.template" Event="{../../dbv.HoverEvent}"/>-->
+               <Splitter/>
+               <DbgEventView Template="#ui.DbgEventView.template" Event="{../../dbv.HoverEvent}"/>
                <Splitter/>
                <DbgEventView Template="#ui.DbgEventView.template" Event="{CurrentEvent}"/>
        </HorizontalStack>