From: Jean-Philippe Bruyère Date: Tue, 4 Mar 2025 18:59:40 +0000 (+0100) Subject: Crow widget tree, wip X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=bb90c21fe425c9f996559bac253f71059c55f689;p=jp%2Fcrowedit.git Crow widget tree, wip --- diff --git a/CrowEditBase/CrowEditBase.csproj b/CrowEditBase/CrowEditBase.csproj index 569c244..f2eadad 100644 --- a/CrowEditBase/CrowEditBase.csproj +++ b/CrowEditBase/CrowEditBase.csproj @@ -17,7 +17,7 @@ - + diff --git a/CrowEditBase/icons/bug-1.svg b/CrowEditBase/icons/bug-1.svg deleted file mode 100644 index 8c73946..0000000 --- a/CrowEditBase/icons/bug-1.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/CrowEditBase/icons/bug.svg b/CrowEditBase/icons/bug.svg new file mode 100644 index 0000000..8c73946 --- /dev/null +++ b/CrowEditBase/icons/bug.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/CrowEditBase/icons/categories/Appearance.svg b/CrowEditBase/icons/categories/Appearance.svg new file mode 100644 index 0000000..8e425f7 --- /dev/null +++ b/CrowEditBase/icons/categories/Appearance.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/CrowEditBase/icons/categories/Behaviour.svg b/CrowEditBase/icons/categories/Behaviour.svg new file mode 100644 index 0000000..1f4c3ca --- /dev/null +++ b/CrowEditBase/icons/categories/Behaviour.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/CrowEditBase/icons/categories/Data.svg b/CrowEditBase/icons/categories/Data.svg new file mode 100644 index 0000000..65a8f06 --- /dev/null +++ b/CrowEditBase/icons/categories/Data.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/CrowEditBase/icons/categories/Divers.svg b/CrowEditBase/icons/categories/Divers.svg new file mode 100644 index 0000000..de5dd37 --- /dev/null +++ b/CrowEditBase/icons/categories/Divers.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/CrowEditBase/icons/categories/Layout.svg b/CrowEditBase/icons/categories/Layout.svg new file mode 100644 index 0000000..bbc9719 --- /dev/null +++ b/CrowEditBase/icons/categories/Layout.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/CrowEditBase/icons/crow.svg b/CrowEditBase/icons/crow.svg new file mode 100644 index 0000000..94f5cfc --- /dev/null +++ b/CrowEditBase/icons/crow.svg @@ -0,0 +1,16 @@ + + + + diff --git a/CrowEditBase/icons/exclamation.svg b/CrowEditBase/icons/exclamation.svg new file mode 100644 index 0000000..cc1b268 --- /dev/null +++ b/CrowEditBase/icons/exclamation.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/CrowEditBase/icons/presentation.svg b/CrowEditBase/icons/presentation.svg new file mode 100644 index 0000000..c79f5a4 --- /dev/null +++ b/CrowEditBase/icons/presentation.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/CrowEditBase/src/Service.cs b/CrowEditBase/src/Service.cs index 7d8f1cc..3f042a7 100644 --- a/CrowEditBase/src/Service.cs +++ b/CrowEditBase/src/Service.cs @@ -23,17 +23,20 @@ namespace CrowEditBase protected Service () { Name = this.GetType().Name; log = CrowEditBase.App.MainLog; + initCommands(); + //ensureConfigWinDataSource(); + Log(LogType.Low, $"[{Name}] Service Instanciated"); + } + public Command CMDStart, CMDStop, CMDPause, CMDOpenConfig; + public CommandGroup Commands; + void initCommands() { CMDStart = new ActionCommand ("Start", Start, "#icons.play-button.svg", true); CMDStop = new ActionCommand ("Stop", Stop, "#icons.stop.svg", false); CMDPause = new ActionCommand ("Pause", Pause, "#icons.pause-symbol.svg", false); CMDOpenConfig = new ActionCommand ("Service configuration", - () => CrowEditBase.App.LoadWindow (ConfigurationWindowPath, this), "#icons.cogwheel.svg", true); + () => CrowEditBase.App.LoadWindow (ServiceWindowsPath[0], this), "#icons.cogwheel.svg", true); Commands = new CommandGroup (CMDStart, CMDPause, CMDStop, CMDOpenConfig); - ensureConfigWinDataSource(); - Log(LogType.Low, $"[{Name}] Service Instanciated"); } - public Command CMDStart, CMDStop, CMDPause, CMDOpenConfig; - public CommandGroup Commands; Status currentState; public Status CurrentState { get => currentState; @@ -55,15 +58,16 @@ namespace CrowEditBase CMDStop.CanExecute = IsRunning || CurrentState == Status.Paused; Log(LogType.High, $"[{Name}] Status: {previousState} -> {newState}"); } - protected void ensureConfigWinDataSource() { - if (CrowEditBase.App.TryGetWindow (ConfigurationWindowPath, out Window win)) + /*protected void ensureConfigWinDataSource() { + if (CrowEditBase.App.TryGetWindow (ServiceWindowsPath[0], out Window win)) win.DataSource = this; - } + }*/ public readonly string Name; public abstract void Start (); public abstract void Stop (); public abstract void Pause (); - public virtual string ConfigurationWindowPath => "#ui.winServiceConfig.crow"; + //windows having this service as datasource + public virtual string[] ServiceWindowsPath => ["#ui.winServiceConfig.crow"]; public virtual Document OpenDocument (string fullPath) => null; } diff --git a/CrowEditBase/src/SourceEditor.cs b/CrowEditBase/src/SourceEditor.cs index ed51e45..8775135 100644 --- a/CrowEditBase/src/SourceEditor.cs +++ b/CrowEditBase/src/SourceEditor.cs @@ -4,13 +4,13 @@ using System; using Glfw; +using Crow; using Crow.Text; using Drawing2D; using System.Collections; using static CrowEditBase.CrowEditBase; using System.Collections.Generic; using System.Linq; -using Crow; using System.Text.Unicode; using System.Text; @@ -97,7 +97,7 @@ namespace CrowEditBase - + diff --git a/CrowEditBase/src/Suggestions.cs b/CrowEditBase/src/Suggestions.cs index 645c1dc..de63092 100644 --- a/CrowEditBase/src/Suggestions.cs +++ b/CrowEditBase/src/Suggestions.cs @@ -28,20 +28,4 @@ namespace CrowEditBase MemberInfo = memberInfo; } } - public class WidgetSuggestion : Suggestion { - public Type Type; - public override string Icon => $"#icons.{Type.FullName}.svg"; - public WidgetSuggestion(Type type, TextChange change = default, int finalPositionOffset = 0) - : base(type.Name, change, finalPositionOffset) { - Type = type; - } - } - public class ColorSuggestion : Suggestion { - public Fill Fill; - public override string Icon => $"#icons.fill.svg"; - public ColorSuggestion(Fill fill, TextChange change = default, int finalPositionOffset = 0) - : base(fill.ToString(), change, finalPositionOffset) { - Fill = fill; - } - } } \ No newline at end of file diff --git a/CrowEditBase/src/TextBuffer.cs b/CrowEditBase/src/TextBuffer.cs deleted file mode 100644 index 4d6981e..0000000 --- a/CrowEditBase/src/TextBuffer.cs +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (c) 2021-2021 Jean-Philippe Bruyère -// -// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) - -using System; -using System.Linq; -using System.Collections.Generic; -using Crow.Text; - -namespace CrowEditBase -{ - public class TextBuffer { - static int bufferExpension = 100; - int length; - Memory buffer; - ReadOnlyMemory origBuffer; - LineCollection lines; - public bool mixedLineBreak = false; - public string lineBreak = null; - - internal LineCollection GetLineListCopy() => new LineCollection(lines.ToArray()); - public Span Span => buffer.Span.Slice(0, length); - public ReadOnlySpan ReadOnlySpan => buffer.Span.Slice(0, length); - public bool IsEmpty => length == 0; - public bool IsDirty => !origBuffer.Span.Equals(Span, StringComparison.Ordinal); - public int LinesCount => lines.Count; - public int Length => length; - public ReadOnlyMemory ReadOnlyCopy { - get { - return ReadOnlySpan.ToArray(); - } - } - public void ResetDirtyState () { - origBuffer = Span.ToArray(); - } - public TextBuffer(ReadOnlySpan origText) { - length = origText.Length; - buffer = new char[length + bufferExpension]; - origText.CopyTo(buffer.Span); - lines = new LineCollection (10); - if (IsEmpty) - lines.Add (new TextLine (0, 0, 0)); - else - lines.Update (Span); - ResetDirtyState (); - } - public void Update (TextChange change) { - ReadOnlySpan orig = buffer.Span; - char[] newBuff = null; - Span tmp; - if (buffer.Length < length + change.CharDiff) { - newBuff = new char[length + change.CharDiff + bufferExpension]; - tmp = newBuff; - orig.Slice(0, change.Start).CopyTo(tmp); - if (change.CharDiff == 0) - orig.Slice(change.End, length - change.End).CopyTo(tmp.Slice(change.End)); - } else - tmp = buffer.Span; - - if (change.CharDiff != 0) - orig.Slice(change.End, length - change.End).CopyTo(tmp.Slice(change.End2)); - if (!string.IsNullOrEmpty (change.ChangedText)) - change.ChangedText.AsSpan ().CopyTo (tmp.Slice (change.Start)); - - if (newBuff != null) - buffer = newBuff; - length += change.CharDiff; - - lines.Update (change); - } - public string GetLineBreak () { - if (string.IsNullOrEmpty (lineBreak)) { - mixedLineBreak = false; - - if (lines.Count == 0 || lines[0].LineBreakLength == 0) - lineBreak = Environment.NewLine; - else { - lineBreak = ReadOnlySpan.GetLineBreak (lines[0]).ToString (); - for (int i = 1; i < lines.Count; i++) { - if (!ReadOnlySpan.GetLineBreak (lines[i]).SequenceEqual (lineBreak)) { - mixedLineBreak = true; - break; - } - } - } - } - return lineBreak; - } - public CharLocation GetLocation (int absolutePosition) => lines.GetLocation (absolutePosition); - public TextLine GetLine (int index) => lines[index]; - public void SetLine (int index, TextLine line) => lines[index] = line; - public ReadOnlySpan GetText (TextLine line) => GetText(line.Span); - public ReadOnlySpan GetText (TextSpan textSpan) => buffer.Span.Slice(textSpan.Start, textSpan.Length); - public int GetAbsolutePosition (CharLocation loc) => lines.GetAbsolutePosition (loc); - public CharLocation EndLocation => new CharLocation (lines.Count - 1, lines[lines.Count - 1].Length); - public override string ToString() => ReadOnlySpan.ToString(); - } -} \ No newline at end of file diff --git a/CrowEditBase/ui/MenuButton.template b/CrowEditBase/ui/MenuButton.template index d220f1a..3a3e2c6 100644 --- a/CrowEditBase/ui/MenuButton.template +++ b/CrowEditBase/ui/MenuButton.template @@ -1,7 +1,7 @@