]> O.S.I.I.S - jp/crowedit.git/commitdiff
CrowPlugin Edit/Run modes
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 16 Jul 2025 22:57:09 +0000 (00:57 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 16 Jul 2025 22:57:09 +0000 (00:57 +0200)
plugins/CECrowPlugin/src/CrowService.cs
plugins/CECrowPlugin/src/DebugInterface.cs
plugins/CECrowPlugin/src/DebugInterfaceWidget.cs
plugins/CEXmlPlugin/src/Parsing/XmlSyntaxNodes.cs

index d38a4cfb32a271772e188c682655bcfb55cb0fa3..22902049d5385f5a2b738c2bf7f50ccf7f5171c7 100644 (file)
@@ -59,6 +59,7 @@ namespace CECrowPlugin
                public Command CMDOptions_SelectCrowAssemblyLocation, CMDOptions_AddCrowAssembly, CMDOptions_RemoveCrowAssembly;
                public Command CMDOptions_SelectDebugLogDirectory;
                public Command CMDViewPreview, CMDViewGraphicTree, CMDViewProperties;
+               public Command CMDEditMode, CMDRun;
                public CommandGroup ViewCommands;
                
                void initCommands ()
@@ -68,6 +69,9 @@ namespace CECrowPlugin
                        CMDViewProperties = new ActionCommand("Widget Properties", () => App.LoadWindow (ServiceWindowsPath[2], this), "#icons.property.svg");
                        ViewCommands = new CommandGroup("C.R.O.W.", "#icons.crow.svg" ,CMDViewPreview, CMDViewGraphicTree, CMDViewProperties);
 
+                       CMDRun = new ActionCommand ("Run", () => EditMode = false, "#icons.presentation.svg", true);
+                       CMDEditMode = new ActionCommand ("Edit mode", () => EditMode = true, "#icons.edit.svg", false);
+
                        CMDRefresh = new ActionCommand ("Refresh", refresh, "#icons.refresh.svg", IsRunning);
                        CMDStartRecording = new ActionCommand ("Start Recording", () => Recording = true, "#icons.circle.svg", false);
                        CMDStopRecording = new ActionCommand ("Stop Recording", stopRecording, "#icons.circle-red.svg", false);
@@ -252,11 +256,21 @@ namespace CECrowPlugin
 
 
                FieldInfo fiDbg_IncludedEvents, fiDbg_ConsoleOutput, fiDbgIFace_MaxLayoutingTries, fiDbgIFace_MaxDiscardCount, fiDbgIFace_Terminate;
+               FieldInfo fiDbgIFace_UPDATE_INTERVAL, fiDbgIFace_Edition;
                FieldInfo fiITor_NextInstantiatorID;
                
                #endregion
 
                public bool HasVkvgBackend { get; private set; }
+               public int CrowUpdateInterval {
+                       get => (int)fiDbgIFace_UPDATE_INTERVAL.GetValue(null);
+                       set {
+                               if (CrowUpdateInterval == value)
+                                       return;
+                               fiDbgIFace_UPDATE_INTERVAL.SetValue (null, value);
+                               NotifyValueChanged (value);
+                       }
+               }               
                public int RefreshRate {
                        get => Configuration.Global.Get<int> ("RefreshRate", 10);
                        set {
@@ -286,6 +300,18 @@ namespace CECrowPlugin
                                fiDbgIFace_MaxDiscardCount.SetValue (null, value);
                        }
                }
+               public bool EditMode {
+                       get => (bool)fiDbgIFace_Edition.GetValue(dbgIFace);
+                       set {
+                               if (EditMode == value)
+                                       return;
+                               fiDbgIFace_Edition.SetValue(dbgIFace, value);
+                               CMDEditMode.CanExecute = !value;
+                               CMDRun.CanExecute = value;
+                               NotifyValueChanged(value);
+                       }
+               }
+               
                public double ZoomFactor {
                        get => Configuration.Global.Get<Double> ("CrowPreviewZoomFactor", 1.0);
                        set {
@@ -533,6 +559,8 @@ namespace CECrowPlugin
 
                        fiDbgIFace_Terminate = dbgIfaceType.GetField("Terminate");
                        fiDbgIFace_IsDirty = dbgIfaceType.GetField("IsDirty");
+                       fiDbgIFace_Edition = dbgIfaceType.GetField("Edition");
+                       fiDbgIFace_UPDATE_INTERVAL = dbgIfaceType.GetField("UPDATE_INTERVAL", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);
                        fiDbgIFace_MaxLayoutingTries = dbgIfaceType.GetField("MaxLayoutingTries", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);
                        fiDbgIFace_MaxDiscardCount = dbgIfaceType.GetField("MaxDiscardCount", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);
 
@@ -689,8 +717,10 @@ namespace CECrowPlugin
                        if (CurrentState == Status.Running) {
                                try
                                {
-                                       //e.Handled = delMouseDown (e.Button);
-                                       CurrentWidget = HoverWidget;
+                                       if (EditMode)
+                                               CurrentWidget = HoverWidget;
+                                       else
+                                               e.Handled = delMouseDown (e.Button);
                                }
                                catch (System.Exception ex)
                                {
@@ -703,7 +733,10 @@ namespace CECrowPlugin
                        if (CurrentState == Status.Running) {
                                try
                                {
-                                       e.Handled = true;//delMouseUp (e.Button);
+                                       if (EditMode)
+                                               e.Handled = true;
+                                       else
+                                               delMouseUp (e.Button);
                                }
                                catch (System.Exception ex)
                                {
@@ -716,7 +749,10 @@ namespace CECrowPlugin
                        if (CurrentState == Status.Running) {
                                try
                                {
-                                       e.Handled = true;// delMouseWheelChanged (e.Delta);
+                                       if (EditMode)
+                                               e.Handled = true;
+                                       else
+                                               delMouseWheelChanged (e.Delta);
                                }
                                catch (System.Exception ex)
                                {
index 2555bf606ef23d4d2355d26d316a274b1f7e7701..e8f86c77b182f2863373f301791872d99b2b2d80 100644 (file)
@@ -52,10 +52,11 @@ namespace CECrowPlugin
                        };
                        t.Start ();
                }
-               public bool Terminate;
-               public bool Edition = true;
-               public bool FirstRenderingFinished = false;
+               public bool Terminate = false;
+        public bool Edition = true;
+        public bool FirstRenderingFinished = false;
                
+
                bool checkEditHoverWidget() {
                        if (lastEditHoverWidget != editHoverWidget) {
                                if (editHoverWidget == null)
@@ -89,6 +90,8 @@ namespace CECrowPlugin
                                                                lqiCount = LayoutingQueue.Count;
                                                }
                                                FirstRenderingFinished = true;
+                                       } else {
+                                               Update();
                                        }
                                }
                                catch (System.Exception ex)
@@ -191,9 +194,7 @@ namespace CECrowPlugin
                        }
                }
 
-
-               
-               void resetInterface () {
+        void resetInterface () {
                        ClearInterface();
                        initDictionaries();
                        foreach (object style in delCrowServiceGetStyling ()) {
index 0192b32ceb91e6bc85db1b5e0152172817450e14..e6ee64af594463fb03417622324bec6c768bf713 100644 (file)
@@ -46,15 +46,13 @@ namespace CECrowPlugin
                                                RegisterForGraphicUpdate ();
                                        }
                                }, "#icons.zoom-out.svg");
-                       //CMDRun = new ToggleCommand(this,"Run",,)
-
                        Thread t = new Thread (backgroundThreadFunc);
                        t.IsBackground = true;
                        t.Start ();
                }
         ~DebugInterfaceWidget() {
                        if (crowIFaceService != null)
-                               crowIFaceService.ValueChanged -= service_ValueChanged;                  
+                               crowIFaceService.ValueChanged -= service_ValueChanged;
                }
         void service_ValueChanged(object instance, ValueChangeEventArgs e) {
                        if (e.MemberName == "CurrentWidget") {
@@ -74,8 +72,10 @@ namespace CECrowPlugin
                ImlDocument document;
                ForeignWidgetContainer currentWidget, hoverWidget;
                
-               Command CMDRefresh, CMDZoomIn, CMDZoomOut, CMDRun;
+               Command CMDRefresh, CMDZoomIn, CMDZoomOut;
                public CommandGroup WindowCommands => new CommandGroup (
+                       crowIFaceService.CMDRun,
+                       crowIFaceService.CMDEditMode,
                        CMDRefresh, //CMDZoomIn, CMDZoomOut,
                        crowIFaceService.CMDStartRecording,
                        crowIFaceService.CMDStopRecording,
@@ -215,24 +215,26 @@ namespace CECrowPlugin
                        if (crowIFaceService != null && crowIFaceService.IsRunning && bmp != null) {
                                //crowIFaceService.LockRenderMutex();
                                paintCache (ctx, Slot + Parent.ClientRectangle.Position);
-                               if (hoverWidget != null && hoverWidget != currentWidget) {
-                                       //currentWidget.
-                                       RectangleD r = hoverWidget.GetScreenCoordinate() + Slot.Position + Parent.ClientRectangle.Position;
-                                       ctx.SetDash([1,3]);
-                                       ctx.SetSource(Colors.Yellow);
-                                       ctx.Rectangle(r, 1);
-                                       ctx.SetDash([]);
-                               }                               
-                               if (currentWidget != null) {
-                                       //currentWidget.
-                                       RectangleD r = currentWidget.GetScreenCoordinate() + Slot.Position + Parent.ClientRectangle.Position;
-                                       //ctx.ResetClip();
-                                       //ctx.SetDash([2,3]);
-                                       ctx.SetSource(Colors.White);
-                                       ctx.Rectangle(r.Inflated(1), 1);
-//                                     ctx.Stroke();
-                                       //ctx.SetDash([0]);
-                               }                               
+                               if (crowIFaceService.EditMode) {
+                                       if (hoverWidget != null && hoverWidget != currentWidget) {
+                                               //currentWidget.
+                                               RectangleD r = hoverWidget.GetScreenCoordinate() + Slot.Position + Parent.ClientRectangle.Position;
+                                               ctx.SetDash([1,3]);
+                                               ctx.SetSource(Colors.Yellow);
+                                               ctx.Rectangle(r, 1);
+                                               ctx.SetDash([]);
+                                       }                               
+                                       if (currentWidget != null) {
+                                               //currentWidget.
+                                               RectangleD r = currentWidget.GetScreenCoordinate() + Slot.Position + Parent.ClientRectangle.Position;
+                                               //ctx.ResetClip();
+                                               //ctx.SetDash([2,3]);
+                                               ctx.SetSource(Colors.White);
+                                               ctx.Rectangle(r.Inflated(1), 1);
+       //                                      ctx.Stroke();
+                                               //ctx.SetDash([0]);
+                                       }
+                               }
                                //crowIFaceService.UnlockRenderMutex();
                                crowIFaceService.ResetDirtyState ();
                        } 
index 2259b57248fa19b0ee189e6b26d0f99bfc965bed..e170ba1b2a3c1f833e1076b486cf181d7bc69154 100644 (file)
@@ -36,7 +36,7 @@ namespace CrowEdit.Xml
                        AddChild(new XMLSingleTokenSyntax(openTok));
                }
         public override bool IsComplete => HasOpeningToken && HasName &&  HasClosingToken;
-               public bool HasName => HasChilds && Children.ElementAtOrDefault(1).IsSimilar(XmlTokenType.ElementName);
+               public bool HasName => !string.IsNullOrEmpty(Name);
                public string Name => Children.ElementAtOrDefault(1) is SingleTokenSyntax sts &&
                                                          sts.token.GetTokenType() == XmlTokenType.ElementName ? sts.AsText(): "";
                public virtual bool HasOpeningToken => Children.FirstOrDefault() is SingleTokenSyntax sts && sts.token.GetTokenType() == XmlTokenType.ElementOpen;