From a5e5738dcf304b80781cf9ff85d02f953e9ee159 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Thu, 17 Jul 2025 00:57:09 +0200 Subject: [PATCH] CrowPlugin Edit/Run modes --- plugins/CECrowPlugin/src/CrowService.cs | 44 ++++++++++++++++-- plugins/CECrowPlugin/src/DebugInterface.cs | 13 +++--- .../CECrowPlugin/src/DebugInterfaceWidget.cs | 46 ++++++++++--------- .../CEXmlPlugin/src/Parsing/XmlSyntaxNodes.cs | 2 +- 4 files changed, 72 insertions(+), 33 deletions(-) diff --git a/plugins/CECrowPlugin/src/CrowService.cs b/plugins/CECrowPlugin/src/CrowService.cs index d38a4cf..2290204 100644 --- a/plugins/CECrowPlugin/src/CrowService.cs +++ b/plugins/CECrowPlugin/src/CrowService.cs @@ -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 ("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 ("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) { diff --git a/plugins/CECrowPlugin/src/DebugInterface.cs b/plugins/CECrowPlugin/src/DebugInterface.cs index 2555bf6..e8f86c7 100644 --- a/plugins/CECrowPlugin/src/DebugInterface.cs +++ b/plugins/CECrowPlugin/src/DebugInterface.cs @@ -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 ()) { diff --git a/plugins/CECrowPlugin/src/DebugInterfaceWidget.cs b/plugins/CECrowPlugin/src/DebugInterfaceWidget.cs index 0192b32..e6ee64a 100644 --- a/plugins/CECrowPlugin/src/DebugInterfaceWidget.cs +++ b/plugins/CECrowPlugin/src/DebugInterfaceWidget.cs @@ -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 (); } diff --git a/plugins/CEXmlPlugin/src/Parsing/XmlSyntaxNodes.cs b/plugins/CEXmlPlugin/src/Parsing/XmlSyntaxNodes.cs index 2259b57..e170ba1 100644 --- a/plugins/CEXmlPlugin/src/Parsing/XmlSyntaxNodes.cs +++ b/plugins/CEXmlPlugin/src/Parsing/XmlSyntaxNodes.cs @@ -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; -- 2.47.3