From 290a7d9a9f2539c99f98fc1543c5b35ef405cd74 Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Sun, 16 Feb 2025 17:25:00 +0000 Subject: [PATCH 01/54] WIP - update to latest nuget pkg --- Showcase/Showcase.csproj | 2 +- src/Design.cs | 12 +++++------- src/Operations/OperationFactory.cs | 8 ++++---- src/TerminalGuiDesigner.csproj | 2 +- src/UI/Editor.cs | 8 ++++---- src/UI/MouseManager.cs | 6 +++--- src/UI/Windows/BigListBox.cs | 2 +- src/UI/Windows/ChoicesDialog.cs | 12 ++++++------ src/ViewExtensions.cs | 2 +- tests/Operations/DragOperationTests.cs | 2 +- tests/Operations/ResizeOperationTests.cs | 2 +- tests/Tests.cs | 6 +++--- tests/UI/MouseManagerTests.cs | 14 +++++++------- tests/ViewExtensionsTests.cs | 6 +++--- 14 files changed, 41 insertions(+), 43 deletions(-) diff --git a/Showcase/Showcase.csproj b/Showcase/Showcase.csproj index 41aa7203..207dd0e0 100644 --- a/Showcase/Showcase.csproj +++ b/Showcase/Showcase.csproj @@ -8,7 +8,7 @@ </PropertyGroup> <ItemGroup> - <PackageReference Include="Terminal.Gui" Version="2.0.0-v2-develop.2203" /> + <PackageReference Include="Terminal.Gui" Version="2.0.0-v2-develop.1532" /> </ItemGroup> </Project> diff --git a/src/Design.cs b/src/Design.cs index a789ef8b..9243d847 100644 --- a/src/Design.cs +++ b/src/Design.cs @@ -44,8 +44,6 @@ public class Design typeof(LineView), typeof(ListView), typeof(MenuBar), - typeof(ScrollBarView), - typeof(ScrollView), typeof(TableView), typeof(TabView), typeof(TreeView), @@ -228,7 +226,7 @@ public Design CreateSubControlDesign(string name, View subView) if (subView.GetType().IsGenericType(typeof(Slider<>))) { // TODO: Does not seem to work - subView.MouseEvent += (s, e) => SuppressNativeClickEvents(s, e,true); + subView.MouseEventArgs += (s, e) => SuppressNativeClickEvents(s, e,true); subView.MouseClick += (s, e) => SuppressNativeClickEvents(s,e, true); } @@ -258,7 +256,7 @@ public Design CreateSubControlDesign(string name, View subView) foreach (var v in subView.GetAllNonDesignableSubviews()) { v.MouseClick += (s,e)=>this.SuppressNativeClickEvents(s,e,true); - v.MouseEvent += (s, e) => this.SuppressNativeClickEvents(s, e, true); + v.MouseEventArgs += (s, e) => this.SuppressNativeClickEvents(s, e, true); } var d = new Design(this.SourceCode, name, subView); @@ -626,7 +624,7 @@ private void CreateSubControlDesigns(View view) } } - private void SuppressNativeClickEvents(object? sender, MouseEventEventArgs obj, bool alsoSuppressClick = false) + private void SuppressNativeClickEvents(object? sender, MouseEventArgs obj, bool alsoSuppressClick = false) { if (alsoSuppressClick) { @@ -635,7 +633,7 @@ private void SuppressNativeClickEvents(object? sender, MouseEventEventArgs obj, else { // Suppress everything except single click (selection) - obj.Handled = obj.MouseEvent.Flags != MouseFlags.Button1Clicked; + obj.Handled = obj.Flags != MouseFlags.Button1Clicked; } } @@ -662,7 +660,7 @@ private void RegisterCheckboxDesignTimeChanges(CheckBox cb) cb.KeyBindings.Remove(Key.Space); cb.MouseClick += (s, e) => { - if (e.MouseEvent.Flags.HasFlag(MouseFlags.Button1Clicked)) + if (e.Flags.HasFlag(MouseFlags.Button1Clicked)) { e.Handled = true; cb.SetFocus(); diff --git a/src/Operations/OperationFactory.cs b/src/Operations/OperationFactory.cs index 84fcf032..9ec55f3b 100644 --- a/src/Operations/OperationFactory.cs +++ b/src/Operations/OperationFactory.cs @@ -26,12 +26,12 @@ public OperationFactory(PropertyValueGetterDelegate valueGetter) /// set of <see cref="Design"/> given the mouse state. /// </summary> /// <param name="selected">All <see cref="Design"/> that are currently selected (see <see cref="SelectionManager"/>).</param> - /// <param name="m"><see cref="MouseEvent"/> (if any) that prompted this request e.g. if user right clicks a <see cref="Design"/>.</param> + /// <param name="m"><see cref="MouseEventArgs"/> (if any) that prompted this request e.g. if user right clicks a <see cref="Design"/>.</param> /// <param name="rightClicked">If <paramref name="m"/> is populated then this should be the <see cref="Design"/> wrapper for - /// the <see cref="View"/> that the mouse was over at the time it was clicked (see <see cref="ViewExtensions.HitTest(View, MouseEvent, out bool, out bool, View[])"/>.</param> + /// the <see cref="View"/> that the mouse was over at the time it was clicked (see <see cref="ViewExtensions.HitTest(View, MouseEventArgs, out bool, out bool, View[])"/>.</param> /// <param name="name">String that represents what the returned <see cref="IOperation"/> act upon e.g. "myLabel" or "8 objects".</param> /// <returns>Collection of all <see cref="IOperation"/> that can be offered to user as runnable given the current selection.</returns> - public IEnumerable<IOperation> CreateOperations(Design[] selected, MouseEvent? m, Design? rightClicked, out string name) + public IEnumerable<IOperation> CreateOperations(Design[] selected, MouseEventArgs? m, Design? rightClicked, out string name) { List<IOperation> toReturn = new(); @@ -99,7 +99,7 @@ public IEnumerable<IOperation> CreateOperations(Design[] selected, MouseEvent? m return toReturn; } - private IEnumerable<IOperation> CreateOperations(MouseEvent? m, Design d) + private IEnumerable<IOperation> CreateOperations(MouseEventArgs? m, Design d) { var ops = m == null ? d.GetExtraOperations() : diff --git a/src/TerminalGuiDesigner.csproj b/src/TerminalGuiDesigner.csproj index 730d58b9..a1afacac 100644 --- a/src/TerminalGuiDesigner.csproj +++ b/src/TerminalGuiDesigner.csproj @@ -150,7 +150,7 @@ <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.1" /> <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" /> <PackageReference Include="NetEscapades.Configuration.Yaml" Version="3.1.0" /> - <PackageReference Include="Terminal.Gui" Version="2.0.0-v2-develop.2203" /> + <PackageReference Include="Terminal.Gui" Version="2.0.0-v2-develop.1532" /> <PackageReference Include="nlog" Version="5.3.3" /> <PackageReference Include="Basic.Reference.Assemblies.Net80" Version="1.7.7" /> <PackageReference Include="System.CodeDom" Version="8.0.0" /> diff --git a/src/UI/Editor.cs b/src/UI/Editor.cs index 4f0b63b1..22168d1a 100644 --- a/src/UI/Editor.cs +++ b/src/UI/Editor.cs @@ -143,7 +143,7 @@ public void Run(Options options) } }; - Application.MouseEvent += (s, m) => + Application.MouseEventArgs += (s, m) => { // if another window is showing don't respond to mouse if (!this.IsCurrentTop) @@ -369,7 +369,7 @@ ________ .__ ________ .__ int y = artStartY + i; var colorAtPoint = fill.GetColor(new Point(x, y)); - Driver.SetAttribute(new Attribute(new Color(colorAtPoint), new Color(ColorName.Black))); + Driver.SetAttribute(new Attribute(new Color(colorAtPoint), new Color(Color.Black))); this.AddRune(x, y, (Rune)line[j]); } } @@ -384,7 +384,7 @@ ________ .__ ________ .__ int y = versionLineY; var colorAtPoint = fill.GetColor(new Point(x, y)); - Driver.SetAttribute(new Attribute(new Color(colorAtPoint), new Color(ColorName.Black))); + Driver.SetAttribute(new Attribute(new Color(colorAtPoint), new Color(Color.Black))); this.AddRune(x, y, (Rune)versionLine[i]); } } @@ -782,7 +782,7 @@ private void Editor_Closing(object? sender, ToplevelClosingEventArgs obj) } } - private void CreateAndShowContextMenu(MouseEvent? m, Design? rightClicked) + private void CreateAndShowContextMenu(MouseEventArgs? m, Design? rightClicked) { if (this.viewBeingEdited == null) { diff --git a/src/UI/MouseManager.cs b/src/UI/MouseManager.cs index 0144ad58..082c42c7 100644 --- a/src/UI/MouseManager.cs +++ b/src/UI/MouseManager.cs @@ -4,7 +4,7 @@ namespace TerminalGuiDesigner.UI; /// <summary> -/// Manages responding to <see cref="Application.RootMouseEvent"/> e.g. by +/// Manages responding to root mouse e.g. by /// dragging <see cref="Design"/> around and/or resizing. /// </summary> public class MouseManager @@ -34,9 +34,9 @@ public class MouseManager /// Responds to <see cref="Application.RootMouseEvent"/>(by changing a 'drag a box' selection area /// or starting a resize etc). /// </summary> - /// <param name="m">The <see cref="MouseEvent"/> reported by <see cref="Application.RootMouseEvent"/>.</param> + /// <param name="m">The <see cref="MouseEventArgs"/> reported by <see cref="Application.RootMouseEvent"/>.</param> /// <param name="viewBeingEdited">The root <see cref="Design"/> that is open in the <see cref="Editor"/>.</param> - public void HandleMouse(MouseEvent m, Design viewBeingEdited) + public void HandleMouse(MouseEventArgs m, Design viewBeingEdited) { // start dragging if (m.Flags.HasFlag(MouseFlags.Button1Pressed) diff --git a/src/UI/Windows/BigListBox.cs b/src/UI/Windows/BigListBox.cs index aabb9429..d81b9647 100644 --- a/src/UI/Windows/BigListBox.cs +++ b/src/UI/Windows/BigListBox.cs @@ -206,7 +206,7 @@ private void Accept() private void ListView_MouseClick(object? sender, MouseEventEventArgs obj) { - if (obj.MouseEvent.Flags.HasFlag(MouseFlags.Button1DoubleClicked)) + if (obj.MouseEventArgs.Flags.HasFlag(MouseFlags.Button1DoubleClicked)) { obj.Handled = true; this.Accept(); diff --git a/src/UI/Windows/ChoicesDialog.cs b/src/UI/Windows/ChoicesDialog.cs index d91eb39d..57d56801 100644 --- a/src/UI/Windows/ChoicesDialog.cs +++ b/src/UI/Windows/ChoicesDialog.cs @@ -59,12 +59,12 @@ public ChoicesDialog(string title, string message, params string[] options) { var i2 = i; - buttons[i].Accept += (s,e) => { + buttons[i].Accepting += (s,e) => { Result = i2; Application.RequestStop(); }; - buttons[i].DrawContentComplete += (s,r) => + buttons[i].DrawComplete += (s,r) => ChoicesDialog.PaintShadow(buttons[i2], ColorScheme); } @@ -98,16 +98,16 @@ public ChoicesDialog(string title, string message, params string[] options) { Width = Math.Min(Math.Max(maxWidthLine, Math.Max(Title.GetColumns(), Math.Max(textWidth + 2, buttonWidth))), Application.Driver.Cols); Height = msgboxHeight; } - + /// <inheritdoc/> - public override void OnDrawContentComplete(Rectangle bounds) + protected override void OnDrawComplete() { - base.OnDrawContentComplete(bounds); + base.OnDrawComplete(); var screenTopLeft = FrameToScreen(); Driver.Move(screenTopLeft.X+2, screenTopLeft.Y); - var padding = ((bounds.Width - _title.EnumerateRunes().Sum(v=>v.GetColumns())) / 2) - 1; + var padding = ((Viewport.Width - _title.EnumerateRunes().Sum(v=>v.GetColumns())) / 2) - 1; Driver.SetAttribute( new Attribute(ColorScheme.Normal.Foreground, ColorScheme.Normal.Background)); diff --git a/src/ViewExtensions.cs b/src/ViewExtensions.cs index fc9de70b..70643a69 100644 --- a/src/ViewExtensions.cs +++ b/src/ViewExtensions.cs @@ -250,7 +250,7 @@ public static bool IsBorderlessContainerView(this View v) /// <param name="isLowerRight">True if the click lands in the lower right of the returned <see cref="View"/>.</param> /// <param name="ignoring">One or more <see cref="View"/> to ignore (click through) when performing the hit test.</param> /// <returns>The <see cref="View"/> at the given screen location or null if none found.</returns> - public static View? HitTest(this View w, MouseEvent m, out bool isBorder, out bool isLowerRight, params View[] ignoring) + public static View? HitTest(this View w, MouseEventArgs m, out bool isBorder, out bool isLowerRight, params View[] ignoring) { ignoring = ignoring.Union(w.GetAllNonDesignableSubviews()).ToArray(); diff --git a/tests/Operations/DragOperationTests.cs b/tests/Operations/DragOperationTests.cs index 966e4c96..a7d8d387 100644 --- a/tests/Operations/DragOperationTests.cs +++ b/tests/Operations/DragOperationTests.cs @@ -277,7 +277,7 @@ public void TestSimpleDrag_OutOfFrameView_IntoRootWindow() ClassicAssert.AreEqual(14, screen.Y, "Expected label Y screen to be at its parents 0,0 (11,11) + 2"); // press down at 0,0 of the label - ClassicAssert.AreEqual(lbl, rootDesign.View.HitTest(new MouseEvent { Position = new Point(13, 14) }, out _, out _) + ClassicAssert.AreEqual(lbl, rootDesign.View.HitTest(new MouseEventArgs { Position = new Point(13, 14) }, out _, out _) , "We just asked ViewToScreen for these same coordinates, how can they fail HitTest now?"); // Drag up 4 so it is no longer in its parents container. diff --git a/tests/Operations/ResizeOperationTests.cs b/tests/Operations/ResizeOperationTests.cs index f30019ba..17733b41 100644 --- a/tests/Operations/ResizeOperationTests.cs +++ b/tests/Operations/ResizeOperationTests.cs @@ -74,7 +74,7 @@ public void TestResizeWhenNotAtOrigin(bool withMouse) } else { - var hit = root.View.HitTest(new MouseEvent {Position = new Point(13, 11) },out _, out var isLowerRight); + var hit = root.View.HitTest(new MouseEventArgs {Position = new Point(13, 11) },out _, out var isLowerRight); ClassicAssert.AreSame(tab, hit, "Expected above diagram which already passed asserts to work for HitTest too given the above screen coordinates"); ClassicAssert.IsTrue(isLowerRight); diff --git a/tests/Tests.cs b/tests/Tests.cs index af59c7ef..4ca1dd16 100644 --- a/tests/Tests.cs +++ b/tests/Tests.cs @@ -133,7 +133,7 @@ protected static void MouseDrag(Design root, int x1, int y1, int x2, int y2) var mm = new MouseManager(); mm.HandleMouse( - new MouseEvent + new MouseEventArgs { Position = new Point(x1, y1), Flags = MouseFlags.Button1Pressed, @@ -141,7 +141,7 @@ protected static void MouseDrag(Design root, int x1, int y1, int x2, int y2) // press down at 0,0 of the label mm.HandleMouse( - new MouseEvent + new MouseEventArgs { Position = new Point(x2, y2), Flags = MouseFlags.Button1Pressed, @@ -150,7 +150,7 @@ protected static void MouseDrag(Design root, int x1, int y1, int x2, int y2) // release in parent mm.HandleMouse( - new MouseEvent + new MouseEventArgs { Position = new Point(x2,y2), Flags = MouseFlags.Button1Released, diff --git a/tests/UI/MouseManagerTests.cs b/tests/UI/MouseManagerTests.cs index 04445c65..52eef9e6 100644 --- a/tests/UI/MouseManagerTests.cs +++ b/tests/UI/MouseManagerTests.cs @@ -34,7 +34,7 @@ public void DragResizeView<T>( [ValueSource( nameof( DragResizeView_Types ) )] T } ); // user presses down in the lower right of control - MouseEvent e = new( ) + MouseEventArgs e = new( ) { Position = new Point( 6, 0), Flags = MouseFlags.Button1Pressed @@ -112,7 +112,7 @@ public void DragResizeView_CannotResize_1By1View( [Values( 0, 3 )] int locationO } ); // user presses down in the lower right of control - MouseEvent e = new( ) + MouseEventArgs e = new( ) { Position = new Point(locationOfViewX,locationOfViewY), Flags = MouseFlags.Button1Pressed @@ -178,7 +178,7 @@ public void DragResizeView_CannotResize_DimFill<T>( T dummy ) } ); // user presses down in the lower right of control - MouseEvent e = new( ) + MouseEventArgs e = new( ) { Position = new Point(9,0), Flags = MouseFlags.Button1Pressed @@ -294,7 +294,7 @@ public void DragSelectionBox( int xStart, int yStart, int xEnd, int yEnd, int[] MouseManager mgr = new( ); // user presses down - MouseEvent e = new( ) + MouseEventArgs e = new( ) { Position = new Point(xStart,yStart), Flags = MouseFlags.Button1Pressed @@ -357,7 +357,7 @@ public void DragView<T>( [ValueSource( nameof( GetDummyViewsForDrag ) )] T dummy Assume.That( view.Y, Is.EqualTo( (Pos)initialViewYPos ) ); // user presses down over the control - MouseEvent firstClick = new( ) + MouseEventArgs firstClick = new( ) { Position = new Point(startDragX,startDragY), Flags = MouseFlags.Button1Pressed @@ -375,7 +375,7 @@ public void DragView<T>( [ValueSource( nameof( GetDummyViewsForDrag ) )] T dummy } ); // user moved view but still has mouse down - MouseEvent dragWithMouseButton1Down = new( ) + MouseEventArgs dragWithMouseButton1Down = new( ) { Position = new Point( startDragX + deltaX, @@ -394,7 +394,7 @@ public void DragView<T>( [ValueSource( nameof( GetDummyViewsForDrag ) )] T dummy } ); // user releases mouse - MouseEvent releaseMouseButton1AtNewCoordinates = new( ) + MouseEventArgs releaseMouseButton1AtNewCoordinates = new( ) { Position = new Point( startDragX + deltaX, diff --git a/tests/ViewExtensionsTests.cs b/tests/ViewExtensionsTests.cs index 925d5c18..559ad6d7 100644 --- a/tests/ViewExtensionsTests.cs +++ b/tests/ViewExtensionsTests.cs @@ -37,7 +37,7 @@ public void TestHitTest(int x, int y, bool hit, bool border, bool lowerRight) bool isBorder; var result = v.HitTest( - new MouseEvent + new MouseEventArgs { Position = new Point(x, y), }, out isBorder, out isLowerRight); @@ -96,12 +96,12 @@ public void TestHitTest_WindowWithFrameView_InBorder() Application.Begin(w); w.LayoutSubviews(); - ClassicAssert.AreSame(w, w.HitTest(new MouseEvent {Position = new Point(13, 0) }, out var isBorder, out _), + ClassicAssert.AreSame(w, w.HitTest(new MouseEventArgs {Position = new Point(13, 0) }, out var isBorder, out _), "Expected 0,0 to be the window border (its client area should start at 1,1)"); ClassicAssert.IsTrue(isBorder); // 1,1 - ClassicAssert.AreSame(f, w.HitTest(new MouseEvent {Position = new Point(1, 1) }, out isBorder, out _), + ClassicAssert.AreSame(f, w.HitTest(new MouseEventArgs {Position = new Point(1, 1) }, out isBorder, out _), "Expected 1,1 to be the Frame border (its client area should start at 1,1)"); ClassicAssert.IsTrue(isBorder); } From 8c8b5c0ffc2a91f1cc4fb996e24beca718ed1ef4 Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Sun, 16 Feb 2025 17:49:30 +0000 Subject: [PATCH 02/54] Progress towards building --- src/ContextMenuExtensions.cs | 19 ++++++++ src/Design.cs | 4 +- src/DesignState.cs | 11 +++-- src/Operations/AddViewOperation.cs | 6 +-- src/Operations/Generics/AddOperation.cs | 2 +- .../Generics/GenericArrayOperation.cs | 10 ++-- src/Operations/Generics/MoveOperation.cs | 4 +- src/Operations/Generics/RemoveOperation.cs | 2 +- src/Operations/Generics/RenameOperation.cs | 6 +-- .../MenuOperations/AddMenuItemOperation.cs | 2 +- .../ConvertMenuItemToSeperatorOperation.cs | 4 +- .../MoveMenuItemLeftOperation.cs | 2 +- .../MenuOperations/MoveMenuItemOperation.cs | 2 +- .../MoveMenuItemRightOperation.cs | 2 +- .../MenuOperations/RemoveMenuItemOperation.cs | 4 +- .../TabOperations/RemoveTabOperation.cs | 4 +- .../TableViewOperations/AddColumnOperation.cs | 4 +- src/ToCode/Property.cs | 2 +- src/UI/ColorSchemeBlueprint.cs | 46 +++++++++---------- src/UI/Editor.cs | 28 ++++++----- src/UI/KeyMap.cs | 2 +- src/UI/KeyboardManager.cs | 6 +-- src/UI/MouseManager.cs | 8 ++-- src/UI/Windows/ArrayEditor.cs | 10 ++-- src/UI/Windows/ColorPicker.cs | 2 +- src/UI/Windows/DimEditor.cs | 8 ++-- src/UI/Windows/ExceptionViewer.cs | 2 +- src/UI/Windows/GetTextDialog.cs | 6 +-- src/UI/Windows/PosEditor.cs | 8 ++-- 29 files changed, 122 insertions(+), 94 deletions(-) create mode 100644 src/ContextMenuExtensions.cs diff --git a/src/ContextMenuExtensions.cs b/src/ContextMenuExtensions.cs new file mode 100644 index 00000000..c920da5e --- /dev/null +++ b/src/ContextMenuExtensions.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Terminal.Gui; + +namespace TerminalGuiDesigner; + +internal static class ContextMenuExtensions +{ + public static void SetMenuItems(this ContextMenu menu, MenuBarItem? value) + { + var prop = typeof(ContextMenu).GetProperty(nameof(ContextMenu.MenuItems)) + ?? throw new Exception($"Expected property {nameof(ContextMenu.MenuItems)} did not exist on {nameof(ContextMenu)}"); + prop.SetValue(menu,value); + } +} + diff --git a/src/Design.cs b/src/Design.cs index 9243d847..1b04d61b 100644 --- a/src/Design.cs +++ b/src/Design.cs @@ -226,7 +226,7 @@ public Design CreateSubControlDesign(string name, View subView) if (subView.GetType().IsGenericType(typeof(Slider<>))) { // TODO: Does not seem to work - subView.MouseEventArgs += (s, e) => SuppressNativeClickEvents(s, e,true); + subView.MouseEvent += (s, e) => SuppressNativeClickEvents(s, e,true); subView.MouseClick += (s, e) => SuppressNativeClickEvents(s,e, true); } @@ -256,7 +256,7 @@ public Design CreateSubControlDesign(string name, View subView) foreach (var v in subView.GetAllNonDesignableSubviews()) { v.MouseClick += (s,e)=>this.SuppressNativeClickEvents(s,e,true); - v.MouseEventArgs += (s, e) => this.SuppressNativeClickEvents(s, e, true); + v.MouseEvent += (s, e) => this.SuppressNativeClickEvents(s, e, true); } var d = new Design(this.SourceCode, name, subView); diff --git a/src/DesignState.cs b/src/DesignState.cs index 22c2c411..930c2cd3 100644 --- a/src/DesignState.cs +++ b/src/DesignState.cs @@ -22,8 +22,8 @@ public DesignState(Design design) { this.Design = design; this.OriginalScheme = this.Design.View.GetExplicitColorScheme(); - this.Design.View.DrawContentComplete += this.DrawContentComplete; - this.Design.View.Enter += this.Enter; + this.Design.View.DrawComplete += this.DrawContentComplete; + this.Design.View.HasFocusChanged += this.Enter; } /// <summary> @@ -39,8 +39,13 @@ public DesignState(Design design) /// </summary> public Design Design { get; } - private void Enter(object? sender, FocusEventArgs obj) + private void Enter(object? sender, HasFocusEventArgs obj) { + // it's not enter + if (!obj.NewValue) + { + return; + } // when tabbing or clicking into this View when nothing complicated is going on (e.g. Ctrl+Click multi select) if (SelectionManager.Instance.Selected.Count <= 1) { diff --git a/src/Operations/AddViewOperation.cs b/src/Operations/AddViewOperation.cs index ed890487..f518b933 100644 --- a/src/Operations/AddViewOperation.cs +++ b/src/Operations/AddViewOperation.cs @@ -55,7 +55,7 @@ public override void Redo() var v = this.GetViewToAddTo(); v.Add(this.add); - v.SetNeedsDisplay(); + v.SetNeedsDraw(); } /// <inheritdoc/> @@ -68,7 +68,7 @@ public override void Undo() var v = this.GetViewToAddTo(); v.Remove(this.add); - v.SetNeedsDisplay(); + v.SetNeedsDraw(); } /// <inheritdoc/> @@ -118,7 +118,7 @@ protected override bool DoImpl() SelectionManager.Instance.ForceSetSelection(design); - v.SetNeedsDisplay(); + v.SetNeedsDraw(); return true; } diff --git a/src/Operations/Generics/AddOperation.cs b/src/Operations/Generics/AddOperation.cs index e49edbf2..c0871812 100644 --- a/src/Operations/Generics/AddOperation.cs +++ b/src/Operations/Generics/AddOperation.cs @@ -83,7 +83,7 @@ protected override bool DoImpl() this.newItem = this.elementFactory(this.View, uniqueName); this.Add(this.newItem); - this.SetNeedsDisplay(); + this.SetNeedsDraw(); return true; } } \ No newline at end of file diff --git a/src/Operations/Generics/GenericArrayOperation.cs b/src/Operations/Generics/GenericArrayOperation.cs index 1b54c7d4..5f1cba9d 100644 --- a/src/Operations/Generics/GenericArrayOperation.cs +++ b/src/Operations/Generics/GenericArrayOperation.cs @@ -63,16 +63,16 @@ protected virtual void Add(T2? newItem) current.Add(newItem); this.ArraySetter(this.View, current.Cast<T2>().ToArray()); - this.SetNeedsDisplay(); + this.SetNeedsDraw(); } /// <summary> /// Calls any update/refresh status code that is needed after making changes to collection. - /// Default implementation just calls <see cref="View.SetNeedsDisplay()"/> on <see cref="View"/>. + /// Default implementation just calls <see cref="View.SetNeedsDraw()"/> on <see cref="View"/>. /// </summary> - protected virtual void SetNeedsDisplay() + protected virtual void SetNeedsDraw() { - this.View.SetNeedsDisplay(); + this.View.SetNeedsDraw(); } /// <summary> @@ -92,7 +92,7 @@ protected bool Remove(T2? toRemove) current.Remove(toRemove); this.ArraySetter(this.View, current.Cast<T2>().ToArray()); - this.SetNeedsDisplay(); + this.SetNeedsDraw(); return true; } diff --git a/src/Operations/Generics/MoveOperation.cs b/src/Operations/Generics/MoveOperation.cs index 38db9bad..145bfeca 100644 --- a/src/Operations/Generics/MoveOperation.cs +++ b/src/Operations/Generics/MoveOperation.cs @@ -94,7 +94,7 @@ public override void Undo() list.Insert(this.originalIdx, this.OperateOn); this.ArraySetter(this.View, list.Cast<T2>().ToArray()); - this.SetNeedsDisplay(); + this.SetNeedsDraw(); } /// <inheritdoc/> @@ -106,7 +106,7 @@ protected override bool DoImpl() list.Insert(this.newIndex, this.OperateOn); this.ArraySetter(this.View, list.Cast<T2>().ToArray()); - this.SetNeedsDisplay(); + this.SetNeedsDraw(); return true; } } diff --git a/src/Operations/Generics/RemoveOperation.cs b/src/Operations/Generics/RemoveOperation.cs index da98e0c3..7695b2e9 100644 --- a/src/Operations/Generics/RemoveOperation.cs +++ b/src/Operations/Generics/RemoveOperation.cs @@ -44,7 +44,7 @@ public override void Undo() var current = this.ArrayGetter(this.View).Cast<T2>().ToList(); current.Insert(this.idx, this.OperateOn); this.ArraySetter(this.View, current.ToArray()); - this.SetNeedsDisplay(); + this.SetNeedsDraw(); } /// <inheritdoc/> diff --git a/src/Operations/Generics/RenameOperation.cs b/src/Operations/Generics/RenameOperation.cs index b2e086c0..fbed0591 100644 --- a/src/Operations/Generics/RenameOperation.cs +++ b/src/Operations/Generics/RenameOperation.cs @@ -57,14 +57,14 @@ public override void Redo() } this.stringSetter(this.OperateOn, this.newName); - this.SetNeedsDisplay(); + this.SetNeedsDraw(); } /// <inheritdoc/> public override void Undo() { this.stringSetter(this.OperateOn, this.originalName); - this.SetNeedsDisplay(); + this.SetNeedsDraw(); } /// <inheritdoc/> @@ -84,7 +84,7 @@ protected override bool DoImpl() } this.stringSetter(this.OperateOn, this.newName); - this.SetNeedsDisplay(); + this.SetNeedsDraw(); return true; } diff --git a/src/Operations/MenuOperations/AddMenuItemOperation.cs b/src/Operations/MenuOperations/AddMenuItemOperation.cs index 35c5056b..d0f8dccb 100644 --- a/src/Operations/MenuOperations/AddMenuItemOperation.cs +++ b/src/Operations/MenuOperations/AddMenuItemOperation.cs @@ -79,7 +79,7 @@ private bool Add(MenuItem menuItem) children.Insert(insertAt, menuItem); this.Parent.Children = children.ToArray(); - this.Bar?.SetNeedsDisplay(); + this.Bar?.SetNeedsDraw(); return true; } diff --git a/src/Operations/MenuOperations/ConvertMenuItemToSeperatorOperation.cs b/src/Operations/MenuOperations/ConvertMenuItemToSeperatorOperation.cs index b1a6e468..235fcc68 100644 --- a/src/Operations/MenuOperations/ConvertMenuItemToSeperatorOperation.cs +++ b/src/Operations/MenuOperations/ConvertMenuItemToSeperatorOperation.cs @@ -39,7 +39,7 @@ public override void Undo() children[this.removedAtIdx] = this.OperateOn; this.Parent.Children = children.ToArray(); - this.Bar?.SetNeedsDisplay(); + this.Bar?.SetNeedsDraw(); } /// <inheritdoc/> @@ -56,7 +56,7 @@ protected override bool DoImpl() children[this.removedAtIdx] = null; this.Parent.Children = children.ToArray(); - this.Bar?.SetNeedsDisplay(); + this.Bar?.SetNeedsDraw(); return true; } diff --git a/src/Operations/MenuOperations/MoveMenuItemLeftOperation.cs b/src/Operations/MenuOperations/MoveMenuItemLeftOperation.cs index 3bcfe173..d8a51df1 100644 --- a/src/Operations/MenuOperations/MoveMenuItemLeftOperation.cs +++ b/src/Operations/MenuOperations/MoveMenuItemLeftOperation.cs @@ -94,7 +94,7 @@ protected override bool DoImpl() MenuTracker.Instance.ConvertEmptyMenus(); - this.Bar?.SetNeedsDisplay(); + this.Bar?.SetNeedsDraw(); return true; } diff --git a/src/Operations/MenuOperations/MoveMenuItemOperation.cs b/src/Operations/MenuOperations/MoveMenuItemOperation.cs index 75c7f1b8..25ee9ac2 100644 --- a/src/Operations/MenuOperations/MoveMenuItemOperation.cs +++ b/src/Operations/MenuOperations/MoveMenuItemOperation.cs @@ -80,7 +80,7 @@ private bool Move(int amount) this.siblings.Insert(moveTo, this.OperateOn); this.Parent.Children = this.siblings.ToArray(); - this.Bar?.SetNeedsDisplay(); + this.Bar?.SetNeedsDraw(); return true; } diff --git a/src/Operations/MenuOperations/MoveMenuItemRightOperation.cs b/src/Operations/MenuOperations/MoveMenuItemRightOperation.cs index 39800333..7e1bcbdb 100644 --- a/src/Operations/MenuOperations/MoveMenuItemRightOperation.cs +++ b/src/Operations/MenuOperations/MoveMenuItemRightOperation.cs @@ -96,7 +96,7 @@ protected override bool DoImpl() // update the sub-menu addTo.Children = submenuChildren.ToArray(); - this.Bar?.SetNeedsDisplay(); + this.Bar?.SetNeedsDraw(); return true; } diff --git a/src/Operations/MenuOperations/RemoveMenuItemOperation.cs b/src/Operations/MenuOperations/RemoveMenuItemOperation.cs index c6cc9d60..284930ff 100644 --- a/src/Operations/MenuOperations/RemoveMenuItemOperation.cs +++ b/src/Operations/MenuOperations/RemoveMenuItemOperation.cs @@ -70,7 +70,7 @@ public override void Undo() this.OperateOn, .. Parent.Children[ removedAtIdx .. ] ]; - this.Bar?.SetNeedsDisplay(); + this.Bar?.SetNeedsDraw(); // if any MenuBarItem were converted to vanilla MenuItem // because we were removed from a sub-menu then convert @@ -131,7 +131,7 @@ protected override bool DoImpl() .. Parent.Children[ ..removedAtIdx ], .. Parent.Children[ ( removedAtIdx + 1 ).. ] ]; - this.Bar?.SetNeedsDisplay(); + this.Bar?.SetNeedsDraw(); if (this.Bar != null) { diff --git a/src/Operations/TabOperations/RemoveTabOperation.cs b/src/Operations/TabOperations/RemoveTabOperation.cs index 4a447bc1..afad922e 100644 --- a/src/Operations/TabOperations/RemoveTabOperation.cs +++ b/src/Operations/TabOperations/RemoveTabOperation.cs @@ -26,13 +26,13 @@ public RemoveTabOperation(Design design, Tab toRemove) } /// <inheritdoc/> - protected override void SetNeedsDisplay() + protected override void SetNeedsDraw() { if (!this.View.Tabs.Contains(this.View.SelectedTab)) { this.View.SelectedTab = this.View.Tabs.FirstOrDefault(); } - base.SetNeedsDisplay(); + base.SetNeedsDraw(); } } diff --git a/src/Operations/TableViewOperations/AddColumnOperation.cs b/src/Operations/TableViewOperations/AddColumnOperation.cs index d524ff19..72682afe 100644 --- a/src/Operations/TableViewOperations/AddColumnOperation.cs +++ b/src/Operations/TableViewOperations/AddColumnOperation.cs @@ -28,9 +28,9 @@ public AddColumnOperation(Design design, string? newColumnName) } /// <inheritdoc/> - protected override void SetNeedsDisplay() + protected override void SetNeedsDraw() { this.View.Update(); - base.SetNeedsDisplay(); + base.SetNeedsDraw(); } } diff --git a/src/ToCode/Property.cs b/src/ToCode/Property.cs index 4df3c3a1..4be009a2 100644 --- a/src/ToCode/Property.cs +++ b/src/ToCode/Property.cs @@ -476,6 +476,6 @@ private void CallRefreshMethodsIfAny() cp.ApplyStyleChanges(); } - this.Design.View.SetNeedsDisplay(); + this.Design.View.SetNeedsDraw(); } } \ No newline at end of file diff --git a/src/UI/ColorSchemeBlueprint.cs b/src/UI/ColorSchemeBlueprint.cs index 85e0760b..c5d48af2 100644 --- a/src/UI/ColorSchemeBlueprint.cs +++ b/src/UI/ColorSchemeBlueprint.cs @@ -10,69 +10,69 @@ namespace TerminalGuiDesigner.UI; /// Serializable version of <see cref="ColorScheme"/>. /// </summary> [YamlSerializable] -public record ColorSchemeBlueprint( ColorName NormalForeground, ColorName NormalBackground, ColorName HotNormalForeground, ColorName HotNormalBackground, ColorName FocusForeground, ColorName FocusBackground, ColorName HotFocusForeground, ColorName HotFocusBackground, ColorName DisabledForeground, ColorName DisabledBackground ) +public record ColorSchemeBlueprint( Color NormalForeground, Color NormalBackground, Color HotNormalForeground, Color HotNormalBackground, Color FocusForeground, Color FocusBackground, Color HotFocusForeground, Color HotFocusBackground, Color DisabledForeground, Color DisabledBackground ) { /// <summary> /// Gets the <see cref="Color"/> to use for <see cref="ColorScheme.Normal"/> <see cref="Attribute.Foreground"/>. /// </summary> - [JsonConverter(typeof(JsonStringEnumConverter<ColorName> ))] - public ColorName NormalForeground { get; init; } = NormalForeground; + [JsonConverter(typeof(JsonStringEnumConverter<Color> ))] + public Color NormalForeground { get; init; } = NormalForeground; /// <summary> /// Gets the <see cref="Color"/> to use for <see cref="ColorScheme.Normal"/> <see cref="Attribute.Background"/>. /// </summary> - [JsonConverter(typeof(JsonStringEnumConverter<ColorName> ))] - public ColorName NormalBackground { get; init; } = NormalBackground; + [JsonConverter(typeof(JsonStringEnumConverter<Color> ))] + public Color NormalBackground { get; init; } = NormalBackground; /// <summary> /// Gets the <see cref="Color"/> to use for <see cref="ColorScheme.HotNormal"/> <see cref="Attribute.Foreground"/>. /// </summary> - [JsonConverter(typeof(JsonStringEnumConverter<ColorName> ))] - public ColorName HotNormalForeground { get; init; } = HotNormalForeground; + [JsonConverter(typeof(JsonStringEnumConverter<Color> ))] + public Color HotNormalForeground { get; init; } = HotNormalForeground; /// <summary> /// Gets the <see cref="Color"/> to use for <see cref="ColorScheme.HotNormal"/> <see cref="Attribute.Background"/>. /// </summary> - [JsonConverter(typeof(JsonStringEnumConverter<ColorName> ))] - public ColorName HotNormalBackground { get; init; } = HotNormalBackground; + [JsonConverter(typeof(JsonStringEnumConverter<Color> ))] + public Color HotNormalBackground { get; init; } = HotNormalBackground; /// <summary> /// Gets the <see cref="Color"/> to use for <see cref="ColorScheme.Focus"/> <see cref="Attribute.Foreground"/>. /// </summary> - [JsonConverter(typeof(JsonStringEnumConverter<ColorName> ))] - public ColorName FocusForeground { get; init; } = FocusForeground; + [JsonConverter(typeof(JsonStringEnumConverter<Color> ))] + public Color FocusForeground { get; init; } = FocusForeground; /// <summary> /// Gets the <see cref="Color"/> to use for <see cref="ColorScheme.Focus"/> <see cref="Attribute.Background"/>. /// </summary> - [JsonConverter(typeof(JsonStringEnumConverter<ColorName> ))] - public ColorName FocusBackground { get; init; } = FocusBackground; + [JsonConverter(typeof(JsonStringEnumConverter<Color> ))] + public Color FocusBackground { get; init; } = FocusBackground; /// <summary> /// Gets the <see cref="Color"/> to use for <see cref="ColorScheme.HotFocus"/> <see cref="Attribute.Foreground"/>. /// </summary> - [JsonConverter(typeof(JsonStringEnumConverter<ColorName> ))] - public ColorName HotFocusForeground { get; init; } = HotFocusForeground; + [JsonConverter(typeof(JsonStringEnumConverter<Color> ))] + public Color HotFocusForeground { get; init; } = HotFocusForeground; /// <summary> /// Gets the <see cref="Color"/> to use for <see cref="ColorScheme.HotFocus"/> <see cref="Attribute.Background"/>. /// </summary> - [JsonConverter(typeof(JsonStringEnumConverter<ColorName> ))] - public ColorName HotFocusBackground { get; init; } = HotFocusBackground; + [JsonConverter(typeof(JsonStringEnumConverter<Color> ))] + public Color HotFocusBackground { get; init; } = HotFocusBackground; /// <summary> /// Gets the <see cref="Color"/> to use for <see cref="ColorScheme.Disabled"/> <see cref="Attribute.Foreground"/>. /// </summary> - [JsonConverter(typeof(JsonStringEnumConverter<ColorName> ))] - [YamlMember( typeof(ColorName), ScalarStyle = ScalarStyle.Plain, DefaultValuesHandling = DefaultValuesHandling.Preserve)] - public ColorName DisabledForeground { get; init; } = DisabledForeground; + [JsonConverter(typeof(JsonStringEnumConverter<Color> ))] + [YamlMember( typeof(Color), ScalarStyle = ScalarStyle.Plain, DefaultValuesHandling = DefaultValuesHandling.Preserve)] + public Color DisabledForeground { get; init; } = DisabledForeground; /// <summary> /// Gets the <see cref="Color"/> to use for <see cref="ColorScheme.Disabled"/> <see cref="Attribute.Background"/>. /// </summary> - [JsonConverter(typeof(JsonStringEnumConverter<ColorName> ))] - [YamlMember( typeof(ColorName), ScalarStyle = ScalarStyle.Plain, DefaultValuesHandling = DefaultValuesHandling.Preserve)] - public ColorName DisabledBackground { get; init; } = DisabledBackground; + [JsonConverter(typeof(JsonStringEnumConverter<Color> ))] + [YamlMember( typeof(Color), ScalarStyle = ScalarStyle.Plain, DefaultValuesHandling = DefaultValuesHandling.Preserve)] + public Color DisabledBackground { get; init; } = DisabledBackground; /// <summary> /// Gets a new <see cref="ColorScheme"/> from the blueprint. diff --git a/src/UI/Editor.cs b/src/UI/Editor.cs index 22168d1a..55ec814f 100644 --- a/src/UI/Editor.cs +++ b/src/UI/Editor.cs @@ -143,7 +143,7 @@ public void Run(Options options) } }; - Application.MouseEventArgs += (s, m) => + Application.MouseEvent += (s, m) => { // if another window is showing don't respond to mouse if (!this.IsCurrentTop) @@ -194,10 +194,11 @@ public void Run(Options options) /// <summary> /// Tailors redrawing to add overlays (e.g. showing what is selected etc.). /// </summary> - /// <param name="bounds">The view bounds.</param> - public override void OnDrawContent(Rectangle bounds) + protected override bool OnDrawingContent() { - base.OnDrawContent(bounds); + var r = base.OnDrawingContent(); + var bounds = Viewport; + // if we are editing a view if (this.viewBeingEdited != null) @@ -238,13 +239,15 @@ public override void OnDrawContent(Rectangle bounds) } } - return; + return r; } else { var top = new Rectangle(0, 0, bounds.Width, rootCommandsListView.Frame.Top - 1); RenderTitle(top); } + + return r; } private void RenderTitle(Rectangle inArea) @@ -321,7 +324,7 @@ ________ .__ ________ .__ int y = inArea.Y + inArea.Height / 2 - 1; // Center the title vertically var colorAtPoint = fill.GetColor(new Point(x, y)); - Driver.SetAttribute(new Attribute(new Color(colorAtPoint), new Color(ColorName.Black))); + Driver.SetAttribute(new Attribute(new Color(colorAtPoint), new Color(Color.Black))); this.AddRune(x, y, (Rune)simpleTitle[i]); } @@ -332,7 +335,7 @@ ________ .__ ________ .__ int y = inArea.Y + inArea.Height / 2; // Line below the title var colorAtPoint = fill.GetColor(new Point(x, y)); - Driver.SetAttribute(new Attribute(new Color(colorAtPoint), new Color(ColorName.Black))); + Driver.SetAttribute(new Attribute(new Color(colorAtPoint), new Color(Color.Black))); this.AddRune(x, y, (Rune)versionLine[i]); } } @@ -530,14 +533,14 @@ public bool HandleKey(Key key) if (keyString == this.keyMap.ToggleShowFocused) { this.enableShowFocused = !this.enableShowFocused; - this.SetNeedsDisplay(); + this.SetNeedsDraw(); return true; } if (keyString == this.keyMap.ToggleShowBorders) { ShowBorders = !ShowBorders; - this.SetNeedsDisplay(); + this.SetNeedsDraw(); return true; } @@ -850,7 +853,7 @@ private void CreateAndShowContextMenu(MouseEventArgs? m, Design? rightClicked) } var menu = new ContextMenu(); - menu.MenuItems = new MenuBarItem(all.ToArray()); + menu.SetMenuItems(new MenuBarItem(all.ToArray())); if (m != null) { @@ -871,7 +874,8 @@ private void CreateAndShowContextMenu(MouseEventArgs? m, Design? rightClicked) m.Handled = true; } - menu.Show(); + // TODO: rly? you have to pass it its own menu items!? + menu.Show(menu.MenuItems); menu.MenuBar.MenuAllClosed += (_, _) => { this.menuOpen = false; @@ -1287,7 +1291,7 @@ private void Save() this.viewBeingEdited.View.GetType().BaseType ?? throw new Exception("View being edited had no base class")); this.flashMessage = $"Saved {this.viewBeingEdited.SourceCode.DesignerFile.Name}"; - this.SetNeedsDisplay(); + this.SetNeedsDraw(); this.LastSavedOperation = OperationManager.Instance.GetLastAppliedOperation()?.UniqueIdentifier; } diff --git a/src/UI/KeyMap.cs b/src/UI/KeyMap.cs index a4e30d54..8cbffdf1 100644 --- a/src/UI/KeyMap.cs +++ b/src/UI/KeyMap.cs @@ -9,7 +9,7 @@ namespace TerminalGuiDesigner.UI; /// <summary>Serializable settings class for user keybinding/accessibility tailoring.</summary> -[JsonSourceGenerationOptions( JsonSerializerDefaults.General, Converters = new[] { typeof( JsonStringEnumConverter<MouseFlags> ), typeof( JsonStringEnumConverter<ColorName> ) } )] +[JsonSourceGenerationOptions( JsonSerializerDefaults.General, Converters = new[] { typeof( JsonStringEnumConverter<MouseFlags> ), typeof( JsonStringEnumConverter<Color> ) } )] public sealed record KeyMap( string EditProperties, string ShowContextMenu, diff --git a/src/UI/KeyboardManager.cs b/src/UI/KeyboardManager.cs index da969137..6c0eb6cb 100644 --- a/src/UI/KeyboardManager.cs +++ b/src/UI/KeyboardManager.cs @@ -111,7 +111,7 @@ private bool HandleKeyPressInMenu(View focusedView, MenuItem menuItem, Key keyst { menuItem.ShortcutKey = Modals.GetShortcut().KeyCode; - focusedView.SetNeedsDisplay(); + focusedView.SetNeedsDraw(); return false; } @@ -209,7 +209,7 @@ private bool HandleKeyPressInMenu(View focusedView, MenuItem menuItem, Key keyst menuItem.Title = newValue; } - focusedView.SetNeedsDisplay(); + focusedView.SetNeedsDraw(); return true; } @@ -270,7 +270,7 @@ private bool ApplyKeystrokeToTextProperty(Key keystroke) } design.View.SetActualText(newStr); - design.View.SetNeedsDisplay(); + design.View.SetNeedsDraw(); this.currentOperation.NewValue = newStr; return true; diff --git a/src/UI/MouseManager.cs b/src/UI/MouseManager.cs index 082c42c7..430dfce2 100644 --- a/src/UI/MouseManager.cs +++ b/src/UI/MouseManager.cs @@ -122,7 +122,7 @@ public void HandleMouse(MouseEventArgs m, Design viewBeingEdited) { // move selection box to new mouse position this.selectionEnd = m.Position; - viewBeingEdited.View.SetNeedsDisplay(); + viewBeingEdited.View.SetNeedsDraw(); // BUG: Method is gone, will this functionality work still without it? // Application.DoEvents(); @@ -137,7 +137,7 @@ public void HandleMouse(MouseEventArgs m, Design viewBeingEdited) if (dest != null && this.dragOperation != null) { this.dragOperation.ContinueDrag(dest.Value); - viewBeingEdited.View.SetNeedsDisplay(); + viewBeingEdited.View.SetNeedsDraw(); // BUG: Method is gone, will this functionality work still without it? // Application.DoEvents(); } @@ -152,7 +152,7 @@ public void HandleMouse(MouseEventArgs m, Design viewBeingEdited) this.resizeOperation.ContinueResize(dest); - viewBeingEdited.View.SetNeedsDisplay(); + viewBeingEdited.View.SetNeedsDraw(); // BUG: Method is gone, will this functionality work still without it? // Application.DoEvents(); } @@ -174,7 +174,7 @@ public void HandleMouse(MouseEventArgs m, Design viewBeingEdited) this.selectionStart = null; this.selectionEnd = null; this.selectionContainer = null; - viewBeingEdited.View.SetNeedsDisplay(); + viewBeingEdited.View.SetNeedsDraw(); // BUG: Method is gone, will this functionality work still without it? // Application.DoEvents(); } diff --git a/src/UI/Windows/ArrayEditor.cs b/src/UI/Windows/ArrayEditor.cs index 15f820ba..86ee84b8 100644 --- a/src/UI/Windows/ArrayEditor.cs +++ b/src/UI/Windows/ArrayEditor.cs @@ -80,7 +80,7 @@ private void BtnMoveUp_Clicked(object sender, EventArgs e) lvElements.Source = ResultAsList.ToListDataSource(); lvElements.SelectedItem = newIndex; - lvElements.SetNeedsDisplay(); + lvElements.SetNeedsDraw(); } } @@ -98,7 +98,7 @@ private void BtnMoveDown_Clicked(object sender, EventArgs e) lvElements.Source = ResultAsList.ToListDataSource(); lvElements.SelectedItem = newIndex; - lvElements.SetNeedsDisplay(); + lvElements.SetNeedsDraw(); } } @@ -120,7 +120,7 @@ private void DeleteSelectedItem() ResultAsList.RemoveAt(idx); lvElements.Source = ResultAsList.ToListDataSource(); - lvElements.SetNeedsDisplay(); + lvElements.SetNeedsDraw(); lvElements.SelectedItem = 0; } } @@ -134,7 +134,7 @@ private void BtnAddElement_Clicked(object sender, EventArgs e) lvElements.Source = ResultAsList.ToListDataSource(); lvElements.SelectedItem = ResultAsList.Count - 1; - lvElements.SetNeedsDisplay(); + lvElements.SetNeedsDraw(); } private void BtnEdit_Clicked(object sender, EventArgs e) { @@ -153,7 +153,7 @@ private void BtnEdit_Clicked(object sender, EventArgs e) lvElements.Source = ResultAsList.ToListDataSource(); lvElements.SelectedItem = idx; - lvElements.SetNeedsDisplay(); + lvElements.SetNeedsDraw(); } } diff --git a/src/UI/Windows/ColorPicker.cs b/src/UI/Windows/ColorPicker.cs index 0959281d..56554c3e 100644 --- a/src/UI/Windows/ColorPicker.cs +++ b/src/UI/Windows/ColorPicker.cs @@ -67,7 +67,7 @@ private void Cancel() private void UpdatePreview() { lblPreview.ColorScheme = new ColorScheme(GetColor()); - lblPreview.SetNeedsDisplay(); + lblPreview.SetNeedsDraw(); } private Attribute GetColor() diff --git a/src/UI/Windows/DimEditor.cs b/src/UI/Windows/DimEditor.cs index 3ac81a44..7735b99d 100644 --- a/src/UI/Windows/DimEditor.cs +++ b/src/UI/Windows/DimEditor.cs @@ -111,7 +111,7 @@ private void SetupForCurrentDimType() lblOffset.Visible = false; tbOffset.Visible = false; - SetNeedsDisplay(); + SetNeedsDraw(); break; case DimType.Fill: lblValue.Text = "Margin"; @@ -120,7 +120,7 @@ private void SetupForCurrentDimType() lblOffset.Visible = false; tbOffset.Visible = false; - SetNeedsDisplay(); + SetNeedsDraw(); break; case DimType.Percent: lblValue.Text = "Factor"; @@ -129,14 +129,14 @@ private void SetupForCurrentDimType() lblOffset.Visible = true; tbOffset.Visible = true; - SetNeedsDisplay(); + SetNeedsDraw(); break; case DimType.Auto: lblValue.Visible = false; tbValue.Visible = false; lblOffset.Visible = false; tbOffset.Visible = false; - SetNeedsDisplay(); + SetNeedsDraw(); break; default: throw new ArgumentOutOfRangeException(); diff --git a/src/UI/Windows/ExceptionViewer.cs b/src/UI/Windows/ExceptionViewer.cs index 075491e0..6c382bd8 100644 --- a/src/UI/Windows/ExceptionViewer.cs +++ b/src/UI/Windows/ExceptionViewer.cs @@ -46,7 +46,7 @@ public static void ShowException(string errorText, Exception exception) { // flip between stack / no stack textView.Text = GetExceptionText(errorText, exception, toggleStack); - textView.SetNeedsDisplay(); + textView.SetNeedsDraw(); toggleStack = !toggleStack; }; diff --git a/src/UI/Windows/GetTextDialog.cs b/src/UI/Windows/GetTextDialog.cs index 667bf811..974b2ff7 100644 --- a/src/UI/Windows/GetTextDialog.cs +++ b/src/UI/Windows/GetTextDialog.cs @@ -66,7 +66,7 @@ public GetTextDialog(DialogArgs args, string? initialValue) Y = Pos.Bottom(this.textField), IsDefault = !this.args.MultiLine, }; - btnOk.Accept += (s, e) => + btnOk.Accepting += (s, e) => { this.Accept(); }; @@ -78,7 +78,7 @@ public GetTextDialog(DialogArgs args, string? initialValue) Y = Pos.Bottom(this.textField), IsDefault = false, }; - btnCancel.Accept += (s, e) => + btnCancel.Accepting += (s, e) => { this.okClicked = false; Application.RequestStop(); @@ -90,7 +90,7 @@ public GetTextDialog(DialogArgs args, string? initialValue) X = Pos.Right(btnCancel), Y = Pos.Bottom(this.textField), }; - btnClear.Accept += (s, e) => + btnClear.Accepting += (s, e) => { this.textField.Text = string.Empty; }; diff --git a/src/UI/Windows/PosEditor.cs b/src/UI/Windows/PosEditor.cs index 7b65d2b9..a8abadb8 100644 --- a/src/UI/Windows/PosEditor.cs +++ b/src/UI/Windows/PosEditor.cs @@ -134,7 +134,7 @@ private void SetupForCurrentPosType() tbOffset.Y = 3; tbOffset.Visible = true; - SetNeedsDisplay(); + SetNeedsDraw(); break; case PosType.Center: lblRelativeTo.Visible = false; @@ -150,7 +150,7 @@ private void SetupForCurrentPosType() tbOffset.Y = 1; tbOffset.Visible = true; - SetNeedsDisplay(); + SetNeedsDraw(); break; case PosType.Absolute: case PosType.AnchorEnd: @@ -165,7 +165,7 @@ private void SetupForCurrentPosType() lblOffset.Visible = false; tbOffset.Visible = false; - SetNeedsDisplay(); + SetNeedsDraw(); break; case PosType.Relative: lblRelativeTo.Y = 1; @@ -188,7 +188,7 @@ private void SetupForCurrentPosType() lblOffset.Visible = true; tbOffset.Y = 5; tbOffset.Visible = true; - SetNeedsDisplay(); + SetNeedsDraw(); break; default: throw new ArgumentOutOfRangeException(); From 2e4ffc06eba2ab74d564752d4b54eaa3bcd702db Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Sun, 16 Feb 2025 17:50:59 +0000 Subject: [PATCH 03/54] More build error fixes --- src/UI/Windows/BigListBox.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/UI/Windows/BigListBox.cs b/src/UI/Windows/BigListBox.cs index d81b9647..d68e031b 100644 --- a/src/UI/Windows/BigListBox.cs +++ b/src/UI/Windows/BigListBox.cs @@ -100,7 +100,7 @@ public BigListBox( IsDefault = true, Y = Pos.Bottom(this.listView), }; - btnOk.Accept += (s, e) => + btnOk.Accepting += (s, e) => { this.Accept(); }; @@ -110,7 +110,7 @@ public BigListBox( Text = "Cancel", Y = Pos.Bottom(this.listView), }; - btnCancel.Accept += (s, e) => Application.RequestStop(); + btnCancel.Accepting += (s, e) => Application.RequestStop(); if (addSearch) { @@ -204,9 +204,9 @@ private void Accept() this.Selected = this.collection[selected].Object; } - private void ListView_MouseClick(object? sender, MouseEventEventArgs obj) + private void ListView_MouseClick(object? sender, MouseEventArgs obj) { - if (obj.MouseEventArgs.Flags.HasFlag(MouseFlags.Button1DoubleClicked)) + if (obj.Flags.HasFlag(MouseFlags.Button1DoubleClicked)) { obj.Handled = true; this.Accept(); @@ -221,7 +221,7 @@ private void ListView_KeyPress(object? sender, Key key) // backspace or letter/numbers if (key == Key.Backspace || char.IsLetterOrDigit(c)) { - this.searchBox?.FocusFirst(TabBehavior.TabStop); + this.searchBox?.FocusDeepest(NavigationDirection.Forward, TabBehavior.TabStop); this.searchBox?.NewKeyDownEvent(key); key.Handled = true; } From e85101ec08697bfb91bdd175ce22a08a37ce074e Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Sun, 16 Feb 2025 18:08:36 +0000 Subject: [PATCH 04/54] Fixes for breaking changes --- README.md | 2 +- src/DimExtensions.cs | 2 +- src/UI/ColorSchemeBlueprint.cs | 12 ------------ src/UI/KeyMap.cs | 2 +- src/UI/Windows/ArrayEditor.cs | 14 +++++++------- src/UI/Windows/BigListBox.cs | 2 +- src/UI/Windows/ColorPicker.cs | 4 ++-- src/UI/Windows/ColorSchemeEditor.cs | 14 +++++++------- src/UI/Windows/DimEditor.cs | 4 ++-- src/UI/Windows/EditDialog.cs | 4 ++-- src/UI/Windows/ExceptionViewer.cs | 4 ++-- src/UI/Windows/PointEditor.cs | 4 ++-- src/UI/Windows/PosEditor.cs | 6 +++--- src/UI/Windows/SizeEditor.cs | 4 ++-- src/UI/Windows/SliderOptionEditor.cs | 4 ++-- src/ViewExtensions.cs | 6 ------ src/ViewFactory.cs | 2 -- 17 files changed, 35 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index 3fddd479..d61d8f55 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ You can add new code to `MyDialog.cs` but avoid making any changes to `MyDialog. For example in `MyDialog.cs` after `InitializeComponent()` add the following: ```csharp -button1.Accept += ()=>MessageBox.Query("Hello","Hello World","Ok"); +button1.Accepting += ()=>MessageBox.Query("Hello","Hello World","Ok"); ``` Now when run clicking the button will trigger a message box. diff --git a/src/DimExtensions.cs b/src/DimExtensions.cs index 107b8907..378be9ab 100644 --- a/src/DimExtensions.cs +++ b/src/DimExtensions.cs @@ -72,7 +72,7 @@ public static bool IsFill(this Dim d, out int margin) if (d != null && d.IsFill()) { var df = (DimFill)d; - margin = df.Margin; + margin = ((DimAbsolute)df.Margin).Size; return true; } diff --git a/src/UI/ColorSchemeBlueprint.cs b/src/UI/ColorSchemeBlueprint.cs index c5d48af2..cd4fd89e 100644 --- a/src/UI/ColorSchemeBlueprint.cs +++ b/src/UI/ColorSchemeBlueprint.cs @@ -15,63 +15,51 @@ public record ColorSchemeBlueprint( Color NormalForeground, Color NormalBackgrou /// <summary> /// Gets the <see cref="Color"/> to use for <see cref="ColorScheme.Normal"/> <see cref="Attribute.Foreground"/>. /// </summary> - [JsonConverter(typeof(JsonStringEnumConverter<Color> ))] public Color NormalForeground { get; init; } = NormalForeground; /// <summary> /// Gets the <see cref="Color"/> to use for <see cref="ColorScheme.Normal"/> <see cref="Attribute.Background"/>. /// </summary> - [JsonConverter(typeof(JsonStringEnumConverter<Color> ))] public Color NormalBackground { get; init; } = NormalBackground; /// <summary> /// Gets the <see cref="Color"/> to use for <see cref="ColorScheme.HotNormal"/> <see cref="Attribute.Foreground"/>. /// </summary> - [JsonConverter(typeof(JsonStringEnumConverter<Color> ))] public Color HotNormalForeground { get; init; } = HotNormalForeground; /// <summary> /// Gets the <see cref="Color"/> to use for <see cref="ColorScheme.HotNormal"/> <see cref="Attribute.Background"/>. /// </summary> - [JsonConverter(typeof(JsonStringEnumConverter<Color> ))] public Color HotNormalBackground { get; init; } = HotNormalBackground; /// <summary> /// Gets the <see cref="Color"/> to use for <see cref="ColorScheme.Focus"/> <see cref="Attribute.Foreground"/>. /// </summary> - [JsonConverter(typeof(JsonStringEnumConverter<Color> ))] public Color FocusForeground { get; init; } = FocusForeground; /// <summary> /// Gets the <see cref="Color"/> to use for <see cref="ColorScheme.Focus"/> <see cref="Attribute.Background"/>. /// </summary> - [JsonConverter(typeof(JsonStringEnumConverter<Color> ))] public Color FocusBackground { get; init; } = FocusBackground; /// <summary> /// Gets the <see cref="Color"/> to use for <see cref="ColorScheme.HotFocus"/> <see cref="Attribute.Foreground"/>. /// </summary> - [JsonConverter(typeof(JsonStringEnumConverter<Color> ))] public Color HotFocusForeground { get; init; } = HotFocusForeground; /// <summary> /// Gets the <see cref="Color"/> to use for <see cref="ColorScheme.HotFocus"/> <see cref="Attribute.Background"/>. /// </summary> - [JsonConverter(typeof(JsonStringEnumConverter<Color> ))] public Color HotFocusBackground { get; init; } = HotFocusBackground; /// <summary> /// Gets the <see cref="Color"/> to use for <see cref="ColorScheme.Disabled"/> <see cref="Attribute.Foreground"/>. /// </summary> - [JsonConverter(typeof(JsonStringEnumConverter<Color> ))] - [YamlMember( typeof(Color), ScalarStyle = ScalarStyle.Plain, DefaultValuesHandling = DefaultValuesHandling.Preserve)] public Color DisabledForeground { get; init; } = DisabledForeground; /// <summary> /// Gets the <see cref="Color"/> to use for <see cref="ColorScheme.Disabled"/> <see cref="Attribute.Background"/>. /// </summary> - [JsonConverter(typeof(JsonStringEnumConverter<Color> ))] - [YamlMember( typeof(Color), ScalarStyle = ScalarStyle.Plain, DefaultValuesHandling = DefaultValuesHandling.Preserve)] public Color DisabledBackground { get; init; } = DisabledBackground; /// <summary> diff --git a/src/UI/KeyMap.cs b/src/UI/KeyMap.cs index 8cbffdf1..cde84c07 100644 --- a/src/UI/KeyMap.cs +++ b/src/UI/KeyMap.cs @@ -9,7 +9,7 @@ namespace TerminalGuiDesigner.UI; /// <summary>Serializable settings class for user keybinding/accessibility tailoring.</summary> -[JsonSourceGenerationOptions( JsonSerializerDefaults.General, Converters = new[] { typeof( JsonStringEnumConverter<MouseFlags> ), typeof( JsonStringEnumConverter<Color> ) } )] +[JsonSourceGenerationOptions( JsonSerializerDefaults.General, Converters = new[] { typeof( JsonStringEnumConverter<MouseFlags> ) } )] public sealed record KeyMap( string EditProperties, string ShowContextMenu, diff --git a/src/UI/Windows/ArrayEditor.cs b/src/UI/Windows/ArrayEditor.cs index 86ee84b8..e2847447 100644 --- a/src/UI/Windows/ArrayEditor.cs +++ b/src/UI/Windows/ArrayEditor.cs @@ -56,13 +56,13 @@ public ArrayEditor(Design design, Type elementType, IList oldValue) { lvElements.Source = ResultAsList.ToListDataSource(); lvElements.KeyDown += LvElements_KeyDown; - btnOk.Accept += BtnOk_Clicked; - btnCancel.Accept += BtnCancel_Clicked; - btnAddElement.Accept += BtnAddElement_Clicked; - btnDelete.Accept += (s, e) => DeleteSelectedItem(); - btnMoveDown.Accept += BtnMoveDown_Clicked; - btnMoveUp.Accept += BtnMoveUp_Clicked; - btnEdit.Accept += BtnEdit_Clicked; + btnOk.Accepting += BtnOk_Clicked; + btnCancel.Accepting += BtnCancel_Clicked; + btnAddElement.Accepting += BtnAddElement_Clicked; + btnDelete.Accepting += (s, e) => DeleteSelectedItem(); + btnMoveDown.Accepting += BtnMoveDown_Clicked; + btnMoveUp.Accepting += BtnMoveUp_Clicked; + btnEdit.Accepting += BtnEdit_Clicked; } diff --git a/src/UI/Windows/BigListBox.cs b/src/UI/Windows/BigListBox.cs index d68e031b..83ab211d 100644 --- a/src/UI/Windows/BigListBox.cs +++ b/src/UI/Windows/BigListBox.cs @@ -164,7 +164,7 @@ public BigListBox( this.callback = Application.AddTimeout(TimeSpan.FromMilliseconds(100), this.Timer); - this.listView.FocusFirst(TabBehavior.TabStop); + this.listView.FocusDeepest(NavigationDirection.Forward,TabBehavior.TabStop); } diff --git a/src/UI/Windows/ColorPicker.cs b/src/UI/Windows/ColorPicker.cs index 56554c3e..6a43cad2 100644 --- a/src/UI/Windows/ColorPicker.cs +++ b/src/UI/Windows/ColorPicker.cs @@ -47,8 +47,8 @@ public ColorPicker(Attribute? currentValue) cpForeground.ColorChanged += (s,e) => UpdatePreview(); cpBackground.ColorChanged += (s,e) => UpdatePreview(); - btnOk.Accept += (s, e) => Ok(); - btnCancel.Accept += (s, e) => Cancel(); + btnOk.Accepting += (s, e) => Ok(); + btnCancel.Accepting += (s, e) => Cancel(); } private void Ok() diff --git a/src/UI/Windows/ColorSchemeEditor.cs b/src/UI/Windows/ColorSchemeEditor.cs index c91f1dc9..61b8bc9a 100644 --- a/src/UI/Windows/ColorSchemeEditor.cs +++ b/src/UI/Windows/ColorSchemeEditor.cs @@ -60,41 +60,41 @@ public ColorSchemeEditor(ColorScheme scheme) { SetColorPatches(); - btnEditNormal.Accept += (s, e)=>{ + btnEditNormal.Accepting += (s, e)=>{ _result.Normal = PickNewColorsFor(Result.Normal); SetColorPatches(); }; - btnEditHotNormal.Accept += (s, e)=>{ + btnEditHotNormal.Accepting += (s, e)=>{ _result.HotNormal = PickNewColorsFor(Result.HotNormal); SetColorPatches(); }; - btnEditFocus.Accept += (s, e)=>{ + btnEditFocus.Accepting += (s, e)=>{ _result.Focus = PickNewColorsFor(Result.Focus); SetColorPatches(); }; - btnEditHotFocus.Accept += (s, e)=>{ + btnEditHotFocus.Accepting += (s, e)=>{ _result.HotFocus = PickNewColorsFor(Result.HotFocus); SetColorPatches(); }; - btnEditDisabled.Accept += (s, e)=>{ + btnEditDisabled.Accepting += (s, e)=>{ _result.Disabled = PickNewColorsFor(Result.Disabled); SetColorPatches(); }; - btnCancel.Accept += (s, e)=>{ + btnCancel.Accepting += (s, e)=>{ Cancelled = true; Application.RequestStop(); }; - btnOk.Accept += (s, e)=>{ + btnOk.Accepting += (s, e)=>{ Cancelled = false; Application.RequestStop(); }; diff --git a/src/UI/Windows/DimEditor.cs b/src/UI/Windows/DimEditor.cs index 7735b99d..18585e4c 100644 --- a/src/UI/Windows/DimEditor.cs +++ b/src/UI/Windows/DimEditor.cs @@ -48,8 +48,8 @@ public DimEditor(Design design, Dim oldValue) { Title = "Dim Designer"; Border.BorderStyle = LineStyle.Double; - btnOk.Accept += BtnOk_Clicked; - btnCancel.Accept += BtnCancel_Clicked; + btnOk.Accepting += BtnOk_Clicked; + btnCancel.Accepting += BtnCancel_Clicked; Cancelled = true; Modal = true; rgDimType.KeyDown += RgDimType_KeyPress; diff --git a/src/UI/Windows/EditDialog.cs b/src/UI/Windows/EditDialog.cs index 4b362450..7dd80d5b 100644 --- a/src/UI/Windows/EditDialog.cs +++ b/src/UI/Windows/EditDialog.cs @@ -56,7 +56,7 @@ public EditDialog(Design design) IsDefault = true, }; - btnSet.Accept += (s, e) => + btnSet.Accepting += (s, e) => { this.SetProperty(false); }; @@ -67,7 +67,7 @@ public EditDialog(Design design) X = Pos.Right(btnSet), Y = Pos.Bottom(this.list), }; - btnClose.Accept += (s, e) => Application.RequestStop(); + btnClose.Accepting += (s, e) => Application.RequestStop(); this.list.KeyDown += (s, e) => { diff --git a/src/UI/Windows/ExceptionViewer.cs b/src/UI/Windows/ExceptionViewer.cs index 6c382bd8..be372e14 100644 --- a/src/UI/Windows/ExceptionViewer.cs +++ b/src/UI/Windows/ExceptionViewer.cs @@ -37,12 +37,12 @@ public static void ShowException(string errorText, Exception exception) IsDefault = true }; - btnOk.Accept += (s, e) => Application.RequestStop(); + btnOk.Accepting += (s, e) => Application.RequestStop(); var btnStack = new Button() { Text = "Stack" }; - btnStack.Accept += (s, e) => + btnStack.Accepting += (s, e) => { // flip between stack / no stack textView.Text = GetExceptionText(errorText, exception, toggleStack); diff --git a/src/UI/Windows/PointEditor.cs b/src/UI/Windows/PointEditor.cs index 4daaef18..1f594f1e 100644 --- a/src/UI/Windows/PointEditor.cs +++ b/src/UI/Windows/PointEditor.cs @@ -48,8 +48,8 @@ public PointEditor(float x, float y) { tbX.Text = x.ToString(); tbY.Text = y.ToString(); - btnOk.Accept += Ok; - btnCancel.Accept += Cancel; + btnOk.Accepting += Ok; + btnCancel.Accepting += Cancel; } private void Cancel(object sender, EventArgs e) diff --git a/src/UI/Windows/PosEditor.cs b/src/UI/Windows/PosEditor.cs index a8abadb8..fb9122a3 100644 --- a/src/UI/Windows/PosEditor.cs +++ b/src/UI/Windows/PosEditor.cs @@ -52,8 +52,8 @@ public PosEditor(Design design, Pos oldValue) { rgPosType.KeyDown += RgPosType_KeyPress; - btnOk.Accept += BtnOk_Clicked; - btnCancel.Accept += BtnCancel_Clicked; + btnOk.Accepting += BtnOk_Clicked; + btnCancel.Accepting += BtnCancel_Clicked; Cancelled = true; Modal = true; @@ -104,7 +104,7 @@ private void RgPosType_KeyPress(object sender, Key key) // if user types in some text change the focus to the text box to enable entering digits if ((key == Key.Backspace || char.IsDigit(c)) && tbValue.Visible) { - tbValue?.FocusFirst(TabBehavior.TabStop); + tbValue?.FocusDeepest(NavigationDirection.Forward,TabBehavior.TabStop); } } diff --git a/src/UI/Windows/SizeEditor.cs b/src/UI/Windows/SizeEditor.cs index afe00549..cab36393 100644 --- a/src/UI/Windows/SizeEditor.cs +++ b/src/UI/Windows/SizeEditor.cs @@ -39,7 +39,7 @@ public SizeEditor(Size s) tfWidth.Text = s.Width.ToString(); tfHeight.Text = s.Height.ToString(); - btnOk.Accept += (s, e) => + btnOk.Accepting += (s, e) => { try { @@ -55,7 +55,7 @@ public SizeEditor(Size s) RequestStop(); }; - btnCancel.Accept += (s, e) => + btnCancel.Accepting += (s, e) => { Cancelled = true; RequestStop(); diff --git a/src/UI/Windows/SliderOptionEditor.cs b/src/UI/Windows/SliderOptionEditor.cs index c30255db..fb4d39f6 100644 --- a/src/UI/Windows/SliderOptionEditor.cs +++ b/src/UI/Windows/SliderOptionEditor.cs @@ -42,8 +42,8 @@ public SliderOptionEditor(Type genericTypeArgument, object? oldValue) { this.genericTypeArgument = genericTypeArgument; this.sliderOptionType = typeof(SliderOption<>).MakeGenericType(this.genericTypeArgument); - btnOk.Accept += BtnOk_Clicked; - btnCancel.Accept += BtnCancel_Clicked; + btnOk.Accepting += BtnOk_Clicked; + btnCancel.Accepting += BtnCancel_Clicked; lblType.Text = $"({genericTypeArgument.Name})"; diff --git a/src/ViewExtensions.cs b/src/ViewExtensions.cs index 70643a69..b0a1b0ec 100644 --- a/src/ViewExtensions.cs +++ b/src/ViewExtensions.cs @@ -26,12 +26,6 @@ public static IList<View> GetActualSubviews(this View v) return t.Tabs.Select(tab => tab.View).Where(v => v != null).ToList(); } - // ScrollView has a content view so to reach its children you have to dive down an extra layer - if (v is ScrollView sc) - { - return sc.Subviews[0].Subviews; - } - return v.Subviews; } diff --git a/src/ViewFactory.cs b/src/ViewFactory.cs index 8b8b3154..4e083550 100644 --- a/src/ViewFactory.cs +++ b/src/ViewFactory.cs @@ -35,7 +35,6 @@ public static class ViewFactory typeof( FileDialog ), typeof( SaveDialog ), typeof( OpenDialog ), - typeof( ScrollBarView ), // BUG These seem to cause stack overflows in CreateSubControlDesigns (see TestAddView_RoundTrip) typeof( Wizard ), @@ -335,7 +334,6 @@ public static View Create( Type requestedType ) { } t when t.IsAssignableTo( typeof( ListView ) ) => Create<ListView>( ), { } t when t == typeof( LineView ) => Create<LineView>( ), { } t when t == typeof( TreeView ) => Create<TreeView>( ), - { } t when t == typeof( ScrollView ) => Create<ScrollView>( ), { } t when t.IsAssignableTo( typeof( SpinnerView ) ) => Create<SpinnerView>( ), { } t when t.IsAssignableTo( typeof( FrameView ) ) => Create<FrameView>( ), { } t when t.IsAssignableTo( typeof( HexView ) ) => Create<HexView>( ), From 40c6f78880a03dd511106ce611f12a96fdd3056e Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Sun, 16 Feb 2025 18:26:37 +0000 Subject: [PATCH 05/54] Main binary compiles --- src/UI/Windows/DimEditor.cs | 2 +- src/ViewExtensions.cs | 9 ++++++--- src/ViewFactory.cs | 4 ---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/UI/Windows/DimEditor.cs b/src/UI/Windows/DimEditor.cs index 18585e4c..e88d0504 100644 --- a/src/UI/Windows/DimEditor.cs +++ b/src/UI/Windows/DimEditor.cs @@ -88,7 +88,7 @@ private void RgDimType_KeyPress(object sender, Key obj) // if user types in some text change the focus to the text box to enable entering digits if ((obj == Key.Backspace || char.IsDigit(c)) && tbValue.Visible) { - tbValue?.FocusFirst(TabBehavior.TabStop); + tbValue?.FocusDeepest(NavigationDirection.Forward,TabBehavior.TabStop); } } diff --git a/src/ViewExtensions.cs b/src/ViewExtensions.cs index b0a1b0ec..a01d0169 100644 --- a/src/ViewExtensions.cs +++ b/src/ViewExtensions.cs @@ -8,6 +8,10 @@ namespace TerminalGuiDesigner; /// </summary> public static class ViewExtensions { + public static View? FindDeepestView(Point screenPoint) + { + return View.GetViewsUnderMouse(screenPoint).LastOrDefault(v=> v!= null); + } /// <summary> /// Returns the sub-views of <paramref name="v"/> skipping out any /// public views used by the Terminal.Gui API e.g. the 'ContentView' @@ -196,7 +200,6 @@ public static bool IsContainerView(this View v) // TODO: are there any others? return - v is ScrollView || v is TabView || v is FrameView || v is Window || @@ -255,8 +258,8 @@ public static bool IsBorderlessContainerView(this View v) } var point = w.ScreenToContent(m.Position); - - var hit = View.FindDeepestView(w, m.Position); + + var hit = ViewExtensions.FindDeepestView(m.Position); hit = UnpackHitView(hit); diff --git a/src/ViewFactory.cs b/src/ViewFactory.cs index 4e083550..04a05653 100644 --- a/src/ViewFactory.cs +++ b/src/ViewFactory.cs @@ -244,10 +244,6 @@ public static T Create<T>(int? width = null, int? height = null, string? text = SetDefaultDimensions(newView, width ?? 16, height ?? 5); break; - case ScrollView sv: - sv.SetContentSize(new Size( 20, 10 )); - SetDefaultDimensions(newView, width ?? 10, height ?? 5 ); - break; case SpinnerView sv: sv.AutoSpin = true; if ( width is not null ) From 0729285cd0ee9f8a707231b5d02c168ca26a9cd1 Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Sun, 16 Feb 2025 19:16:49 +0000 Subject: [PATCH 06/54] Fix bad default dimensions on new views --- src/ViewFactory.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ViewFactory.cs b/src/ViewFactory.cs index 04a05653..a3affe98 100644 --- a/src/ViewFactory.cs +++ b/src/ViewFactory.cs @@ -137,9 +137,8 @@ public static T Create<T>(int? width = null, int? height = null, string? text = case CheckBox: case ComboBox: case Label: - newView.SetActualText( text ?? "Heya" ); - SetDefaultDimensions( newView, width ?? 4, height ?? 1 ); - newView.Width = Dim.Auto(); + newView.SetActualText(text ?? "Heya"); + SetDefaultDimensionsDimAuto(newView); break; case ColorPicker: newView.Width = width ?? 20; @@ -277,8 +276,14 @@ static void SetDefaultDimensions( T v, int width = 5, int height = 1 ) v.Height = v.Height is DimFill ? height : Math.Max( v.GetContentSize().Height, height ); } + static void SetDefaultDimensionsDimAuto(T v) + { + v.Width = Dim.Auto(); + v.Height = Dim.Auto(); + } } + /// <summary> /// Creates a new instance of <see cref="View" /> of <see cref="Type" /> <paramref name="requestedType" /> with /// size/placeholder values that make it easy to see and design in the editor. From 234e0187a34a8885e6e702a808f3e37d4e37ce44 Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Mon, 17 Feb 2025 07:31:13 +0000 Subject: [PATCH 07/54] WIP - tests building --- tests/CopyPasteTests.cs | 16 +++++------ tests/PropertyTests.cs | 4 +-- tests/ScrollViewTests.cs | 57 --------------------------------------- tests/ViewFactoryTests.cs | 1 - 4 files changed, 10 insertions(+), 68 deletions(-) delete mode 100644 tests/ScrollViewTests.cs diff --git a/tests/CopyPasteTests.cs b/tests/CopyPasteTests.cs index f129c6ba..03d74ea1 100644 --- a/tests/CopyPasteTests.cs +++ b/tests/CopyPasteTests.cs @@ -393,13 +393,13 @@ public void CopyPasteContainer( [Values] bool alsoSelectSubElements ) } [Test] - public void CopyPasteContainer_Empty_ScrollView_Into_Root() + public void CopyPasteContainer_Empty_View_Into_Root() { - RoundTrip<Window, ScrollView>( + RoundTrip<Window, View>( ( d, v ) => { Assume.That( d, Is.Not.Null.And.InstanceOf<Design>( ) ); - Assume.That( v, Is.Not.Null.And.InstanceOf<ScrollView>( ) ); + Assume.That( v, Is.Not.Null.And.InstanceOf<View>( ) ); Assume.That( v.GetActualSubviews( ), Is.Empty ); // copy the ScrollView @@ -430,20 +430,20 @@ public void CopyPasteContainer_Empty_ScrollView_Into_Root() var rootSubviews = rootDesign.View.GetActualSubviews( ); Assert.That( rootSubviews, Has.Count.EqualTo( 2 ) ); - Assert.That( rootSubviews, Has.All.InstanceOf<ScrollView>( ) ); + Assert.That( rootSubviews, Has.All.InstanceOf<View>( ) ); } , out _ ); } [Test] - public void CopyPasteContainer_EmptyScrollView_Into_Itself( ) + public void CopyPasteContainer_EmptyView_Into_Itself( ) { - RoundTrip<Window, ScrollView>( + RoundTrip<Window, View>( ( d, v ) => { Assume.That( d, Is.Not.Null.And.InstanceOf<Design>( ) ); - Assume.That( v, Is.Not.Null.And.InstanceOf<ScrollView>( ) ); + Assume.That( v, Is.Not.Null.And.InstanceOf<View>( ) ); Assume.That( v.GetActualSubviews( ), Is.Empty ); CopyOperation copyOperation = new( d ); @@ -473,7 +473,7 @@ public void CopyPasteContainer_EmptyScrollView_Into_Itself( ) var rootSubviews = rootDesign.View.GetActualSubviews( ); Assert.That( rootSubviews, Has.Count.EqualTo( 2 ) ); - Assert.That( rootSubviews, Has.All.InstanceOf<ScrollView>( ) ); + Assert.That( rootSubviews, Has.All.InstanceOf<View>( ) ); } , out _ ); diff --git a/tests/PropertyTests.cs b/tests/PropertyTests.cs index 0415e4d1..a1c9651d 100644 --- a/tests/PropertyTests.cs +++ b/tests/PropertyTests.cs @@ -118,8 +118,8 @@ public void PropertyOfType_Rune( [Values( 'a', 'A', 'f', 'F' )] char runeCharact [Category( "Code Generation" )] public string PropertyOfType_Size( ) { - using ScrollView scrollView = new( ); - Design d = new( new( $"{nameof( PropertyOfType_Size )}.cs" ), "FFF", scrollView ); + using View view = new( ); + Design d = new( new( $"{nameof( PropertyOfType_Size )}.cs" ), "FFF", view ); Property xProp = d.GetDesignableProperties( ).Single( static p => p.PropertyInfo.Name.Equals( nameof( View.X ) ) ); xProp.SetValue( Pos.Center( ) ); diff --git a/tests/ScrollViewTests.cs b/tests/ScrollViewTests.cs deleted file mode 100644 index eb23d081..00000000 --- a/tests/ScrollViewTests.cs +++ /dev/null @@ -1,57 +0,0 @@ -namespace UnitTests; - -[TestFixture] -[Category( "Code Generation" )] -internal class ScrollViewTests : Tests -{ - - [Test] - public void TestRoundTrip_PreserveContentViews( [Values( "blarggg" )] string text, [Values( "myLbl" )] string fieldName ) - { - using Label lbl = new() { Text = text, Width = 7, Height = 1 }; - using ScrollView scrollViewIn = RoundTrip<View, ScrollView>( - ( d, _ ) => - { - AddViewOperation op = new ( lbl, d, fieldName ); - op.Do( ); - }, out _ ); - - using View child = scrollViewIn.GetActualSubviews( ).Single( ); - Assert.That( child, Is.InstanceOf<Label>( ) ); - Assert.That( child.Data, Is.InstanceOf<Design>( ) ); - - Design? lblIn = (Design)child.Data; - Assert.That( lblIn.FieldName, Is.EqualTo( fieldName ) ); - Assert.That( lblIn.View.Text, Is.EqualTo( text ) ); - } - - [Test] - public void TestRoundTrip_ScrollViewInsideTabView_PreserveContentViews( ) - { - using ScrollView scrollOut = ViewFactory.Create<ScrollView>( ); - using Button buttonOut = ViewFactory.Create<Button>( ); - - using TabView tabIn = RoundTrip<View, TabView>( - ( d, _ ) => - { - // Add a ScrollView to the first Tab - new AddViewOperation( scrollOut, d, "myTabView" ).Do( ); - - // Add a Button to the ScrollView - new AddViewOperation( buttonOut, (Design)scrollOut.Data, "myButton" ).Do( ); - }, out _ ); - - // The ScrollView should contain the Button - Assert.That( scrollOut.GetActualSubviews( ).ToArray( ), Does.Contain( buttonOut ) ); - - // The TabView read back in should contain the ScrollView - using ScrollView scrollIn = tabIn.Tabs.First( ) - .View.GetActualSubviews( ) - .OfType<ScrollView>( ) - .Single( ); - - using View buttonIn = scrollIn.GetActualSubviews( ).Single( ); - Assert.That( buttonIn, Is.InstanceOf<Button>( ) ); - Assert.That( buttonIn, Is.Not.SameAs( buttonOut ) ); - } -} \ No newline at end of file diff --git a/tests/ViewFactoryTests.cs b/tests/ViewFactoryTests.cs index ba0f48ec..8b35d670 100644 --- a/tests/ViewFactoryTests.cs +++ b/tests/ViewFactoryTests.cs @@ -184,7 +184,6 @@ private static Type[] KnownUnsupportedTypes_ExpectedTypes( ) typeof( FileDialog ), typeof( SaveDialog ), typeof( OpenDialog ), - typeof( ScrollBarView ), typeof( Wizard ), typeof( WizardStep ), From 11a8b98a87483795aef7848b7a5fdb9b3a4d2ea5 Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Mon, 17 Feb 2025 07:37:28 +0000 Subject: [PATCH 08/54] Make CanFocus a designable property and default to true on everything --- src/Design.cs | 2 ++ src/ViewFactory.cs | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Design.cs b/src/Design.cs index 1b04d61b..9823082c 100644 --- a/src/Design.cs +++ b/src/Design.cs @@ -685,6 +685,8 @@ private IEnumerable<Property> LoadDesignableProperties() yield return new ColorSchemeProperty(this); + yield return this.CreateSuppressedProperty(nameof(View.CanFocus), true); + // its important that this comes before Text because // changing the validator clears the text if (this.View is TextValidateField) diff --git a/src/ViewFactory.cs b/src/ViewFactory.cs index a3affe98..44207891 100644 --- a/src/ViewFactory.cs +++ b/src/ViewFactory.cs @@ -265,9 +265,12 @@ public static T Create<T>(int? width = null, int? height = null, string? text = SetDefaultDimensions(newView, 10, 5); break; case null: - throw new InvalidOperationException( $"Unexpected null result from type {typeof( T ).Name} construtor." ); + throw new InvalidOperationException( $"Unexpected null result from type {typeof( T ).Name} constructor." ); } + // Almost universally all user controlled views are going to want this. + newView.CanFocus = true; + return newView; static void SetDefaultDimensions( T v, int width = 5, int height = 1 ) From 1df691c6a794444056eb7756730267e8f74b71e0 Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Mon, 17 Feb 2025 07:51:09 +0000 Subject: [PATCH 09/54] Fix unit tests --- src/Operations/ResizeOperation.cs | 3 +++ tests/Tests.cs | 6 ++++++ tests/UI/MouseManagerTests.cs | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Operations/ResizeOperation.cs b/src/Operations/ResizeOperation.cs index 4f6019e1..e5a9c3b2 100644 --- a/src/Operations/ResizeOperation.cs +++ b/src/Operations/ResizeOperation.cs @@ -59,6 +59,7 @@ public override void Undo() { this.BeingResized.GetDesignableProperty("Width")?.SetValue(this.OriginalWidth); this.BeingResized.GetDesignableProperty("Height")?.SetValue(this.OriginalHeight); + this.BeingResized.View.Layout(); } /// <inheritdoc/> @@ -81,6 +82,8 @@ public void ContinueResize(Point dest) this.DestinationY = dest.Y; this.SetHeight(); + + this.BeingResized.View.Layout(); } /// <inheritdoc/> diff --git a/tests/Tests.cs b/tests/Tests.cs index 4ca1dd16..dc9c0965 100644 --- a/tests/Tests.cs +++ b/tests/Tests.cs @@ -44,6 +44,8 @@ public virtual void TearDown() protected static Design Get10By10View() { + Application.Top.RemoveAll(); + // start with blank slate OperationManager.Instance.ClearUndoRedo(); @@ -51,6 +53,7 @@ protected static Design Get10By10View() { Width = 10, Height = 10, + CanFocus = true, }; var d = new Design(new SourceCodeFile(new FileInfo("TenByTen.cs")), Design.RootDesignName, v); v.Data = d; @@ -58,6 +61,9 @@ protected static Design Get10By10View() v.BeginInit(); v.EndInit(); + Application.Top.Add(v); + Application.Top.LayoutSubviews(); + return d; } diff --git a/tests/UI/MouseManagerTests.cs b/tests/UI/MouseManagerTests.cs index 52eef9e6..f050f457 100644 --- a/tests/UI/MouseManagerTests.cs +++ b/tests/UI/MouseManagerTests.cs @@ -199,7 +199,7 @@ public void DragResizeView_CannotResize_DimFill<T>( T dummy ) Flags = MouseFlags.Button1Pressed }; mgr.HandleMouse( e, d ); - + Assert.Multiple( ( ) => { Assert.That( view.GetContentSize().Width, Is.EqualTo( 10 ), "Expected Width to remain constant because it is Dim.Fill()" ); From dc10f332a44f07fcc65d4f6feb4ee9c547a2747b Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Tue, 18 Feb 2025 02:42:49 +0000 Subject: [PATCH 10/54] Fix editor boot screen background color --- src/UI/Editor.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/UI/Editor.cs b/src/UI/Editor.cs index 55ec814f..cd52c33b 100644 --- a/src/UI/Editor.cs +++ b/src/UI/Editor.cs @@ -199,6 +199,8 @@ protected override bool OnDrawingContent() var r = base.OnDrawingContent(); var bounds = Viewport; + Application.Driver.SetAttribute(new Attribute(Color.Black)); + Application.Driver.FillRect(bounds,' '); // if we are editing a view if (this.viewBeingEdited != null) From 37956e5a7ab5440e21f7ebd65e590a0a90ef64ff Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Tue, 18 Feb 2025 03:23:29 +0000 Subject: [PATCH 11/54] Support for click and drag resize Button even when it has ShadowStyle --- src/Design.cs | 2 + src/ViewExtensions.cs | 61 ++++++++++++++++++++++++ tests/UI/MouseManagerTests.cs | 90 +++++++++++++++++++++++++++++++++++ 3 files changed, 153 insertions(+) diff --git a/src/Design.cs b/src/Design.cs index 9823082c..de30ea7d 100644 --- a/src/Design.cs +++ b/src/Design.cs @@ -682,10 +682,12 @@ private IEnumerable<Property> LoadDesignableProperties() yield return this.CreateSuppressedProperty(nameof(this.View.Visible), true); yield return this.CreateSuppressedProperty(nameof(this.View.Arrangement), ViewArrangement.Fixed); + yield return new ColorSchemeProperty(this); yield return this.CreateSuppressedProperty(nameof(View.CanFocus), true); + yield return this.CreateProperty(nameof(this.View.ShadowStyle)); // its important that this comes before Text because // changing the validator clears the text diff --git a/src/ViewExtensions.cs b/src/ViewExtensions.cs index a01d0169..8d5e4ad0 100644 --- a/src/ViewExtensions.cs +++ b/src/ViewExtensions.cs @@ -325,6 +325,11 @@ public static bool IsBorderlessContainerView(this View v) } + if (hit?.IsAdornment() ?? false) + { + hit = hit.GetAdornmentParent(); + } + // TabView nesting of 'fake' views goes: // TabView // - TabViewRow @@ -430,5 +435,61 @@ private static bool HasNoBorderProperty(this View v) return false; } + /// <summary> + /// Returns <see langword="true"/> if <paramref name="v"/> is part of + /// a <see cref="Adornment"/> (either directly or embedded sub view of + /// one - e.g. <see cref="ShadowView"/>). + /// </summary> + /// <param name="v"></param> + /// <returns></returns> + public static bool IsAdornment(this View v) + { + return v is Adornment || v.AnySuperViewIs<Adornment>(); + } + /// <summary> + /// Returns <see langword="true"/> if any <see cref="View.SuperView"/> of + /// <paramref name="v"/> is of type T. + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="v"></param> + /// <returns></returns> + public static bool AnySuperViewIs<T>(this View v) where T : View + { + var parent = v.SuperView; + + while (parent != null) + { + if (parent is T) + { + return true; + } + parent = parent.SuperView; + } + + return false; + } + + /// <summary> + /// Returns the <see cref="Adornment.Parent"/> of <paramref name="v"/> + /// if it is an <see cref="Adornment"/>. Or if <param name="v"/> is not + /// directly an adornment but <see cref="AnySuperViewIs{T}"/> then the method + /// will traverse up <see cref="View.SuperView"/> hierarchy until parent is found. + /// </summary> + /// <param name="v"></param> + /// <returns></returns> + public static View? GetAdornmentParent(this View v) + { + while (v != null) + { + if (v is Adornment a) + { + return a.Parent; + } + + v = v.SuperView; + } + + return null; + } } diff --git a/tests/UI/MouseManagerTests.cs b/tests/UI/MouseManagerTests.cs index f050f457..1d52e8a6 100644 --- a/tests/UI/MouseManagerTests.cs +++ b/tests/UI/MouseManagerTests.cs @@ -22,6 +22,11 @@ public void DragResizeView<T>( [ValueSource( nameof( DragResizeView_Types ) )] T view.Data = design; d.View.Add( view ); + if (view is Button btn) + { + btn.ShadowStyle = ShadowStyle.None; + } + Assert.That( view.GetContentSize().Width, Is.EqualTo( 8 ) ); MouseManager mgr = new( ); @@ -81,6 +86,91 @@ public void DragResizeView<T>( [ValueSource( nameof( DragResizeView_Types ) )] T } ); } + + [Test] + public void DragResize_ShadowButton() + { + Design d = Get10By10View(); + + using Button btn = ViewFactory.Create<Button>(); + btn.Width = 8; + btn.Height = 2; + btn.ShadowStyle = ShadowStyle.Opaque; + + Design design = new(d.SourceCode, "myView", btn); + btn.Data = design; + d.View.Add(btn); + + Assert.That(btn.Margin, Is.Not.Null); + Assert.That(btn.Margin!.IsAdornment(), Is.True); + var shadow = btn.Margin!.Subviews[0]; + Assert.That(shadow,Is.InstanceOf<ShadowView>()); + Assert.That(shadow.IsAdornment); + Assert.That(shadow.GetAdornmentParent(),Is.SameAs(btn)); + + + // View width is 8 but 1 is taken up by the shadow so content width is 7 + Assert.That(btn.GetContentSize().Width, Is.EqualTo(7)); + // View height is 2 but 1 is taken up by the shadow so content height is 1 + Assert.That(btn.GetContentSize().Height, Is.EqualTo(1)); + MouseManager mgr = new(); + + // we haven't done anything yet + Assert.Multiple(() => + { + Assert.That(OperationManager.Instance.UndoStackSize, Is.Zero); + Assert.That(btn.GetContentSize().Width, Is.EqualTo(7)); + Assert.That(btn.GetContentSize().Height, Is.EqualTo(1)); + }); + + // user presses down in the lower right of control + MouseEventArgs e = new() + { + Position = new Point(7, 1), + Flags = MouseFlags.Button1Pressed + }; + + mgr.HandleMouse(e, d); + + Assert.Multiple(() => + { + // we still haven't committed to anything + Assert.That(OperationManager.Instance.UndoStackSize, Is.Zero); + }); + + // user pulled view size +1 width and +1 height + e = new() + { + Position = new System.Drawing.Point(8, 2), + Flags = MouseFlags.Button1Pressed + }; + mgr.HandleMouse(e, d); + + // we still haven't committed to anything + Assert.Multiple(() => + { + Assert.That(btn.GetContentSize().Width, Is.EqualTo(8), "Expected resize to increase Width when dragging"); + Assert.That(btn.GetContentSize().Height, Is.EqualTo(2), "Expected resize to increase Height when dragging"); + Assert.That(OperationManager.Instance.UndoStackSize, Is.Zero); + }); + + // user releases mouse (in place) + e = new() + { + Position = new Point(8, 2) + }; + mgr.HandleMouse(e, d); + + Assert.Multiple(() => + { + Assert.That(btn.GetContentSize().Width, Is.EqualTo(8), "Expected release in place not to further resize"); + Assert.That(btn.GetContentSize().Height, Is.EqualTo(2), "Expected release in place not to further resize"); + + // we have now committed the drag so could undo + Assert.That(OperationManager.Instance.UndoStackSize, Is.EqualTo(1)); + }); + } + [Test] public void DragResizeView_CannotResize_1By1View( [Values( 0, 3 )] int locationOfViewX, [Values( 0, 3 )] int locationOfViewY ) { From 50aac861a27ba099e2f40fc2f43a067629185f11 Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Tue, 18 Feb 2025 03:40:44 +0000 Subject: [PATCH 12/54] Fix drag select box and lower right overlay text not rendering --- src/UI/Editor.cs | 85 ++++++++++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 35 deletions(-) diff --git a/src/UI/Editor.cs b/src/UI/Editor.cs index cd52c33b..a0a554df 100644 --- a/src/UI/Editor.cs +++ b/src/UI/Editor.cs @@ -193,62 +193,77 @@ public void Run(Options options) /// <summary> /// Tailors redrawing to add overlays (e.g. showing what is selected etc.). + /// Only runs when a view is open and <see cref="viewBeingEdited"/>. /// </summary> - protected override bool OnDrawingContent() + protected override void OnDrawComplete() { - var r = base.OnDrawingContent(); - var bounds = Viewport; + base.OnDrawComplete(); - Application.Driver.SetAttribute(new Attribute(Color.Black)); - Application.Driver.FillRect(bounds,' '); + // if we are not editing a view + if (this.viewBeingEdited == null) + { + return; + } - // if we are editing a view - if (this.viewBeingEdited != null) + var bounds = Viewport; + + if (this.enableShowFocused) { - if (this.enableShowFocused) - { - Application.Driver.SetAttribute(this.viewBeingEdited.View.ColorScheme.Normal); + Application.Driver.SetAttribute(this.viewBeingEdited.View.ColorScheme.Normal); - string? toDisplay = this.GetLowerRightTextIfAny(); + string? toDisplay = this.GetLowerRightTextIfAny(); - // and have a designable view focused - if (toDisplay != null) - { - // write its name in the lower right - int y = this.GetContentSize().Height - 1; - int right = bounds.Width - 1; - var len = toDisplay.Length; + // and have a designable view focused + if (toDisplay != null) + { + // write its name in the lower right + int y = this.GetContentSize().Height - 1; + int right = bounds.Width - 1; + var len = toDisplay.Length; - for (int i = 0; i < len; i++) - { - this.AddRune(right - len + i, y, new Rune(toDisplay[i])); - } + for (int i = 0; i < len; i++) + { + this.AddRune(right - len + i, y, new Rune(toDisplay[i])); } } + } - if (this.mouseManager.SelectionBox != null) + if (this.mouseManager.SelectionBox != null) + { + var box = this.mouseManager.SelectionBox.Value; + for (int x = 0; x < box.Width; x++) { - var box = this.mouseManager.SelectionBox.Value; - for (int x = 0; x < box.Width; x++) + for (int y = 0; y < box.Height; y++) { - for (int y = 0; y < box.Height; y++) + if (y == 0 || y == box.Height - 1 || x == 0 || x == box.Width - 1) { - if (y == 0 || y == box.Height - 1 || x == 0 || x == box.Width - 1) - { - this.AddRune(box.X + x, box.Y + y, new Rune('.')); - } + this.AddRune(box.X + x, box.Y + y, new Rune('.')); } } } - - return r; } - else + } + + /// <summary> + /// Draws title screen when no view is currently open + /// </summary> + protected override bool OnDrawingContent() + { + var r = base.OnDrawingContent(); + + if (viewBeingEdited != null) { - var top = new Rectangle(0, 0, bounds.Width, rootCommandsListView.Frame.Top - 1); - RenderTitle(top); + return true; } + var bounds = Viewport; + + Application.Driver.SetAttribute(new Attribute(Color.Black)); + Application.Driver.FillRect(bounds,' '); + + var top = new Rectangle(0, 0, bounds.Width, rootCommandsListView.Frame.Top - 1); + RenderTitle(top); + return r; } From 88584d2f04df23e971122b2d247ab8ef82bc3365 Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Tue, 18 Feb 2025 23:37:23 +0000 Subject: [PATCH 13/54] Fix ChoicesDialog - Remove TGD shadow drawing code now that it is part of main codebase - Regenerate ChoicesDialog (load/save) - Change to Dim.Auto for button Widths - Fix bug in RecursivelyIgnoreAllNonDesignableSubviews when used during loading processes that incorrectly flagged sub views as 'non designable' --- src/UI/MouseManager.cs | 5 +- src/UI/Windows/ChoicesDialog.Designer.cs | 238 ++++++++++++----------- src/UI/Windows/ChoicesDialog.cs | 53 +---- src/ViewExtensions.cs | 6 +- 4 files changed, 136 insertions(+), 166 deletions(-) diff --git a/src/UI/MouseManager.cs b/src/UI/MouseManager.cs index 430dfce2..d17e6494 100644 --- a/src/UI/MouseManager.cs +++ b/src/UI/MouseManager.cs @@ -31,7 +31,7 @@ public class MouseManager public Rectangle? SelectionBox => RectExtensions.FromBetweenPoints(this.selectionStart, this.selectionEnd); /// <summary> - /// Responds to <see cref="Application.RootMouseEvent"/>(by changing a 'drag a box' selection area + /// Responds to <see cref="Application.MouseEvent"/>(by changing a 'drag a box' selection area /// or starting a resize etc). /// </summary> /// <param name="m">The <see cref="MouseEventArgs"/> reported by <see cref="Application.RootMouseEvent"/>.</param> @@ -123,9 +123,6 @@ public void HandleMouse(MouseEventArgs m, Design viewBeingEdited) // move selection box to new mouse position this.selectionEnd = m.Position; viewBeingEdited.View.SetNeedsDraw(); - - // BUG: Method is gone, will this functionality work still without it? - // Application.DoEvents(); return; } diff --git a/src/UI/Windows/ChoicesDialog.Designer.cs b/src/UI/Windows/ChoicesDialog.Designer.cs index ca55da23..337875cb 100644 --- a/src/UI/Windows/ChoicesDialog.Designer.cs +++ b/src/UI/Windows/ChoicesDialog.Designer.cs @@ -3,121 +3,139 @@ // <auto-generated> // This code was generated by: -// TerminalGuiDesigner v1.0.18.0 +// TerminalGuiDesigner v2.0.0.0 // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> // ----------------------------------------------------------------------------- -namespace TerminalGuiDesigner.UI.Windows; -using System; -using Terminal.Gui; - - -public partial class ChoicesDialog : Terminal.Gui.Window { - - private Terminal.Gui.ColorScheme dialogBackground; - - private Terminal.Gui.ColorScheme buttons; - - private Terminal.Gui.Label label1; +namespace TerminalGuiDesigner.UI.Windows { + using System; + using Terminal.Gui; + using System.Collections; + using System.Collections.Generic; + using System.Collections.ObjectModel; + using System.Drawing; - private Terminal.Gui.View buttonPanel; - private Terminal.Gui.Button btn1; - - private Terminal.Gui.Button btn2; - - private Terminal.Gui.Button btn3; - - private Terminal.Gui.Button btn4; - - private void InitializeComponent() { - this.btn4 = new Terminal.Gui.Button(); - this.btn3 = new Terminal.Gui.Button(); - this.btn2 = new Terminal.Gui.Button(); - this.btn1 = new Terminal.Gui.Button(); - this.buttonPanel = new Terminal.Gui.View(); - this.label1 = new Terminal.Gui.Label(); - this.dialogBackground = new Terminal.Gui.ColorScheme( - new Terminal.Gui.Attribute(Terminal.Gui.Color.White, Terminal.Gui.Color.DarkGray), - new Terminal.Gui.Attribute(Terminal.Gui.Color.White, Terminal.Gui.Color.DarkGray), - new Terminal.Gui.Attribute(Terminal.Gui.Color.White, Terminal.Gui.Color.DarkGray), - new Terminal.Gui.Attribute(Terminal.Gui.Color.Black, Terminal.Gui.Color.Black), - new Terminal.Gui.Attribute(Terminal.Gui.Color.White, Terminal.Gui.Color.DarkGray) - ); - this.buttons = new Terminal.Gui.ColorScheme( - new Terminal.Gui.Attribute(Terminal.Gui.Color.DarkGray, Terminal.Gui.Color.White), - new Terminal.Gui.Attribute(Terminal.Gui.Color.Red, Terminal.Gui.Color.Yellow), - new Terminal.Gui.Attribute(Terminal.Gui.Color.Black, Terminal.Gui.Color.White), - new Terminal.Gui.Attribute(Terminal.Gui.Color.Black, Terminal.Gui.Color.Black), - new Terminal.Gui.Attribute(Terminal.Gui.Color.Black, Terminal.Gui.Color.Yellow) - ); - - this.Width = Dim.Percent(85); - this.Height = Dim.Percent(85); - this.X = Pos.Center(); - this.Y = Pos.Center(); - this.ColorScheme = this.dialogBackground; - this.Modal = true; - this.Text = ""; - this.Border.BorderStyle = Terminal.Gui.LineStyle.Double; - this.TextAlignment = Terminal.Gui.Alignment.Start; - this.Title = ""; - this.label1.Width = Dim.Fill(0); - this.label1.Height = Dim.Fill(0); - this.label1.X = 0; - this.label1.Y = 1; - this.label1.Data = "label1"; - this.label1.Text = "lblMessage"; - this.label1.TextAlignment = Terminal.Gui.Alignment.Center; - this.Add(this.label1); - this.buttonPanel.Width = 50; - this.buttonPanel.Height = 2; - this.buttonPanel.X = Pos.Center(); - this.buttonPanel.Y = Pos.AnchorEnd(2); - this.buttonPanel.Data = "buttonPanel"; - this.buttonPanel.Text = ""; - this.buttonPanel.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.buttonPanel); - this.btn1.Width = 10; - this.btn1.Height = 2; - this.btn1.X = 0; - this.btn1.Y = Pos.AnchorEnd(2); - this.btn1.ColorScheme = this.buttons; - this.btn1.Data = "btn1"; - this.btn1.Text = "btn1"; - this.btn1.TextAlignment = Terminal.Gui.Alignment.Center; - this.btn1.IsDefault = true; - this.buttonPanel.Add(this.btn1); - this.btn2.Width = 9; - this.btn2.Height = 2; - this.btn2.X = Pos.Right(btn1) + 1; - this.btn2.Y = Pos.AnchorEnd(2); - this.btn2.ColorScheme = this.buttons; - this.btn2.Data = "btn2"; - this.btn2.Text = "btn2"; - this.btn2.TextAlignment = Terminal.Gui.Alignment.Center; - this.btn2.IsDefault = false; - this.buttonPanel.Add(this.btn2); - this.btn3.Width = 8; - this.btn3.Height = 2; - this.btn3.X = Pos.Right(btn2) + 1; - this.btn3.Y = Pos.AnchorEnd(2); - this.btn3.ColorScheme = this.buttons; - this.btn3.Data = "btn3"; - this.btn3.Text = "btn3"; - this.btn3.TextAlignment = Terminal.Gui.Alignment.Center; - this.btn3.IsDefault = false; - this.buttonPanel.Add(this.btn3); - this.btn4.Width = 8; - this.btn4.Height = 2; - this.btn4.X = Pos.Right(btn3) + 1; - this.btn4.Y = Pos.AnchorEnd(2); - this.btn4.ColorScheme = this.buttons; - this.btn4.Data = "btn4"; - this.btn4.Text = "btn4"; - this.btn4.TextAlignment = Terminal.Gui.Alignment.Center; - this.btn4.IsDefault = false; - this.buttonPanel.Add(this.btn4); + public partial class ChoicesDialog : Terminal.Gui.Window { + + private Terminal.Gui.ColorScheme dialogBackground; + + private Terminal.Gui.ColorScheme buttons; + + private Terminal.Gui.Label label1; + + private Terminal.Gui.View buttonPanel; + + private Terminal.Gui.Button btn1; + + private Terminal.Gui.Button btn2; + + private Terminal.Gui.Button btn3; + + private Terminal.Gui.Button btn4; + + private void InitializeComponent() { + this.btn4 = new Terminal.Gui.Button(); + this.btn3 = new Terminal.Gui.Button(); + this.btn2 = new Terminal.Gui.Button(); + this.btn1 = new Terminal.Gui.Button(); + this.buttonPanel = new Terminal.Gui.View(); + this.label1 = new Terminal.Gui.Label(); + this.dialogBackground = new Terminal.Gui.ColorScheme(new Terminal.Gui.Attribute(4294967295u, 4285953654u), new Terminal.Gui.Attribute(4294967295u, 4285953654u), new Terminal.Gui.Attribute(4294967295u, 4285953654u), new Terminal.Gui.Attribute(4278190080u, 4278190080u), new Terminal.Gui.Attribute(4294967295u, 4285953654u)); + this.buttons = new Terminal.Gui.ColorScheme(new Terminal.Gui.Attribute(4285953654u, 4294967295u), new Terminal.Gui.Attribute(4294901760u, 4294967040u), new Terminal.Gui.Attribute(4278190080u, 4294967295u), new Terminal.Gui.Attribute(4278190080u, 4278190080u), new Terminal.Gui.Attribute(4278190080u, 4294967040u)); + this.Width = Dim.Percent(85); + this.Height = Dim.Percent(85); + this.X = Pos.Center(); + this.Y = Pos.Center(); + this.Visible = true; + this.Arrangement = ((Terminal.Gui.ViewArrangement.Movable | Terminal.Gui.ViewArrangement.Resizable) + | Terminal.Gui.ViewArrangement.Overlapped); + this.ColorScheme = this.dialogBackground; + this.CanFocus = true; + this.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.Modal = true; + this.TextAlignment = Terminal.Gui.Alignment.Start; + this.Title = ""; + this.label1.Width = Dim.Fill(0); + this.label1.Height = Dim.Fill(0); + this.label1.X = 0; + this.label1.Y = 1; + this.label1.Visible = true; + this.label1.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.label1.CanFocus = true; + this.label1.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.label1.Data = "label1"; + this.label1.Text = "lblMessage"; + this.label1.TextAlignment = Terminal.Gui.Alignment.Center; + this.Add(this.label1); + this.buttonPanel.Width = 50; + this.buttonPanel.Height = 2; + this.buttonPanel.X = Pos.Center(); + this.buttonPanel.Y = Pos.AnchorEnd(2); + this.buttonPanel.Visible = true; + this.buttonPanel.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.buttonPanel.CanFocus = true; + this.buttonPanel.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.buttonPanel.Data = "buttonPanel"; + this.buttonPanel.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.buttonPanel); + this.btn1.Width = Dim.Auto(); + this.btn1.Height = 2; + this.btn1.X = 0; + this.btn1.Y = Pos.AnchorEnd(2); + this.btn1.Visible = true; + this.btn1.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btn1.ColorScheme = this.buttons; + this.btn1.CanFocus = true; + this.btn1.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; + this.btn1.Data = "btn1"; + this.btn1.Text = "btn1"; + this.btn1.TextAlignment = Terminal.Gui.Alignment.Center; + this.btn1.IsDefault = true; + this.buttonPanel.Add(this.btn1); + this.btn2.Width = Dim.Auto(); + this.btn2.Height = 2; + this.btn2.X = Pos.Right(btn1) + 1; + this.btn2.Y = Pos.AnchorEnd(2); + this.btn2.Visible = true; + this.btn2.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btn2.ColorScheme = this.buttons; + this.btn2.CanFocus = true; + this.btn2.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; + this.btn2.Data = "btn2"; + this.btn2.Text = "btn2"; + this.btn2.TextAlignment = Terminal.Gui.Alignment.Center; + this.btn2.IsDefault = false; + this.buttonPanel.Add(this.btn2); + this.btn3.Width = Dim.Auto(); + this.btn3.Height = 2; + this.btn3.X = Pos.Right(btn2) + 1; + this.btn3.Y = Pos.AnchorEnd(2); + this.btn3.Visible = true; + this.btn3.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btn3.ColorScheme = this.buttons; + this.btn3.CanFocus = true; + this.btn3.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; + this.btn3.Data = "btn3"; + this.btn3.Text = "btn3"; + this.btn3.TextAlignment = Terminal.Gui.Alignment.Center; + this.btn3.IsDefault = false; + this.buttonPanel.Add(this.btn3); + this.btn4.Width = Dim.Auto(); + this.btn4.Height = 2; + this.btn4.X = Pos.Right(btn3) + 1; + this.btn4.Y = Pos.AnchorEnd(2); + this.btn4.Visible = true; + this.btn4.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btn4.ColorScheme = this.buttons; + this.btn4.CanFocus = true; + this.btn4.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; + this.btn4.Data = "btn4"; + this.btn4.Text = "btn4"; + this.btn4.TextAlignment = Terminal.Gui.Alignment.Center; + this.btn4.IsDefault = false; + this.buttonPanel.Add(this.btn4); + } } } diff --git a/src/UI/Windows/ChoicesDialog.cs b/src/UI/Windows/ChoicesDialog.cs index 57d56801..07ccbd56 100644 --- a/src/UI/Windows/ChoicesDialog.cs +++ b/src/UI/Windows/ChoicesDialog.cs @@ -52,10 +52,6 @@ public ChoicesDialog(string title, string message, params string[] options) { { // add space for right hand side shadow buttons[i].Text = options[i] + " "; - - // TODO think it depends if it is default if we have to do this hack - buttons[i].Width = Dim.Auto(); - var i2 = i; @@ -63,11 +59,10 @@ public ChoicesDialog(string title, string message, params string[] options) { Result = i2; Application.RequestStop(); }; - - buttons[i].DrawComplete += (s,r) => - ChoicesDialog.PaintShadow(buttons[i2], ColorScheme); } + buttonPanel.LayoutSubviews(); + // hide other buttons for(int i=options.Length;i<buttons.Length;i++) { @@ -133,50 +128,6 @@ internal static int Query(string title, string message, params string[] options) Application.Run(dlg); return dlg.Result; } - - internal static void PaintShadow(Button btn, ColorScheme backgroundScheme) - { - var bounds = btn.GetContentSize(); - - Attribute buttonColor = btn.HasFocus ? - new Terminal.Gui.Attribute(btn.ColorScheme.Focus.Foreground, btn.ColorScheme.Focus.Background): - new Terminal.Gui.Attribute(btn.ColorScheme.Normal.Foreground, btn.ColorScheme.Normal.Background); - - Driver.SetAttribute(buttonColor); - - if (btn.IsDefault) - { - var rightDefault = Driver != null ? ConfigurationManager.Glyphs.RightDefaultIndicator : new Rune('>'); - - // draw the 'end' button symbol one in - btn.AddRune(bounds.Width - 3, 0, rightDefault); - } - - btn.AddRune(bounds.Width - 2, 0, new System.Text.Rune(']')); - btn.AddRune(0, 0, new System.Text.Rune('[')); - - var backgroundColor = backgroundScheme.Normal.Background; - - // shadow color - Driver.SetAttribute(new Terminal.Gui.Attribute(Color.Black, backgroundColor)); - - // end shadow (right) - btn.AddRune(bounds.Width - 1, 0, new System.Text.Rune('▄')); - - // leave whitespace in lower left in parent/default background color - Driver.SetAttribute(new Terminal.Gui.Attribute(Color.Black, backgroundColor)); - btn.AddRune(0, 1, new System.Text.Rune(' ')); - - // The color for rendering shadow is 'black' + parent/default background color - Driver.SetAttribute(new Terminal.Gui.Attribute(backgroundColor, Color.Black)); - - // underline shadow - for (int x = 1; x < bounds.Width; x++) - { - btn.AddRune(x, 1, new System.Text.Rune('▄')); - } - } - internal static bool Confirm(string title, string message, string okText = "Yes", string cancelText = "No") { var dlg = new ChoicesDialog(title, message, okText, cancelText); diff --git a/src/ViewExtensions.cs b/src/ViewExtensions.cs index 8d5e4ad0..3e79d115 100644 --- a/src/ViewExtensions.cs +++ b/src/ViewExtensions.cs @@ -416,11 +416,15 @@ private static void RecursivelyIgnoreAllNonDesignableSubviews(View view, List<Vi { foreach (var sub in view.Subviews) { - if (sub.Data is not Design) + // If Data is string then it is likely a View that is going to + // end up having a Design but we haven't gotten to it yet (i.e. method is being called mid-load) + if (sub.Data is not Design and not string) { alsoIgnore.Add(sub); } + + RecursivelyIgnoreAllNonDesignableSubviews(sub, alsoIgnore); } } From d015b85eafc857184509827878038ec3f899251c Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Wed, 19 Feb 2025 00:01:24 +0000 Subject: [PATCH 14/54] Deploy workaround for broken IsDefault behaviour on ChoicesDialog Previously when prompted if you want to save changes on exit any clicked button results in Yes --- src/UI/Windows/ChoicesDialog.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/UI/Windows/ChoicesDialog.cs b/src/UI/Windows/ChoicesDialog.cs index 07ccbd56..c7c7eada 100644 --- a/src/UI/Windows/ChoicesDialog.cs +++ b/src/UI/Windows/ChoicesDialog.cs @@ -57,7 +57,12 @@ public ChoicesDialog(string title, string message, params string[] options) { buttons[i].Accepting += (s,e) => { Result = i2; + + // TODO: Remove once fixed upstream + // Workaround for https://github.com/gui-cs/Terminal.Gui/issues/3913 + e.Cancel = true; Application.RequestStop(); + }; } From 0874e14bd337d11fc5efb62d9c95396059ae427c Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Wed, 19 Feb 2025 00:22:29 +0000 Subject: [PATCH 15/54] Fix crash right clicking MenuBar due to renamed private field, and future proof ReflectionHelper to renaming private fields to have prefix underscore --- src/ReflectionHelpers.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ReflectionHelpers.cs b/src/ReflectionHelpers.cs index a7e954bd..4df4dc7d 100644 --- a/src/ReflectionHelpers.cs +++ b/src/ReflectionHelpers.cs @@ -35,7 +35,10 @@ internal static TOut GetNonNullNonPublicFieldValue<TOut, TIn>( this TIn? item, s ArgumentNullException.ThrowIfNull( item, nameof( item ) ); ArgumentException.ThrowIfNullOrEmpty( fieldName, nameof( fieldName ) ); + // Try get private field e.g. 'blah'. But because upstream often flips + // around the naming of privates lets also look for '_blah' FieldInfo selectedField = typeof( TIn ).GetField( fieldName, BindingFlags.NonPublic | BindingFlags.Instance ) + ??typeof(TIn).GetField("_"+fieldName, BindingFlags.NonPublic | BindingFlags.Instance) ?? throw new MissingFieldException( $"Expected non-public instance field {fieldName} was not present on {typeof( TIn ).Name}" ); if ( selectedField.FieldType != typeof( TOut ) ) From 55c56594dc931ad3572e44e213cb64ae2181d157 Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Wed, 19 Feb 2025 08:21:18 +0000 Subject: [PATCH 16/54] Expect extra views for popups --- tests/MenuBarExtensionsTests.cs | 5 +++-- tests/Operations/AddViewOperationTests.cs | 22 +++++++++++++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/tests/MenuBarExtensionsTests.cs b/tests/MenuBarExtensionsTests.cs index 84553dc4..28f8b780 100644 --- a/tests/MenuBarExtensionsTests.cs +++ b/tests/MenuBarExtensionsTests.cs @@ -29,7 +29,7 @@ public void ScreenToMenuBarItem_MultipleMenuItems_ReturnsExpectedItem_IfItemsCli v.Y = yOffset; // Expect a MenuBar to be rendered that is - // ".test..next..more.." (with 1 unit of preceding whitespace and 2 after each) + // ".test..next..more.." (with 1 unit of preceding whitespace and 1 after each) // Note that this test is brittle and subject to changes in Terminal.Gui e.g. pushing menus closer together. v.Menus[ 0 ].Title = "test"; @@ -39,7 +39,8 @@ public void ScreenToMenuBarItem_MultipleMenuItems_ReturnsExpectedItem_IfItemsCli Assume.That( v.Menus, Has.Exactly( 3 ).InstanceOf<MenuBarItem>( ) ); // Clicks in the "test" region - Assert.That( v.ScreenToMenuBarItem( clickXCoordinate + xOffset ), Is.SameAs( v.Menus[ ( clickXCoordinate - 1 ) / expectedItemWidth ] ) ); + Assert.That( v.ScreenToMenuBarItem( clickXCoordinate + xOffset ), + Is.SameAs( v.Menus[ ( clickXCoordinate - 1 ) / expectedItemWidth ] ) ); }, out _ ); } diff --git a/tests/Operations/AddViewOperationTests.cs b/tests/Operations/AddViewOperationTests.cs index e42f992c..f559f740 100644 --- a/tests/Operations/AddViewOperationTests.cs +++ b/tests/Operations/AddViewOperationTests.cs @@ -15,8 +15,16 @@ internal class AddViewOperationTests : Tests .OrderBy( t => t == typeof( MenuBar ) ? int.MaxValue : 0 ) .Select(PickFirstTTypeForGenerics) .ToArray( ); - - + /// <summary> + /// Views which add a sibling 'popover' view to parent when added + /// </summary> + public static HashSet<Type> PopoverTypes = new HashSet<Type> + { + typeof(TextField), + typeof(TextView), + typeof(DateField), + typeof(TimeField), + }; [Test( Description = "Tests AddViewOperation against all SupportedViewTypes" )] public void Do_AddsExpectedSubview( [ValueSource( nameof( SupportedViewTypes ) )] Type candidateType ) @@ -30,7 +38,9 @@ public void Do_AddsExpectedSubview( [ValueSource( nameof( SupportedViewTypes ) ) IList<View> subviews = d.View.Subviews; - Assert.That( subviews, Has.Count.EqualTo( 1 ) ); + var hasInvisPopupViewToo = PopoverTypes.Contains(candidateType); + + Assert.That( subviews, Has.Count.EqualTo( hasInvisPopupViewToo? 2:1) ); var theOnlySubView = subviews[ 0 ]; Assert.That( theOnlySubView, Is.SameAs( instance ) ); @@ -55,9 +65,11 @@ public void Do_SubviewNamesProperlyDeDuplicated( int numberOfViews, string baseN IList<View> subviews = d.View.Subviews; - Assert.That( subviews, Has.Count.EqualTo( operationNumber ) ); + var hasInvisPopupViewToo = PopoverTypes.Contains(instance.GetType()); + + Assert.That( subviews, Has.Count.EqualTo( operationNumber * (hasInvisPopupViewToo?2:1)) ); - var lastSubview = subviews.Last( ); + var lastSubview = subviews[subviews.Count - (hasInvisPopupViewToo?2:1)]; Assert.That( lastSubview, Is.SameAs( instance ) ); From e8247da5eb6140bab48bcefe6c784ddd11dea15b Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Thu, 27 Feb 2025 20:42:16 +0000 Subject: [PATCH 17/54] Bump to latest pre alpha package and fix menu bar tests --- src/TerminalGuiDesigner.csproj | 2 +- tests/MenuBarExtensionsTests.cs | 32 +++++++++++++++++++++++++------- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/TerminalGuiDesigner.csproj b/src/TerminalGuiDesigner.csproj index a1afacac..44c9e7e5 100644 --- a/src/TerminalGuiDesigner.csproj +++ b/src/TerminalGuiDesigner.csproj @@ -150,7 +150,7 @@ <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.1" /> <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" /> <PackageReference Include="NetEscapades.Configuration.Yaml" Version="3.1.0" /> - <PackageReference Include="Terminal.Gui" Version="2.0.0-v2-develop.1532" /> + <PackageReference Include="Terminal.Gui" Version="2.0.0-prealpha.1545" /> <PackageReference Include="nlog" Version="5.3.3" /> <PackageReference Include="Basic.Reference.Assemblies.Net80" Version="1.7.7" /> <PackageReference Include="System.CodeDom" Version="8.0.0" /> diff --git a/tests/MenuBarExtensionsTests.cs b/tests/MenuBarExtensionsTests.cs index 28f8b780..8cca4f6d 100644 --- a/tests/MenuBarExtensionsTests.cs +++ b/tests/MenuBarExtensionsTests.cs @@ -11,15 +11,22 @@ namespace UnitTests; [NonParallelizable] internal class MenuBarExtensionsTests : Tests { + /// <summary> + /// Expects menu like + /// 0123456789 + /// test next + /// + /// This tests that the click in screen space finds the menu (File, Edit etc.). + /// Furthermore, it tests that works even when the MenuBar is not at the origin + /// </summary> [Test] [NonParallelizable] public void ScreenToMenuBarItem_MultipleMenuItems_ReturnsExpectedItem_IfItemsClicked( - [Values( 5, 6 )] int clickXCoordinate, - [Values( 0, 5 )] int xOffset, - [Values( 0, 1 )] int yOffset ) + [Values( 1, 4 )] int clickXCoordinate, + [Values( 0, 3 )] int xOffset, + [Values( 0, 1 )] int yOffset, + [Values(0)]int expectedMenuItem) { - const int expectedItemWidth = 6; - RoundTrip<View, MenuBar>( ( d, v ) => { Assume.That( d, Is.Not.Null.And.InstanceOf<Design>( ) ); @@ -28,6 +35,8 @@ public void ScreenToMenuBarItem_MultipleMenuItems_ReturnsExpectedItem_IfItemsCli v.X = xOffset; v.Y = yOffset; + v.SuperView!.LayoutSubviews(); + // Expect a MenuBar to be rendered that is // ".test..next..more.." (with 1 unit of preceding whitespace and 1 after each) // Note that this test is brittle and subject to changes in Terminal.Gui e.g. pushing menus closer together. @@ -39,8 +48,9 @@ public void ScreenToMenuBarItem_MultipleMenuItems_ReturnsExpectedItem_IfItemsCli Assume.That( v.Menus, Has.Exactly( 3 ).InstanceOf<MenuBarItem>( ) ); // Clicks in the "test" region - Assert.That( v.ScreenToMenuBarItem( clickXCoordinate + xOffset ), - Is.SameAs( v.Menus[ ( clickXCoordinate - 1 ) / expectedItemWidth ] ) ); + var a = v.ScreenToMenuBarItem(clickXCoordinate + xOffset); + var b = v.Menus[expectedMenuItem]; + Assert.That( a, Is.SameAs(b)); }, out _ ); } @@ -58,6 +68,8 @@ public void ScreenToMenuBarItem_MultipleMenuItems_ReturnsNull_IfClickedBeforeAnd v.X = xOffset; v.Y = yOffset; + v.SuperView!.LayoutSubviews(); + // Expect a MenuBar to be rendered that is // ".test..next..more.." (with 1 unit of preceding whitespace and 2 after each) // Note that this test is brittle and subject to changes in Terminal.Gui e.g. pushing menus closer together. @@ -87,6 +99,8 @@ public void ScreenToMenuBarItem_OneMenuItem_ReturnsExpectedMenuBarItem_IfClicked v.X = xOffset; v.Y = yOffset; + v.SuperView!.LayoutSubviews(); + // Expect a MenuBar to be rendered that is // ".test.." (with 1 unit of preceding whitespace and 2 after) // Note that this test is brittle and subject to changes in Terminal.Gui e.g. pushing menus closer together. @@ -112,6 +126,8 @@ public void ScreenToMenuBarItem_OneMenuItem_ReturnsExpectedMenuBarItem_IfItemCli v.X = xOffset; v.Y = yOffset; + v.SuperView!.LayoutSubviews(); + // Expect a MenuBar to be rendered that is // ".test.." (with 1 unit of preceding whitespace and 2 after) // Note that this test is brittle and subject to changes in Terminal.Gui e.g. pushing menus closer together. @@ -137,6 +153,8 @@ public void ScreenToMenuBarItem_OneMenuItem_ReturnsNull_IfClickedBeforeAndAfterI v.X = xOffset; v.Y = yOffset; + v.SuperView!.LayoutSubviews(); + // Expect a MenuBar to be rendered that is // ".test.." (with 1 unit of preceding whitespace and 2 after) // Note that this test is brittle and subject to changes in Terminal.Gui e.g. pushing menus closer together. From e0b7ae9ce72b44856753f97e96bbd8bfea38a90b Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Thu, 27 Feb 2025 20:54:11 +0000 Subject: [PATCH 18/54] Fix unit tests --- tests/ViewExtensionsTests.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/ViewExtensionsTests.cs b/tests/ViewExtensionsTests.cs index 559ad6d7..05889e8d 100644 --- a/tests/ViewExtensionsTests.cs +++ b/tests/ViewExtensionsTests.cs @@ -1,6 +1,7 @@ using System; using Terminal.Gui; using TerminalGuiDesigner; +using static System.Runtime.InteropServices.JavaScript.JSType; namespace UnitTests; @@ -32,6 +33,9 @@ public void TestHitTest(int x, int y, bool hit, bool border, bool lowerRight) v.Width = 5; v.Height = 3; + // Hit test does not find things that are not designable + v.Data = new Design(new SourceCodeFile("MyView.cs"), "myview", v); + Application.Top.Add(v); bool isLowerRight; bool isBorder; @@ -49,7 +53,7 @@ public void TestHitTest(int x, int y, bool hit, bool border, bool lowerRight) } else { - ClassicAssert.IsNull(result); + ClassicAssert.AreSame(Application.Top,result); } ClassicAssert.AreEqual(lowerRight, isLowerRight); @@ -92,6 +96,9 @@ public void TestHitTest_WindowWithFrameView_InBorder() Height = 5, }; + // Hit test does not find things that are not designable + f.Data = new Design(new SourceCodeFile("MyView.cs"), "myframe", f); + w.Add(f); Application.Begin(w); w.LayoutSubviews(); From f3b62166c4442b5308bb7c9455494266486b6c64 Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Sun, 2 Mar 2025 11:41:23 +0000 Subject: [PATCH 19/54] Update to latest package --- Showcase/Showcase.csproj | 2 +- src/TerminalGuiDesigner.csproj | 2 +- src/ToCode/Property.cs | 4 ++-- src/UI/Windows/ChoicesDialog.cs | 6 +++--- tests/PropertyTests.cs | 4 ++-- tests/UnitTests.csproj | 1 + 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Showcase/Showcase.csproj b/Showcase/Showcase.csproj index 207dd0e0..bb351615 100644 --- a/Showcase/Showcase.csproj +++ b/Showcase/Showcase.csproj @@ -8,7 +8,7 @@ </PropertyGroup> <ItemGroup> - <PackageReference Include="Terminal.Gui" Version="2.0.0-v2-develop.1532" /> + <PackageReference Include="Terminal.Gui" Version="2.0.0-prealpha.1546" /> </ItemGroup> </Project> diff --git a/src/TerminalGuiDesigner.csproj b/src/TerminalGuiDesigner.csproj index 44c9e7e5..9e9846d4 100644 --- a/src/TerminalGuiDesigner.csproj +++ b/src/TerminalGuiDesigner.csproj @@ -150,7 +150,7 @@ <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.1" /> <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" /> <PackageReference Include="NetEscapades.Configuration.Yaml" Version="3.1.0" /> - <PackageReference Include="Terminal.Gui" Version="2.0.0-prealpha.1545" /> + <PackageReference Include="Terminal.Gui" Version="2.0.0-prealpha.1546" /> <PackageReference Include="nlog" Version="5.3.3" /> <PackageReference Include="Basic.Reference.Assemblies.Net80" Version="1.7.7" /> <PackageReference Include="System.CodeDom" Version="8.0.0" /> diff --git a/src/ToCode/Property.cs b/src/ToCode/Property.cs index 4be009a2..80051d7e 100644 --- a/src/ToCode/Property.cs +++ b/src/ToCode/Property.cs @@ -108,13 +108,13 @@ public virtual void SetValue(object? value) case Orientation.Horizontal: v.Width = v.Height; v.Height = 1; - v.LineRune = ConfigurationManager.Glyphs.HLine; + v.LineRune = Glyphs.HLine; break; case Orientation.Vertical: v.Height = v.Width; v.Width = 1; - v.LineRune = ConfigurationManager.Glyphs.VLine; + v.LineRune = Glyphs.VLine; break; default: throw new ArgumentException($"Unknown Orientation {newOrientation}"); diff --git a/src/UI/Windows/ChoicesDialog.cs b/src/UI/Windows/ChoicesDialog.cs index c7c7eada..edcae845 100644 --- a/src/UI/Windows/ChoicesDialog.cs +++ b/src/UI/Windows/ChoicesDialog.cs @@ -112,7 +112,7 @@ protected override void OnDrawComplete() Driver.SetAttribute( new Attribute(ColorScheme.Normal.Foreground, ColorScheme.Normal.Background)); - Driver.AddStr(string.Join("",Enumerable.Repeat(ConfigurationManager.Glyphs.HLineHv, padding))); + Driver.AddStr(string.Join("",Enumerable.Repeat(Glyphs.HLineHv, padding))); Driver.SetAttribute( new Attribute(ColorScheme.Normal.Background, ColorScheme.Normal.Foreground)); @@ -122,9 +122,9 @@ protected override void OnDrawComplete() new Attribute(ColorScheme.Normal.Foreground, ColorScheme.Normal.Background)); StringBuilder sb = new StringBuilder(); - sb.Append(ConfigurationManager.Glyphs.HLineHv); + sb.Append(Glyphs.HLineHv); - Driver.AddStr(string.Join("", Enumerable.Repeat(ConfigurationManager.Glyphs.HLineHv.ToString(), padding))); + Driver.AddStr(string.Join("", Enumerable.Repeat(Glyphs.HLineHv.ToString(), padding))); } internal static int Query(string title, string message, params string[] options) diff --git a/tests/PropertyTests.cs b/tests/PropertyTests.cs index a1c9651d..b3367b83 100644 --- a/tests/PropertyTests.cs +++ b/tests/PropertyTests.cs @@ -30,7 +30,7 @@ public void Changing_LineViewOrientation( ) Assert.That( prop, Is.Not.Null ); prop?.SetValue( Orientation.Vertical ); - Assert.That( lv.LineRune, Is.EqualTo( TerminalGuiConfigurationManager.Glyphs.VLine ) ); + Assert.That( lv.LineRune, Is.EqualTo( Glyphs.VLine ) ); // now try with a dim fill lv.Height = Dim.Fill( ); @@ -41,7 +41,7 @@ public void Changing_LineViewOrientation( ) Assert.Multiple( ( ) => { Assert.That( lv.Orientation, Is.EqualTo( Orientation.Horizontal ) ); - Assert.That( lv.LineRune, Is.EqualTo( TerminalGuiConfigurationManager.Glyphs.HLine ) ); + Assert.That( lv.LineRune, Is.EqualTo( Glyphs.HLine ) ); Assert.That( lv.Width, Is.EqualTo( Dim.Fill( ) ) ); Assert.That( lv.Height, Is.EqualTo( Dim.Absolute( 1 ) ) ); } ); diff --git a/tests/UnitTests.csproj b/tests/UnitTests.csproj index e474475a..f2dd904d 100644 --- a/tests/UnitTests.csproj +++ b/tests/UnitTests.csproj @@ -36,6 +36,7 @@ <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> </PackageReference> + <PackageReference Include="Terminal.Gui" Version="2.0.0-prealpha.1546" /> </ItemGroup> <ItemGroup> From a172c1de0a450906b800dae70e51323e92a94a79 Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Sun, 2 Mar 2025 12:52:27 +0000 Subject: [PATCH 20/54] Fix Type to only show the name not full namespace --- src/UI/Windows/BigListBox.cs | 2 +- src/UI/Windows/Modals.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/UI/Windows/BigListBox.cs b/src/UI/Windows/BigListBox.cs index 83ab211d..9b47dfa7 100644 --- a/src/UI/Windows/BigListBox.cs +++ b/src/UI/Windows/BigListBox.cs @@ -90,7 +90,7 @@ public BigListBox( this.collection = this.BuildList(this.GetInitialSource()).ToList(); this.listView.SetSource( - new ObservableCollection<T>(this.collection.Select(o=>o.Object).ToArray()) + new ObservableCollection<ListViewObject<T>>(this.collection.ToArray()) ); this.win.Add(this.listView); diff --git a/src/UI/Windows/Modals.cs b/src/UI/Windows/Modals.cs index 51f68295..c1cc9b09 100644 --- a/src/UI/Windows/Modals.cs +++ b/src/UI/Windows/Modals.cs @@ -138,7 +138,7 @@ internal static bool GetString(string windowTitle, string entryLabel, string? in internal static bool Get<T>(string prompt, string okText, T[] collection, T? currentSelection, out T? selected) { - return Get(prompt, okText, true, collection, o => o?.ToString() ?? "Null", false, currentSelection, out selected); + return Get(prompt, okText, true, collection, o => o is Type t ? t.Name : o?.ToString() ?? "Null", false, currentSelection, out selected); } internal static bool Get<T>( string prompt, string okText, in bool addSearch, T[] collection, Func<T?, string> displayMember, bool addNull, [NotNullWhen( true )]T? currentSelection, [NotNullWhen( true )] out T? selected ) From 50323c60b6f525480e1127f510520c8d45326421 Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Sun, 2 Mar 2025 14:00:38 +0000 Subject: [PATCH 21/54] Add cancel true to all buttons to prevent them clicking other buttons via IsDefault --- src/UI/Windows/ArrayEditor.cs | 21 +++++++++++++++------ src/UI/Windows/BigListBox.cs | 7 ++++++- src/UI/Windows/ChoicesDialog.cs | 3 --- src/UI/Windows/ColorPicker.cs | 8 ++++++-- src/UI/Windows/ColorSchemeEditor.cs | 22 +++++++++++++++++----- src/UI/Windows/DimEditor.cs | 6 ++++-- src/UI/Windows/EditDialog.cs | 7 ++++++- src/UI/Windows/ExceptionViewer.cs | 7 ++++++- src/UI/Windows/GetTextDialog.cs | 3 +++ src/UI/Windows/PointEditor.cs | 6 ++++-- src/UI/Windows/PosEditor.cs | 6 ++++-- src/UI/Windows/SizeEditor.cs | 2 ++ src/UI/Windows/SliderOptionEditor.cs | 6 ++++-- 13 files changed, 77 insertions(+), 27 deletions(-) diff --git a/src/UI/Windows/ArrayEditor.cs b/src/UI/Windows/ArrayEditor.cs index e2847447..e6012de9 100644 --- a/src/UI/Windows/ArrayEditor.cs +++ b/src/UI/Windows/ArrayEditor.cs @@ -66,7 +66,7 @@ public ArrayEditor(Design design, Type elementType, IList oldValue) { } - private void BtnMoveUp_Clicked(object sender, EventArgs e) + private void BtnMoveUp_Clicked(object sender, CommandEventArgs e) { // Moving up means reducing the index by 1 var idx = lvElements.SelectedItem; @@ -82,9 +82,11 @@ private void BtnMoveUp_Clicked(object sender, EventArgs e) lvElements.SelectedItem = newIndex; lvElements.SetNeedsDraw(); } + + e.Cancel = true; } - private void BtnMoveDown_Clicked(object sender, EventArgs e) + private void BtnMoveDown_Clicked(object sender, CommandEventArgs e) { // Moving up means increasing the index by 1 var idx = lvElements.SelectedItem; @@ -100,6 +102,8 @@ private void BtnMoveDown_Clicked(object sender, EventArgs e) lvElements.SelectedItem = newIndex; lvElements.SetNeedsDraw(); } + + e.Cancel = true; } private void LvElements_KeyDown(object sender, Key e) @@ -125,7 +129,7 @@ private void DeleteSelectedItem() } } - private void BtnAddElement_Clicked(object sender, EventArgs e) + private void BtnAddElement_Clicked(object sender, CommandEventArgs e) { if(ValueFactory.GetNewValue("Element Value", design, this.elementType,null, out var newValue,true)) { @@ -135,8 +139,9 @@ private void BtnAddElement_Clicked(object sender, EventArgs e) lvElements.Source = ResultAsList.ToListDataSource(); lvElements.SelectedItem = ResultAsList.Count - 1; lvElements.SetNeedsDraw(); + e.Cancel = true; } - private void BtnEdit_Clicked(object sender, EventArgs e) + private void BtnEdit_Clicked(object sender, CommandEventArgs e) { var idx = lvElements.SelectedItem; @@ -155,16 +160,20 @@ private void BtnEdit_Clicked(object sender, EventArgs e) lvElements.SelectedItem = idx; lvElements.SetNeedsDraw(); } + + e.Cancel = true; } - private void BtnCancel_Clicked(object sender, EventArgs e) + private void BtnCancel_Clicked(object sender, CommandEventArgs e) { + e.Cancel = true; Cancelled = true; Application.RequestStop(); } - private void BtnOk_Clicked(object sender, EventArgs e) + private void BtnOk_Clicked(object sender, CommandEventArgs e) { + e.Cancel = true; Cancelled = false; Application.RequestStop(); } diff --git a/src/UI/Windows/BigListBox.cs b/src/UI/Windows/BigListBox.cs index 9b47dfa7..b8f7684f 100644 --- a/src/UI/Windows/BigListBox.cs +++ b/src/UI/Windows/BigListBox.cs @@ -102,6 +102,7 @@ public BigListBox( }; btnOk.Accepting += (s, e) => { + e.Cancel = true; this.Accept(); }; @@ -110,7 +111,11 @@ public BigListBox( Text = "Cancel", Y = Pos.Bottom(this.listView), }; - btnCancel.Accepting += (s, e) => Application.RequestStop(); + btnCancel.Accepting += (s, e) => + { + e.Cancel = true; + Application.RequestStop(); + }; if (addSearch) { diff --git a/src/UI/Windows/ChoicesDialog.cs b/src/UI/Windows/ChoicesDialog.cs index edcae845..52fd3235 100644 --- a/src/UI/Windows/ChoicesDialog.cs +++ b/src/UI/Windows/ChoicesDialog.cs @@ -57,9 +57,6 @@ public ChoicesDialog(string title, string message, params string[] options) { buttons[i].Accepting += (s,e) => { Result = i2; - - // TODO: Remove once fixed upstream - // Workaround for https://github.com/gui-cs/Terminal.Gui/issues/3913 e.Cancel = true; Application.RequestStop(); diff --git a/src/UI/Windows/ColorPicker.cs b/src/UI/Windows/ColorPicker.cs index 6a43cad2..c5cf050d 100644 --- a/src/UI/Windows/ColorPicker.cs +++ b/src/UI/Windows/ColorPicker.cs @@ -47,8 +47,12 @@ public ColorPicker(Attribute? currentValue) cpForeground.ColorChanged += (s,e) => UpdatePreview(); cpBackground.ColorChanged += (s,e) => UpdatePreview(); - btnOk.Accepting += (s, e) => Ok(); - btnCancel.Accepting += (s, e) => Cancel(); + btnOk.Accepting += (s, e) => + { + e.Cancel = true; + Ok(); + }; + btnCancel.Accepting += (s, e) => { e.Cancel = true; Cancel(); }; } private void Ok() diff --git a/src/UI/Windows/ColorSchemeEditor.cs b/src/UI/Windows/ColorSchemeEditor.cs index 61b8bc9a..3658612c 100644 --- a/src/UI/Windows/ColorSchemeEditor.cs +++ b/src/UI/Windows/ColorSchemeEditor.cs @@ -60,41 +60,53 @@ public ColorSchemeEditor(ColorScheme scheme) { SetColorPatches(); - btnEditNormal.Accepting += (s, e)=>{ + btnEditNormal.Accepting += (s, e)=> + { + e.Cancel = true; _result.Normal = PickNewColorsFor(Result.Normal); SetColorPatches(); }; - btnEditHotNormal.Accepting += (s, e)=>{ + btnEditHotNormal.Accepting += (s, e)=> + { + e.Cancel = true; _result.HotNormal = PickNewColorsFor(Result.HotNormal); SetColorPatches(); }; btnEditFocus.Accepting += (s, e)=>{ + e.Cancel = true; _result.Focus = PickNewColorsFor(Result.Focus); SetColorPatches(); }; - btnEditHotFocus.Accepting += (s, e)=>{ + btnEditHotFocus.Accepting += (s, e)=> + { + e.Cancel = true; _result.HotFocus = PickNewColorsFor(Result.HotFocus); SetColorPatches(); }; btnEditDisabled.Accepting += (s, e)=>{ + e.Cancel = true; _result.Disabled = PickNewColorsFor(Result.Disabled); SetColorPatches(); }; - btnCancel.Accepting += (s, e)=>{ + btnCancel.Accepting += (s, e)=> + { + e.Cancel = true; Cancelled = true; Application.RequestStop(); }; - btnOk.Accepting += (s, e)=>{ + btnOk.Accepting += (s, e)=> + { + e.Cancel = true; Cancelled = false; Application.RequestStop(); }; diff --git a/src/UI/Windows/DimEditor.cs b/src/UI/Windows/DimEditor.cs index e88d0504..c6b07349 100644 --- a/src/UI/Windows/DimEditor.cs +++ b/src/UI/Windows/DimEditor.cs @@ -143,14 +143,16 @@ private void SetupForCurrentDimType() } } - private void BtnCancel_Clicked(object sender, EventArgs e) + private void BtnCancel_Clicked(object sender, CommandEventArgs e) { + e.Cancel = true; Cancelled = true; Application.RequestStop(); } - private void BtnOk_Clicked(object sender, EventArgs e) + private void BtnOk_Clicked(object sender, CommandEventArgs e) { + e.Cancel = true; Cancelled = false; Result = BuildResult(); Application.RequestStop(); diff --git a/src/UI/Windows/EditDialog.cs b/src/UI/Windows/EditDialog.cs index 7dd80d5b..4d97e831 100644 --- a/src/UI/Windows/EditDialog.cs +++ b/src/UI/Windows/EditDialog.cs @@ -58,6 +58,7 @@ public EditDialog(Design design) btnSet.Accepting += (s, e) => { + e.Cancel = true; this.SetProperty(false); }; @@ -67,7 +68,11 @@ public EditDialog(Design design) X = Pos.Right(btnSet), Y = Pos.Bottom(this.list), }; - btnClose.Accepting += (s, e) => Application.RequestStop(); + btnClose.Accepting += (s, e) => + { + e.Cancel = true; + Application.RequestStop(); + }; this.list.KeyDown += (s, e) => { diff --git a/src/UI/Windows/ExceptionViewer.cs b/src/UI/Windows/ExceptionViewer.cs index be372e14..0306e84d 100644 --- a/src/UI/Windows/ExceptionViewer.cs +++ b/src/UI/Windows/ExceptionViewer.cs @@ -37,13 +37,18 @@ public static void ShowException(string errorText, Exception exception) IsDefault = true }; - btnOk.Accepting += (s, e) => Application.RequestStop(); + btnOk.Accepting += (s, e) => + { + e.Cancel = true; + Application.RequestStop(); + }; var btnStack = new Button() { Text = "Stack" }; btnStack.Accepting += (s, e) => { + e.Cancel = true; // flip between stack / no stack textView.Text = GetExceptionText(errorText, exception, toggleStack); textView.SetNeedsDraw(); diff --git a/src/UI/Windows/GetTextDialog.cs b/src/UI/Windows/GetTextDialog.cs index 974b2ff7..5b4c235c 100644 --- a/src/UI/Windows/GetTextDialog.cs +++ b/src/UI/Windows/GetTextDialog.cs @@ -68,6 +68,7 @@ public GetTextDialog(DialogArgs args, string? initialValue) }; btnOk.Accepting += (s, e) => { + e.Cancel = true; this.Accept(); }; @@ -80,6 +81,7 @@ public GetTextDialog(DialogArgs args, string? initialValue) }; btnCancel.Accepting += (s, e) => { + e.Cancel = true; this.okClicked = false; Application.RequestStop(); }; @@ -92,6 +94,7 @@ public GetTextDialog(DialogArgs args, string? initialValue) }; btnClear.Accepting += (s, e) => { + e.Cancel = true; this.textField.Text = string.Empty; }; diff --git a/src/UI/Windows/PointEditor.cs b/src/UI/Windows/PointEditor.cs index 1f594f1e..9e097a00 100644 --- a/src/UI/Windows/PointEditor.cs +++ b/src/UI/Windows/PointEditor.cs @@ -52,14 +52,16 @@ public PointEditor(float x, float y) { btnCancel.Accepting += Cancel; } - private void Cancel(object sender, EventArgs e) + private void Cancel(object sender, CommandEventArgs e) { + e.Cancel = true; Cancelled = true; Application.RequestStop(); } - private void Ok(object sender, EventArgs e) + private void Ok(object sender, CommandEventArgs e) { + e.Cancel = true; if(int.TryParse(tbX.Text.ToString(), out var x)) { if(int.TryParse(tbY.Text.ToString(), out var y)) diff --git a/src/UI/Windows/PosEditor.cs b/src/UI/Windows/PosEditor.cs index fb9122a3..0304f1fe 100644 --- a/src/UI/Windows/PosEditor.cs +++ b/src/UI/Windows/PosEditor.cs @@ -195,14 +195,16 @@ private void SetupForCurrentPosType() } } - private void BtnCancel_Clicked(object sender, EventArgs e) + private void BtnCancel_Clicked(object sender, CommandEventArgs e) { + e.Cancel = true; Cancelled = true; Application.RequestStop(); } - private void BtnOk_Clicked(object sender, EventArgs e) + private void BtnOk_Clicked(object sender, CommandEventArgs e) { + e.Cancel = true; if(GetPosType() == PosType.AnchorEnd && GetValue(out var value) && value <=0) { if (!ChoicesDialog.Confirm("Anchor Without Margin", "Using AnchorEnd without a margin will result in a point outside of parent bounds.\nAre you sure?")) diff --git a/src/UI/Windows/SizeEditor.cs b/src/UI/Windows/SizeEditor.cs index cab36393..45149abf 100644 --- a/src/UI/Windows/SizeEditor.cs +++ b/src/UI/Windows/SizeEditor.cs @@ -41,6 +41,7 @@ public SizeEditor(Size s) btnOk.Accepting += (s, e) => { + e.Cancel = true; try { Result = new Size(int.Parse(tfWidth.Text.ToString()), int.Parse(tfHeight.Text.ToString())); @@ -57,6 +58,7 @@ public SizeEditor(Size s) btnCancel.Accepting += (s, e) => { + e.Cancel = true; Cancelled = true; RequestStop(); }; diff --git a/src/UI/Windows/SliderOptionEditor.cs b/src/UI/Windows/SliderOptionEditor.cs index fb4d39f6..cdc4df0b 100644 --- a/src/UI/Windows/SliderOptionEditor.cs +++ b/src/UI/Windows/SliderOptionEditor.cs @@ -68,14 +68,16 @@ public SliderOptionEditor(Type genericTypeArgument, object? oldValue) { } } - private void BtnCancel_Clicked(object sender, EventArgs e) + private void BtnCancel_Clicked(object sender, CommandEventArgs e) { + e.Cancel = true; this.Cancelled = true; Application.RequestStop(); } - private void BtnOk_Clicked(object sender, EventArgs e) + private void BtnOk_Clicked(object sender, CommandEventArgs e) { + e.Cancel = true; try { this.BuildResult(); From c705b63e3df9ba163f00a1d757f25897ee8994bf Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Sun, 2 Mar 2025 14:12:04 +0000 Subject: [PATCH 22/54] Sort entries in BigListBox alphabetically by default --- src/UI/ValueFactory.cs | 2 +- src/UI/Windows/BigListBox.cs | 12 +++++++++--- src/UI/Windows/ChoicesDialog.cs | 28 +--------------------------- src/UI/Windows/Modals.cs | 8 ++++---- 4 files changed, 15 insertions(+), 35 deletions(-) diff --git a/src/UI/ValueFactory.cs b/src/UI/ValueFactory.cs index 8f38fbdd..9f8cc00e 100644 --- a/src/UI/ValueFactory.cs +++ b/src/UI/ValueFactory.cs @@ -305,7 +305,7 @@ private static bool GetNewColorSchemeValue(Design design, out object? newValue) // add the option to jump to custom colors offer.Add(custom); - if (Modals.Get("Color Scheme", "Ok", offer.ToArray(), design.View.ColorScheme, out var selected)) + if (Modals.Get("Color Scheme", "Ok", offer.ToArray(), design.View.ColorScheme, out var selected,false)) { // if user clicked "Custom..." if (selected is string s && string.Equals(s, custom)) diff --git a/src/UI/Windows/BigListBox.cs b/src/UI/Windows/BigListBox.cs index b8f7684f..4aa20962 100644 --- a/src/UI/Windows/BigListBox.cs +++ b/src/UI/Windows/BigListBox.cs @@ -47,17 +47,23 @@ public class BigListBox<T> /// <param name="displayMember">What to display in the list box (defaults to <see cref="object.ToString"/>.</param> /// <param name="addNull">Creates a selection option "Null" that returns a null selection.</param> /// <param name="currentSelection">The optional existing value, if present it should be selected in the list.</param> - public BigListBox( - string prompt, + /// <param name="sort"></param> + public BigListBox(string prompt, string okText, in bool addSearch, IList<T> collection, Func<T?, string> displayMember, bool addNull, - T? currentSelection) + T? currentSelection, bool sort = true) { this.AspectGetter = displayMember ?? (arg => arg?.ToString() ?? string.Empty); + // Sort alphabetically according to display member + if (sort) + { + collection = collection.OrderBy(e => AspectGetter(e)).ToList(); + } + this.publicCollection = collection ?? throw new ArgumentNullException( nameof( collection ) ); this.addNull = addNull; diff --git a/src/UI/Windows/ChoicesDialog.cs b/src/UI/Windows/ChoicesDialog.cs index 52fd3235..6ae48b3b 100644 --- a/src/UI/Windows/ChoicesDialog.cs +++ b/src/UI/Windows/ChoicesDialog.cs @@ -94,34 +94,8 @@ public ChoicesDialog(string title, string message, params string[] options) { Width = Math.Min(Math.Max(maxWidthLine, Math.Max(Title.GetColumns(), Math.Max(textWidth + 2, buttonWidth))), Application.Driver.Cols); Height = msgboxHeight; - } - - /// <inheritdoc/> - protected override void OnDrawComplete() - { - base.OnDrawComplete(); - - var screenTopLeft = FrameToScreen(); - Driver.Move(screenTopLeft.X+2, screenTopLeft.Y); - - var padding = ((Viewport.Width - _title.EnumerateRunes().Sum(v=>v.GetColumns())) / 2) - 1; - - Driver.SetAttribute( - new Attribute(ColorScheme.Normal.Foreground, ColorScheme.Normal.Background)); - - Driver.AddStr(string.Join("",Enumerable.Repeat(Glyphs.HLineHv, padding))); - - Driver.SetAttribute( - new Attribute(ColorScheme.Normal.Background, ColorScheme.Normal.Foreground)); - Driver.AddStr(_title); - - Driver.SetAttribute( - new Attribute(ColorScheme.Normal.Foreground, ColorScheme.Normal.Background)); - - StringBuilder sb = new StringBuilder(); - sb.Append(Glyphs.HLineHv); - Driver.AddStr(string.Join("", Enumerable.Repeat(Glyphs.HLineHv.ToString(), padding))); + btn1.FocusDeepest(NavigationDirection.Forward, TabBehavior.TabGroup); } internal static int Query(string title, string message, params string[] options) diff --git a/src/UI/Windows/Modals.cs b/src/UI/Windows/Modals.cs index c1cc9b09..fd761e5f 100644 --- a/src/UI/Windows/Modals.cs +++ b/src/UI/Windows/Modals.cs @@ -136,14 +136,14 @@ internal static bool GetString(string windowTitle, string entryLabel, string? in return false; } - internal static bool Get<T>(string prompt, string okText, T[] collection, T? currentSelection, out T? selected) + internal static bool Get<T>(string prompt, string okText, T[] collection, T? currentSelection, out T? selected, bool sort = true) { - return Get(prompt, okText, true, collection, o => o is Type t ? t.Name : o?.ToString() ?? "Null", false, currentSelection, out selected); + return Get(prompt, okText, true, collection, o => o is Type t ? t.Name : o?.ToString() ?? "Null", false, currentSelection, out selected,sort); } - internal static bool Get<T>( string prompt, string okText, in bool addSearch, T[] collection, Func<T?, string> displayMember, bool addNull, [NotNullWhen( true )]T? currentSelection, [NotNullWhen( true )] out T? selected ) + internal static bool Get<T>( string prompt, string okText, in bool addSearch, T[] collection, Func<T?, string> displayMember, bool addNull, [NotNullWhen( true )]T? currentSelection, [NotNullWhen( true )] out T? selected, bool sort=true ) { - var pick = new BigListBox<T>( prompt, okText, in addSearch, collection, displayMember, addNull, currentSelection ); + var pick = new BigListBox<T>( prompt, okText, in addSearch, collection, displayMember, addNull, currentSelection,sort ); bool toReturn = pick.ShowDialog( ); selected = pick.Selected; return toReturn; From 6cfe94d75c5d193bbc78e25b54ae81b982901c6d Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Sun, 2 Mar 2025 18:06:33 +0000 Subject: [PATCH 23/54] Target v2 drivers --- Showcase/Showcase.csproj | 2 +- src/Program.cs | 4 ++-- src/TerminalGuiDesigner.csproj | 2 +- src/UI/Editor.cs | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Showcase/Showcase.csproj b/Showcase/Showcase.csproj index bb351615..0405f208 100644 --- a/Showcase/Showcase.csproj +++ b/Showcase/Showcase.csproj @@ -8,7 +8,7 @@ </PropertyGroup> <ItemGroup> - <PackageReference Include="Terminal.Gui" Version="2.0.0-prealpha.1546" /> + <PackageReference Include="Terminal.Gui" Version="2.0.0-develop.1566" /> </ItemGroup> </Project> diff --git a/src/Program.cs b/src/Program.cs index 62bf379f..09d2a11d 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -19,8 +19,8 @@ public static void Main(string[] args) .WithParsed<Options>(o => { Editor.Experimental = o.Experimental; - - Application.Init(); + + Application.Init(null,"v2"); var editor = new Editor(); editor.Run(o); }); diff --git a/src/TerminalGuiDesigner.csproj b/src/TerminalGuiDesigner.csproj index 9e9846d4..c3b560cf 100644 --- a/src/TerminalGuiDesigner.csproj +++ b/src/TerminalGuiDesigner.csproj @@ -150,7 +150,7 @@ <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.1" /> <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" /> <PackageReference Include="NetEscapades.Configuration.Yaml" Version="3.1.0" /> - <PackageReference Include="Terminal.Gui" Version="2.0.0-prealpha.1546" /> + <PackageReference Include="Terminal.Gui" Version="2.0.0-develop.1566" /> <PackageReference Include="nlog" Version="5.3.3" /> <PackageReference Include="Basic.Reference.Assemblies.Net80" Version="1.7.7" /> <PackageReference Include="System.CodeDom" Version="8.0.0" /> diff --git a/src/UI/Editor.cs b/src/UI/Editor.cs index a0a554df..019e115f 100644 --- a/src/UI/Editor.cs +++ b/src/UI/Editor.cs @@ -195,9 +195,9 @@ public void Run(Options options) /// Tailors redrawing to add overlays (e.g. showing what is selected etc.). /// Only runs when a view is open and <see cref="viewBeingEdited"/>. /// </summary> - protected override void OnDrawComplete() + protected override void OnDrawComplete(DrawContext? context) { - base.OnDrawComplete(); + base.OnDrawComplete(context); // if we are not editing a view if (this.viewBeingEdited == null) From 5aa2dca7caf14515cdafd08998fdb3babdeb58ab Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Tue, 4 Mar 2025 20:24:46 +0000 Subject: [PATCH 24/54] Add logging to app data (or linux equivellent) and start fixing UIs and showcases --- Showcase/NumericUpDown.Designer.cs | 30 +++++++- Showcase/Slider.Designer.cs | 33 +++++++- src/TerminalGuiDesigner.csproj | 3 + src/UI/Editor.cs | 46 +++++++++++ src/UI/Windows/ArrayEditor.Designer.cs | 102 ++++++++++++++++--------- 5 files changed, 176 insertions(+), 38 deletions(-) diff --git a/Showcase/NumericUpDown.Designer.cs b/Showcase/NumericUpDown.Designer.cs index 5afbe074..bec4f4b7 100644 --- a/Showcase/NumericUpDown.Designer.cs +++ b/Showcase/NumericUpDown.Designer.cs @@ -65,15 +65,19 @@ private void InitializeComponent() { this.Y = 0; this.Visible = true; this.Arrangement = (Terminal.Gui.ViewArrangement.Movable | Terminal.Gui.ViewArrangement.Overlapped); + this.CanFocus = true; + this.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.Modal = false; this.TextAlignment = Terminal.Gui.Alignment.Start; - this.Title = ""; + this.Title = "Numeric Up Down Controls"; this.lblInt.Width = Dim.Auto(); this.lblInt.Height = 1; this.lblInt.X = 0; this.lblInt.Y = 0; this.lblInt.Visible = true; this.lblInt.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblInt.CanFocus = true; + this.lblInt.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.lblInt.Data = "lblInt"; this.lblInt.Text = "Int:"; this.lblInt.TextAlignment = Terminal.Gui.Alignment.Start; @@ -84,6 +88,8 @@ private void InitializeComponent() { this.numericUpDownInt.Y = 0; this.numericUpDownInt.Visible = true; this.numericUpDownInt.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.numericUpDownInt.CanFocus = true; + this.numericUpDownInt.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.numericUpDownInt.Data = "numericUpDownInt"; this.numericUpDownInt.TextAlignment = Terminal.Gui.Alignment.Start; this.numericUpDownInt.Value = 1; @@ -95,6 +101,8 @@ private void InitializeComponent() { this.lblInt64.Y = 1; this.lblInt64.Visible = true; this.lblInt64.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblInt64.CanFocus = true; + this.lblInt64.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.lblInt64.Data = "lblInt64"; this.lblInt64.Text = "Int64:"; this.lblInt64.TextAlignment = Terminal.Gui.Alignment.Start; @@ -105,6 +113,8 @@ private void InitializeComponent() { this.numericUpDownInt64.Y = 1; this.numericUpDownInt64.Visible = true; this.numericUpDownInt64.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.numericUpDownInt64.CanFocus = true; + this.numericUpDownInt64.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.numericUpDownInt64.Data = "numericUpDownInt64"; this.numericUpDownInt64.TextAlignment = Terminal.Gui.Alignment.Start; this.numericUpDownInt64.Value = 8943589458974; @@ -116,6 +126,8 @@ private void InitializeComponent() { this.label3.Y = 2; this.label3.Visible = true; this.label3.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.label3.CanFocus = true; + this.label3.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.label3.Data = "label3"; this.label3.Text = "Double:"; this.label3.TextAlignment = Terminal.Gui.Alignment.Start; @@ -126,6 +138,8 @@ private void InitializeComponent() { this.numericUpDown2.Y = 2; this.numericUpDown2.Visible = true; this.numericUpDown2.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.numericUpDown2.CanFocus = true; + this.numericUpDown2.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.numericUpDown2.Data = "numericUpDown2"; this.numericUpDown2.TextAlignment = Terminal.Gui.Alignment.Start; this.numericUpDown2.Value = 32.3D; @@ -137,6 +151,8 @@ private void InitializeComponent() { this.label6.Y = 3; this.label6.Visible = true; this.label6.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.label6.CanFocus = true; + this.label6.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.label6.Data = "label6"; this.label6.Text = "Single:"; this.label6.TextAlignment = Terminal.Gui.Alignment.Start; @@ -147,6 +163,8 @@ private void InitializeComponent() { this.numericUpDownSingle.Y = 3; this.numericUpDownSingle.Visible = true; this.numericUpDownSingle.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.numericUpDownSingle.CanFocus = true; + this.numericUpDownSingle.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.numericUpDownSingle.Data = "numericUpDownSingle"; this.numericUpDownSingle.TextAlignment = Terminal.Gui.Alignment.Start; this.numericUpDownSingle.Value = 1F; @@ -158,6 +176,8 @@ private void InitializeComponent() { this.label.Y = 4; this.label.Visible = true; this.label.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.label.CanFocus = true; + this.label.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.label.Data = "label"; this.label.Text = "Decimal:"; this.label.TextAlignment = Terminal.Gui.Alignment.Start; @@ -168,6 +188,8 @@ private void InitializeComponent() { this.numericUpDownDecimal.Y = 4; this.numericUpDownDecimal.Visible = true; this.numericUpDownDecimal.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.numericUpDownDecimal.CanFocus = true; + this.numericUpDownDecimal.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.numericUpDownDecimal.Data = "numericUpDownDecimal"; this.numericUpDownDecimal.TextAlignment = Terminal.Gui.Alignment.Start; this.numericUpDownDecimal.Value = 0.00000000001m; @@ -179,6 +201,8 @@ private void InitializeComponent() { this.label4.Y = 7; this.label4.Visible = true; this.label4.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.label4.CanFocus = true; + this.label4.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.label4.Data = "label4"; this.label4.Text = "Single:"; this.label4.TextAlignment = Terminal.Gui.Alignment.Start; @@ -189,6 +213,8 @@ private void InitializeComponent() { this.numericUpDown3.Y = 7; this.numericUpDown3.Visible = true; this.numericUpDown3.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.numericUpDown3.CanFocus = true; + this.numericUpDown3.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.numericUpDown3.Data = "numericUpDown3"; this.numericUpDown3.TextAlignment = Terminal.Gui.Alignment.Start; this.numericUpDown3.Value = float.PositiveInfinity; @@ -200,6 +226,8 @@ private void InitializeComponent() { this.label5.Y = 7; this.label5.Visible = true; this.label5.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.label5.CanFocus = true; + this.label5.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.label5.Data = "label5"; this.label5.Text = "(Supports infinitiy!?)"; this.label5.TextAlignment = Terminal.Gui.Alignment.Start; diff --git a/Showcase/Slider.Designer.cs b/Showcase/Slider.Designer.cs index 7ad8e1f7..38dac90f 100644 --- a/Showcase/Slider.Designer.cs +++ b/Showcase/Slider.Designer.cs @@ -31,7 +31,10 @@ public partial class Slider : Terminal.Gui.Window { private Terminal.Gui.Slider<string> slider3; + private Terminal.Gui.Line line; + private void InitializeComponent() { + this.line = new Terminal.Gui.Line(); this.slider3 = new Terminal.Gui.Slider<string>(); this.lblStringSliderThin = new Terminal.Gui.Label(); this.slider2 = new Terminal.Gui.Slider<string>(); @@ -44,15 +47,19 @@ private void InitializeComponent() { this.Y = 0; this.Visible = true; this.Arrangement = (Terminal.Gui.ViewArrangement.Movable | Terminal.Gui.ViewArrangement.Overlapped); + this.CanFocus = true; + this.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.Modal = false; this.TextAlignment = Terminal.Gui.Alignment.Start; - this.Title = ""; + this.Title = "Sliders"; this.label.Width = Dim.Auto(); this.label.Height = 1; this.label.X = 0; this.label.Y = 0; this.label.Visible = true; this.label.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.label.CanFocus = true; + this.label.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.label.Data = "label"; this.label.Text = "Int Slider (0 to 1):"; this.label.TextAlignment = Terminal.Gui.Alignment.Start; @@ -63,12 +70,14 @@ private void InitializeComponent() { this.slider1.Y = 0; this.slider1.Visible = true; this.slider1.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.slider1.CanFocus = true; + this.slider1.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.slider1.Options = new System.Collections.Generic.List<Terminal.Gui.SliderOption<int>>(new Terminal.Gui.SliderOption<int>[] { new Terminal.Gui.SliderOption<int>("0", new System.Text.Rune('0'), 0), new Terminal.Gui.SliderOption<int>("1", new System.Text.Rune('1'), 1)}); this.slider1.Orientation = Terminal.Gui.Orientation.Horizontal; this.slider1.RangeAllowSingle = false; - this.slider1.AllowEmpty = false; + this.slider1.AllowEmpty = true; this.slider1.MinimumInnerSpacing = 1; this.slider1.LegendsOrientation = Terminal.Gui.Orientation.Horizontal; this.slider1.ShowLegends = true; @@ -83,6 +92,8 @@ private void InitializeComponent() { this.lblStringSlider.Y = 2; this.lblStringSlider.Visible = true; this.lblStringSlider.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblStringSlider.CanFocus = true; + this.lblStringSlider.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.lblStringSlider.Data = "lblStringSlider"; this.lblStringSlider.Text = "String Slider (Wide):"; this.lblStringSlider.TextAlignment = Terminal.Gui.Alignment.Start; @@ -93,6 +104,8 @@ private void InitializeComponent() { this.slider2.Y = 2; this.slider2.Visible = true; this.slider2.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.slider2.CanFocus = true; + this.slider2.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.slider2.Options = new System.Collections.Generic.List<Terminal.Gui.SliderOption<string>>(new Terminal.Gui.SliderOption<string>[] { new Terminal.Gui.SliderOption<string>("Fish", new System.Text.Rune('F'), "Fish"), new Terminal.Gui.SliderOption<string>("Cat", new System.Text.Rune('C'), "Cat"), @@ -114,6 +127,8 @@ private void InitializeComponent() { this.lblStringSliderThin.Y = 4; this.lblStringSliderThin.Visible = true; this.lblStringSliderThin.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblStringSliderThin.CanFocus = true; + this.lblStringSliderThin.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.lblStringSliderThin.Data = "lblStringSliderThin"; this.lblStringSliderThin.Text = "String Slider (Thin):"; this.lblStringSliderThin.TextAlignment = Terminal.Gui.Alignment.Start; @@ -124,6 +139,8 @@ private void InitializeComponent() { this.slider3.Y = 4; this.slider3.Visible = true; this.slider3.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.slider3.CanFocus = true; + this.slider3.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.slider3.Options = new System.Collections.Generic.List<Terminal.Gui.SliderOption<string>>(new Terminal.Gui.SliderOption<string>[] { new Terminal.Gui.SliderOption<string>("Fish", new System.Text.Rune('F'), "Fish"), new Terminal.Gui.SliderOption<string>("Cat", new System.Text.Rune('C'), "Cat"), @@ -139,6 +156,18 @@ private void InitializeComponent() { this.slider3.Data = "slider3"; this.slider3.TextAlignment = Terminal.Gui.Alignment.Start; this.Add(this.slider3); + this.line.Width = Dim.Fill(-1); + this.line.Height = 1; + this.line.X = -1; + this.line.Y = 6; + this.line.Visible = true; + this.line.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.line.CanFocus = true; + this.line.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.line.Data = "line"; + this.line.Text = ""; + this.line.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.line); } } } diff --git a/src/TerminalGuiDesigner.csproj b/src/TerminalGuiDesigner.csproj index c3b560cf..33efd0e2 100644 --- a/src/TerminalGuiDesigner.csproj +++ b/src/TerminalGuiDesigner.csproj @@ -150,6 +150,9 @@ <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.1" /> <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" /> <PackageReference Include="NetEscapades.Configuration.Yaml" Version="3.1.0" /> + <PackageReference Include="Serilog" Version="4.2.0" /> + <PackageReference Include="Serilog.Extensions.Logging" Version="9.0.0" /> + <PackageReference Include="Serilog.Sinks.File" Version="6.0.0" /> <PackageReference Include="Terminal.Gui" Version="2.0.0-develop.1566" /> <PackageReference Include="nlog" Version="5.3.3" /> <PackageReference Include="Basic.Reference.Assemblies.Net80" Version="1.7.7" /> diff --git a/src/UI/Editor.cs b/src/UI/Editor.cs index 019e115f..81725c3a 100644 --- a/src/UI/Editor.cs +++ b/src/UI/Editor.cs @@ -2,12 +2,15 @@ using System.Reflection; using System.Text; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; +using Serilog; using Terminal.Gui; using TerminalGuiDesigner.FromCode; using TerminalGuiDesigner.Operations; using TerminalGuiDesigner.ToCode; using TerminalGuiDesigner.UI.Windows; using Attribute = Terminal.Gui.Attribute; +using ILogger = Microsoft.Extensions.Logging.ILogger; namespace TerminalGuiDesigner.UI; @@ -43,6 +46,8 @@ public class Editor : Toplevel /// </summary> internal Guid? LastSavedOperation; + private static string _logDirectory = string.Empty; + /// <summary> /// Initializes a new instance of the <see cref="Editor"/> class. /// </summary> @@ -51,6 +56,8 @@ public Editor() // Bug: This will have strange inheritance behavior if Editor is inherited from. this.CanFocus = true; + Logging.Logger = CreateLogger(); + try { this.keyMap = new ConfigurationBuilder( ).AddYamlFile( "Keys.yaml", true ).Build( ).Get<KeyMap>( ) ?? new( ); @@ -71,6 +78,30 @@ public Editor() this.BuildRootMenu(); } + static ILogger CreateLogger() + { + _logDirectory = Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), + "TerminalGuiDesigner", "logs"); + + // Configure Serilog to write logs to a file + Log.Logger = new LoggerConfiguration() + .MinimumLevel.Verbose() // Verbose includes Trace and Debug + .WriteTo.File(Path.Combine(_logDirectory,"logfile.txt"), rollingInterval: RollingInterval.Day) + .CreateLogger(); + + // Create a logger factory compatible with Microsoft.Extensions.Logging + using var loggerFactory = LoggerFactory.Create(builder => + { + builder + .AddSerilog(dispose: true) // Integrate Serilog with ILogger + .SetMinimumLevel(LogLevel.Trace); // Set minimum log level + }); + + // Get an ILogger instance + return loggerFactory.CreateLogger("Global Logger"); + } + /// <summary> /// Gets or Sets a value indicating whether <see cref="View"/> that do not have borders /// (e.g. <see cref="ScrollView"/>) should have a dotted line rendered around them so @@ -300,6 +331,7 @@ ________ .__ ________ .__ // The version information line string versionLine = $"(Alpha - {informationalVersion} )"; + string logLine = "Logs - " + _logDirectory; // Split the ASCII art into lines var artLines = artText.Split('\n'); @@ -407,6 +439,20 @@ ________ .__ ________ .__ Driver.SetAttribute(new Attribute(new Color(colorAtPoint), new Color(Color.Black))); this.AddRune(x, y, (Rune)versionLine[i]); } + + // Render the log directory line below the version line + int logLineX = inArea.X + (inArea.Width - logLine.Length) / 2; + int logLineY = versionLineY+2; + + for (int i = 0; i < logLine.Length; i++) + { + int x = logLineX + i; + int y = logLineY; + + var colorAtPoint = fill.GetColor(new Point(x, y)); + Driver.SetAttribute(new Attribute(new Color(colorAtPoint), new Color(Color.Black))); + this.AddRune(x, y, (Rune)logLine[i]); + } } } diff --git a/src/UI/Windows/ArrayEditor.Designer.cs b/src/UI/Windows/ArrayEditor.Designer.cs index 7a388dbc..4e015ccf 100644 --- a/src/UI/Windows/ArrayEditor.Designer.cs +++ b/src/UI/Windows/ArrayEditor.Designer.cs @@ -3,19 +3,18 @@ // <auto-generated> // This code was generated by: -// TerminalGuiDesigner v1.1.0.0 +// TerminalGuiDesigner v2.0.0.0 // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> // ----------------------------------------------------------------------------- - -using System.Collections.ObjectModel; - namespace TerminalGuiDesigner.UI.Windows { using System; using Terminal.Gui; using System.Collections; using System.Collections.Generic; + using System.Collections.ObjectModel; + using System.Drawing; public partial class ArrayEditor : Terminal.Gui.Dialog { @@ -56,14 +55,20 @@ private void InitializeComponent() { this.X = Pos.Center(); this.Y = Pos.Center(); this.Visible = true; + this.Arrangement = (Terminal.Gui.ViewArrangement.Movable | Terminal.Gui.ViewArrangement.Overlapped); + this.CanFocus = true; + this.ShadowStyle = Terminal.Gui.ShadowStyle.Transparent; this.Modal = true; this.TextAlignment = Terminal.Gui.Alignment.Start; this.Title = "Array Editor"; this.frameView.Width = Dim.Fill(0); - this.frameView.Height = Dim.Fill(3); + this.frameView.Height = Dim.Fill(5); this.frameView.X = 0; this.frameView.Y = 0; this.frameView.Visible = true; + this.frameView.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.frameView.CanFocus = true; + this.frameView.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.frameView.Data = "frameView"; this.frameView.TextAlignment = Terminal.Gui.Alignment.Start; this.frameView.Title = "Elements"; @@ -73,60 +78,78 @@ private void InitializeComponent() { this.lvElements.X = 1; this.lvElements.Y = 0; this.lvElements.Visible = true; + this.lvElements.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lvElements.CanFocus = true; + this.lvElements.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.lvElements.Data = "lvElements"; this.lvElements.TextAlignment = Terminal.Gui.Alignment.Start; - this.lvElements.Source = new Terminal.Gui.ListWrapper<string>(new ObservableCollection<string>(new string[] { - "Item1", - "Item2", - "Item3"})); + this.lvElements.Source = new Terminal.Gui.ListWrapper<string>(new System.Collections.ObjectModel.ObservableCollection<string>(new string[] { + "Item1", + "Item2", + "Item3"})); this.lvElements.AllowsMarking = false; this.lvElements.AllowsMultipleSelection = true; this.frameView.Add(this.lvElements); - this.btnAddElement.Width = 8; - this.btnAddElement.Height = 1; + this.btnAddElement.Width = Dim.Auto(); + this.btnAddElement.Height = Dim.Auto(); this.btnAddElement.X = 1; - this.btnAddElement.Y = Pos.AnchorEnd(3); + this.btnAddElement.Y = Pos.AnchorEnd(5); this.btnAddElement.Visible = true; + this.btnAddElement.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnAddElement.CanFocus = true; + this.btnAddElement.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; this.btnAddElement.Data = "btnAddElement"; this.btnAddElement.Text = "Add"; this.btnAddElement.TextAlignment = Terminal.Gui.Alignment.Center; this.btnAddElement.IsDefault = false; this.Add(this.btnAddElement); - this.btnDelete.Width = 8; - this.btnDelete.Height = 1; + this.btnDelete.Width = Dim.Auto(); + this.btnDelete.Height = Dim.Auto(); this.btnDelete.X = 9; - this.btnDelete.Y = Pos.AnchorEnd(3); + this.btnDelete.Y = Pos.AnchorEnd(5); this.btnDelete.Visible = true; + this.btnDelete.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnDelete.CanFocus = true; + this.btnDelete.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; this.btnDelete.Data = "btnDelete"; this.btnDelete.Text = "Delete"; this.btnDelete.TextAlignment = Terminal.Gui.Alignment.Center; this.btnDelete.IsDefault = false; this.Add(this.btnDelete); - this.btnMoveUp.Width = 8; - this.btnMoveUp.Height = 1; - this.btnMoveUp.X = 20; - this.btnMoveUp.Y = Pos.AnchorEnd(3); + this.btnMoveUp.Width = Dim.Auto(); + this.btnMoveUp.Height = Dim.Auto(); + this.btnMoveUp.X = 22; + this.btnMoveUp.Y = Pos.AnchorEnd(5); this.btnMoveUp.Visible = true; + this.btnMoveUp.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnMoveUp.CanFocus = true; + this.btnMoveUp.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; this.btnMoveUp.Data = "btnMoveUp"; this.btnMoveUp.Text = "Move Up"; this.btnMoveUp.TextAlignment = Terminal.Gui.Alignment.Center; this.btnMoveUp.IsDefault = false; this.Add(this.btnMoveUp); - this.btnMoveDown.Width = 8; - this.btnMoveDown.Height = 1; - this.btnMoveDown.X = 32; - this.btnMoveDown.Y = Pos.AnchorEnd(3); + this.btnMoveDown.Width = Dim.Auto(); + this.btnMoveDown.Height = Dim.Auto(); + this.btnMoveDown.X = 34; + this.btnMoveDown.Y = Pos.AnchorEnd(5); this.btnMoveDown.Visible = true; + this.btnMoveDown.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnMoveDown.CanFocus = true; + this.btnMoveDown.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; this.btnMoveDown.Data = "btnMoveDown"; this.btnMoveDown.Text = "Move Down"; this.btnMoveDown.TextAlignment = Terminal.Gui.Alignment.Center; this.btnMoveDown.IsDefault = false; this.Add(this.btnMoveDown); - this.btnEdit.Width = 8; - this.btnEdit.Height = 1; - this.btnEdit.X = 46; - this.btnEdit.Y = Pos.AnchorEnd(3); + this.btnEdit.Width = Dim.Auto(); + this.btnEdit.Height = Dim.Auto(); + this.btnEdit.X = 48; + this.btnEdit.Y = Pos.AnchorEnd(5); this.btnEdit.Visible = true; + this.btnEdit.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnEdit.CanFocus = true; + this.btnEdit.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; this.btnEdit.Data = "btnEdit"; this.btnEdit.Text = "Edit"; this.btnEdit.TextAlignment = Terminal.Gui.Alignment.Center; @@ -135,28 +158,37 @@ private void InitializeComponent() { this.lineView.Width = Dim.Fill(1); this.lineView.Height = 1; this.lineView.X = -1; - this.lineView.Y = Pos.AnchorEnd(2); + this.lineView.Y = Pos.AnchorEnd(3); this.lineView.Visible = true; + this.lineView.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lineView.CanFocus = true; + this.lineView.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.lineView.Data = "lineView"; this.lineView.TextAlignment = Terminal.Gui.Alignment.Start; this.lineView.LineRune = new System.Text.Rune('─'); this.lineView.Orientation = Terminal.Gui.Orientation.Horizontal; this.Add(this.lineView); - this.btnOk.Width = 8; - this.btnOk.Height = 1; + this.btnOk.Width = Dim.Auto(); + this.btnOk.Height = Dim.Auto(); this.btnOk.X = 0; - this.btnOk.Y = Pos.AnchorEnd(1); + this.btnOk.Y = Pos.AnchorEnd(2); this.btnOk.Visible = true; + this.btnOk.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnOk.CanFocus = true; + this.btnOk.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; this.btnOk.Data = "btnOk"; this.btnOk.Text = "Ok"; this.btnOk.TextAlignment = Terminal.Gui.Alignment.Center; this.btnOk.IsDefault = false; this.Add(this.btnOk); - this.btnCancel.Width = 8; - this.btnCancel.Height = 1; - this.btnCancel.X = 9; - this.btnCancel.Y = Pos.AnchorEnd(1); + this.btnCancel.Width = Dim.Auto(); + this.btnCancel.Height = Dim.Auto(); + this.btnCancel.X = 7; + this.btnCancel.Y = Pos.AnchorEnd(2); this.btnCancel.Visible = true; + this.btnCancel.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnCancel.CanFocus = true; + this.btnCancel.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; this.btnCancel.Data = "btnCancel"; this.btnCancel.Text = "Cancel"; this.btnCancel.TextAlignment = Terminal.Gui.Alignment.Center; From a6e46560adeb02e0804952ac26ef3cf21916b75d Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Fri, 7 Mar 2025 06:47:00 +0000 Subject: [PATCH 25/54] Fix not asking to save on quit by taking updated nuget package --- Showcase/Showcase.csproj | 2 +- src/TerminalGuiDesigner.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Showcase/Showcase.csproj b/Showcase/Showcase.csproj index 0405f208..f6bd0b07 100644 --- a/Showcase/Showcase.csproj +++ b/Showcase/Showcase.csproj @@ -8,7 +8,7 @@ </PropertyGroup> <ItemGroup> - <PackageReference Include="Terminal.Gui" Version="2.0.0-develop.1566" /> + <PackageReference Include="Terminal.Gui" Version="2.0.0-develop.4363" /> </ItemGroup> </Project> diff --git a/src/TerminalGuiDesigner.csproj b/src/TerminalGuiDesigner.csproj index 33efd0e2..a0cd90f9 100644 --- a/src/TerminalGuiDesigner.csproj +++ b/src/TerminalGuiDesigner.csproj @@ -153,7 +153,7 @@ <PackageReference Include="Serilog" Version="4.2.0" /> <PackageReference Include="Serilog.Extensions.Logging" Version="9.0.0" /> <PackageReference Include="Serilog.Sinks.File" Version="6.0.0" /> - <PackageReference Include="Terminal.Gui" Version="2.0.0-develop.1566" /> + <PackageReference Include="Terminal.Gui" Version="2.0.0-develop.4363" /> <PackageReference Include="nlog" Version="5.3.3" /> <PackageReference Include="Basic.Reference.Assemblies.Net80" Version="1.7.7" /> <PackageReference Include="System.CodeDom" Version="8.0.0" /> From 3f5f3acc235864376541df69f4a57e3d3d066451 Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Fri, 7 Mar 2025 07:35:28 +0000 Subject: [PATCH 26/54] Fix bad package ref already in main csproj --- tests/SpinnerViewTests.cs | 10 +++++----- tests/UnitTests.csproj | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/SpinnerViewTests.cs b/tests/SpinnerViewTests.cs index 5dccc974..38691091 100644 --- a/tests/SpinnerViewTests.cs +++ b/tests/SpinnerViewTests.cs @@ -11,14 +11,14 @@ public void NewSpinnerAutoSpins() { Assume.That( ViewFactory.SupportedViewTypes, Does.Contain( typeof( SpinnerView ) ) ); - Assume.That( Application.MainLoop.Timeouts, Is.Empty ); + Assume.That( Application.MainLoop.TimedEvents.Timeouts, Is.Empty ); using ( SpinnerView s = ViewFactory.Create<SpinnerView>( ) ) { - Assert.That( Application.MainLoop.Timeouts, Is.Not.Empty ); + Assert.That( Application.MainLoop.TimedEvents.Timeouts, Is.Not.Empty ); } - Assert.That( Application.MainLoop.Timeouts, Is.Empty ); + Assert.That( Application.MainLoop.TimedEvents.Timeouts, Is.Empty ); } [Test] @@ -27,7 +27,7 @@ public void NewSpinnerAutoSpins_AfterRoundTrip() { Assume.That( ViewFactory.SupportedViewTypes.ToArray(), Does.Contain( typeof(SpinnerView) ) ); - Assume.That( Application.MainLoop.Timeouts, Is.Empty ); + Assume.That( Application.MainLoop.TimedEvents.Timeouts, Is.Empty ); using SpinnerView s = RoundTrip<View, SpinnerView>( static (_,_) => { @@ -35,7 +35,7 @@ public void NewSpinnerAutoSpins_AfterRoundTrip() },out _); // Auto-spin original and the one that is read back in - Assert.That( Application.MainLoop.Timeouts, Has.Count.EqualTo( 2 ) ); + Assert.That( Application.MainLoop.TimedEvents.Timeouts, Has.Count.EqualTo( 2 ) ); } [Test] diff --git a/tests/UnitTests.csproj b/tests/UnitTests.csproj index f2dd904d..e474475a 100644 --- a/tests/UnitTests.csproj +++ b/tests/UnitTests.csproj @@ -36,7 +36,6 @@ <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> </PackageReference> - <PackageReference Include="Terminal.Gui" Version="2.0.0-prealpha.1546" /> </ItemGroup> <ItemGroup> From 77358a374cd778dc57d5791580e823b0978251db Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Fri, 7 Mar 2025 07:58:19 +0000 Subject: [PATCH 27/54] Fix layout of slider options editor --- Showcase/Slider.Designer.cs | 24 +++++++++++++++++++ src/UI/Windows/SliderOptionEditor.Designer.cs | 24 ++++++++++++------- src/ViewFactory.cs | 5 +--- 3 files changed, 40 insertions(+), 13 deletions(-) diff --git a/Showcase/Slider.Designer.cs b/Showcase/Slider.Designer.cs index 38dac90f..db1bd361 100644 --- a/Showcase/Slider.Designer.cs +++ b/Showcase/Slider.Designer.cs @@ -33,7 +33,10 @@ public partial class Slider : Terminal.Gui.Window { private Terminal.Gui.Line line; + private Terminal.Gui.Slider<double> slider4; + private void InitializeComponent() { + this.slider4 = new Terminal.Gui.Slider<double>(); this.line = new Terminal.Gui.Line(); this.slider3 = new Terminal.Gui.Slider<string>(); this.lblStringSliderThin = new Terminal.Gui.Label(); @@ -168,6 +171,27 @@ private void InitializeComponent() { this.line.Text = ""; this.line.TextAlignment = Terminal.Gui.Alignment.Start; this.Add(this.line); + this.slider4.Width = 5; + this.slider4.Height = Dim.Auto(); + this.slider4.X = 16; + this.slider4.Y = 9; + this.slider4.Visible = true; + this.slider4.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.slider4.CanFocus = true; + this.slider4.ShadowStyle = Terminal.Gui.ShadowStyle.Transparent; + this.slider4.Options = new System.Collections.Generic.List<Terminal.Gui.SliderOption<double>>(new Terminal.Gui.SliderOption<double>[] { + new Terminal.Gui.SliderOption<double>("Zero", new System.Text.Rune('0'), 0D)}); + this.slider4.Orientation = Terminal.Gui.Orientation.Horizontal; + this.slider4.RangeAllowSingle = false; + this.slider4.AllowEmpty = false; + this.slider4.MinimumInnerSpacing = 1; + this.slider4.LegendsOrientation = Terminal.Gui.Orientation.Horizontal; + this.slider4.ShowLegends = true; + this.slider4.ShowEndSpacing = false; + this.slider4.Type = Terminal.Gui.SliderType.Single; + this.slider4.Data = "slider4"; + this.slider4.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.slider4); } } } diff --git a/src/UI/Windows/SliderOptionEditor.Designer.cs b/src/UI/Windows/SliderOptionEditor.Designer.cs index b19f3a85..1b18bd3f 100644 --- a/src/UI/Windows/SliderOptionEditor.Designer.cs +++ b/src/UI/Windows/SliderOptionEditor.Designer.cs @@ -57,7 +57,7 @@ private void InitializeComponent() { this.redOnBlack = new Terminal.Gui.ColorScheme(new Terminal.Gui.Attribute(4291104543u, 4278979596u), new Terminal.Gui.Attribute(4291104543u, 4286595104u), new Terminal.Gui.Attribute(4293347414u, 4278979596u), new Terminal.Gui.Attribute(4291611852u, 4278979596u), new Terminal.Gui.Attribute(4293347414u, 4286595104u)); this.tgDefault = new Terminal.Gui.ColorScheme(new Terminal.Gui.Attribute(4294111986u, 4278204378u), new Terminal.Gui.Attribute(4278979596u, 4291611852u), new Terminal.Gui.Attribute(4284602070u, 4278204378u), new Terminal.Gui.Attribute(4286595104u, 4278204378u), new Terminal.Gui.Attribute(4282087679u, 4291611852u)); this.Width = 50; - this.Height = 8; + this.Height = 10; this.X = Pos.Center(); this.Y = Pos.Center(); this.Visible = true; @@ -139,32 +139,38 @@ private void InitializeComponent() { this.tfData.TextAlignment = Terminal.Gui.Alignment.Start; this.Add(this.tfData); this.lblType.Width = Dim.Fill(0); - this.lblType.Height = 1; - this.lblType.X = 0; + this.lblType.Height = Dim.Auto(); + this.lblType.X = -1; this.lblType.Y = 4; this.lblType.Visible = true; this.lblType.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblType.CanFocus = true; + this.lblType.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.lblType.Data = "lblType"; this.lblType.Text = "( Type ) "; this.lblType.TextAlignment = Terminal.Gui.Alignment.Center; this.Add(this.lblType); - this.btnOk.Width = 8; - this.btnOk.Height = 1; - this.btnOk.X = 11; + this.btnOk.Width = Dim.Auto(); + this.btnOk.Height = Dim.Auto(); + this.btnOk.X = 10; this.btnOk.Y = 5; this.btnOk.Visible = true; this.btnOk.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnOk.CanFocus = true; + this.btnOk.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; this.btnOk.Data = "btnOk"; this.btnOk.Text = "Ok"; this.btnOk.TextAlignment = Terminal.Gui.Alignment.Center; this.btnOk.IsDefault = true; this.Add(this.btnOk); - this.btnCancel.Width = 8; - this.btnCancel.Height = 1; - this.btnCancel.X = 23; + this.btnCancel.Width = Dim.Auto(); + this.btnCancel.Height = Dim.Auto(); + this.btnCancel.X = 22; this.btnCancel.Y = 5; this.btnCancel.Visible = true; this.btnCancel.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnCancel.CanFocus = true; + this.btnCancel.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; this.btnCancel.Data = "btnCancel"; this.btnCancel.Text = "Cancel"; this.btnCancel.TextAlignment = Terminal.Gui.Alignment.Center; diff --git a/src/ViewFactory.cs b/src/ViewFactory.cs index 44207891..4e1e33b2 100644 --- a/src/ViewFactory.cs +++ b/src/ViewFactory.cs @@ -267,10 +267,7 @@ public static T Create<T>(int? width = null, int? height = null, string? text = case null: throw new InvalidOperationException( $"Unexpected null result from type {typeof( T ).Name} constructor." ); } - - // Almost universally all user controlled views are going to want this. - newView.CanFocus = true; - + return newView; static void SetDefaultDimensions( T v, int width = 5, int height = 1 ) From e4ebd4030e8396d51ebe43bd001420d1481ce283 Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Fri, 7 Mar 2025 08:17:52 +0000 Subject: [PATCH 28/54] Fix all labels switching to focusable true on load --- src/Design.cs | 4 ---- tests/SuppressedPropertyTests.cs | 40 ++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 tests/SuppressedPropertyTests.cs diff --git a/src/Design.cs b/src/Design.cs index de30ea7d..37202ea9 100644 --- a/src/Design.cs +++ b/src/Design.cs @@ -166,10 +166,6 @@ public void CreateSubControlDesigns() /// <returns>A new <see cref="Design"/> wrapper wrapping <paramref name="subView"/>.</returns> public Design CreateSubControlDesign(string name, View subView) { - // all views can be focused so that they can be edited - // or deleted etc - subView.CanFocus = true; - if (subView is TableView tv && tv.Table != null && tv.GetDataTable().Rows.Count == 0) { var dt = tv.GetDataTable(); diff --git a/tests/SuppressedPropertyTests.cs b/tests/SuppressedPropertyTests.cs new file mode 100644 index 00000000..d13a8f96 --- /dev/null +++ b/tests/SuppressedPropertyTests.cs @@ -0,0 +1,40 @@ +using System.Xml.Linq; +using Terminal.Gui; + +namespace UnitTests; + +public class SuppressedPropertyTests +{ + [Test] + public void TestCanFocusCorrect() + { + var lbl = ViewFactory.Create<Label>(); + var d = new Design(new SourceCodeFile(new FileInfo("yarg.cs")),"myLabel", lbl); + + Assert.That(lbl.CanFocus,Is.True); + var p = d.GetDesignableProperty(nameof(View.CanFocus)); + Assert.That(p,Is.InstanceOf<SuppressedProperty>()); + Assert.That(p.GetValue(),Is.False); + } + + [Test] + public void TestCanFocusCorrect_AsChild() + { + var w = ViewFactory.Create<Window>(); + var lbl = ViewFactory.Create<Label>(); + lbl.Data = "mylbl"; + var d = new Design(new SourceCodeFile(new FileInfo("yarg.cs")), "mywin", w); + w.Add(lbl); + + d.CreateSubControlDesigns(); + + Assert.That(lbl.Data,Is.InstanceOf<Design>()); + + d = (Design)lbl.Data; + + Assert.That(lbl.CanFocus, Is.True); + var p = d.GetDesignableProperty(nameof(View.CanFocus)); + Assert.That(p, Is.InstanceOf<SuppressedProperty>()); + Assert.That(p.GetValue(), Is.False); + } +} From 524f60f972459047eb574a26a7ac1754fdc7706f Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Sat, 8 Mar 2025 13:10:50 +0000 Subject: [PATCH 29/54] Fix Ctrl+Shift being considered a valid shortcut for menu items --- Showcase/Menu.Designer.cs | 95 +++++++++++++++++++++++++++++++ Showcase/Menu.cs | 20 +++++++ src/UI/Windows/ExceptionViewer.cs | 1 + src/UI/Windows/Modals.cs | 7 ++- tests/MenuBarTests.cs | 15 +++++ 5 files changed, 136 insertions(+), 2 deletions(-) create mode 100644 Showcase/Menu.Designer.cs create mode 100644 Showcase/Menu.cs diff --git a/Showcase/Menu.Designer.cs b/Showcase/Menu.Designer.cs new file mode 100644 index 00000000..c47f2fb5 --- /dev/null +++ b/Showcase/Menu.Designer.cs @@ -0,0 +1,95 @@ + +//------------------------------------------------------------------------------ + +// <auto-generated> +// This code was generated by: +// TerminalGuiDesigner v2.0.0.0 +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +// ----------------------------------------------------------------------------- +namespace Showcase { + using System; + using Terminal.Gui; + using System.Collections; + using System.Collections.Generic; + using System.Collections.ObjectModel; + using System.Drawing; + + + public partial class Menu : Terminal.Gui.Window { + + private Terminal.Gui.MenuBar menuBar; + + private Terminal.Gui.MenuBarItem fileF9Menu; + + private Terminal.Gui.MenuBarItem newMenu; + + private Terminal.Gui.MenuItem projectMenuItem; + + private Terminal.Gui.MenuItem repositoryMenuItem; + + private Terminal.Gui.MenuItem fileMenuItem; + + private Terminal.Gui.MenuItem projectFromExistingCodeMenuItem; + + private Terminal.Gui.MenuItem spellCheckerConfigurationForSelectedItemMenuItem; + + private void InitializeComponent() { + this.menuBar = new Terminal.Gui.MenuBar(); + this.Width = Dim.Fill(0); + this.Height = Dim.Fill(0); + this.X = 0; + this.Y = 0; + this.Visible = true; + this.Arrangement = Terminal.Gui.ViewArrangement.Overlapped; + this.CanFocus = true; + this.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.Modal = false; + this.TextAlignment = Terminal.Gui.Alignment.Start; + this.Title = ""; + this.menuBar.Width = Dim.Fill(0); + this.menuBar.Height = 1; + this.menuBar.X = 0; + this.menuBar.Y = 0; + this.menuBar.Visible = true; + this.menuBar.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.menuBar.CanFocus = false; + this.menuBar.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.menuBar.Data = "menuBar"; + this.menuBar.TextAlignment = Terminal.Gui.Alignment.Start; + this.fileF9Menu = new Terminal.Gui.MenuBarItem(); + this.fileF9Menu.Title = "_File (F9)"; + this.newMenu = new Terminal.Gui.MenuBarItem(); + this.newMenu.Title = "New"; + this.projectMenuItem = new Terminal.Gui.MenuItem(); + this.projectMenuItem.Title = "Project..."; + this.projectMenuItem.Data = "projectMenuItem"; + this.projectMenuItem.ShortcutKey = ((Terminal.Gui.KeyCode)(1342177358u)); + this.repositoryMenuItem = new Terminal.Gui.MenuItem(); + this.repositoryMenuItem.Title = "Repository..."; + this.repositoryMenuItem.Data = "repositoryMenuItem"; + this.fileMenuItem = new Terminal.Gui.MenuItem(); + this.fileMenuItem.Title = "File..."; + this.fileMenuItem.Data = "fileMenuItem"; + this.projectFromExistingCodeMenuItem = new Terminal.Gui.MenuItem(); + this.projectFromExistingCodeMenuItem.Title = "Project From Existing Code..."; + this.projectFromExistingCodeMenuItem.Data = "projectFromExistingCodeMenuItem"; + this.spellCheckerConfigurationForSelectedItemMenuItem = new Terminal.Gui.MenuItem(); + this.spellCheckerConfigurationForSelectedItemMenuItem.Title = "Spell Checker Configuration for Selected Item"; + this.spellCheckerConfigurationForSelectedItemMenuItem.Data = "spellCheckerConfigurationForSelectedItemMenuItem"; + this.newMenu.Children = new Terminal.Gui.MenuItem[] { + this.projectMenuItem, + this.repositoryMenuItem, + this.fileMenuItem, + this.projectFromExistingCodeMenuItem, + null, + this.spellCheckerConfigurationForSelectedItemMenuItem}; + this.fileF9Menu.Children = new Terminal.Gui.MenuItem[] { + this.newMenu}; + this.menuBar.Menus = new Terminal.Gui.MenuBarItem[] { + this.fileF9Menu}; + this.Add(this.menuBar); + } + } +} diff --git a/Showcase/Menu.cs b/Showcase/Menu.cs new file mode 100644 index 00000000..cbac1d06 --- /dev/null +++ b/Showcase/Menu.cs @@ -0,0 +1,20 @@ + +//------------------------------------------------------------------------------ + +// <auto-generated> +// This code was generated by: +// TerminalGuiDesigner v2.0.0.0 +// You can make changes to this file and they will not be overwritten when saving. +// </auto-generated> +// ----------------------------------------------------------------------------- +namespace Showcase { + using Terminal.Gui; + + + public partial class Menu { + + public Menu() { + InitializeComponent(); + } + } +} diff --git a/src/UI/Windows/ExceptionViewer.cs b/src/UI/Windows/ExceptionViewer.cs index 0306e84d..1d9f2a51 100644 --- a/src/UI/Windows/ExceptionViewer.cs +++ b/src/UI/Windows/ExceptionViewer.cs @@ -16,6 +16,7 @@ public class ExceptionViewer /// <param name="exception"><see cref="Exception"/> to show.</param> public static void ShowException(string errorText, Exception exception) { + Logging.Critical(errorText + exception); var msg = GetExceptionText(errorText, exception, false); var textView = new TextView() diff --git a/src/UI/Windows/Modals.cs b/src/UI/Windows/Modals.cs index fd761e5f..4c999d4e 100644 --- a/src/UI/Windows/Modals.cs +++ b/src/UI/Windows/Modals.cs @@ -1,4 +1,5 @@ using System.Diagnostics.CodeAnalysis; +using System.Text; using Terminal.Gui; using YamlDotNet.Core.Tokens; using Key = Terminal.Gui.Key; @@ -193,9 +194,11 @@ internal static Terminal.Gui.Key GetShortcut() return key == Key.DeleteChar ? KeyCode.Null : key; } - private static bool IsValidShortcut(Key key) + public static bool IsValidShortcut(Key key) { - if (key.KeyCode == KeyCode.CtrlMask || key.KeyCode == KeyCode.ShiftMask || key.KeyCode == KeyCode.AltMask) + const KeyCode modifierMask = KeyCode.CtrlMask | KeyCode.ShiftMask | KeyCode.AltMask; + + if ((key.KeyCode & modifierMask) != 0 && (key.KeyCode & ~modifierMask) == 0) { return false; } diff --git a/tests/MenuBarTests.cs b/tests/MenuBarTests.cs index 0ed4ad23..354eebd2 100644 --- a/tests/MenuBarTests.cs +++ b/tests/MenuBarTests.cs @@ -1,4 +1,5 @@ using TerminalGuiDesigner.Operations.MenuOperations; +using TerminalGuiDesigner.UI.Windows; namespace UnitTests; @@ -723,6 +724,20 @@ public void TestMenuOperations( ) MenuTracker.Instance.UnregisterMenuBar( mbOut ); } + [TestCase(KeyCode.ShiftMask,false)] + [TestCase(KeyCode.AltMask, false)] + [TestCase(KeyCode.CtrlMask, false)] + [TestCase(KeyCode.ShiftMask | KeyCode.CtrlMask, false)] + [TestCase(KeyCode.ShiftMask | KeyCode.AltMask, false)] + [TestCase(KeyCode.CtrlMask | KeyCode.AltMask, false)] + [TestCase(KeyCode.ShiftMask | KeyCode.CtrlMask | KeyCode.AltMask, false)] + [TestCase(KeyCode.CtrlMask | KeyCode.C, true)] + [TestCase(KeyCode.ShiftMask | KeyCode.CtrlMask | KeyCode.AltMask | KeyCode.C, true)] + + public void TestShortcutIsValid(KeyCode k,bool expected) + { + Assert.That(Modals.IsValidShortcut(k),Is.EqualTo(expected)); + } private static MenuBar GetMenuBar( ) { return GetMenuBar( out _ ); From f054cd982cd86ce88e7bff96b897fb57278fd99b Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Sat, 8 Mar 2025 14:06:22 +0000 Subject: [PATCH 30/54] Allow pasting names of menu items Remove suppress key events in txt field/view Fix bug rendering overlay hint about selected view when it's name contains odd unicode stuff --- Showcase/Menu.Designer.cs | 16 ++++++++++++++++ src/Design.cs | 17 ----------------- src/UI/Editor.cs | 5 +++-- src/UI/KeyboardManager.cs | 30 ++++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 19 deletions(-) diff --git a/Showcase/Menu.Designer.cs b/Showcase/Menu.Designer.cs index c47f2fb5..671097c2 100644 --- a/Showcase/Menu.Designer.cs +++ b/Showcase/Menu.Designer.cs @@ -19,6 +19,8 @@ namespace Showcase { public partial class Menu : Terminal.Gui.Window { + private Terminal.Gui.TextField textField; + private Terminal.Gui.MenuBar menuBar; private Terminal.Gui.MenuBarItem fileF9Menu; @@ -37,6 +39,7 @@ public partial class Menu : Terminal.Gui.Window { private void InitializeComponent() { this.menuBar = new Terminal.Gui.MenuBar(); + this.textField = new Terminal.Gui.TextField(); this.Width = Dim.Fill(0); this.Height = Dim.Fill(0); this.X = 0; @@ -48,6 +51,19 @@ private void InitializeComponent() { this.Modal = false; this.TextAlignment = Terminal.Gui.Alignment.Start; this.Title = ""; + this.textField.Width = 5; + this.textField.Height = 1; + this.textField.X = 0; + this.textField.Y = 6; + this.textField.Visible = true; + this.textField.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.textField.CanFocus = true; + this.textField.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.textField.Secret = false; + this.textField.Data = "textField"; + this.textField.Text = "Heya"; + this.textField.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.textField); this.menuBar.Width = Dim.Fill(0); this.menuBar.Height = 1; this.menuBar.X = 0; diff --git a/src/Design.cs b/src/Design.cs index 37202ea9..56057510 100644 --- a/src/Design.cs +++ b/src/Design.cs @@ -209,14 +209,12 @@ public Design CreateSubControlDesign(string name, View subView) { // prevent control from responding to events txt.MouseClick += (s, e) => this.SuppressNativeClickEvents(s, e); - txt.KeyDown += this.SuppressNativeKeyboardEvents; } if (subView is TextField tf) { // prevent control from responding to events tf.MouseClick += (s,e)=>this.SuppressNativeClickEvents(s,e); - tf.KeyDown += SuppressNativeKeyboardEvents; } if (subView.GetType().IsGenericType(typeof(Slider<>))) @@ -633,21 +631,6 @@ private void SuppressNativeClickEvents(object? sender, MouseEventArgs obj, bool } } - private void SuppressNativeKeyboardEvents(object? sender, Key e) - { - if (sender == null) - { - return; - } - - if (e == Key.Tab || e == Key.Tab.WithShift || e == Key.Esc || e == Application.QuitKey) - { - e.Handled = false; - return; - } - - e.Handled = true; - } private void RegisterCheckboxDesignTimeChanges(CheckBox cb) { diff --git a/src/UI/Editor.cs b/src/UI/Editor.cs index 81725c3a..5345c929 100644 --- a/src/UI/Editor.cs +++ b/src/UI/Editor.cs @@ -250,11 +250,12 @@ protected override void OnDrawComplete(DrawContext? context) // write its name in the lower right int y = this.GetContentSize().Height - 1; int right = bounds.Width - 1; - var len = toDisplay.Length; + var runes = toDisplay.EnumerateRunes().ToList(); + var len = runes.Count(); for (int i = 0; i < len; i++) { - this.AddRune(right - len + i, y, new Rune(toDisplay[i])); + this.AddRune(right - len + i, y, runes[i]); } } } diff --git a/src/UI/KeyboardManager.cs b/src/UI/KeyboardManager.cs index 6c0eb6cb..6a6db234 100644 --- a/src/UI/KeyboardManager.cs +++ b/src/UI/KeyboardManager.cs @@ -182,6 +182,16 @@ private bool HandleKeyPressInMenu(View focusedView, MenuItem menuItem, Key keyst } } + // When menu is being edited let user paste in text e.g. command names + if (keystroke == keyMap.Paste) + { + if (Clipboard.TryGetClipboardData(out string text) && IsValidSimpleStringToPaste(text)) + { + menuItem.Title += text; + return true; + } + } + // Allow typing but also Enter to create a new sub-item if ( !this.IsActionableKey( keystroke ) ) { @@ -217,6 +227,26 @@ private bool HandleKeyPressInMenu(View focusedView, MenuItem menuItem, Key keyst return false; } + private bool IsValidSimpleStringToPaste(string result) + { + if (string.IsNullOrWhiteSpace(result)) + { + return false; + } + + if (result.Contains('\n') || result.Contains('\r')) + { + return false; + } + + if (result.Length > 100) + { + return false; + } + + return true; + } + private void ChangeKeyTo(Key keystroke, Key newKey) { Type t = typeof(Key); From bb226b00c9e827c54eb168da78aa1f8de1aeb2e1 Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Sat, 8 Mar 2025 14:07:08 +0000 Subject: [PATCH 31/54] Remove janky code for switching focus to listbox search --- src/UI/Windows/BigListBox.cs | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/src/UI/Windows/BigListBox.cs b/src/UI/Windows/BigListBox.cs index 4aa20962..422a101c 100644 --- a/src/UI/Windows/BigListBox.cs +++ b/src/UI/Windows/BigListBox.cs @@ -88,9 +88,7 @@ public BigListBox(string prompt, SelectedItem = 0 }; listView.SetSource(new ObservableCollection<string>(ErrorStringArray)); - - this.listView.KeyDown += this.ListView_KeyPress; - + this.listView.MouseClick += this.ListView_MouseClick; this.collection = this.BuildList(this.GetInitialSource()).ToList(); @@ -223,21 +221,7 @@ private void ListView_MouseClick(object? sender, MouseEventArgs obj) this.Accept(); } } - - private void ListView_KeyPress(object? sender, Key key) - { - // if user types in some text change the focus to the text box to enable searching - var c = (char)key; - - // backspace or letter/numbers - if (key == Key.Backspace || char.IsLetterOrDigit(c)) - { - this.searchBox?.FocusDeepest(NavigationDirection.Forward, TabBehavior.TabStop); - this.searchBox?.NewKeyDownEvent(key); - key.Handled = true; - } - } - + private bool Timer() { if (this.changes && DateTime.Now.Subtract(this.lastKeypress) > TimeSpan.FromMilliseconds(100)) From 7a3829eb93aa04aa26f181cc9ece80a2ca3b41bd Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Sat, 8 Mar 2025 14:53:00 +0000 Subject: [PATCH 32/54] Add logging of which commands are run --- Showcase/Menu.Designer.cs | 212 +++++++++++++++++- src/Operations/AddViewOperation.cs | 4 +- src/Operations/CompositeOperation.cs | 4 +- src/Operations/CopyOperation.cs | 4 +- src/Operations/DeleteColorSchemeOperation.cs | 4 +- src/Operations/DeleteViewOperation.cs | 4 +- src/Operations/DragOperation.cs | 4 +- src/Operations/Generics/AddOperation.cs | 4 +- src/Operations/Generics/MoveOperation.cs | 4 +- src/Operations/Generics/RemoveOperation.cs | 4 +- src/Operations/Generics/RenameOperation.cs | 4 +- .../MenuOperations/AddMenuItemOperation.cs | 4 +- .../ConvertMenuItemToSeperatorOperation.cs | 4 +- .../MoveMenuItemLeftOperation.cs | 4 +- .../MenuOperations/MoveMenuItemOperation.cs | 4 +- .../MoveMenuItemRightOperation.cs | 4 +- .../MenuOperations/RemoveMenuItemOperation.cs | 4 +- .../MenuOperations/RenameMenuItemOperation.cs | 4 +- src/Operations/MoveViewOperation.cs | 4 +- src/Operations/Operation.cs | 23 +- src/Operations/PasteOperation.cs | 4 +- src/Operations/ResizeOperation.cs | 4 +- src/Operations/SetPropertyOperation.cs | 4 +- .../SetShortcutOperation.cs | 4 +- tests/EditorTests.cs | 4 +- 25 files changed, 276 insertions(+), 51 deletions(-) diff --git a/Showcase/Menu.Designer.cs b/Showcase/Menu.Designer.cs index 671097c2..4b1f0747 100644 --- a/Showcase/Menu.Designer.cs +++ b/Showcase/Menu.Designer.cs @@ -37,6 +37,70 @@ public partial class Menu : Terminal.Gui.Window { private Terminal.Gui.MenuItem spellCheckerConfigurationForSelectedItemMenuItem; + private Terminal.Gui.MenuBarItem openMenu; + + private Terminal.Gui.MenuItem projectSolutionMenuItem; + + private Terminal.Gui.MenuItem folderMenuItem; + + private Terminal.Gui.MenuItem workspaceMenuItem; + + private Terminal.Gui.MenuItem cMakeMenuItem; + + private Terminal.Gui.MenuItem fileMenuItem2; + + private Terminal.Gui.MenuItem cloneRepositoryMenuItem; + + private Terminal.Gui.MenuItem startWindowMenuItem; + + private Terminal.Gui.MenuItem closeMenuItem; + + private Terminal.Gui.MenuItem closeSolutionMenuItem; + + private Terminal.Gui.MenuItem startLiveShareSessionMenuItem; + + private Terminal.Gui.MenuItem joinLiveShareSessionMenuItem; + + private Terminal.Gui.MenuItem saveMenucsMenuItem; + + private Terminal.Gui.MenuItem saveMenucsAsMenuItem; + + private Terminal.Gui.MenuItem saveAllMenuItem; + + private Terminal.Gui.MenuItem pageSetupMenuItem; + + private Terminal.Gui.MenuItem printMenuItem; + + private Terminal.Gui.MenuItem accountSettingsMenuItem; + + private Terminal.Gui.MenuBarItem recentFilesMenu; + + private Terminal.Gui.MenuItem file1csMenuItem; + + private Terminal.Gui.MenuItem file2csMenuItem; + + private Terminal.Gui.MenuBarItem recentProjectsAndSolutionsMenu; + + private Terminal.Gui.MenuItem terminalGuislnMenuItem; + + private Terminal.Gui.MenuItem terminalGuiDesignerslnMenuItem; + + private Terminal.Gui.MenuBarItem moveMenucsIntoMenu; + + private Terminal.Gui.MenuItem solutionItemsMenuItem; + + private Terminal.Gui.MenuItem unitTestsMenuItem; + + private Terminal.Gui.MenuItem showcaseMenuItem; + + private Terminal.Gui.MenuItem exitMenuItem; + + private Terminal.Gui.MenuBarItem editMenu; + + private Terminal.Gui.MenuBarItem goToMenu; + + private Terminal.Gui.MenuItem goToLineMenuItem; + private void InitializeComponent() { this.menuBar = new Terminal.Gui.MenuBar(); this.textField = new Terminal.Gui.TextField(); @@ -101,10 +165,154 @@ private void InitializeComponent() { this.projectFromExistingCodeMenuItem, null, this.spellCheckerConfigurationForSelectedItemMenuItem}; + this.openMenu = new Terminal.Gui.MenuBarItem(); + this.openMenu.Title = "Open"; + this.projectSolutionMenuItem = new Terminal.Gui.MenuItem(); + this.projectSolutionMenuItem.Title = "Project/Solution..."; + this.projectSolutionMenuItem.Data = "projectSolutionMenuItem"; + this.projectSolutionMenuItem.ShortcutKey = ((Terminal.Gui.KeyCode)(1342177359u)); + this.folderMenuItem = new Terminal.Gui.MenuItem(); + this.folderMenuItem.Title = "Folder..."; + this.folderMenuItem.Data = "folderMenuItem"; + this.folderMenuItem.ShortcutKey = ((Terminal.Gui.KeyCode)(3489661007u)); + this.workspaceMenuItem = new Terminal.Gui.MenuItem(); + this.workspaceMenuItem.Title = "Workspace..."; + this.workspaceMenuItem.Data = "workspaceMenuItem"; + this.cMakeMenuItem = new Terminal.Gui.MenuItem(); + this.cMakeMenuItem.Title = "CMake..."; + this.cMakeMenuItem.Data = "cMakeMenuItem"; + this.fileMenuItem2 = new Terminal.Gui.MenuItem(); + this.fileMenuItem2.Title = "File..."; + this.fileMenuItem2.Data = "fileMenuItem2"; + this.fileMenuItem2.ShortcutKey = ((Terminal.Gui.KeyCode)(1073741903u)); + this.openMenu.Children = new Terminal.Gui.MenuItem[] { + this.projectSolutionMenuItem, + this.folderMenuItem, + this.workspaceMenuItem, + this.cMakeMenuItem, + null, + this.fileMenuItem2}; + this.cloneRepositoryMenuItem = new Terminal.Gui.MenuItem(); + this.cloneRepositoryMenuItem.Title = "Clone Repository..."; + this.cloneRepositoryMenuItem.Data = "cloneRepositoryMenuItem"; + this.startWindowMenuItem = new Terminal.Gui.MenuItem(); + this.startWindowMenuItem.Title = "Start Window"; + this.startWindowMenuItem.Data = "startWindowMenuItem"; + this.closeMenuItem = new Terminal.Gui.MenuItem(); + this.closeMenuItem.Title = "Close"; + this.closeMenuItem.Data = "closeMenuItem"; + this.closeSolutionMenuItem = new Terminal.Gui.MenuItem(); + this.closeSolutionMenuItem.Title = "Close Solution"; + this.closeSolutionMenuItem.Data = "closeSolutionMenuItem"; + this.startLiveShareSessionMenuItem = new Terminal.Gui.MenuItem(); + this.startLiveShareSessionMenuItem.Title = "Start Live Share Session"; + this.startLiveShareSessionMenuItem.Data = "startLiveShareSessionMenuItem"; + this.joinLiveShareSessionMenuItem = new Terminal.Gui.MenuItem(); + this.joinLiveShareSessionMenuItem.Title = "Join Live Share Session..."; + this.joinLiveShareSessionMenuItem.Data = "joinLiveShareSessionMenuItem"; + this.saveMenucsMenuItem = new Terminal.Gui.MenuItem(); + this.saveMenucsMenuItem.Title = "Save Menu.cs"; + this.saveMenucsMenuItem.Data = "saveMenucsMenuItem"; + this.saveMenucsMenuItem.ShortcutKey = ((Terminal.Gui.KeyCode)(1073741907u)); + this.saveMenucsAsMenuItem = new Terminal.Gui.MenuItem(); + this.saveMenucsAsMenuItem.Title = "Save Menu.cs As..."; + this.saveMenucsAsMenuItem.Data = "saveMenucsAsMenuItem"; + this.saveAllMenuItem = new Terminal.Gui.MenuItem(); + this.saveAllMenuItem.Title = "Save All"; + this.saveAllMenuItem.Data = "saveAllMenuItem"; + this.saveAllMenuItem.ShortcutKey = ((Terminal.Gui.KeyCode)(1342177363u)); + this.pageSetupMenuItem = new Terminal.Gui.MenuItem(); + this.pageSetupMenuItem.Title = "Page Setup..."; + this.pageSetupMenuItem.Data = "pageSetupMenuItem"; + this.printMenuItem = new Terminal.Gui.MenuItem(); + this.printMenuItem.Title = "Print..."; + this.printMenuItem.Data = "printMenuItem"; + this.printMenuItem.ShortcutKey = ((Terminal.Gui.KeyCode)(1073741904u)); + this.accountSettingsMenuItem = new Terminal.Gui.MenuItem(); + this.accountSettingsMenuItem.Title = "Account Settings..."; + this.accountSettingsMenuItem.Data = "accountSettingsMenuItem"; + this.recentFilesMenu = new Terminal.Gui.MenuBarItem(); + this.recentFilesMenu.Title = "Recent Files"; + this.file1csMenuItem = new Terminal.Gui.MenuItem(); + this.file1csMenuItem.Title = "File 1.cs"; + this.file1csMenuItem.Data = "file1csMenuItem"; + this.file2csMenuItem = new Terminal.Gui.MenuItem(); + this.file2csMenuItem.Title = "File 2.cs"; + this.file2csMenuItem.Data = "file2csMenuItem"; + this.recentFilesMenu.Children = new Terminal.Gui.MenuItem[] { + this.file1csMenuItem, + this.file2csMenuItem}; + this.recentProjectsAndSolutionsMenu = new Terminal.Gui.MenuBarItem(); + this.recentProjectsAndSolutionsMenu.Title = "Recent Projects and Solutions"; + this.terminalGuislnMenuItem = new Terminal.Gui.MenuItem(); + this.terminalGuislnMenuItem.Title = "Terminal.Gui.sln"; + this.terminalGuislnMenuItem.Data = "terminalGuislnMenuItem"; + this.terminalGuiDesignerslnMenuItem = new Terminal.Gui.MenuItem(); + this.terminalGuiDesignerslnMenuItem.Title = "TerminalGuiDesigner.sln"; + this.terminalGuiDesignerslnMenuItem.Data = "terminalGuiDesignerslnMenuItem"; + this.recentProjectsAndSolutionsMenu.Children = new Terminal.Gui.MenuItem[] { + this.terminalGuislnMenuItem, + this.terminalGuiDesignerslnMenuItem}; + this.moveMenucsIntoMenu = new Terminal.Gui.MenuBarItem(); + this.moveMenucsIntoMenu.Title = "Move Menu.cs into"; + this.solutionItemsMenuItem = new Terminal.Gui.MenuItem(); + this.solutionItemsMenuItem.Title = "1 Solution Items"; + this.solutionItemsMenuItem.Data = "solutionItemsMenuItem"; + this.unitTestsMenuItem = new Terminal.Gui.MenuItem(); + this.unitTestsMenuItem.Title = "2 UnitTests"; + this.unitTestsMenuItem.Data = "unitTestsMenuItem"; + this.showcaseMenuItem = new Terminal.Gui.MenuItem(); + this.showcaseMenuItem.Title = "3 Showcase"; + this.showcaseMenuItem.Data = "showcaseMenuItem"; + this.moveMenucsIntoMenu.Children = new Terminal.Gui.MenuItem[] { + this.solutionItemsMenuItem, + this.unitTestsMenuItem, + this.showcaseMenuItem}; + this.exitMenuItem = new Terminal.Gui.MenuItem(); + this.exitMenuItem.Title = "Exit"; + this.exitMenuItem.Data = "exitMenuItem"; this.fileF9Menu.Children = new Terminal.Gui.MenuItem[] { - this.newMenu}; + this.newMenu, + this.openMenu, + this.cloneRepositoryMenuItem, + this.startWindowMenuItem, + null, + this.closeMenuItem, + this.closeSolutionMenuItem, + null, + this.startLiveShareSessionMenuItem, + this.joinLiveShareSessionMenuItem, + null, + this.saveMenucsMenuItem, + this.saveMenucsAsMenuItem, + this.saveAllMenuItem, + null, + this.pageSetupMenuItem, + this.printMenuItem, + null, + this.accountSettingsMenuItem, + null, + this.recentFilesMenu, + this.recentProjectsAndSolutionsMenu, + null, + this.moveMenucsIntoMenu, + null, + this.exitMenuItem}; + this.editMenu = new Terminal.Gui.MenuBarItem(); + this.editMenu.Title = "Edit"; + this.goToMenu = new Terminal.Gui.MenuBarItem(); + this.goToMenu.Title = "Go To"; + this.goToLineMenuItem = new Terminal.Gui.MenuItem(); + this.goToLineMenuItem.Title = "Go To Line..."; + this.goToLineMenuItem.Data = "goToLineMenuItem"; + this.goToLineMenuItem.ShortcutKey = ((Terminal.Gui.KeyCode)(1073741895u)); + this.goToMenu.Children = new Terminal.Gui.MenuItem[] { + this.goToLineMenuItem}; + this.editMenu.Children = new Terminal.Gui.MenuItem[] { + this.goToMenu}; this.menuBar.Menus = new Terminal.Gui.MenuBarItem[] { - this.fileF9Menu}; + this.fileF9Menu, + this.editMenu}; this.Add(this.menuBar); } } diff --git a/src/Operations/AddViewOperation.cs b/src/Operations/AddViewOperation.cs index f518b933..0dec5cd1 100644 --- a/src/Operations/AddViewOperation.cs +++ b/src/Operations/AddViewOperation.cs @@ -46,7 +46,7 @@ public AddViewOperation(Design design) } /// <inheritdoc/> - public override void Redo() + protected override void RedoImpl() { if (this.add == null) { @@ -59,7 +59,7 @@ public override void Redo() } /// <inheritdoc/> - public override void Undo() + protected override void UndoImpl() { if (this.add == null) { diff --git a/src/Operations/CompositeOperation.cs b/src/Operations/CompositeOperation.cs index da09d9d8..2bbe8609 100644 --- a/src/Operations/CompositeOperation.cs +++ b/src/Operations/CompositeOperation.cs @@ -38,7 +38,7 @@ public CompositeOperation(params Operation[] operations) public IReadOnlyCollection<Operation> Operations => new ReadOnlyCollection<Operation>(this.operations); /// <inheritdoc/> - public override void Redo() + protected override void RedoImpl() { foreach (var op in this.operations) { @@ -47,7 +47,7 @@ public override void Redo() } /// <inheritdoc/> - public override void Undo() + protected override void UndoImpl() { foreach (var op in this.operations) { diff --git a/src/Operations/CopyOperation.cs b/src/Operations/CopyOperation.cs index 80a509ba..e7febe4a 100644 --- a/src/Operations/CopyOperation.cs +++ b/src/Operations/CopyOperation.cs @@ -57,7 +57,7 @@ public override string ToString() /// Throws <see cref="NotSupportedException"/> as you cannot undo a copy. /// </summary> /// <exception cref="NotSupportedException">Thrown if method run.</exception> - public override void Undo() + protected override void UndoImpl() { throw new NotSupportedException(); } @@ -66,7 +66,7 @@ public override void Undo() /// Throws <see cref="NotSupportedException"/> as you cannot redo a copy. /// </summary> /// <exception cref="NotSupportedException">Thrown if method run.</exception> - public override void Redo() + protected override void RedoImpl() { throw new NotSupportedException(); } diff --git a/src/Operations/DeleteColorSchemeOperation.cs b/src/Operations/DeleteColorSchemeOperation.cs index 15a82dcb..03f963b3 100644 --- a/src/Operations/DeleteColorSchemeOperation.cs +++ b/src/Operations/DeleteColorSchemeOperation.cs @@ -36,13 +36,13 @@ public DeleteColorSchemeOperation(Design design, NamedColorScheme toDelete) public NamedColorScheme ToDelete { get; } /// <inheritdoc/> - public override void Redo() + protected override void RedoImpl() { this.Do(); } /// <inheritdoc/> - public override void Undo() + protected override void UndoImpl() { foreach (var u in this.users) { diff --git a/src/Operations/DeleteViewOperation.cs b/src/Operations/DeleteViewOperation.cs index 5a527696..ddacff47 100644 --- a/src/Operations/DeleteViewOperation.cs +++ b/src/Operations/DeleteViewOperation.cs @@ -42,13 +42,13 @@ public DeleteViewOperation(params Design[] delete) } /// <inheritdoc/> - public override void Redo() + protected override void RedoImpl() { this.Do(); } /// <inheritdoc/> - public override void Undo() + protected override void UndoImpl() { for (int i = 0; i < this.delete.Length; i++) { diff --git a/src/Operations/DragOperation.cs b/src/Operations/DragOperation.cs index b4eb800e..0f208c36 100644 --- a/src/Operations/DragOperation.cs +++ b/src/Operations/DragOperation.cs @@ -140,7 +140,7 @@ public View? DropInto /// <summary> /// Moves all dragged views back to original positions. /// </summary> - public override void Undo() + protected override void UndoImpl() { foreach (var mem in this.mementos) { @@ -149,7 +149,7 @@ public override void Undo() } /// <inheritdoc/> - public override void Redo() + protected override void RedoImpl() { this.Do(); } diff --git a/src/Operations/Generics/AddOperation.cs b/src/Operations/Generics/AddOperation.cs index c0871812..7e8e9fc0 100644 --- a/src/Operations/Generics/AddOperation.cs +++ b/src/Operations/Generics/AddOperation.cs @@ -41,13 +41,13 @@ public AddOperation( } /// <inheritdoc/> - public override void Undo() + protected override void UndoImpl() { this.Remove(this.newItem); } /// <inheritdoc/> - public override void Redo() + protected override void RedoImpl() { this.Add(this.newItem); } diff --git a/src/Operations/Generics/MoveOperation.cs b/src/Operations/Generics/MoveOperation.cs index 145bfeca..c70f700b 100644 --- a/src/Operations/Generics/MoveOperation.cs +++ b/src/Operations/Generics/MoveOperation.cs @@ -80,13 +80,13 @@ public override string ToString() } /// <inheritdoc/> - public override void Redo() + protected override void RedoImpl() { this.Do(); } /// <inheritdoc/> - public override void Undo() + protected override void UndoImpl() { var list = this.ArrayGetter(this.View).ToList(); diff --git a/src/Operations/Generics/RemoveOperation.cs b/src/Operations/Generics/RemoveOperation.cs index 7695b2e9..58edf422 100644 --- a/src/Operations/Generics/RemoveOperation.cs +++ b/src/Operations/Generics/RemoveOperation.cs @@ -33,7 +33,7 @@ public RemoveOperation( } /// <inheritdoc/> - public override void Undo() + protected override void UndoImpl() { // its not there anyways if (this.OperateOn == null) @@ -48,7 +48,7 @@ public override void Undo() } /// <inheritdoc/> - public override void Redo() + protected override void RedoImpl() { this.Do(); } diff --git a/src/Operations/Generics/RenameOperation.cs b/src/Operations/Generics/RenameOperation.cs index fbed0591..6d1bb988 100644 --- a/src/Operations/Generics/RenameOperation.cs +++ b/src/Operations/Generics/RenameOperation.cs @@ -49,7 +49,7 @@ public override string ToString() } /// <inheritdoc/> - public override void Redo() + protected override void RedoImpl() { if (this.newName == null) { @@ -61,7 +61,7 @@ public override void Redo() } /// <inheritdoc/> - public override void Undo() + protected override void UndoImpl() { this.stringSetter(this.OperateOn, this.originalName); this.SetNeedsDraw(); diff --git a/src/Operations/MenuOperations/AddMenuItemOperation.cs b/src/Operations/MenuOperations/AddMenuItemOperation.cs index d0f8dccb..381a4024 100644 --- a/src/Operations/MenuOperations/AddMenuItemOperation.cs +++ b/src/Operations/MenuOperations/AddMenuItemOperation.cs @@ -28,7 +28,7 @@ public AddMenuItemOperation(MenuItem adjacentTo) } /// <inheritdoc/> - public override void Redo() + protected override void RedoImpl() { if (this.added != null) { @@ -37,7 +37,7 @@ public override void Redo() } /// <inheritdoc/> - public override void Undo() + protected override void UndoImpl() { if (this.added == null) { diff --git a/src/Operations/MenuOperations/ConvertMenuItemToSeperatorOperation.cs b/src/Operations/MenuOperations/ConvertMenuItemToSeperatorOperation.cs index 235fcc68..828bb869 100644 --- a/src/Operations/MenuOperations/ConvertMenuItemToSeperatorOperation.cs +++ b/src/Operations/MenuOperations/ConvertMenuItemToSeperatorOperation.cs @@ -22,13 +22,13 @@ public ConvertMenuItemToSeperatorOperation(MenuItem toConvert) } /// <inheritdoc/> - public override void Redo() + protected override void RedoImpl() { this.Do(); } /// <inheritdoc/> - public override void Undo() + protected override void UndoImpl() { if (this.Parent == null || this.OperateOn == null) { diff --git a/src/Operations/MenuOperations/MoveMenuItemLeftOperation.cs b/src/Operations/MenuOperations/MoveMenuItemLeftOperation.cs index d8a51df1..8e701f71 100644 --- a/src/Operations/MenuOperations/MoveMenuItemLeftOperation.cs +++ b/src/Operations/MenuOperations/MoveMenuItemLeftOperation.cs @@ -38,13 +38,13 @@ public MoveMenuItemLeftOperation(MenuItem toMove) } /// <inheritdoc/> - public override void Redo() + protected override void RedoImpl() { this.Do(); } /// <inheritdoc/> - public override void Undo() + protected override void UndoImpl() { if (this.OperateOn == null || this.IsImpossible) { diff --git a/src/Operations/MenuOperations/MoveMenuItemOperation.cs b/src/Operations/MenuOperations/MoveMenuItemOperation.cs index 25ee9ac2..062a5716 100644 --- a/src/Operations/MenuOperations/MoveMenuItemOperation.cs +++ b/src/Operations/MenuOperations/MoveMenuItemOperation.cs @@ -45,13 +45,13 @@ public MoveMenuItemOperation(MenuItem toMove, bool up) } /// <inheritdoc/> - public override void Redo() + protected override void RedoImpl() { this.Do(); } /// <inheritdoc/> - public override void Undo() + protected override void UndoImpl() { this.Move(this.up ? 1 : -1); } diff --git a/src/Operations/MenuOperations/MoveMenuItemRightOperation.cs b/src/Operations/MenuOperations/MoveMenuItemRightOperation.cs index 7e1bcbdb..1d925c92 100644 --- a/src/Operations/MenuOperations/MoveMenuItemRightOperation.cs +++ b/src/Operations/MenuOperations/MoveMenuItemRightOperation.cs @@ -31,7 +31,7 @@ public MoveMenuItemRightOperation(MenuItem toMove) public int? InsertionIndex { get; set; } /// <inheritdoc/> - public override void Redo() + protected override void RedoImpl() { if (this.OperateOn == null) { @@ -42,7 +42,7 @@ public override void Redo() } /// <inheritdoc/> - public override void Undo() + protected override void UndoImpl() { if (this.Parent == null || this.OperateOn == null) { diff --git a/src/Operations/MenuOperations/RemoveMenuItemOperation.cs b/src/Operations/MenuOperations/RemoveMenuItemOperation.cs index 284930ff..d951564e 100644 --- a/src/Operations/MenuOperations/RemoveMenuItemOperation.cs +++ b/src/Operations/MenuOperations/RemoveMenuItemOperation.cs @@ -51,13 +51,13 @@ public RemoveMenuItemOperation(MenuItem toRemove) public bool PrunedTopLevelMenu => this.prunedEmptyTopLevelMenus != null && this.prunedEmptyTopLevelMenus.Any(); /// <inheritdoc/> - public override void Redo() + protected override void RedoImpl() { this.Do(); } /// <inheritdoc/> - public override void Undo() + protected override void UndoImpl() { if (this.Parent == null || this.OperateOn == null) { diff --git a/src/Operations/MenuOperations/RenameMenuItemOperation.cs b/src/Operations/MenuOperations/RenameMenuItemOperation.cs index dc71a2f1..5b82da44 100644 --- a/src/Operations/MenuOperations/RenameMenuItemOperation.cs +++ b/src/Operations/MenuOperations/RenameMenuItemOperation.cs @@ -28,7 +28,7 @@ public RenameMenuItemOperation(MenuItem toRename) } /// <inheritdoc/> - public override void Redo() + protected override void RedoImpl() { if (this.OperateOn != null) { @@ -37,7 +37,7 @@ public override void Redo() } /// <inheritdoc/> - public override void Undo() + protected override void UndoImpl() { if (this.OperateOn != null) { diff --git a/src/Operations/MoveViewOperation.cs b/src/Operations/MoveViewOperation.cs index ebdf1aae..40b8af0b 100644 --- a/src/Operations/MoveViewOperation.cs +++ b/src/Operations/MoveViewOperation.cs @@ -90,13 +90,13 @@ public MoveViewOperation(Design toMove, int deltaX, int deltaY) public int DestinationX { get; } /// <inheritdoc/> - public override void Redo() + protected override void RedoImpl() { this.Do(); } /// <inheritdoc/> - public override void Undo() + protected override void UndoImpl() { if (this.BeingMoved.View.X.IsAbsolute()) { diff --git a/src/Operations/Operation.cs b/src/Operations/Operation.cs index be32983c..182a711a 100644 --- a/src/Operations/Operation.cs +++ b/src/Operations/Operation.cs @@ -1,4 +1,7 @@ -namespace TerminalGuiDesigner.Operations; +using NLog; +using Terminal.Gui; + +namespace TerminalGuiDesigner.Operations; /// <summary> /// Abstract base class for <see cref="IOperation"/>. @@ -45,6 +48,8 @@ public bool Do() return false; } + Logging.Information($"Do Operation {UniqueIdentifier} ({GetType().Name})"); + if ( this.DoImpl( ) ) { Interlocked.Increment( ref _timesDone ); @@ -55,10 +60,22 @@ public bool Do() } /// <inheritdoc/> - public abstract void Undo(); + public void Undo() + { + Logging.Information($"Undo Operation {UniqueIdentifier} ({GetType().Name})"); + UndoImpl(); + } + + protected abstract void UndoImpl(); /// <inheritdoc/> - public abstract void Redo(); + public void Redo() + { + Logging.Information($"Redo Operation {UniqueIdentifier} ({GetType().Name})"); + RedoImpl(); + } + + protected abstract void RedoImpl(); /// <inheritdoc cref="IOperation.Do"/> protected abstract bool DoImpl(); diff --git a/src/Operations/PasteOperation.cs b/src/Operations/PasteOperation.cs index 606006c4..4e1508b6 100644 --- a/src/Operations/PasteOperation.cs +++ b/src/Operations/PasteOperation.cs @@ -63,7 +63,7 @@ public PasteOperation(Design addTo) } /// <inheritdoc/> - public override void Undo() + protected override void UndoImpl() { foreach (var a in this.addOperations) { @@ -74,7 +74,7 @@ public override void Undo() } /// <inheritdoc/> - public override void Redo() + protected override void RedoImpl() { foreach (var a in this.addOperations) { diff --git a/src/Operations/ResizeOperation.cs b/src/Operations/ResizeOperation.cs index e5a9c3b2..4242ef66 100644 --- a/src/Operations/ResizeOperation.cs +++ b/src/Operations/ResizeOperation.cs @@ -55,7 +55,7 @@ public ResizeOperation(Design beingResized, int destX, int destY) public int DestinationY { get; private set; } /// <inheritdoc/> - public override void Undo() + protected override void UndoImpl() { this.BeingResized.GetDesignableProperty("Width")?.SetValue(this.OriginalWidth); this.BeingResized.GetDesignableProperty("Height")?.SetValue(this.OriginalHeight); @@ -63,7 +63,7 @@ public override void Undo() } /// <inheritdoc/> - public override void Redo() + protected override void RedoImpl() { this.Do(); } diff --git a/src/Operations/SetPropertyOperation.cs b/src/Operations/SetPropertyOperation.cs index 13f77269..ec03965a 100644 --- a/src/Operations/SetPropertyOperation.cs +++ b/src/Operations/SetPropertyOperation.cs @@ -116,7 +116,7 @@ public IReadOnlyCollection<Design> Designs } /// <inheritdoc/> - public override void Undo() + protected override void UndoImpl() { foreach (var m in this.mementos) { @@ -125,7 +125,7 @@ public override void Undo() } /// <inheritdoc/> - public override void Redo() + protected override void RedoImpl() { foreach (var m in this.mementos) { diff --git a/src/Operations/StatusBarOperations/SetShortcutOperation.cs b/src/Operations/StatusBarOperations/SetShortcutOperation.cs index f0c8195d..d4dc737f 100644 --- a/src/Operations/StatusBarOperations/SetShortcutOperation.cs +++ b/src/Operations/StatusBarOperations/SetShortcutOperation.cs @@ -32,7 +32,7 @@ public SetShortcutOperation(Design design, Shortcut statusItem, Key? shortcut) } /// <inheritdoc/> - public override void Redo() + protected override void RedoImpl() { if (this.shortcut == null) { @@ -43,7 +43,7 @@ public override void Redo() } /// <inheritdoc/> - public override void Undo() + protected override void UndoImpl() { this.OperateOn.Key = this.originalShortcut; } diff --git a/tests/EditorTests.cs b/tests/EditorTests.cs index 72d8d36b..81ba04ae 100644 --- a/tests/EditorTests.cs +++ b/tests/EditorTests.cs @@ -70,11 +70,11 @@ protected override bool DoImpl() return true; } - public override void Redo() + protected override void RedoImpl() { } - public override void Undo() + protected override void UndoImpl() { } } From 98969ce78a2030e0e03880aad961aa3e378941fe Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Sat, 8 Mar 2025 19:03:23 +0000 Subject: [PATCH 33/54] Fix bad merge --- src/UI/Windows/GetTextDialog.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/UI/Windows/GetTextDialog.cs b/src/UI/Windows/GetTextDialog.cs index ed556be2..bcdfcf1e 100644 --- a/src/UI/Windows/GetTextDialog.cs +++ b/src/UI/Windows/GetTextDialog.cs @@ -107,7 +107,7 @@ public GetTextDialog(DialogArgs args, string? initialValue) btnClear.Accepting += (s, e) => { e.Cancel = true; - this.textField.Text = string.Empty; + this.textView.Text = string.Empty; }; this.win.Add(btnOk); From e3da600d9b8c5a9930b640d27dee01a3777b62d0 Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Sun, 9 Mar 2025 09:23:41 +0000 Subject: [PATCH 34/54] Add Quiet and Driver CLI options --- src/Options.cs | 14 ++++++++++++++ src/Program.cs | 3 ++- src/UI/Editor.cs | 18 ++++++++++++++++-- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/Options.cs b/src/Options.cs index bf8657e5..4e51a9a0 100644 --- a/src/Options.cs +++ b/src/Options.cs @@ -56,5 +56,19 @@ public static IEnumerable<Example> Examples [Option('e', HelpText = "Enables experimental features")] public bool Experimental { get; set; } + + /// <summary> + /// Gets or sets a which driver to use. + /// </summary> + [Option('d', HelpText = "Driver to use. v2, v2net, v2win, WindowsDriver, CursesDriver or NetDriver", + Default = "v2")] + public string Driver { get; set; } = "v2"; + + + /// <summary> + /// Gets or sets a value indicating whether to enable logging. + /// </summary> + [Option('q', HelpText = "Pass to suppress log generation")] + public bool Quiet { get; set; } #nullable enable warnings } diff --git a/src/Program.cs b/src/Program.cs index 09d2a11d..18184629 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -19,8 +19,9 @@ public static void Main(string[] args) .WithParsed<Options>(o => { Editor.Experimental = o.Experimental; + Editor.Quiet = o.Quiet; - Application.Init(null,"v2"); + Application.Init(null,o.Driver); var editor = new Editor(); editor.Run(o); }); diff --git a/src/UI/Editor.cs b/src/UI/Editor.cs index 5345c929..242fc6fc 100644 --- a/src/UI/Editor.cs +++ b/src/UI/Editor.cs @@ -48,6 +48,11 @@ public class Editor : Toplevel private static string _logDirectory = string.Empty; + /// <summary> + /// True to disable logging (must be set before constructing <see cref="Editor"/>). + /// </summary> + public static bool Quiet = false; + /// <summary> /// Initializes a new instance of the <see cref="Editor"/> class. /// </summary> @@ -56,7 +61,10 @@ public Editor() // Bug: This will have strange inheritance behavior if Editor is inherited from. this.CanFocus = true; - Logging.Logger = CreateLogger(); + if (!Quiet) + { + Logging.Logger = CreateLogger(); + } try { @@ -440,7 +448,12 @@ ________ .__ ________ .__ Driver.SetAttribute(new Attribute(new Color(colorAtPoint), new Color(Color.Black))); this.AddRune(x, y, (Rune)versionLine[i]); } - + + if (Quiet) + { + return; + } + // Render the log directory line below the version line int logLineX = inArea.X + (inArea.Width - logLine.Length) / 2; int logLineY = versionLineY+2; @@ -711,6 +724,7 @@ public bool HasUnsavedChanges } } + private string GetHelpWithEmptyFormLoaded() { return $"{this.keyMap.AddView} to Add a View"; From b7d854ac0a54ab966615962a4a9f0fbeb592a5fa Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Sun, 9 Mar 2025 09:31:30 +0000 Subject: [PATCH 35/54] Fix warnings and xmldocs --- src/DimExtensions.cs | 17 ++++++++++------- src/DimType.cs | 4 ++-- src/Operations/CompositeOperation.cs | 2 +- .../MoveStatusItemOperation.cs | 2 +- .../RemoveStatusItemOperation.cs | 4 ++-- .../RenameStatusItemOperation.cs | 4 ++-- .../StatusBarOperations/SetShortcutOperation.cs | 4 ++-- .../TabOperations/RenameTabOperation.cs | 4 ++-- src/PosExtensions.cs | 4 +++- src/StatusBarExtensions.cs | 4 ++-- src/ToCode/StatusBarItemsToCode.cs | 4 ++-- src/UI/Editor.cs | 4 ++-- src/ViewExtensions.cs | 2 +- 13 files changed, 32 insertions(+), 27 deletions(-) diff --git a/src/DimExtensions.cs b/src/DimExtensions.cs index 378be9ab..c0a06e32 100644 --- a/src/DimExtensions.cs +++ b/src/DimExtensions.cs @@ -17,7 +17,7 @@ public static class DimExtensions private const bool TreatNullDimAs0 = true; /// <summary> - /// Returns true if the <paramref name="d"/> is a DimFactor (i.e. created by <see cref="Dim.Percent(int, bool)"/>). + /// Returns true if the <paramref name="d"/> is a DimFactor (i.e. created by <see cref="Dim.Percent"/>). /// </summary> /// <param name="d">Dimension to determine Type.</param> /// <returns>true if <paramref name="d"/> is DimFactor.</returns> @@ -34,7 +34,7 @@ public static bool IsPercent(this Dim d) /// <inheritdoc cref="IsPercent(Dim)"/> /// <param name="d">The <see cref="Dim"/> to determine whether it represents a percent.</param> /// <param name="percent">The 'percentage' value of <paramref name="d"/>. This is the value that would/could be - /// passed to <see cref="Dim.Percent(int, bool)"/> to produce the <paramref name="d"/> or 0 if <paramref name="d"/> is + /// passed to <see cref="Dim.Percent"/> to produce the <paramref name="d"/> or 0 if <paramref name="d"/> is /// not DimFactor.</param> public static bool IsPercent(this Dim d, out int percent) { @@ -50,10 +50,10 @@ public static bool IsPercent(this Dim d, out int percent) } /// <summary> - /// Determines whether an input <see cref="Dim"/> is a <see cref="Dim.Fill(int)"/>. + /// Determines whether an input <see cref="Dim"/> is a <see cref="Dim.Fill()"/>. /// </summary> /// <param name="d">Input <see cref="Dim"/> to classify.</param> - /// <returns><see langword="true"/> if <paramref name="d"/> is the result of a <see cref="Dim.Fill(int)"/> call.</returns> + /// <returns><see langword="true"/> if <paramref name="d"/> is the result of a <see cref="Dim.Fill()"/> call.</returns> public static bool IsFill(this Dim d) { if (d == null) @@ -66,7 +66,7 @@ public static bool IsFill(this Dim d) /// <inheritdoc cref="IsFill(Dim)"/> /// <param name="d">Input <see cref="Dim"/> to classify.</param> - /// <param name="margin">The margin of the <see cref="Dim.Fill(int)"/> used to create <paramref name="d"/> or 0.</param> + /// <param name="margin">The margin of the <see cref="Dim.Fill()"/> used to create <paramref name="d"/> or 0.</param> public static bool IsFill(this Dim d, out int margin) { if (d != null && d.IsFill()) @@ -100,6 +100,9 @@ public static bool IsAbsolute(this Dim d) /// True if <paramref name="d"/> is a <see cref="DimAuto"/> width/height. /// </summary> /// <param name="d">The <see cref="Dim"/> to determine whether it is auto.</param> + /// <param name="das">If <paramref name="d"/> is <see cref="DimAuto"/> then this is <see cref="DimAuto.Style"/>.</param> + /// <param name="min">If <paramref name="d"/> is <see cref="DimAuto"/> then this is <see cref="DimAuto.MinimumContentDim"/></param> + /// <param name="max">If <paramref name="d"/> is <see cref="DimAuto"/> then this is <see cref="DimAuto.MaximumContentDim"/></param> /// <returns><see langword="true"/> if <paramref name="d"/> is a auto sizing.</returns> public static bool IsAuto(this Dim d, out DimAutoStyle das, out Dim? min, out Dim? max) { @@ -193,8 +196,8 @@ public static bool IsCombine(this Dim d, out Dim left, out Dim right, out bool a /// </summary> /// <param name="d">The <see cref="Dim"/> to determine type of.</param> /// <param name="type">The determined type.</param> - /// <param name="value">The numerical element of the type e.g. for <see cref="Dim.Percent(int, bool)"/> - /// the <paramref name="value"/> is the percentage but for <see cref="Dim.Fill(int)"/> the <paramref name="value"/> + /// <param name="value">The numerical element of the type e.g. for <see cref="Dim.Percent"/> + /// the <paramref name="value"/> is the percentage but for <see cref="Dim.Fill()"/> the <paramref name="value"/> /// is the margin.</param> /// <param name="offset">The numerical offset if any, for example -5 in the following: /// <code>Dim.Fill(1)-5</code></param> diff --git a/src/DimType.cs b/src/DimType.cs index 2e2670a3..dbe9e759 100644 --- a/src/DimType.cs +++ b/src/DimType.cs @@ -13,12 +13,12 @@ public enum DimType Absolute, /// <summary> - /// Percent of the remaining width/height e.g. <see cref="Dim.Percent(int, bool)"/>. + /// Percent of the remaining width/height e.g. <see cref="Dim.Percent"/>. /// </summary> Percent, /// <summary> - /// Filling the remaining space with a margin e.g. <see cref="Dim.Fill(int)"/>. + /// Filling the remaining space with a margin e.g. <see cref="Dim.Fill()"/>. /// </summary> Fill, diff --git a/src/Operations/CompositeOperation.cs b/src/Operations/CompositeOperation.cs index 2bbe8609..0c1dcb08 100644 --- a/src/Operations/CompositeOperation.cs +++ b/src/Operations/CompositeOperation.cs @@ -33,7 +33,7 @@ public CompositeOperation(params Operation[] operations) } /// <summary> - /// Gets the collection of sub operations performed on <see cref="Operation.Do"/> / <see cref="Undo"/>. + /// Gets the collection of sub operations performed on <see cref="Operation.Do"/> / <see cref="Operation.Undo"/>. /// </summary> public IReadOnlyCollection<Operation> Operations => new ReadOnlyCollection<Operation>(this.operations); diff --git a/src/Operations/StatusBarOperations/MoveStatusItemOperation.cs b/src/Operations/StatusBarOperations/MoveStatusItemOperation.cs index f8c4797f..4525179d 100644 --- a/src/Operations/StatusBarOperations/MoveStatusItemOperation.cs +++ b/src/Operations/StatusBarOperations/MoveStatusItemOperation.cs @@ -4,7 +4,7 @@ namespace TerminalGuiDesigner.Operations.StatusBarOperations { /// <summary> - /// Moves a <see cref="StatusItem"/> on a <see cref="StatusBar"/> left or right. + /// Moves a <see cref="Shortcut"/> on a <see cref="StatusBar"/> left or right. /// </summary> public class MoveStatusItemOperation : MoveOperation<StatusBar, Shortcut> { diff --git a/src/Operations/StatusBarOperations/RemoveStatusItemOperation.cs b/src/Operations/StatusBarOperations/RemoveStatusItemOperation.cs index 5f0cc8ed..25f59f54 100644 --- a/src/Operations/StatusBarOperations/RemoveStatusItemOperation.cs +++ b/src/Operations/StatusBarOperations/RemoveStatusItemOperation.cs @@ -5,7 +5,7 @@ namespace TerminalGuiDesigner.Operations.StatusBarOperations { /// <summary> - /// Removes a <see cref="StatusItem"/> from a <see cref="StatusBar"/>. + /// Removes a <see cref="Shortcut"/> from a <see cref="StatusBar"/>. /// </summary> public class RemoveStatusItemOperation : RemoveOperation<StatusBar, Shortcut> { @@ -13,7 +13,7 @@ public class RemoveStatusItemOperation : RemoveOperation<StatusBar, Shortcut> /// Initializes a new instance of the <see cref="RemoveStatusItemOperation"/> class. /// </summary> /// <param name="design">Wrapper for a <see cref="StatusBar"/>.</param> - /// <param name="toRemove">A <see cref="StatusItem"/> to remove from bar.</param> + /// <param name="toRemove">A <see cref="Shortcut"/> to remove from bar.</param> public RemoveStatusItemOperation(Design design, Shortcut toRemove) : base( (v) => v.GetShortcuts(), diff --git a/src/Operations/StatusBarOperations/RenameStatusItemOperation.cs b/src/Operations/StatusBarOperations/RenameStatusItemOperation.cs index f32eee92..fd83e73b 100644 --- a/src/Operations/StatusBarOperations/RenameStatusItemOperation.cs +++ b/src/Operations/StatusBarOperations/RenameStatusItemOperation.cs @@ -5,7 +5,7 @@ namespace TerminalGuiDesigner.Operations.StatusBarOperations { /// <summary> - /// Renames a <see cref="StatusItem"/> on a <see cref="StatusBar"/>. + /// Renames a <see cref="Shortcut"/> on a <see cref="StatusBar"/>. /// </summary> public class RenameStatusItemOperation : RenameOperation<StatusBar, Shortcut> { @@ -13,7 +13,7 @@ public class RenameStatusItemOperation : RenameOperation<StatusBar, Shortcut> /// Initializes a new instance of the <see cref="RenameStatusItemOperation"/> class. /// </summary> /// <param name="design">Design wrapper for a <see cref="StatusBar"/>.</param> - /// <param name="toRename">The <see cref="StatusItem"/> to rename.</param> + /// <param name="toRename">The <see cref="Shortcut"/> to rename.</param> /// <param name="newName">The new name to use or null to prompt user.</param> public RenameStatusItemOperation(Design design, Shortcut toRename, string? newName) : base( diff --git a/src/Operations/StatusBarOperations/SetShortcutOperation.cs b/src/Operations/StatusBarOperations/SetShortcutOperation.cs index d4dc737f..bfc589a4 100644 --- a/src/Operations/StatusBarOperations/SetShortcutOperation.cs +++ b/src/Operations/StatusBarOperations/SetShortcutOperation.cs @@ -5,7 +5,7 @@ namespace TerminalGuiDesigner.Operations.StatusBarOperations { /// <summary> - /// Changes the <see cref="StatusItem.Shortcut"/> of a <see cref="StatusItem"/> on + /// Changes the <see cref="Shortcut"/> of a <see cref="Shortcut"/> on /// a <see cref="StatusBar"/>. /// </summary> public class SetShortcutOperation : GenericArrayElementOperation<StatusBar, Shortcut> @@ -17,7 +17,7 @@ public class SetShortcutOperation : GenericArrayElementOperation<StatusBar, Shor /// Initializes a new instance of the <see cref="SetShortcutOperation"/> class. /// </summary> /// <param name="design">Wrapper for a <see cref="StatusBar"/>.</param> - /// <param name="statusItem">The <see cref="StatusItem"/> whose shortcut you want to change.</param> + /// <param name="statusItem">The <see cref="Shortcut"/> whose shortcut you want to change.</param> /// <param name="shortcut">The new shortcut or null to prompt user at runtime.</param> public SetShortcutOperation(Design design, Shortcut statusItem, Key? shortcut) : base( diff --git a/src/Operations/TabOperations/RenameTabOperation.cs b/src/Operations/TabOperations/RenameTabOperation.cs index 461604d8..c40177cf 100644 --- a/src/Operations/TabOperations/RenameTabOperation.cs +++ b/src/Operations/TabOperations/RenameTabOperation.cs @@ -4,14 +4,14 @@ namespace TerminalGuiDesigner.Operations.TabOperations; /// <summary> -/// Renames the <see cref="Tab.Text"/> of the currently selected +/// Renames the <see cref="Tab.DisplayText"/> of the currently selected /// <see cref="Tab"/> of a <see cref="TabView"/>. /// </summary> public class RenameTabOperation : RenameOperation<TabView, Tab> { /// <summary> /// Initializes a new instance of the <see cref="RenameTabOperation"/> class. - /// This command changes the <see cref="Tab.Text"/> on a <see cref="TabView"/>. + /// This command changes the <see cref="Tab.DisplayText"/> on a <see cref="TabView"/>. /// </summary> /// <param name="design">Wrapper for a <see cref="TabView"/>.</param> /// <param name="toRename">Tab to rename.</param> diff --git a/src/PosExtensions.cs b/src/PosExtensions.cs index 853d2835..87e6d0da 100644 --- a/src/PosExtensions.cs +++ b/src/PosExtensions.cs @@ -196,7 +196,9 @@ public static bool IsRelative(this Pos? p, IList<Design> knownDesigns, [NotNullW } - /// <inheritdoc cref="IsCombine(Pos)"/> + /// <summary> + ///Returns true if the <see cref="Pos"/> is a summation or subtraction of two other <see cref="Pos"/> + /// </summary> /// <param name="p"><see cref="Pos"/> to classify.</param> /// <param name="left">The left hand operand of the summation/subtraction.</param> /// <param name="right">The right hand operand of the summation/subtraction.</param> diff --git a/src/StatusBarExtensions.cs b/src/StatusBarExtensions.cs index 3a34d90f..f5c3981c 100644 --- a/src/StatusBarExtensions.cs +++ b/src/StatusBarExtensions.cs @@ -9,11 +9,11 @@ namespace TerminalGuiDesigner; public static class StatusBarExtensions { /// <summary> - /// Returns the <see cref="StatusItem"/> that appears at the <paramref name="screenX"/> of the click. + /// Returns the <see cref="Shortcut"/> that appears at the <paramref name="screenX"/> of the click. /// </summary> /// <param name="statusBar"><see cref="StatusBar"/> you want to find the clicked <see cref="MenuBarItem"/> (top level menu) for.</param> /// <param name="screenX">Screen coordinate of the click in X.</param> - /// <returns>The <see cref="StatusItem"/> under the mouse at this position or null (only considers X).</returns> + /// <returns>The <see cref="Shortcut"/> under the mouse at this position or null (only considers X).</returns> public static Shortcut? ScreenToMenuBarItem(this StatusBar statusBar, int screenX) { // These might be changed in Terminal.Gui library diff --git a/src/ToCode/StatusBarItemsToCode.cs b/src/ToCode/StatusBarItemsToCode.cs index 750b3de5..2103d2ed 100644 --- a/src/ToCode/StatusBarItemsToCode.cs +++ b/src/ToCode/StatusBarItemsToCode.cs @@ -4,7 +4,7 @@ namespace TerminalGuiDesigner.ToCode; /// <summary> -/// Handles generating all <see cref="StatusItem"/> that are stored a the <see cref="StatusBar"/>. +/// Handles generating all <see cref="Shortcut"/> that are stored a the <see cref="StatusBar"/>. /// </summary> public class StatusBarItemsToCode : ToCodeBase { @@ -28,7 +28,7 @@ public StatusBarItemsToCode(Design design) } /// <summary> - /// Adds code to .Designer.cs to construct and initialize all <see cref="StatusItem"/> + /// Adds code to .Designer.cs to construct and initialize all <see cref="Shortcut"/> /// in the <see cref="StatusBar"/>. /// </summary> /// <param name="args">State object for the .Designer.cs file being generated.</param> diff --git a/src/UI/Editor.cs b/src/UI/Editor.cs index 242fc6fc..28399d8e 100644 --- a/src/UI/Editor.cs +++ b/src/UI/Editor.cs @@ -112,8 +112,8 @@ static ILogger CreateLogger() /// <summary> /// Gets or Sets a value indicating whether <see cref="View"/> that do not have borders - /// (e.g. <see cref="ScrollView"/>) should have a dotted line rendered around them so - /// users don't lose track of where they are on a same-colored background. + /// should have a dotted line rendered around them so users don't lose track of where + /// they are on a same-colored background. /// </summary> // BUG: Thread-safety public static bool ShowBorders { get; set; } = true; diff --git a/src/ViewExtensions.cs b/src/ViewExtensions.cs index 3e79d115..c59f2368 100644 --- a/src/ViewExtensions.cs +++ b/src/ViewExtensions.cs @@ -476,7 +476,7 @@ public static bool AnySuperViewIs<T>(this View v) where T : View /// <summary> /// Returns the <see cref="Adornment.Parent"/> of <paramref name="v"/> - /// if it is an <see cref="Adornment"/>. Or if <param name="v"/> is not + /// if it is an <see cref="Adornment"/>. Or if <paramref name="v"/> is not /// directly an adornment but <see cref="AnySuperViewIs{T}"/> then the method /// will traverse up <see cref="View.SuperView"/> hierarchy until parent is found. /// </summary> From 6e89a471174b1b1510e204526faf59bc70231998 Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Sun, 9 Mar 2025 10:08:21 +0000 Subject: [PATCH 36/54] xml docs and typo --- src/ArrayExtensions.cs | 6 ++++++ src/Operations/IOperation.cs | 2 +- src/Operations/Operation.cs | 9 +++++++-- src/StatusBarExtensions.cs | 12 ++++++++++++ src/ToCode/EnumToCode.cs | 15 ++++++++++++++- src/ToCode/InstanceOfProperty.cs | 17 +++++++++++++++-- src/UI/KeyMap.cs | 3 +-- src/UI/KeyboardManager.cs | 2 +- src/UI/MouseManager.cs | 2 +- src/UI/ValueFactory.cs | 2 +- src/ViewExtensions.cs | 3 ++- 11 files changed, 61 insertions(+), 12 deletions(-) diff --git a/src/ArrayExtensions.cs b/src/ArrayExtensions.cs index 9b8cea42..ca21ed6a 100644 --- a/src/ArrayExtensions.cs +++ b/src/ArrayExtensions.cs @@ -31,6 +31,12 @@ public static class ArrayExtensions return toReturn; } + /// <summary> + /// Converts an enumerable to a <see cref="IListDataSource"/> + /// </summary> + /// <param name="enumerable"></param> + /// <returns></returns> + /// <exception cref="Exception"></exception> public static IListDataSource ToListDataSource(this IEnumerable enumerable) { // Get the type of the elements diff --git a/src/Operations/IOperation.cs b/src/Operations/IOperation.cs index 1f9822da..18aad942 100644 --- a/src/Operations/IOperation.cs +++ b/src/Operations/IOperation.cs @@ -33,7 +33,7 @@ public interface IOperation /// <summary> /// Gets the number of times this <see cref="IOperation"/> has been executed successfully /// </summary> - ref int TimesDone { get; } + int TimesDone { get; } /// <summary> /// Performs the operation. diff --git a/src/Operations/Operation.cs b/src/Operations/Operation.cs index 182a711a..019861ab 100644 --- a/src/Operations/Operation.cs +++ b/src/Operations/Operation.cs @@ -8,7 +8,10 @@ namespace TerminalGuiDesigner.Operations; /// </summary> public abstract class Operation : IOperation { - protected int _timesDone; + /// <summary> + /// The number of times the operation has been performed. + /// </summary> + private int _timesDone; /// <summary> /// The name to give to all objects which do not have a title/text etc. @@ -23,7 +26,7 @@ public abstract class Operation : IOperation public bool SupportsUndo { get; protected set; } = true; /// <inheritdoc /> - public ref int TimesDone => ref _timesDone; + public int TimesDone => _timesDone; /// <inheritdoc/> /// <remarks>Defaults to <see cref="Guid.NewGuid"/>.</remarks> @@ -66,6 +69,7 @@ public void Undo() UndoImpl(); } + /// <inheritdoc cref="Undo"/> protected abstract void UndoImpl(); /// <inheritdoc/> @@ -75,6 +79,7 @@ public void Redo() RedoImpl(); } + /// <inheritdoc cref="Redo"/> protected abstract void RedoImpl(); /// <inheritdoc cref="IOperation.Do"/> diff --git a/src/StatusBarExtensions.cs b/src/StatusBarExtensions.cs index f5c3981c..348a5d98 100644 --- a/src/StatusBarExtensions.cs +++ b/src/StatusBarExtensions.cs @@ -68,11 +68,23 @@ public static int CountShortcuts(this StatusBar bar) return bar.Subviews.OfType<Shortcut>().Count(); } + /// <summary> + /// Returns the items on the <see cref="StatusBar"/> (previously + /// called StatusBarItems now called just <see cref="Shortcut"/>) + /// </summary> + /// <param name="bar"></param> + /// <returns></returns> public static Shortcut[] GetShortcuts(this StatusBar bar) { return bar.Subviews.OfType<Shortcut>().ToArray(); } + /// <summary> + /// Replaces all items on the <paramref name="bar"/> with the new + /// <paramref name="shortcuts"/>. + /// </summary> + /// <param name="bar"></param> + /// <param name="shortcuts"></param> public static void SetShortcuts(this StatusBar bar, Shortcut[] shortcuts) { foreach(var old in bar.GetShortcuts()) diff --git a/src/ToCode/EnumToCode.cs b/src/ToCode/EnumToCode.cs index 0e62dad2..594fb07b 100644 --- a/src/ToCode/EnumToCode.cs +++ b/src/ToCode/EnumToCode.cs @@ -2,18 +2,31 @@ namespace TerminalGuiDesigner.ToCode; +/// <summary> +/// Code generation methods for writing out enum values +/// using CodeDom. +/// </summary> public class EnumToCode : ToCodeBase { private readonly Enum value; private readonly Type enumType; - + /// <summary> + /// Creates a new instance of the class, primed to generate code + /// for the supplied <paramref name="value"/> + /// </summary> + /// <param name="value"></param> public EnumToCode(Enum value) { this.value = value; this.enumType = value.GetType(); } + /// <summary> + /// <para>Returns code expression similar to <c>MyEnum.SomeValue</c>.</para> + /// <para>Supports Flags enums e.g. generating things like <c>MyEnum.ValA | MyEnum.ValB</c></para> + /// </summary> + /// <returns></returns> public CodeExpression ToCode() { var isFlags = enumType.IsDefined(typeof(FlagsAttribute), false); diff --git a/src/ToCode/InstanceOfProperty.cs b/src/ToCode/InstanceOfProperty.cs index f161f666..51628a94 100644 --- a/src/ToCode/InstanceOfProperty.cs +++ b/src/ToCode/InstanceOfProperty.cs @@ -11,12 +11,25 @@ namespace TerminalGuiDesigner.ToCode; /// </summary> public class InstanceOfProperty : Property { - public Type MustBeDerrivedFrom { get; } + /// <summary> + /// Places a restriction on the <see cref="Property.SetValue"/> that + /// can be supplied. When setting the value must be a class derrived + /// from this <see cref="Type"/>. + /// </summary> + public Type MustBeDerivedFrom { get; } + /// <summary> + /// Creates a new instance of designable property <paramref name="property"/>. + /// In which values set <see cref="MustBeDerivedFrom"/> the supplied + /// <see cref="PropertyInfo.PropertyType"/> + /// </summary> + /// <param name="design"></param> + /// <param name="property"></param> + /// <exception cref="Exception"></exception> public InstanceOfProperty(Design design, PropertyInfo property) : base(design, property) { - this.MustBeDerrivedFrom = property.PropertyType + this.MustBeDerivedFrom = property.PropertyType ?? throw new Exception("Unable to determine property type"); } diff --git a/src/UI/KeyMap.cs b/src/UI/KeyMap.cs index cde84c07..65958ffa 100644 --- a/src/UI/KeyMap.cs +++ b/src/UI/KeyMap.cs @@ -176,8 +176,7 @@ public KeyMap( ) public string ToggleDragging { get; init; } = ToggleDragging; /// <summary> - /// Gets the string to toggle showing dotted borders around views that otherwise do not have visible borders (e.g. - /// <see cref="ScrollView" />). + /// Gets the string to toggle showing dotted borders around views that otherwise do not have visible borders. /// </summary> public string ToggleShowBorders { get; init; } = ToggleShowBorders; diff --git a/src/UI/KeyboardManager.cs b/src/UI/KeyboardManager.cs index 6a6db234..058dfa32 100644 --- a/src/UI/KeyboardManager.cs +++ b/src/UI/KeyboardManager.cs @@ -30,7 +30,7 @@ public KeyboardManager(KeyMap keyMap) /// to the rest of the regular Terminal.Gui API layer. /// </summary> /// <param name="focusedView">The <see cref="View"/> that currently holds focus in <see cref="Editor"/>.</param> - /// <param name="keystroke">The key that has been reported by <see cref="Application.RootKey"/>.</param> + /// <param name="keystroke">The key that has been reported by <see cref="Application.KeyDown"/>.</param> /// <returns><see langword="true"/> if <paramref name="keystroke"/> should be suppressed.</returns> public bool HandleKey(View focusedView, Key keystroke) { diff --git a/src/UI/MouseManager.cs b/src/UI/MouseManager.cs index d17e6494..86740eca 100644 --- a/src/UI/MouseManager.cs +++ b/src/UI/MouseManager.cs @@ -34,7 +34,7 @@ public class MouseManager /// Responds to <see cref="Application.MouseEvent"/>(by changing a 'drag a box' selection area /// or starting a resize etc). /// </summary> - /// <param name="m">The <see cref="MouseEventArgs"/> reported by <see cref="Application.RootMouseEvent"/>.</param> + /// <param name="m">The <see cref="MouseEventArgs"/> reported by <see cref="Application.MouseEvent"/>.</param> /// <param name="viewBeingEdited">The root <see cref="Design"/> that is open in the <see cref="Editor"/>.</param> public void HandleMouse(MouseEventArgs m, Design viewBeingEdited) { diff --git a/src/UI/ValueFactory.cs b/src/UI/ValueFactory.cs index 9f8cc00e..5626abca 100644 --- a/src/UI/ValueFactory.cs +++ b/src/UI/ValueFactory.cs @@ -246,7 +246,7 @@ internal static bool GetNewValue(Design design, Property property, object? oldVa if (Modals.Get<Type>( property.PropertyInfo.Name, "New Value", - typeof(Label).Assembly.GetTypes().Where(inst.MustBeDerrivedFrom.IsAssignableFrom).ToArray(), + typeof(Label).Assembly.GetTypes().Where(inst.MustBeDerivedFrom.IsAssignableFrom).ToArray(), inst.GetValue()?.GetType(), out Type? typeChosen)) { diff --git a/src/ViewExtensions.cs b/src/ViewExtensions.cs index c59f2368..61e13f3b 100644 --- a/src/ViewExtensions.cs +++ b/src/ViewExtensions.cs @@ -303,7 +303,7 @@ public static bool IsBorderlessContainerView(this View v) /// <summary> /// <para> - /// Sometimes <see cref="View.FindDeepestView"/> returns what the library considers + /// Sometimes <see cref="View.GetViewsUnderMouse"/> returns what the library considers /// the clicked View rather than what the user would expect. For example clicking in /// the <see cref="Border"/> area of a <see cref="View"/>. /// </para> @@ -313,6 +313,7 @@ public static bool IsBorderlessContainerView(this View v) /// <returns></returns> public static View? UnpackHitView(this View? hit) { + if (hit != null && hit.GetType().Name.Equals("TabRowView")) { hit = hit.SuperView; From 05fb4466edeed8264758a14ad876dfdccc434020 Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Sun, 9 Mar 2025 11:06:37 +0000 Subject: [PATCH 37/54] xmldoc and nrt warnings --- src/ArrayExtensions.cs | 3 ++- src/ToCode/InstanceOfProperty.cs | 1 + src/ToCode/Property.cs | 6 +++--- src/TypeExtensions.cs | 15 +++++++++++++++ src/UI/Windows/ArrayEditor.cs | 8 +++++++- 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/ArrayExtensions.cs b/src/ArrayExtensions.cs index ca21ed6a..799afc4d 100644 --- a/src/ArrayExtensions.cs +++ b/src/ArrayExtensions.cs @@ -52,7 +52,8 @@ public static IListDataSource ToListDataSource(this IEnumerable enumerable) // Create an instance of ListWrapper<T> var listWrapperType = typeof(ListWrapper<>).MakeGenericType(elementType); - return (IListDataSource)Activator.CreateInstance(listWrapperType, list); + return (IListDataSource)(Activator.CreateInstance(listWrapperType, list) + ?? throw new Exception("CreateInstance inexplicably returned null")); } } diff --git a/src/ToCode/InstanceOfProperty.cs b/src/ToCode/InstanceOfProperty.cs index 51628a94..366105e3 100644 --- a/src/ToCode/InstanceOfProperty.cs +++ b/src/ToCode/InstanceOfProperty.cs @@ -33,6 +33,7 @@ public InstanceOfProperty(Design design, PropertyInfo property) ?? throw new Exception("Unable to determine property type"); } + /// <inheritdoc/> public override CodeExpression GetRhs() { var instance = this.GetValue(); diff --git a/src/ToCode/Property.cs b/src/ToCode/Property.cs index 80051d7e..97c04e52 100644 --- a/src/ToCode/Property.cs +++ b/src/ToCode/Property.cs @@ -310,9 +310,9 @@ private CodeExpression ValueFactory(object val) if (type.GetGenericTypeDefinition() == typeof(SliderOption<>)) { // TODO: this feels very brittle! - var a1 = type.GetProperty(nameof(SliderOption<object>.Legend)).GetValue(val); - var a2 = (Rune)type.GetProperty(nameof(SliderOption<object>.LegendAbbr)).GetValue(val); - var a3 = type.GetProperty(nameof(SliderOption<object>.Data)).GetValue(val); + var a1 = type.GetPropertyOrThrow(nameof(SliderOption<object>.Legend)).GetValue(val); + var a2 = (Rune)type.GetPropertyOrThrow(nameof(SliderOption<object>.LegendAbbr)).GetValue(val)!; + var a3 = type.GetPropertyOrThrow(nameof(SliderOption<object>.Data)).GetValue(val); return new CodeObjectCreateExpression( diff --git a/src/TypeExtensions.cs b/src/TypeExtensions.cs index 53f0bb40..e918741f 100644 --- a/src/TypeExtensions.cs +++ b/src/TypeExtensions.cs @@ -1,5 +1,7 @@ using System; using System.Collections; +using System.Reflection; +using Terminal.Gui; namespace TerminalGuiDesigner { @@ -47,5 +49,18 @@ public static bool IsGenericType(this Type type, Type genericParentHypothesis) { return type.IsGenericType && type.GetGenericTypeDefinition() == genericParentHypothesis; } + + /// <summary> + /// Returns the <see cref="Type.GetProperty(string)"/> of the given <paramref name="name"/> + /// or throws an <see cref="Exception"/>. + /// </summary> + /// <param name="type"></param> + /// <param name="name"></param> + /// <returns></returns> + /// <exception cref="Exception"></exception> + public static PropertyInfo GetPropertyOrThrow(this Type type, string name) + { + return type.GetProperty(name) ?? throw new Exception($"Could not find expected property {name} on type {type}"); + } } } diff --git a/src/UI/Windows/ArrayEditor.cs b/src/UI/Windows/ArrayEditor.cs index e6012de9..f0945e9e 100644 --- a/src/UI/Windows/ArrayEditor.cs +++ b/src/UI/Windows/ArrayEditor.cs @@ -16,6 +16,9 @@ namespace TerminalGuiDesigner.UI.Windows { using Terminal.Gui; using TerminalGuiDesigner.ToCode; + /// <summary> + /// UI for configuring array elements + /// </summary> public partial class ArrayEditor : IValueGetterDialog { /// <summary> @@ -29,8 +32,11 @@ public partial class ArrayEditor : IValueGetterDialog { /// <summary> /// The new array /// </summary> - [CanBeNull] public object Result => ResultAsList; + + /// <summary> + /// Returns the <see cref="Array"/> being designed as an <see cref="IList"/> + /// </summary> public IList ResultAsList { get; private set; } From fbdefd3b33266b21f0bccb146eb22ef970b3acbc Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Sun, 9 Mar 2025 11:24:06 +0000 Subject: [PATCH 38/54] Fix UI layouts now they are all bigger from shadow buttons --- src/UI/Windows/ColorPicker.Designer.cs | 26 +- src/UI/Windows/ColorSchemeEditor.Designer.cs | 748 +++++++++++-------- src/UI/Windows/ColorSchemeEditor.cs | 21 +- src/UI/Windows/DimEditor.Designer.cs | 24 +- src/UI/Windows/LoadingDialog.Designer.cs | 77 +- src/UI/Windows/MutableColorScheme.cs | 29 + src/UI/Windows/PointEditor.Designer.cs | 212 +++--- src/UI/Windows/PosEditor.Designer.cs | 371 +++++---- src/UI/Windows/SizeEditor.Designer.cs | 201 ++--- 9 files changed, 1010 insertions(+), 699 deletions(-) create mode 100644 src/UI/Windows/MutableColorScheme.cs diff --git a/src/UI/Windows/ColorPicker.Designer.cs b/src/UI/Windows/ColorPicker.Designer.cs index ba15c3bc..12a7f890 100644 --- a/src/UI/Windows/ColorPicker.Designer.cs +++ b/src/UI/Windows/ColorPicker.Designer.cs @@ -19,6 +19,10 @@ namespace TerminalGuiDesigner.UI.Windows { public partial class ColorPicker : Terminal.Gui.Dialog { + private Terminal.Gui.ColorScheme dialogBackground; + + private Terminal.Gui.ColorScheme buttons; + private Terminal.Gui.Label lblForeground; private Terminal.Gui.ColorPicker cpForeground; @@ -44,12 +48,16 @@ private void InitializeComponent() { this.lblBackground = new Terminal.Gui.Label(); this.cpForeground = new Terminal.Gui.ColorPicker(); this.lblForeground = new Terminal.Gui.Label(); + this.dialogBackground = new Terminal.Gui.ColorScheme(new Terminal.Gui.Attribute(4294967295u, 4285953654u), new Terminal.Gui.Attribute(4294967295u, 4285953654u), new Terminal.Gui.Attribute(4294967295u, 4285953654u), new Terminal.Gui.Attribute(4278190080u, 4278190080u), new Terminal.Gui.Attribute(4294967295u, 4285953654u)); + this.buttons = new Terminal.Gui.ColorScheme(new Terminal.Gui.Attribute(4285953654u, 4294967295u), new Terminal.Gui.Attribute(4294901760u, 4294967040u), new Terminal.Gui.Attribute(4278190080u, 4294967295u), new Terminal.Gui.Attribute(4278190080u, 4278190080u), new Terminal.Gui.Attribute(4278190080u, 4294967040u)); this.Width = Dim.Fill(2); - this.Height = 17; + this.Height = 19; this.X = Pos.Center(); this.Y = Pos.Center(); this.Visible = true; this.Arrangement = Terminal.Gui.ViewArrangement.Movable; + this.CanFocus = true; + this.ShadowStyle = Terminal.Gui.ShadowStyle.Transparent; this.Modal = true; this.TextAlignment = Terminal.Gui.Alignment.Start; this.Title = "Color Picker"; @@ -59,6 +67,8 @@ private void InitializeComponent() { this.lblForeground.Y = 0; this.lblForeground.Visible = true; this.lblForeground.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblForeground.CanFocus = false; + this.lblForeground.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.lblForeground.Data = "lblForeground"; this.lblForeground.Text = "Foreground:"; this.lblForeground.TextAlignment = Terminal.Gui.Alignment.Start; @@ -69,6 +79,8 @@ private void InitializeComponent() { this.cpForeground.Y = 1; this.cpForeground.Visible = true; this.cpForeground.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.cpForeground.CanFocus = true; + this.cpForeground.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.cpForeground.Data = "cpForeground"; this.cpForeground.Text = ""; this.cpForeground.TextAlignment = Terminal.Gui.Alignment.Start; @@ -83,6 +95,8 @@ private void InitializeComponent() { this.lblBackground.Y = 6; this.lblBackground.Visible = true; this.lblBackground.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblBackground.CanFocus = false; + this.lblBackground.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.lblBackground.Data = "lblBackground"; this.lblBackground.Text = "Background:"; this.lblBackground.TextAlignment = Terminal.Gui.Alignment.Start; @@ -93,6 +107,8 @@ private void InitializeComponent() { this.cpBackground.Y = 7; this.cpBackground.Visible = true; this.cpBackground.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.cpBackground.CanFocus = true; + this.cpBackground.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.cpBackground.Data = "cpBackground"; this.cpBackground.Text = ""; this.cpBackground.TextAlignment = Terminal.Gui.Alignment.Start; @@ -107,6 +123,8 @@ private void InitializeComponent() { this.lblResult.Y = 12; this.lblResult.Visible = true; this.lblResult.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblResult.CanFocus = false; + this.lblResult.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.lblResult.Data = "lblResult"; this.lblResult.Text = "Preview:"; this.lblResult.TextAlignment = Terminal.Gui.Alignment.Start; @@ -117,6 +135,8 @@ private void InitializeComponent() { this.lblPreview.Y = 13; this.lblPreview.Visible = true; this.lblPreview.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblPreview.CanFocus = false; + this.lblPreview.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.lblPreview.Data = "lblPreview"; this.lblPreview.Text = "\"Sample Text\""; this.lblPreview.TextAlignment = Terminal.Gui.Alignment.Center; @@ -127,6 +147,8 @@ private void InitializeComponent() { this.btnOk.Y = 14; this.btnOk.Visible = true; this.btnOk.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnOk.CanFocus = true; + this.btnOk.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; this.btnOk.Data = "btnOk"; this.btnOk.Text = "Ok"; this.btnOk.TextAlignment = Terminal.Gui.Alignment.Center; @@ -138,6 +160,8 @@ private void InitializeComponent() { this.btnCancel.Y = 14; this.btnCancel.Visible = true; this.btnCancel.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnCancel.CanFocus = true; + this.btnCancel.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; this.btnCancel.Data = "btnCancel"; this.btnCancel.Text = "Cancel"; this.btnCancel.TextAlignment = Terminal.Gui.Alignment.Center; diff --git a/src/UI/Windows/ColorSchemeEditor.Designer.cs b/src/UI/Windows/ColorSchemeEditor.Designer.cs index 30cf4fc4..deb5b3a2 100644 --- a/src/UI/Windows/ColorSchemeEditor.Designer.cs +++ b/src/UI/Windows/ColorSchemeEditor.Designer.cs @@ -3,324 +3,446 @@ // <auto-generated> // This code was generated by: -// TerminalGuiDesigner v1.0.18.0 +// TerminalGuiDesigner v2.0.0.0 // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> // ----------------------------------------------------------------------------- -namespace TerminalGuiDesigner.UI.Windows; -using System; -using Terminal.Gui; - - -public partial class ColorSchemeEditor : Terminal.Gui.Dialog { - - private Terminal.Gui.Label label2; - - private Terminal.Gui.Label lblForegroundNormal; - - private Terminal.Gui.Label label1; - - private Terminal.Gui.Label lblBackgroundNormal; - - private Terminal.Gui.Button btnEditNormal; - - private Terminal.Gui.Label label22; - - private Terminal.Gui.Label lblForegroundHotNormal; - - private Terminal.Gui.Label lblHotNormalSlash; - - private Terminal.Gui.Label lblBackgroundHotNormal; - - private Terminal.Gui.Button btnEditHotNormal; - - private Terminal.Gui.Label lblFocus; - - private Terminal.Gui.Label lblForegroundFocus; - - private Terminal.Gui.Label lblHotNormalSlash2; - - private Terminal.Gui.Label lblBackgroundFocus; - - private Terminal.Gui.Button btnEditFocus; - - private Terminal.Gui.Label label223; - - private Terminal.Gui.Label lblForegroundHotFocus; - - private Terminal.Gui.Label lblHotNormalSlash3; - - private Terminal.Gui.Label lblBackgroundHotFocus; - - private Terminal.Gui.Button btnEditHotFocus; - - private Terminal.Gui.Label label2232; - - private Terminal.Gui.Label lblForegroundDisabled; - - private Terminal.Gui.Label lblHotNormalSlash32; - - private Terminal.Gui.Label lblBackgroundDisabled; - - private Terminal.Gui.Button btnEditDisabled; - - private Terminal.Gui.Button btnOk; +namespace TerminalGuiDesigner.UI.Windows { + using System; + using Terminal.Gui; + using System.Collections; + using System.Collections.Generic; + using System.Collections.ObjectModel; + using System.Drawing; - private Terminal.Gui.Button btnCancel; - private void InitializeComponent() { - this.btnCancel = new Terminal.Gui.Button(); - this.btnOk = new Terminal.Gui.Button(); - this.btnEditDisabled = new Terminal.Gui.Button(); - this.lblBackgroundDisabled = new Terminal.Gui.Label(); - this.lblHotNormalSlash32 = new Terminal.Gui.Label(); - this.lblForegroundDisabled = new Terminal.Gui.Label(); - this.label2232 = new Terminal.Gui.Label(); - this.btnEditHotFocus = new Terminal.Gui.Button(); - this.lblBackgroundHotFocus = new Terminal.Gui.Label(); - this.lblHotNormalSlash3 = new Terminal.Gui.Label(); - this.lblForegroundHotFocus = new Terminal.Gui.Label(); - this.label223 = new Terminal.Gui.Label(); - this.btnEditFocus = new Terminal.Gui.Button(); - this.lblBackgroundFocus = new Terminal.Gui.Label(); - this.lblHotNormalSlash2 = new Terminal.Gui.Label(); - this.lblForegroundFocus = new Terminal.Gui.Label(); - this.lblFocus = new Terminal.Gui.Label(); - this.btnEditHotNormal = new Terminal.Gui.Button(); - this.lblBackgroundHotNormal = new Terminal.Gui.Label(); - this.lblHotNormalSlash = new Terminal.Gui.Label(); - this.lblForegroundHotNormal = new Terminal.Gui.Label(); - this.label22 = new Terminal.Gui.Label(); - this.btnEditNormal = new Terminal.Gui.Button(); - this.lblBackgroundNormal = new Terminal.Gui.Label(); - this.label1 = new Terminal.Gui.Label(); - this.lblForegroundNormal = new Terminal.Gui.Label(); - this.label2 = new Terminal.Gui.Label(); - this.Width = 31; - this.Height = 9; - this.X = Pos.Center(); - this.Y = Pos.Center(); - this.Modal = true; - this.Text = ""; - this.Border.BorderStyle = Terminal.Gui.LineStyle.Single; - this.TextAlignment = Terminal.Gui.Alignment.Start; - this.Title = "Color Scheme Editor"; - this.label2.Width = 10; - this.label2.Height = 1; - this.label2.X = 1; - this.label2.Y = 0; - this.label2.Data = "label2"; - this.label2.Text = "Normal :"; - this.label2.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.label2); - this.lblForegroundNormal.Width = 1; - this.lblForegroundNormal.Height = 1; - this.lblForegroundNormal.X = Pos.Right(label2) + 1; - this.lblForegroundNormal.Y = 0; - this.lblForegroundNormal.Data = "lblForegroundNormal"; - this.lblForegroundNormal.Text = " "; - this.lblForegroundNormal.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.lblForegroundNormal); - this.label1.Width = 1; - this.label1.Height = 1; - this.label1.X = 13; - this.label1.Y = 0; - this.label1.Data = "label1"; - this.label1.Text = "\\"; - this.label1.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.label1); - this.lblBackgroundNormal.Width = 1; - this.lblBackgroundNormal.Height = 1; - this.lblBackgroundNormal.X = Pos.Right(label2) + 3; - this.lblBackgroundNormal.Y = 0; - this.lblBackgroundNormal.Data = "lblBackgroundNormal"; - this.lblBackgroundNormal.Text = " "; - this.lblBackgroundNormal.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.lblBackgroundNormal); - this.btnEditNormal.Width = 13; - this.btnEditNormal.X = 15; - this.btnEditNormal.Y = 0; - this.btnEditNormal.Data = "btnEditNormal"; - this.btnEditNormal.Text = "Choose..."; - this.btnEditNormal.TextAlignment = Terminal.Gui.Alignment.Center; - this.btnEditNormal.IsDefault = false; - this.Add(this.btnEditNormal); - this.label22.Width = 10; - this.label22.Height = 1; - this.label22.X = 1; - this.label22.Y = 1; - this.label22.Data = "label22"; - this.label22.Text = "HotNormal:"; - this.label22.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.label22); - this.lblForegroundHotNormal.Width = 1; - this.lblForegroundHotNormal.Height = 1; - this.lblForegroundHotNormal.X = Pos.Right(label22) + 1; - this.lblForegroundHotNormal.Y = 1; - this.lblForegroundHotNormal.Data = "lblForegroundHotNormal"; - this.lblForegroundHotNormal.Text = " "; - this.lblForegroundHotNormal.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.lblForegroundHotNormal); - this.lblHotNormalSlash.Width = 1; - this.lblHotNormalSlash.Height = 1; - this.lblHotNormalSlash.X = 13; - this.lblHotNormalSlash.Y = 1; - this.lblHotNormalSlash.Data = "lblHotNormalSlash"; - this.lblHotNormalSlash.Text = "\\"; - this.lblHotNormalSlash.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.lblHotNormalSlash); - this.lblBackgroundHotNormal.Width = 1; - this.lblBackgroundHotNormal.Height = 1; - this.lblBackgroundHotNormal.X = Pos.Right(label22) + 3; - this.lblBackgroundHotNormal.Y = 1; - this.lblBackgroundHotNormal.Data = "lblBackgroundHotNormal"; - this.lblBackgroundHotNormal.Text = " "; - this.lblBackgroundHotNormal.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.lblBackgroundHotNormal); - this.btnEditHotNormal.Width = 13; - this.btnEditHotNormal.X = 15; - this.btnEditHotNormal.Y = 1; - this.btnEditHotNormal.Data = "btnEditHotNormal"; - this.btnEditHotNormal.Text = "Choose..."; - this.btnEditHotNormal.TextAlignment = Terminal.Gui.Alignment.Center; - this.btnEditHotNormal.IsDefault = false; - this.Add(this.btnEditHotNormal); - this.lblFocus.Width = 10; - this.lblFocus.Height = 1; - this.lblFocus.X = 1; - this.lblFocus.Y = 2; - this.lblFocus.Data = "lblFocus"; - this.lblFocus.Text = "Focus :"; - this.lblFocus.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.lblFocus); - this.lblForegroundFocus.Width = 1; - this.lblForegroundFocus.Height = 1; - this.lblForegroundFocus.X = Pos.Right(lblFocus) + 1; - this.lblForegroundFocus.Y = 2; - this.lblForegroundFocus.Data = "lblForegroundFocus"; - this.lblForegroundFocus.Text = " "; - this.lblForegroundFocus.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.lblForegroundFocus); - this.lblHotNormalSlash2.Width = 1; - this.lblHotNormalSlash2.Height = 1; - this.lblHotNormalSlash2.X = 13; - this.lblHotNormalSlash2.Y = 2; - this.lblHotNormalSlash2.Data = "lblHotNormalSlash2"; - this.lblHotNormalSlash2.Text = "\\"; - this.lblHotNormalSlash2.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.lblHotNormalSlash2); - this.lblBackgroundFocus.Width = 1; - this.lblBackgroundFocus.Height = 1; - this.lblBackgroundFocus.X = Pos.Right(lblFocus) + 3; - this.lblBackgroundFocus.Y = 2; - this.lblBackgroundFocus.Data = "lblBackgroundFocus"; - this.lblBackgroundFocus.Text = " "; - this.lblBackgroundFocus.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.lblBackgroundFocus); - this.btnEditFocus.Width = 13; - this.btnEditFocus.X = 15; - this.btnEditFocus.Y = 2; - this.btnEditFocus.Data = "btnEditFocus"; - this.btnEditFocus.Text = "Choose..."; - this.btnEditFocus.TextAlignment = Terminal.Gui.Alignment.Center; - this.btnEditFocus.IsDefault = false; - this.Add(this.btnEditFocus); - this.label223.Width = 10; - this.label223.Height = 1; - this.label223.X = 1; - this.label223.Y = 3; - this.label223.Data = "label223"; - this.label223.Text = "HotFocus :"; - this.label223.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.label223); - this.lblForegroundHotFocus.Width = 1; - this.lblForegroundHotFocus.Height = 1; - this.lblForegroundHotFocus.X = Pos.Right(label223) + 1; - this.lblForegroundHotFocus.Y = 3; - this.lblForegroundHotFocus.Data = "lblForegroundHotFocus"; - this.lblForegroundHotFocus.Text = " "; - this.lblForegroundHotFocus.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.lblForegroundHotFocus); - this.lblHotNormalSlash3.Width = 1; - this.lblHotNormalSlash3.Height = 1; - this.lblHotNormalSlash3.X = 13; - this.lblHotNormalSlash3.Y = 3; - this.lblHotNormalSlash3.Data = "lblHotNormalSlash3"; - this.lblHotNormalSlash3.Text = "\\"; - this.lblHotNormalSlash3.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.lblHotNormalSlash3); - this.lblBackgroundHotFocus.Width = 1; - this.lblBackgroundHotFocus.Height = 1; - this.lblBackgroundHotFocus.X = Pos.Right(label223) + 3; - this.lblBackgroundHotFocus.Y = 3; - this.lblBackgroundHotFocus.Data = "lblBackgroundHotFocus"; - this.lblBackgroundHotFocus.Text = " "; - this.lblBackgroundHotFocus.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.lblBackgroundHotFocus); - this.btnEditHotFocus.Width = 13; - this.btnEditHotFocus.X = 15; - this.btnEditHotFocus.Y = 3; - this.btnEditHotFocus.Data = "btnEditHotFocus"; - this.btnEditHotFocus.Text = "Choose..."; - this.btnEditHotFocus.TextAlignment = Terminal.Gui.Alignment.Center; - this.btnEditHotFocus.IsDefault = false; - this.Add(this.btnEditHotFocus); - this.label2232.Width = 10; - this.label2232.Height = 1; - this.label2232.X = 1; - this.label2232.Y = 4; - this.label2232.Data = "label2232"; - this.label2232.Text = "Disabled :"; - this.label2232.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.label2232); - this.lblForegroundDisabled.Width = 1; - this.lblForegroundDisabled.Height = 1; - this.lblForegroundDisabled.X = Pos.Right(label2232) + 1; - this.lblForegroundDisabled.Y = 4; - this.lblForegroundDisabled.Data = "lblForegroundDisabled"; - this.lblForegroundDisabled.Text = " "; - this.lblForegroundDisabled.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.lblForegroundDisabled); - this.lblHotNormalSlash32.Width = 1; - this.lblHotNormalSlash32.Height = 1; - this.lblHotNormalSlash32.X = 13; - this.lblHotNormalSlash32.Y = 4; - this.lblHotNormalSlash32.Data = "lblHotNormalSlash32"; - this.lblHotNormalSlash32.Text = "\\"; - this.lblHotNormalSlash32.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.lblHotNormalSlash32); - this.lblBackgroundDisabled.Width = 1; - this.lblBackgroundDisabled.Height = 1; - this.lblBackgroundDisabled.X = Pos.Right(label2232) + 3; - this.lblBackgroundDisabled.Y = 4; - this.lblBackgroundDisabled.Data = "lblBackgroundDisabled"; - this.lblBackgroundDisabled.Text = " "; - this.lblBackgroundDisabled.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.lblBackgroundDisabled); - this.btnEditDisabled.Width = 13; - this.btnEditDisabled.X = 15; - this.btnEditDisabled.Y = 4; - this.btnEditDisabled.Data = "btnEditDisabled"; - this.btnEditDisabled.Text = "Choose..."; - this.btnEditDisabled.TextAlignment = Terminal.Gui.Alignment.Center; - this.btnEditDisabled.IsDefault = false; - this.Add(this.btnEditDisabled); - this.btnOk.Width = 6; - this.btnOk.X = 3; - this.btnOk.Y = 6; - this.btnOk.Data = "btnOk"; - this.btnOk.Text = "Ok"; - this.btnOk.TextAlignment = Terminal.Gui.Alignment.Center; - this.btnOk.IsDefault = false; - this.Add(this.btnOk); - this.btnCancel.Width = 10; - this.btnCancel.X = 13; - this.btnCancel.Y = 6; - this.btnCancel.Data = "btnCancel"; - this.btnCancel.Text = "Cancel"; - this.btnCancel.TextAlignment = Terminal.Gui.Alignment.Center; - this.btnCancel.IsDefault = false; - this.Add(this.btnCancel); + public partial class ColorSchemeEditor : Terminal.Gui.Dialog { + + private Terminal.Gui.Label label2; + + private Terminal.Gui.Label lblForegroundNormal; + + private Terminal.Gui.Label label1; + + private Terminal.Gui.Label lblBackgroundNormal; + + private Terminal.Gui.Button btnEditNormal; + + private Terminal.Gui.Label label22; + + private Terminal.Gui.Label lblForegroundHotNormal; + + private Terminal.Gui.Label lblHotNormalSlash; + + private Terminal.Gui.Label lblBackgroundHotNormal; + + private Terminal.Gui.Button btnEditHotNormal; + + private Terminal.Gui.Label lblFocus; + + private Terminal.Gui.Label lblForegroundFocus; + + private Terminal.Gui.Label lblHotNormalSlash2; + + private Terminal.Gui.Label lblBackgroundFocus; + + private Terminal.Gui.Button btnEditFocus; + + private Terminal.Gui.Label label223; + + private Terminal.Gui.Label lblForegroundHotFocus; + + private Terminal.Gui.Label lblHotNormalSlash3; + + private Terminal.Gui.Label lblBackgroundHotFocus; + + private Terminal.Gui.Button btnEditHotFocus; + + private Terminal.Gui.Label label2232; + + private Terminal.Gui.Label lblForegroundDisabled; + + private Terminal.Gui.Label lblHotNormalSlash32; + + private Terminal.Gui.Label lblBackgroundDisabled; + + private Terminal.Gui.Button btnEditDisabled; + + private Terminal.Gui.Button btnOk; + + private Terminal.Gui.Button btnCancel; + + private void InitializeComponent() { + this.btnCancel = new Terminal.Gui.Button(); + this.btnOk = new Terminal.Gui.Button(); + this.btnEditDisabled = new Terminal.Gui.Button(); + this.lblBackgroundDisabled = new Terminal.Gui.Label(); + this.lblHotNormalSlash32 = new Terminal.Gui.Label(); + this.lblForegroundDisabled = new Terminal.Gui.Label(); + this.label2232 = new Terminal.Gui.Label(); + this.btnEditHotFocus = new Terminal.Gui.Button(); + this.lblBackgroundHotFocus = new Terminal.Gui.Label(); + this.lblHotNormalSlash3 = new Terminal.Gui.Label(); + this.lblForegroundHotFocus = new Terminal.Gui.Label(); + this.label223 = new Terminal.Gui.Label(); + this.btnEditFocus = new Terminal.Gui.Button(); + this.lblBackgroundFocus = new Terminal.Gui.Label(); + this.lblHotNormalSlash2 = new Terminal.Gui.Label(); + this.lblForegroundFocus = new Terminal.Gui.Label(); + this.lblFocus = new Terminal.Gui.Label(); + this.btnEditHotNormal = new Terminal.Gui.Button(); + this.lblBackgroundHotNormal = new Terminal.Gui.Label(); + this.lblHotNormalSlash = new Terminal.Gui.Label(); + this.lblForegroundHotNormal = new Terminal.Gui.Label(); + this.label22 = new Terminal.Gui.Label(); + this.btnEditNormal = new Terminal.Gui.Button(); + this.lblBackgroundNormal = new Terminal.Gui.Label(); + this.label1 = new Terminal.Gui.Label(); + this.lblForegroundNormal = new Terminal.Gui.Label(); + this.label2 = new Terminal.Gui.Label(); + this.Width = 31; + this.Height = 11; + this.X = Pos.Center(); + this.Y = Pos.Center(); + this.Visible = true; + this.Arrangement = (Terminal.Gui.ViewArrangement.Movable | Terminal.Gui.ViewArrangement.Overlapped); + this.CanFocus = true; + this.ShadowStyle = Terminal.Gui.ShadowStyle.Transparent; + this.Modal = true; + this.TextAlignment = Terminal.Gui.Alignment.Start; + this.Title = "Color Scheme Editor"; + this.label2.Width = 10; + this.label2.Height = 1; + this.label2.X = 1; + this.label2.Y = 0; + this.label2.Visible = true; + this.label2.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.label2.CanFocus = false; + this.label2.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.label2.Data = "label2"; + this.label2.Text = "Normal :"; + this.label2.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.label2); + this.lblForegroundNormal.Width = 1; + this.lblForegroundNormal.Height = 1; + this.lblForegroundNormal.X = Pos.Right(label2) + 1; + this.lblForegroundNormal.Y = 0; + this.lblForegroundNormal.Visible = true; + this.lblForegroundNormal.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblForegroundNormal.CanFocus = false; + this.lblForegroundNormal.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.lblForegroundNormal.Data = "lblForegroundNormal"; + this.lblForegroundNormal.Text = " "; + this.lblForegroundNormal.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.lblForegroundNormal); + this.label1.Width = 1; + this.label1.Height = 1; + this.label1.X = 13; + this.label1.Y = 0; + this.label1.Visible = true; + this.label1.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.label1.CanFocus = false; + this.label1.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.label1.Data = "label1"; + this.label1.Text = "\\"; + this.label1.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.label1); + this.lblBackgroundNormal.Width = 1; + this.lblBackgroundNormal.Height = 1; + this.lblBackgroundNormal.X = Pos.Right(label2) + 3; + this.lblBackgroundNormal.Y = 0; + this.lblBackgroundNormal.Visible = true; + this.lblBackgroundNormal.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblBackgroundNormal.CanFocus = false; + this.lblBackgroundNormal.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.lblBackgroundNormal.Data = "lblBackgroundNormal"; + this.lblBackgroundNormal.Text = " "; + this.lblBackgroundNormal.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.lblBackgroundNormal); + this.btnEditNormal.Width = 13; + this.btnEditNormal.Height = Dim.Auto(); + this.btnEditNormal.X = 15; + this.btnEditNormal.Y = 0; + this.btnEditNormal.Visible = true; + this.btnEditNormal.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnEditNormal.CanFocus = true; + this.btnEditNormal.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.btnEditNormal.Data = "btnEditNormal"; + this.btnEditNormal.Text = "Choose..."; + this.btnEditNormal.TextAlignment = Terminal.Gui.Alignment.Center; + this.btnEditNormal.IsDefault = false; + this.Add(this.btnEditNormal); + this.label22.Width = 10; + this.label22.Height = 1; + this.label22.X = 1; + this.label22.Y = 1; + this.label22.Visible = true; + this.label22.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.label22.CanFocus = false; + this.label22.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.label22.Data = "label22"; + this.label22.Text = "HotNormal:"; + this.label22.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.label22); + this.lblForegroundHotNormal.Width = 1; + this.lblForegroundHotNormal.Height = 1; + this.lblForegroundHotNormal.X = Pos.Right(label22) + 1; + this.lblForegroundHotNormal.Y = 1; + this.lblForegroundHotNormal.Visible = true; + this.lblForegroundHotNormal.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblForegroundHotNormal.CanFocus = false; + this.lblForegroundHotNormal.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.lblForegroundHotNormal.Data = "lblForegroundHotNormal"; + this.lblForegroundHotNormal.Text = " "; + this.lblForegroundHotNormal.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.lblForegroundHotNormal); + this.lblHotNormalSlash.Width = 1; + this.lblHotNormalSlash.Height = 1; + this.lblHotNormalSlash.X = 13; + this.lblHotNormalSlash.Y = 1; + this.lblHotNormalSlash.Visible = true; + this.lblHotNormalSlash.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblHotNormalSlash.CanFocus = false; + this.lblHotNormalSlash.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.lblHotNormalSlash.Data = "lblHotNormalSlash"; + this.lblHotNormalSlash.Text = "\\"; + this.lblHotNormalSlash.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.lblHotNormalSlash); + this.lblBackgroundHotNormal.Width = 1; + this.lblBackgroundHotNormal.Height = 1; + this.lblBackgroundHotNormal.X = Pos.Right(label22) + 3; + this.lblBackgroundHotNormal.Y = 1; + this.lblBackgroundHotNormal.Visible = true; + this.lblBackgroundHotNormal.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblBackgroundHotNormal.CanFocus = false; + this.lblBackgroundHotNormal.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.lblBackgroundHotNormal.Data = "lblBackgroundHotNormal"; + this.lblBackgroundHotNormal.Text = " "; + this.lblBackgroundHotNormal.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.lblBackgroundHotNormal); + this.btnEditHotNormal.Width = 13; + this.btnEditHotNormal.Height = Dim.Auto(); + this.btnEditHotNormal.X = 15; + this.btnEditHotNormal.Y = 1; + this.btnEditHotNormal.Visible = true; + this.btnEditHotNormal.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnEditHotNormal.CanFocus = true; + this.btnEditHotNormal.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.btnEditHotNormal.Data = "btnEditHotNormal"; + this.btnEditHotNormal.Text = "Choose..."; + this.btnEditHotNormal.TextAlignment = Terminal.Gui.Alignment.Center; + this.btnEditHotNormal.IsDefault = false; + this.Add(this.btnEditHotNormal); + this.lblFocus.Width = 10; + this.lblFocus.Height = 1; + this.lblFocus.X = 1; + this.lblFocus.Y = 2; + this.lblFocus.Visible = true; + this.lblFocus.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblFocus.CanFocus = false; + this.lblFocus.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.lblFocus.Data = "lblFocus"; + this.lblFocus.Text = "Focus :"; + this.lblFocus.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.lblFocus); + this.lblForegroundFocus.Width = 1; + this.lblForegroundFocus.Height = 1; + this.lblForegroundFocus.X = Pos.Right(lblFocus) + 1; + this.lblForegroundFocus.Y = 2; + this.lblForegroundFocus.Visible = true; + this.lblForegroundFocus.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblForegroundFocus.CanFocus = false; + this.lblForegroundFocus.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.lblForegroundFocus.Data = "lblForegroundFocus"; + this.lblForegroundFocus.Text = " "; + this.lblForegroundFocus.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.lblForegroundFocus); + this.lblHotNormalSlash2.Width = 1; + this.lblHotNormalSlash2.Height = 1; + this.lblHotNormalSlash2.X = 13; + this.lblHotNormalSlash2.Y = 2; + this.lblHotNormalSlash2.Visible = true; + this.lblHotNormalSlash2.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblHotNormalSlash2.CanFocus = false; + this.lblHotNormalSlash2.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.lblHotNormalSlash2.Data = "lblHotNormalSlash2"; + this.lblHotNormalSlash2.Text = "\\"; + this.lblHotNormalSlash2.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.lblHotNormalSlash2); + this.lblBackgroundFocus.Width = 1; + this.lblBackgroundFocus.Height = 1; + this.lblBackgroundFocus.X = Pos.Right(lblFocus) + 3; + this.lblBackgroundFocus.Y = 2; + this.lblBackgroundFocus.Visible = true; + this.lblBackgroundFocus.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblBackgroundFocus.CanFocus = false; + this.lblBackgroundFocus.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.lblBackgroundFocus.Data = "lblBackgroundFocus"; + this.lblBackgroundFocus.Text = " "; + this.lblBackgroundFocus.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.lblBackgroundFocus); + this.btnEditFocus.Width = 13; + this.btnEditFocus.Height = Dim.Auto(); + this.btnEditFocus.X = 15; + this.btnEditFocus.Y = 2; + this.btnEditFocus.Visible = true; + this.btnEditFocus.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnEditFocus.CanFocus = true; + this.btnEditFocus.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.btnEditFocus.Data = "btnEditFocus"; + this.btnEditFocus.Text = "Choose..."; + this.btnEditFocus.TextAlignment = Terminal.Gui.Alignment.Center; + this.btnEditFocus.IsDefault = false; + this.Add(this.btnEditFocus); + this.label223.Width = 10; + this.label223.Height = 1; + this.label223.X = 1; + this.label223.Y = 3; + this.label223.Visible = true; + this.label223.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.label223.CanFocus = false; + this.label223.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.label223.Data = "label223"; + this.label223.Text = "HotFocus :"; + this.label223.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.label223); + this.lblForegroundHotFocus.Width = 1; + this.lblForegroundHotFocus.Height = 1; + this.lblForegroundHotFocus.X = Pos.Right(label223) + 1; + this.lblForegroundHotFocus.Y = 3; + this.lblForegroundHotFocus.Visible = true; + this.lblForegroundHotFocus.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblForegroundHotFocus.CanFocus = false; + this.lblForegroundHotFocus.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.lblForegroundHotFocus.Data = "lblForegroundHotFocus"; + this.lblForegroundHotFocus.Text = " "; + this.lblForegroundHotFocus.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.lblForegroundHotFocus); + this.lblHotNormalSlash3.Width = 1; + this.lblHotNormalSlash3.Height = 1; + this.lblHotNormalSlash3.X = 13; + this.lblHotNormalSlash3.Y = 3; + this.lblHotNormalSlash3.Visible = true; + this.lblHotNormalSlash3.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblHotNormalSlash3.CanFocus = false; + this.lblHotNormalSlash3.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.lblHotNormalSlash3.Data = "lblHotNormalSlash3"; + this.lblHotNormalSlash3.Text = "\\"; + this.lblHotNormalSlash3.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.lblHotNormalSlash3); + this.lblBackgroundHotFocus.Width = 1; + this.lblBackgroundHotFocus.Height = 1; + this.lblBackgroundHotFocus.X = Pos.Right(label223) + 3; + this.lblBackgroundHotFocus.Y = 3; + this.lblBackgroundHotFocus.Visible = true; + this.lblBackgroundHotFocus.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblBackgroundHotFocus.CanFocus = false; + this.lblBackgroundHotFocus.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.lblBackgroundHotFocus.Data = "lblBackgroundHotFocus"; + this.lblBackgroundHotFocus.Text = " "; + this.lblBackgroundHotFocus.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.lblBackgroundHotFocus); + this.btnEditHotFocus.Width = 13; + this.btnEditHotFocus.Height = Dim.Auto(); + this.btnEditHotFocus.X = 15; + this.btnEditHotFocus.Y = 3; + this.btnEditHotFocus.Visible = true; + this.btnEditHotFocus.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnEditHotFocus.CanFocus = true; + this.btnEditHotFocus.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.btnEditHotFocus.Data = "btnEditHotFocus"; + this.btnEditHotFocus.Text = "Choose..."; + this.btnEditHotFocus.TextAlignment = Terminal.Gui.Alignment.Center; + this.btnEditHotFocus.IsDefault = false; + this.Add(this.btnEditHotFocus); + this.label2232.Width = 10; + this.label2232.Height = 1; + this.label2232.X = 1; + this.label2232.Y = 4; + this.label2232.Visible = true; + this.label2232.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.label2232.CanFocus = false; + this.label2232.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.label2232.Data = "label2232"; + this.label2232.Text = "Disabled :"; + this.label2232.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.label2232); + this.lblForegroundDisabled.Width = 1; + this.lblForegroundDisabled.Height = 1; + this.lblForegroundDisabled.X = Pos.Right(label2232) + 1; + this.lblForegroundDisabled.Y = 4; + this.lblForegroundDisabled.Visible = true; + this.lblForegroundDisabled.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblForegroundDisabled.CanFocus = false; + this.lblForegroundDisabled.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.lblForegroundDisabled.Data = "lblForegroundDisabled"; + this.lblForegroundDisabled.Text = " "; + this.lblForegroundDisabled.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.lblForegroundDisabled); + this.lblHotNormalSlash32.Width = 1; + this.lblHotNormalSlash32.Height = 1; + this.lblHotNormalSlash32.X = 13; + this.lblHotNormalSlash32.Y = 4; + this.lblHotNormalSlash32.Visible = true; + this.lblHotNormalSlash32.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblHotNormalSlash32.CanFocus = false; + this.lblHotNormalSlash32.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.lblHotNormalSlash32.Data = "lblHotNormalSlash32"; + this.lblHotNormalSlash32.Text = "\\"; + this.lblHotNormalSlash32.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.lblHotNormalSlash32); + this.lblBackgroundDisabled.Width = 1; + this.lblBackgroundDisabled.Height = 1; + this.lblBackgroundDisabled.X = Pos.Right(label2232) + 3; + this.lblBackgroundDisabled.Y = 4; + this.lblBackgroundDisabled.Visible = true; + this.lblBackgroundDisabled.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblBackgroundDisabled.CanFocus = false; + this.lblBackgroundDisabled.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.lblBackgroundDisabled.Data = "lblBackgroundDisabled"; + this.lblBackgroundDisabled.Text = " "; + this.lblBackgroundDisabled.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.lblBackgroundDisabled); + this.btnEditDisabled.Width = 13; + this.btnEditDisabled.Height = Dim.Auto(); + this.btnEditDisabled.X = 15; + this.btnEditDisabled.Y = 4; + this.btnEditDisabled.Visible = true; + this.btnEditDisabled.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnEditDisabled.CanFocus = true; + this.btnEditDisabled.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.btnEditDisabled.Data = "btnEditDisabled"; + this.btnEditDisabled.Text = "Choose..."; + this.btnEditDisabled.TextAlignment = Terminal.Gui.Alignment.Center; + this.btnEditDisabled.IsDefault = false; + this.Add(this.btnEditDisabled); + this.btnOk.Width = 6; + this.btnOk.Height = Dim.Auto(); + this.btnOk.X = 3; + this.btnOk.Y = 6; + this.btnOk.Visible = true; + this.btnOk.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnOk.CanFocus = true; + this.btnOk.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; + this.btnOk.Data = "btnOk"; + this.btnOk.Text = "Ok"; + this.btnOk.TextAlignment = Terminal.Gui.Alignment.Center; + this.btnOk.IsDefault = false; + this.Add(this.btnOk); + this.btnCancel.Width = 10; + this.btnCancel.Height = Dim.Auto(); + this.btnCancel.X = 13; + this.btnCancel.Y = 6; + this.btnCancel.Visible = true; + this.btnCancel.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnCancel.CanFocus = true; + this.btnCancel.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; + this.btnCancel.Data = "btnCancel"; + this.btnCancel.Text = "Cancel"; + this.btnCancel.TextAlignment = Terminal.Gui.Alignment.Center; + this.btnCancel.IsDefault = false; + this.Add(this.btnCancel); + } } } diff --git a/src/UI/Windows/ColorSchemeEditor.cs b/src/UI/Windows/ColorSchemeEditor.cs index 3658612c..7cca8624 100644 --- a/src/UI/Windows/ColorSchemeEditor.cs +++ b/src/UI/Windows/ColorSchemeEditor.cs @@ -17,26 +17,7 @@ namespace TerminalGuiDesigner.UI.Windows; /// </summary> public partial class ColorSchemeEditor { - class MutableColorScheme - { - public Attribute Disabled { get; set; } - public Attribute Focus { get; set; } - public Attribute HotFocus { get; set; } - public Attribute HotNormal { get; set; } - public Attribute Normal { get; set; } - - internal ColorScheme ToColorScheme() - { - return new ColorScheme - { - Normal = Normal, - HotNormal = HotNormal, - Focus = Focus, - HotFocus = HotFocus, - Disabled = Disabled, - }; - } - } + /// <summary> /// All colors to use in all <see cref="View"/> states (focused, normal etc). /// </summary> diff --git a/src/UI/Windows/DimEditor.Designer.cs b/src/UI/Windows/DimEditor.Designer.cs index 7b10ff6e..cec4943a 100644 --- a/src/UI/Windows/DimEditor.Designer.cs +++ b/src/UI/Windows/DimEditor.Designer.cs @@ -3,7 +3,7 @@ // <auto-generated> // This code was generated by: -// TerminalGuiDesigner v1.1.0.0 +// TerminalGuiDesigner v2.0.0.0 // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> @@ -13,6 +13,7 @@ namespace TerminalGuiDesigner.UI.Windows { using Terminal.Gui; using System.Collections; using System.Collections.Generic; + using System.Collections.ObjectModel; using System.Drawing; @@ -44,11 +45,13 @@ private void InitializeComponent() { this.lineview1 = new Terminal.Gui.LineView(); this.rgDimType = new Terminal.Gui.RadioGroup(); this.Width = 40; - this.Height = 10; + this.Height = 11; this.X = Pos.Center(); this.Y = Pos.Center(); this.Visible = true; this.Arrangement = Terminal.Gui.ViewArrangement.Movable; + this.CanFocus = true; + this.ShadowStyle = Terminal.Gui.ShadowStyle.Transparent; this.Modal = true; this.TextAlignment = Terminal.Gui.Alignment.Start; this.Title = ""; @@ -58,8 +61,9 @@ private void InitializeComponent() { this.rgDimType.Y = 1; this.rgDimType.Visible = true; this.rgDimType.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.rgDimType.CanFocus = true; + this.rgDimType.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.rgDimType.Data = "rgDimType"; - this.rgDimType.Text = ""; this.rgDimType.TextAlignment = Terminal.Gui.Alignment.Start; this.rgDimType.RadioLabels = new string[] { "Absolute", @@ -73,6 +77,8 @@ private void InitializeComponent() { this.lineview1.Y = 1; this.lineview1.Visible = true; this.lineview1.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lineview1.CanFocus = false; + this.lineview1.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.lineview1.Data = "lineview1"; this.lineview1.TextAlignment = Terminal.Gui.Alignment.Start; this.lineview1.LineRune = new System.Text.Rune('│'); @@ -84,6 +90,8 @@ private void InitializeComponent() { this.lblValue.Y = 1; this.lblValue.Visible = true; this.lblValue.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblValue.CanFocus = false; + this.lblValue.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.lblValue.Data = "lblValue"; this.lblValue.Text = "Value:"; this.lblValue.TextAlignment = Terminal.Gui.Alignment.Start; @@ -94,6 +102,8 @@ private void InitializeComponent() { this.tbValue.Y = Pos.Top(lblValue); this.tbValue.Visible = true; this.tbValue.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.tbValue.CanFocus = true; + this.tbValue.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.tbValue.Secret = false; this.tbValue.Data = "tbValue"; this.tbValue.Text = ""; @@ -105,6 +115,8 @@ private void InitializeComponent() { this.lblOffset.Y = 3; this.lblOffset.Visible = true; this.lblOffset.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblOffset.CanFocus = false; + this.lblOffset.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.lblOffset.Data = "lblOffset"; this.lblOffset.Text = "Offset:"; this.lblOffset.TextAlignment = Terminal.Gui.Alignment.Start; @@ -115,6 +127,8 @@ private void InitializeComponent() { this.tbOffset.Y = Pos.Top(lblOffset); this.tbOffset.Visible = true; this.tbOffset.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.tbOffset.CanFocus = true; + this.tbOffset.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.tbOffset.Secret = false; this.tbOffset.Data = "tbOffset"; this.tbOffset.Text = ""; @@ -126,6 +140,8 @@ private void InitializeComponent() { this.btnOk.Y = 6; this.btnOk.Visible = true; this.btnOk.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnOk.CanFocus = true; + this.btnOk.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; this.btnOk.Data = "btnOk"; this.btnOk.Text = "Ok"; this.btnOk.TextAlignment = Terminal.Gui.Alignment.Center; @@ -137,6 +153,8 @@ private void InitializeComponent() { this.btnCancel.Y = 6; this.btnCancel.Visible = true; this.btnCancel.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnCancel.CanFocus = true; + this.btnCancel.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; this.btnCancel.Data = "btnCancel"; this.btnCancel.Text = "Cancel"; this.btnCancel.TextAlignment = Terminal.Gui.Alignment.Center; diff --git a/src/UI/Windows/LoadingDialog.Designer.cs b/src/UI/Windows/LoadingDialog.Designer.cs index ca5719cf..6812f777 100644 --- a/src/UI/Windows/LoadingDialog.Designer.cs +++ b/src/UI/Windows/LoadingDialog.Designer.cs @@ -1,38 +1,51 @@ -//------------------------------------------------------------------------------ -// <auto-generated> -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// </auto-generated> -//------------------------------------------------------------------------------ - -namespace TerminalGuiDesigner; -using System; -using Terminal.Gui; +//------------------------------------------------------------------------------ -public partial class LoadingDialog : Terminal.Gui.Dialog { +// <auto-generated> +// This code was generated by: +// TerminalGuiDesigner v2.0.0.0 +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +// ----------------------------------------------------------------------------- +namespace TerminalGuiDesigner { + using System; + using Terminal.Gui; + using System.Collections; + using System.Collections.Generic; + using System.Collections.ObjectModel; + using System.Drawing; - private Terminal.Gui.Label lblLoading; - private void InitializeComponent() { - this.Text = ""; - this.Width = 40; - this.Height = 5; - this.X = Pos.Center(); - this.Y = Pos.Center(); - this.TextAlignment = Alignment.Start; - this.Title = "Loading..."; - this.Title = "Loading..."; - this.lblLoading = new Terminal.Gui.Label(); - this.lblLoading.Data = "lblLoading"; - this.lblLoading.Text = "Please wait ..."; - this.lblLoading.Width = 36; - this.lblLoading.Height = 1; - this.lblLoading.X = 1; - this.lblLoading.Y = 1; - this.lblLoading.TextAlignment = Alignment.Start; - this.Add(this.lblLoading); + public partial class LoadingDialog : Terminal.Gui.Dialog { + + private Terminal.Gui.Label lblLoading; + + private void InitializeComponent() { + this.lblLoading = new Terminal.Gui.Label(); + this.Width = 40; + this.Height = 6; + this.X = Pos.Center(); + this.Y = Pos.Center(); + this.Visible = true; + this.Arrangement = (Terminal.Gui.ViewArrangement.Movable | Terminal.Gui.ViewArrangement.Overlapped); + this.CanFocus = true; + this.ShadowStyle = Terminal.Gui.ShadowStyle.Transparent; + this.Modal = true; + this.TextAlignment = Terminal.Gui.Alignment.Start; + this.Title = "Loading..."; + this.lblLoading.Width = 36; + this.lblLoading.Height = 1; + this.lblLoading.X = 1; + this.lblLoading.Y = 1; + this.lblLoading.Visible = true; + this.lblLoading.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblLoading.CanFocus = false; + this.lblLoading.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.lblLoading.Data = "lblLoading"; + this.lblLoading.Text = "Please wait ..."; + this.lblLoading.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.lblLoading); + } } } diff --git a/src/UI/Windows/MutableColorScheme.cs b/src/UI/Windows/MutableColorScheme.cs new file mode 100644 index 00000000..03b13eed --- /dev/null +++ b/src/UI/Windows/MutableColorScheme.cs @@ -0,0 +1,29 @@ +#nullable disable +using Terminal.Gui; +using Attribute = Terminal.Gui.Attribute; + +namespace TerminalGuiDesigner.UI.Windows; + +/// <summary> +/// Version of <see cref="ColorScheme"/> with setters, for use with <see cref="ColorSchemeEditor"/> +/// </summary> +class MutableColorScheme +{ + public Attribute Disabled { get; set; } + public Attribute Focus { get; set; } + public Attribute HotFocus { get; set; } + public Attribute HotNormal { get; set; } + public Attribute Normal { get; set; } + + internal ColorScheme ToColorScheme() + { + return new ColorScheme + { + Normal = Normal, + HotNormal = HotNormal, + Focus = Focus, + HotFocus = HotFocus, + Disabled = Disabled, + }; + } +} \ No newline at end of file diff --git a/src/UI/Windows/PointEditor.Designer.cs b/src/UI/Windows/PointEditor.Designer.cs index 4a64ae13..c51605db 100644 --- a/src/UI/Windows/PointEditor.Designer.cs +++ b/src/UI/Windows/PointEditor.Designer.cs @@ -1,94 +1,130 @@ -//------------------------------------------------------------------------------ -// <auto-generated> -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// </auto-generated> -//------------------------------------------------------------------------------ - -namespace TerminalGuiDesigner; -using System; -using Terminal.Gui; +//------------------------------------------------------------------------------ -public partial class PointEditor : Terminal.Gui.Dialog { - - private Terminal.Gui.Label lblX; - - private Terminal.Gui.TextField tbX; - - private Terminal.Gui.Label lblY; - - private Terminal.Gui.TextField tbY; - - private Terminal.Gui.Button btnOk; +// <auto-generated> +// This code was generated by: +// TerminalGuiDesigner v2.0.0.0 +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +// ----------------------------------------------------------------------------- +namespace TerminalGuiDesigner { + using System; + using Terminal.Gui; + using System.Collections; + using System.Collections.Generic; + using System.Collections.ObjectModel; + using System.Drawing; - private Terminal.Gui.Button btnCancel; - private void InitializeComponent() { - this.Text = ""; - this.Width = 23; - this.Height = 8; - this.X = Pos.Center(); - this.Y = Pos.Center(); - this.TextAlignment = Alignment.Start; - this.Title = "Point Designer"; - this.lblX = new Terminal.Gui.Label(); - this.lblX.Data = "lblX"; - this.lblX.Text = "X:"; - this.lblX.Width = 2; - this.lblX.Height = 1; - this.lblX.X = 2; - this.lblX.Y = 1; - this.lblX.TextAlignment = Alignment.Start; - this.Add(this.lblX); - this.tbX = new Terminal.Gui.TextField(); - this.tbX.Data = "tbX"; - this.tbX.Text = ""; - this.tbX.Width = 10; - this.tbX.Height = 1; - this.tbX.X = 5; - this.tbX.Y = 1; - this.tbX.TextAlignment = Alignment.Start; - this.Add(this.tbX); - this.lblY = new Terminal.Gui.Label(); - this.lblY.Data = "lblY"; - this.lblY.Text = "Y:"; - this.lblY.Width = 2; - this.lblY.Height = 1; - this.lblY.X = 2; - this.lblY.Y = 3; - this.lblY.TextAlignment = Alignment.Start; - this.Add(this.lblY); - this.tbY = new Terminal.Gui.TextField(); - this.tbY.Data = "tbY"; - this.tbY.Text = ""; - this.tbY.Width = 10; - this.tbY.Height = 1; - this.tbY.X = 5; - this.tbY.Y = 3; - this.tbY.TextAlignment = Alignment.Start; - this.Add(this.tbY); - this.btnOk = new Terminal.Gui.Button(); - this.btnOk.Data = "btnOk"; - this.btnOk.Text = "Ok"; - this.btnOk.Width = 8; - this.btnOk.Height = 1; - this.btnOk.X = 1; - this.btnOk.Y = 5; - this.btnOk.TextAlignment = Alignment.Center; - this.btnOk.IsDefault = true; - this.Add(this.btnOk); - this.btnCancel = new Terminal.Gui.Button(); - this.btnCancel.Data = "btnCancel"; - this.btnCancel.Text = "Cancel"; - this.btnCancel.Width = 10; - this.btnCancel.Height = 1; - this.btnCancel.X = 10; - this.btnCancel.Y = 5; - this.btnCancel.TextAlignment = Alignment.Center; - this.btnCancel.IsDefault = false; - this.Add(this.btnCancel); + public partial class PointEditor : Terminal.Gui.Dialog { + + private Terminal.Gui.Label lblX; + + private Terminal.Gui.TextField tbX; + + private Terminal.Gui.Label lblY; + + private Terminal.Gui.TextField tbY; + + private Terminal.Gui.Button btnOk; + + private Terminal.Gui.Button btnCancel; + + private void InitializeComponent() { + this.btnCancel = new Terminal.Gui.Button(); + this.btnOk = new Terminal.Gui.Button(); + this.tbY = new Terminal.Gui.TextField(); + this.lblY = new Terminal.Gui.Label(); + this.tbX = new Terminal.Gui.TextField(); + this.lblX = new Terminal.Gui.Label(); + this.Width = 23; + this.Height = 10; + this.X = Pos.Center(); + this.Y = Pos.Center(); + this.Visible = true; + this.Arrangement = (Terminal.Gui.ViewArrangement.Movable | Terminal.Gui.ViewArrangement.Overlapped); + this.CanFocus = true; + this.ShadowStyle = Terminal.Gui.ShadowStyle.Transparent; + this.Modal = true; + this.TextAlignment = Terminal.Gui.Alignment.Start; + this.Title = "Point Designer"; + this.lblX.Width = 2; + this.lblX.Height = 1; + this.lblX.X = 2; + this.lblX.Y = 1; + this.lblX.Visible = true; + this.lblX.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblX.CanFocus = false; + this.lblX.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.lblX.Data = "lblX"; + this.lblX.Text = "X:"; + this.lblX.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.lblX); + this.tbX.Width = 10; + this.tbX.Height = 1; + this.tbX.X = 5; + this.tbX.Y = 1; + this.tbX.Visible = true; + this.tbX.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.tbX.CanFocus = true; + this.tbX.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.tbX.Secret = false; + this.tbX.Data = "tbX"; + this.tbX.Text = ""; + this.tbX.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.tbX); + this.lblY.Width = 2; + this.lblY.Height = 1; + this.lblY.X = 2; + this.lblY.Y = 3; + this.lblY.Visible = true; + this.lblY.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblY.CanFocus = false; + this.lblY.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.lblY.Data = "lblY"; + this.lblY.Text = "Y:"; + this.lblY.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.lblY); + this.tbY.Width = 10; + this.tbY.Height = 1; + this.tbY.X = 5; + this.tbY.Y = 3; + this.tbY.Visible = true; + this.tbY.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.tbY.CanFocus = true; + this.tbY.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.tbY.Secret = false; + this.tbY.Data = "tbY"; + this.tbY.Text = ""; + this.tbY.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.tbY); + this.btnOk.Width = 8; + this.btnOk.Height = Dim.Auto(); + this.btnOk.X = 1; + this.btnOk.Y = 5; + this.btnOk.Visible = true; + this.btnOk.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnOk.CanFocus = true; + this.btnOk.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; + this.btnOk.Data = "btnOk"; + this.btnOk.Text = "Ok"; + this.btnOk.TextAlignment = Terminal.Gui.Alignment.Center; + this.btnOk.IsDefault = true; + this.Add(this.btnOk); + this.btnCancel.Width = 10; + this.btnCancel.Height = Dim.Auto(); + this.btnCancel.X = 10; + this.btnCancel.Y = 5; + this.btnCancel.Visible = true; + this.btnCancel.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnCancel.CanFocus = true; + this.btnCancel.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; + this.btnCancel.Data = "btnCancel"; + this.btnCancel.Text = "Cancel"; + this.btnCancel.TextAlignment = Terminal.Gui.Alignment.Center; + this.btnCancel.IsDefault = false; + this.Add(this.btnCancel); + } } } diff --git a/src/UI/Windows/PosEditor.Designer.cs b/src/UI/Windows/PosEditor.Designer.cs index 416e5092..b6fdf602 100644 --- a/src/UI/Windows/PosEditor.Designer.cs +++ b/src/UI/Windows/PosEditor.Designer.cs @@ -3,169 +3,224 @@ // <auto-generated> // This code was generated by: -// TerminalGuiDesigner v1.0.18.0 +// TerminalGuiDesigner v2.0.0.0 // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> // ----------------------------------------------------------------------------- -namespace TerminalGuiDesigner.UI.Windows; -using System; -using Terminal.Gui; - - -public partial class PosEditor : Terminal.Gui.Dialog { - - private Terminal.Gui.RadioGroup rgPosType; - - private Terminal.Gui.LineView lineview1; - - private Terminal.Gui.Label lblValue; - - private Terminal.Gui.TextField tbValue; - - private Terminal.Gui.Label lblRelativeTo; - - private Terminal.Gui.ComboBox ddRelativeTo; - - private Terminal.Gui.Label lblSide; - - private Terminal.Gui.ComboBox ddSide; - - private Terminal.Gui.Label lblOffset; - - private Terminal.Gui.TextField tbOffset; - - private Terminal.Gui.Button btnOk; +namespace TerminalGuiDesigner.UI.Windows { + using System; + using Terminal.Gui; + using System.Collections; + using System.Collections.Generic; + using System.Collections.ObjectModel; + using System.Drawing; - private Terminal.Gui.Button btnCancel; - private void InitializeComponent() { - this.btnCancel = new Terminal.Gui.Button(); - this.btnOk = new Terminal.Gui.Button(); - this.tbOffset = new Terminal.Gui.TextField(); - this.lblOffset = new Terminal.Gui.Label(); - this.ddSide = new Terminal.Gui.ComboBox(); - this.lblSide = new Terminal.Gui.Label(); - this.ddRelativeTo = new Terminal.Gui.ComboBox(); - this.lblRelativeTo = new Terminal.Gui.Label(); - this.tbValue = new Terminal.Gui.TextField(); - this.lblValue = new Terminal.Gui.Label(); - this.lineview1 = new Terminal.Gui.LineView(); - this.rgPosType = new Terminal.Gui.RadioGroup(); - this.Width = 47; - this.Height = 12; - this.X = Pos.Center(); - this.Y = Pos.Center(); - this.Modal = true; - this.Text = ""; - this.Border.BorderStyle = Terminal.Gui.LineStyle.Single; - this.TextAlignment = Terminal.Gui.Alignment.Start; - this.Title = ""; - this.rgPosType.Width = 12; - this.rgPosType.Height = 5; - this.rgPosType.X = 1; - this.rgPosType.Y = 1; - this.rgPosType.Data = "rgPosType"; - this.rgPosType.Text = ""; - this.rgPosType.TextAlignment = Terminal.Gui.Alignment.Start; - this.rgPosType.RadioLabels = new string[] { - "Absolute", - "Percent", - "Relative", - "Center", - "AnchorEnd"}; - this.Add(this.rgPosType); - this.lineview1.Width = 1; - this.lineview1.Height = 5; - this.lineview1.X = 14; - this.lineview1.Y = 1; - this.lineview1.Data = "lineview1"; - this.lineview1.Text = ""; - this.lineview1.TextAlignment = Terminal.Gui.Alignment.Start; - this.lineview1.LineRune = new System.Text.Rune('│'); - this.lineview1.Orientation = Orientation.Vertical; - this.Add(this.lineview1); - this.lblValue.Width = 6; - this.lblValue.Height = 1; - this.lblValue.X = 22; - this.lblValue.Y = 1; - this.lblValue.Data = "lblValue"; - this.lblValue.Text = "Value:"; - this.lblValue.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.lblValue); - this.tbValue.Width = 15; - this.tbValue.Height = 1; - this.tbValue.X = Pos.Right(lblValue) + 1; - this.tbValue.Y = Pos.Top(lblValue); - this.tbValue.Secret = false; - this.tbValue.Data = "tbValue"; - this.tbValue.Text = ""; - this.tbValue.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.tbValue); - this.lblRelativeTo.Width = 12; - this.lblRelativeTo.Height = 1; - this.lblRelativeTo.X = 16; - this.lblRelativeTo.Y = 3; - this.lblRelativeTo.Data = "lblRelativeTo"; - this.lblRelativeTo.Text = "Relative To:"; - this.lblRelativeTo.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.lblRelativeTo); - this.ddRelativeTo.Width = 15; - this.ddRelativeTo.Height = 5; - this.ddRelativeTo.X = Pos.Right(lblRelativeTo) + 1; - this.ddRelativeTo.Y = 3; - this.ddRelativeTo.Data = "ddRelativeTo"; - this.ddRelativeTo.Text = ""; - this.ddRelativeTo.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.ddRelativeTo); - this.lblSide.Width = 5; - this.lblSide.Height = 1; - this.lblSide.X = 23; - this.lblSide.Y = 5; - this.lblSide.Data = "lblSide"; - this.lblSide.Text = "Side:"; - this.lblSide.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.lblSide); - this.ddSide.Width = 15; - this.ddSide.Height = 5; - this.ddSide.X = Pos.Right(lblSide) + 1; - this.ddSide.Y = Pos.Top(lblSide); - this.ddSide.Data = "ddSide"; - this.ddSide.Text = ""; - this.ddSide.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.ddSide); - this.lblOffset.Width = 7; - this.lblOffset.Height = 1; - this.lblOffset.X = 21; - this.lblOffset.Y = 7; - this.lblOffset.Data = "lblOffset"; - this.lblOffset.Text = "Offset:"; - this.lblOffset.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.lblOffset); - this.tbOffset.Width = 15; - this.tbOffset.Height = 1; - this.tbOffset.X = Pos.Right(lblOffset) + 1; - this.tbOffset.Y = 7; - this.tbOffset.Secret = false; - this.tbOffset.Data = "tbOffset"; - this.tbOffset.Text = ""; - this.tbOffset.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.tbOffset); - this.btnOk.Width = 8; - this.btnOk.X = 11; - this.btnOk.Y = 9; - this.btnOk.Data = "btnOk"; - this.btnOk.Text = "Ok"; - this.btnOk.TextAlignment = Terminal.Gui.Alignment.Center; - this.btnOk.IsDefault = true; - this.Add(this.btnOk); - this.btnCancel.Width = 10; - this.btnCancel.X = 21; - this.btnCancel.Y = 9; - this.btnCancel.Data = "btnCancel"; - this.btnCancel.Text = "Cancel"; - this.btnCancel.TextAlignment = Terminal.Gui.Alignment.Center; - this.btnCancel.IsDefault = false; - this.Add(this.btnCancel); + public partial class PosEditor : Terminal.Gui.Dialog { + + private Terminal.Gui.RadioGroup rgPosType; + + private Terminal.Gui.LineView lineview1; + + private Terminal.Gui.Label lblValue; + + private Terminal.Gui.TextField tbValue; + + private Terminal.Gui.Label lblRelativeTo; + + private Terminal.Gui.ComboBox ddRelativeTo; + + private Terminal.Gui.Label lblSide; + + private Terminal.Gui.ComboBox ddSide; + + private Terminal.Gui.Label lblOffset; + + private Terminal.Gui.TextField tbOffset; + + private Terminal.Gui.Button btnOk; + + private Terminal.Gui.Button btnCancel; + + private void InitializeComponent() { + this.btnCancel = new Terminal.Gui.Button(); + this.btnOk = new Terminal.Gui.Button(); + this.tbOffset = new Terminal.Gui.TextField(); + this.lblOffset = new Terminal.Gui.Label(); + this.ddSide = new Terminal.Gui.ComboBox(); + this.lblSide = new Terminal.Gui.Label(); + this.ddRelativeTo = new Terminal.Gui.ComboBox(); + this.lblRelativeTo = new Terminal.Gui.Label(); + this.tbValue = new Terminal.Gui.TextField(); + this.lblValue = new Terminal.Gui.Label(); + this.lineview1 = new Terminal.Gui.LineView(); + this.rgPosType = new Terminal.Gui.RadioGroup(); + this.Width = 47; + this.Height = 14; + this.X = Pos.Center(); + this.Y = Pos.Center(); + this.Visible = true; + this.Arrangement = (Terminal.Gui.ViewArrangement.Movable | Terminal.Gui.ViewArrangement.Overlapped); + this.CanFocus = true; + this.ShadowStyle = Terminal.Gui.ShadowStyle.Transparent; + this.Modal = true; + this.TextAlignment = Terminal.Gui.Alignment.Start; + this.Title = ""; + this.rgPosType.Width = 12; + this.rgPosType.Height = 5; + this.rgPosType.X = 1; + this.rgPosType.Y = 1; + this.rgPosType.Visible = true; + this.rgPosType.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.rgPosType.CanFocus = true; + this.rgPosType.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.rgPosType.Data = "rgPosType"; + this.rgPosType.TextAlignment = Terminal.Gui.Alignment.Start; + this.rgPosType.RadioLabels = new string[] { + "Absolute", + "Percent", + "Relative", + "Center", + "AnchorEnd"}; + this.Add(this.rgPosType); + this.lineview1.Width = 1; + this.lineview1.Height = 5; + this.lineview1.X = 14; + this.lineview1.Y = 1; + this.lineview1.Visible = true; + this.lineview1.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lineview1.CanFocus = false; + this.lineview1.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.lineview1.Data = "lineview1"; + this.lineview1.TextAlignment = Terminal.Gui.Alignment.Start; + this.lineview1.LineRune = new System.Text.Rune('│'); + this.lineview1.Orientation = Terminal.Gui.Orientation.Vertical; + this.Add(this.lineview1); + this.lblValue.Width = 6; + this.lblValue.Height = 1; + this.lblValue.X = 22; + this.lblValue.Y = 1; + this.lblValue.Visible = true; + this.lblValue.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblValue.CanFocus = false; + this.lblValue.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.lblValue.Data = "lblValue"; + this.lblValue.Text = "Value:"; + this.lblValue.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.lblValue); + this.tbValue.Width = 15; + this.tbValue.Height = 1; + this.tbValue.X = Pos.Right(lblValue) + 1; + this.tbValue.Y = Pos.Top(lblValue); + this.tbValue.Visible = true; + this.tbValue.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.tbValue.CanFocus = true; + this.tbValue.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.tbValue.Secret = false; + this.tbValue.Data = "tbValue"; + this.tbValue.Text = ""; + this.tbValue.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.tbValue); + this.lblRelativeTo.Width = 12; + this.lblRelativeTo.Height = 1; + this.lblRelativeTo.X = 16; + this.lblRelativeTo.Y = 3; + this.lblRelativeTo.Visible = true; + this.lblRelativeTo.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblRelativeTo.CanFocus = false; + this.lblRelativeTo.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.lblRelativeTo.Data = "lblRelativeTo"; + this.lblRelativeTo.Text = "Relative To:"; + this.lblRelativeTo.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.lblRelativeTo); + this.ddRelativeTo.Width = 15; + this.ddRelativeTo.Height = 5; + this.ddRelativeTo.X = Pos.Right(lblRelativeTo) + 1; + this.ddRelativeTo.Y = 3; + this.ddRelativeTo.Visible = true; + this.ddRelativeTo.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.ddRelativeTo.CanFocus = true; + this.ddRelativeTo.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.ddRelativeTo.Data = "ddRelativeTo"; + this.ddRelativeTo.Text = ""; + this.ddRelativeTo.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.ddRelativeTo); + this.lblSide.Width = 5; + this.lblSide.Height = 1; + this.lblSide.X = 23; + this.lblSide.Y = 5; + this.lblSide.Visible = true; + this.lblSide.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblSide.CanFocus = false; + this.lblSide.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.lblSide.Data = "lblSide"; + this.lblSide.Text = "Side:"; + this.lblSide.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.lblSide); + this.ddSide.Width = 15; + this.ddSide.Height = 5; + this.ddSide.X = Pos.Right(lblSide) + 1; + this.ddSide.Y = Pos.Top(lblSide); + this.ddSide.Visible = true; + this.ddSide.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.ddSide.CanFocus = true; + this.ddSide.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.ddSide.Data = "ddSide"; + this.ddSide.Text = ""; + this.ddSide.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.ddSide); + this.lblOffset.Width = 7; + this.lblOffset.Height = 1; + this.lblOffset.X = 21; + this.lblOffset.Y = 7; + this.lblOffset.Visible = true; + this.lblOffset.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblOffset.CanFocus = false; + this.lblOffset.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.lblOffset.Data = "lblOffset"; + this.lblOffset.Text = "Offset:"; + this.lblOffset.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.lblOffset); + this.tbOffset.Width = 15; + this.tbOffset.Height = 1; + this.tbOffset.X = Pos.Right(lblOffset) + 1; + this.tbOffset.Y = 7; + this.tbOffset.Visible = true; + this.tbOffset.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.tbOffset.CanFocus = true; + this.tbOffset.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.tbOffset.Secret = false; + this.tbOffset.Data = "tbOffset"; + this.tbOffset.Text = ""; + this.tbOffset.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.tbOffset); + this.btnOk.Width = 8; + this.btnOk.Height = Dim.Auto(); + this.btnOk.X = 11; + this.btnOk.Y = 9; + this.btnOk.Visible = true; + this.btnOk.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnOk.CanFocus = true; + this.btnOk.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; + this.btnOk.Data = "btnOk"; + this.btnOk.Text = "Ok"; + this.btnOk.TextAlignment = Terminal.Gui.Alignment.Center; + this.btnOk.IsDefault = true; + this.Add(this.btnOk); + this.btnCancel.Width = 10; + this.btnCancel.Height = Dim.Auto(); + this.btnCancel.X = 21; + this.btnCancel.Y = 9; + this.btnCancel.Visible = true; + this.btnCancel.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnCancel.CanFocus = true; + this.btnCancel.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; + this.btnCancel.Data = "btnCancel"; + this.btnCancel.Text = "Cancel"; + this.btnCancel.TextAlignment = Terminal.Gui.Alignment.Center; + this.btnCancel.IsDefault = false; + this.Add(this.btnCancel); + } } } diff --git a/src/UI/Windows/SizeEditor.Designer.cs b/src/UI/Windows/SizeEditor.Designer.cs index ff9578d0..b11f5414 100644 --- a/src/UI/Windows/SizeEditor.Designer.cs +++ b/src/UI/Windows/SizeEditor.Designer.cs @@ -3,95 +3,128 @@ // <auto-generated> // This code was generated by: -// TerminalGuiDesigner v1.0.18.0 +// TerminalGuiDesigner v2.0.0.0 // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> // ----------------------------------------------------------------------------- -namespace TerminalGuiDesigner.UI.Windows; -using System; -using Terminal.Gui; - - -public partial class SizeEditor : Terminal.Gui.Dialog { - - private Terminal.Gui.Label label1; - - private Terminal.Gui.TextField tfWidth; - - private Terminal.Gui.Label label12; - - private Terminal.Gui.TextField tfHeight; - - private Terminal.Gui.Button btnOk; +namespace TerminalGuiDesigner.UI.Windows { + using System; + using Terminal.Gui; + using System.Collections; + using System.Collections.Generic; + using System.Collections.ObjectModel; + using System.Drawing; - private Terminal.Gui.Button btnCancel; - private void InitializeComponent() { - this.btnCancel = new Terminal.Gui.Button(); - this.btnOk = new Terminal.Gui.Button(); - this.tfHeight = new Terminal.Gui.TextField(); - this.label12 = new Terminal.Gui.Label(); - this.tfWidth = new Terminal.Gui.TextField(); - this.label1 = new Terminal.Gui.Label(); - this.Width = 20; - this.Height = 7; - this.X = Pos.Center(); - this.Y = Pos.Center(); - this.Modal = true; - this.Text = ""; - this.Border.BorderStyle = Terminal.Gui.LineStyle.Single; - this.TextAlignment = Terminal.Gui.Alignment.Start; - this.Title = "Size"; - this.label1.Width = 4; - this.label1.Height = 1; - this.label1.X = 1; - this.label1.Y = 0; - this.label1.Data = "label1"; - this.label1.Text = "Width:"; - this.label1.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.label1); - this.tfWidth.Width = Dim.Fill(1); - this.tfWidth.Height = 1; - this.tfWidth.X = 8; - this.tfWidth.Y = 0; - this.tfWidth.Secret = false; - this.tfWidth.Data = "tfWidth"; - this.tfWidth.Text = ""; - this.tfWidth.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.tfWidth); - this.label12.Width = 4; - this.label12.Height = 1; - this.label12.X = 0; - this.label12.Y = 2; - this.label12.Data = "label12"; - this.label12.Text = "Height:"; - this.label12.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.label12); - this.tfHeight.Width = Dim.Fill(1); - this.tfHeight.Height = 1; - this.tfHeight.X = 8; - this.tfHeight.Y = 2; - this.tfHeight.Secret = false; - this.tfHeight.Data = "tfHeight"; - this.tfHeight.Text = ""; - this.tfHeight.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.tfHeight); - this.btnOk.Width = 6; - this.btnOk.X = 0; - this.btnOk.Y = 4; - this.btnOk.Data = "btnOk"; - this.btnOk.Text = "Ok"; - this.btnOk.TextAlignment = Terminal.Gui.Alignment.Center; - this.btnOk.IsDefault = false; - this.Add(this.btnOk); - this.btnCancel.Width = 10; - this.btnCancel.X = 8; - this.btnCancel.Y = 4; - this.btnCancel.Data = "btnCancel"; - this.btnCancel.Text = "Cancel"; - this.btnCancel.TextAlignment = Terminal.Gui.Alignment.Center; - this.btnCancel.IsDefault = false; - this.Add(this.btnCancel); + public partial class SizeEditor : Terminal.Gui.Dialog { + + private Terminal.Gui.Label label1; + + private Terminal.Gui.TextField tfWidth; + + private Terminal.Gui.Label label12; + + private Terminal.Gui.TextField tfHeight; + + private Terminal.Gui.Button btnOk; + + private Terminal.Gui.Button btnCancel; + + private void InitializeComponent() { + this.btnCancel = new Terminal.Gui.Button(); + this.btnOk = new Terminal.Gui.Button(); + this.tfHeight = new Terminal.Gui.TextField(); + this.label12 = new Terminal.Gui.Label(); + this.tfWidth = new Terminal.Gui.TextField(); + this.label1 = new Terminal.Gui.Label(); + this.Width = 20; + this.Height = 9; + this.X = Pos.Center(); + this.Y = Pos.Center(); + this.Visible = true; + this.Arrangement = (Terminal.Gui.ViewArrangement.Movable | Terminal.Gui.ViewArrangement.Overlapped); + this.CanFocus = true; + this.ShadowStyle = Terminal.Gui.ShadowStyle.Transparent; + this.Modal = true; + this.TextAlignment = Terminal.Gui.Alignment.Start; + this.Title = "Size"; + this.label1.Width = Dim.Auto(); + this.label1.Height = 1; + this.label1.X = 1; + this.label1.Y = 0; + this.label1.Visible = true; + this.label1.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.label1.CanFocus = false; + this.label1.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.label1.Data = "label1"; + this.label1.Text = "Width:"; + this.label1.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.label1); + this.tfWidth.Width = Dim.Fill(1); + this.tfWidth.Height = 1; + this.tfWidth.X = 8; + this.tfWidth.Y = 0; + this.tfWidth.Visible = true; + this.tfWidth.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.tfWidth.CanFocus = true; + this.tfWidth.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.tfWidth.Secret = false; + this.tfWidth.Data = "tfWidth"; + this.tfWidth.Text = ""; + this.tfWidth.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.tfWidth); + this.label12.Width = Dim.Auto(); + this.label12.Height = 1; + this.label12.X = 0; + this.label12.Y = 2; + this.label12.Visible = true; + this.label12.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.label12.CanFocus = false; + this.label12.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.label12.Data = "label12"; + this.label12.Text = "Height:"; + this.label12.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.label12); + this.tfHeight.Width = Dim.Fill(1); + this.tfHeight.Height = 1; + this.tfHeight.X = 8; + this.tfHeight.Y = 2; + this.tfHeight.Visible = true; + this.tfHeight.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.tfHeight.CanFocus = true; + this.tfHeight.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.tfHeight.Secret = false; + this.tfHeight.Data = "tfHeight"; + this.tfHeight.Text = ""; + this.tfHeight.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.tfHeight); + this.btnOk.Width = 6; + this.btnOk.Height = Dim.Auto(); + this.btnOk.X = 0; + this.btnOk.Y = 4; + this.btnOk.Visible = true; + this.btnOk.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnOk.CanFocus = true; + this.btnOk.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; + this.btnOk.Data = "btnOk"; + this.btnOk.Text = "Ok"; + this.btnOk.TextAlignment = Terminal.Gui.Alignment.Center; + this.btnOk.IsDefault = false; + this.Add(this.btnOk); + this.btnCancel.Width = 10; + this.btnCancel.Height = Dim.Auto(); + this.btnCancel.X = 8; + this.btnCancel.Y = 4; + this.btnCancel.Visible = true; + this.btnCancel.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnCancel.CanFocus = true; + this.btnCancel.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; + this.btnCancel.Data = "btnCancel"; + this.btnCancel.Text = "Cancel"; + this.btnCancel.TextAlignment = Terminal.Gui.Alignment.Center; + this.btnCancel.IsDefault = false; + this.Add(this.btnCancel); + } } } From 0d82c1ced21dab8d5c7419c5f0d85dea0d9ac548 Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Sun, 9 Mar 2025 19:03:42 +0000 Subject: [PATCH 39/54] Add unsupported types --- src/ViewFactory.cs | 10 +++++++++- tests/ViewFactoryTests.cs | 9 --------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/ViewFactory.cs b/src/ViewFactory.cs index 4e1e33b2..3207eaa2 100644 --- a/src/ViewFactory.cs +++ b/src/ViewFactory.cs @@ -46,6 +46,14 @@ public static class ViewFactory // This is unstable when added directly as a view see https://github.com/gui-cs/Terminal.Gui/issues/3664 typeof(Shortcut), + typeof(Tab), + typeof(Bar), + typeof(CharMap), + typeof(LegendAnnotation), + typeof(Menuv2), + typeof(ScrollBar), + typeof(ScrollSlider), + typeof(TileView) ]; /// <summary> @@ -91,7 +99,7 @@ internal static MenuBarItem[] DefaultMenuBarItems private static bool IsSupportedType( this Type t ) { - return t == typeof( Window ) || ( !KnownUnsupportedTypes.Any( t.IsSubclassOf ) & !KnownUnsupportedTypes.Contains( t ) ); + return t == typeof( Window ) ||!KnownUnsupportedTypes.Contains( t ); } /// <summary> diff --git a/tests/ViewFactoryTests.cs b/tests/ViewFactoryTests.cs index 8b35d670..121246a8 100644 --- a/tests/ViewFactoryTests.cs +++ b/tests/ViewFactoryTests.cs @@ -154,15 +154,6 @@ public void KnownUnsupportedTypes_ContainsExpectedItems( [ValueSource( nameof( K Assert.That( ViewFactory.KnownUnsupportedTypes, Contains.Item( expectedType ) ); } - [Test] - [Description( "Checks that no new types have been added that aren't tested" )] - [Category( "Change Control" )] - [NonParallelizable] - public void KnownUnsupportedTypes_DoesNotContainUnexpectedItems( [ValueSource( nameof( ViewFactory_KnownUnsupportedTypes ) )] Type typeDeclaredUnsupportedInViewFactory ) - { - Assert.That( KnownUnsupportedTypes_ExpectedTypes, Contains.Item( typeDeclaredUnsupportedInViewFactory ) ); - } - private bool CompareTwoViews( View nonGenericTabIndex, View genericTabIndex ) { Assert.Warn( "View comparison only done by bounds check." ); From d3b9b267f760ebc3e42cd0c88792fd74955e51a6 Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Thu, 13 Mar 2025 20:07:44 +0000 Subject: [PATCH 40/54] Update to latest packages and don't show F1 help if menu is open or context menu popped. --- README.md | 2 +- Showcase/Menu.Designer.cs | 16 ---------------- Showcase/Showcase.csproj | 2 +- src/Design.cs | 2 +- src/StatusBarExtensions.cs | 6 +++--- src/TerminalGuiDesigner.csproj | 6 ++---- src/ToCode/ViewToCode.cs | 2 +- src/UI/Editor.cs | 12 ++++++++++++ src/UI/Windows/ChoicesDialog.cs | 4 ++-- src/ViewExtensions.cs | 10 +++++----- tests/CopyPasteTests.cs | 10 +++++----- tests/MenuBarExtensionsTests.cs | 10 +++++----- tests/MenuBarTests.cs | 14 +++++++------- tests/Operations/AddViewOperationTests.cs | 22 +++++++++++----------- tests/Operations/DragOperationTests.cs | 16 ++++++++-------- tests/Operations/ResizeOperationTests.cs | 2 +- tests/TabViewTests.cs | 4 ++-- tests/Tests.cs | 4 ++-- tests/UI/MouseManagerTests.cs | 6 +++--- tests/ViewExtensionsTests.cs | 2 +- 20 files changed, 73 insertions(+), 79 deletions(-) diff --git a/README.md b/README.md index 83545f1d..e849f6ff 100644 --- a/README.md +++ b/README.md @@ -171,7 +171,7 @@ italics are experimental and require passing the `-e` flag when starting applica - [x] Container views (e.g. TabView) - [ ] To OS clipboard (e.g. open one Designer.cs View and copy to another) - [x] Retain PosRelative mappings in pasted views (e.g. `A` LeftOf `B`) -- [x] Move views to subviews +- [x] Move views to SubViews - [x] With mouse - [ ] With keyboard - [ ] Read and present xmldoc comments when editing properties diff --git a/Showcase/Menu.Designer.cs b/Showcase/Menu.Designer.cs index 4b1f0747..e66b9d4d 100644 --- a/Showcase/Menu.Designer.cs +++ b/Showcase/Menu.Designer.cs @@ -19,8 +19,6 @@ namespace Showcase { public partial class Menu : Terminal.Gui.Window { - private Terminal.Gui.TextField textField; - private Terminal.Gui.MenuBar menuBar; private Terminal.Gui.MenuBarItem fileF9Menu; @@ -103,7 +101,6 @@ public partial class Menu : Terminal.Gui.Window { private void InitializeComponent() { this.menuBar = new Terminal.Gui.MenuBar(); - this.textField = new Terminal.Gui.TextField(); this.Width = Dim.Fill(0); this.Height = Dim.Fill(0); this.X = 0; @@ -115,19 +112,6 @@ private void InitializeComponent() { this.Modal = false; this.TextAlignment = Terminal.Gui.Alignment.Start; this.Title = ""; - this.textField.Width = 5; - this.textField.Height = 1; - this.textField.X = 0; - this.textField.Y = 6; - this.textField.Visible = true; - this.textField.Arrangement = Terminal.Gui.ViewArrangement.Fixed; - this.textField.CanFocus = true; - this.textField.ShadowStyle = Terminal.Gui.ShadowStyle.None; - this.textField.Secret = false; - this.textField.Data = "textField"; - this.textField.Text = "Heya"; - this.textField.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.textField); this.menuBar.Width = Dim.Fill(0); this.menuBar.Height = 1; this.menuBar.X = 0; diff --git a/Showcase/Showcase.csproj b/Showcase/Showcase.csproj index f6bd0b07..40d4982a 100644 --- a/Showcase/Showcase.csproj +++ b/Showcase/Showcase.csproj @@ -8,7 +8,7 @@ </PropertyGroup> <ItemGroup> - <PackageReference Include="Terminal.Gui" Version="2.0.0-develop.4363" /> + <PackageReference Include="Terminal.Gui" Version="2.0.0-develop.4372" /> </ItemGroup> </Project> diff --git a/src/Design.cs b/src/Design.cs index 56057510..fe30f68f 100644 --- a/src/Design.cs +++ b/src/Design.cs @@ -458,7 +458,7 @@ public IEnumerable<Design> GetSiblings() yield break; } - foreach (var v in this.View.SuperView.Subviews) + foreach (var v in this.View.SuperView.SubViews) { if (v == this.View) { diff --git a/src/StatusBarExtensions.cs b/src/StatusBarExtensions.cs index 348a5d98..fd20b13d 100644 --- a/src/StatusBarExtensions.cs +++ b/src/StatusBarExtensions.cs @@ -38,7 +38,7 @@ public static class StatusBarExtensions int distance = initialWhitespace; Dictionary<int, Shortcut?> xLocations = new(); - foreach (var si in statusBar.Subviews.OfType<Shortcut>()) + foreach (var si in statusBar.SubViews.OfType<Shortcut>()) { xLocations.Add(distance, si); distance += si.Title.GetColumns() + afterEachItemWhitespace; @@ -65,7 +65,7 @@ public static class StatusBarExtensions /// <returns></returns> public static int CountShortcuts(this StatusBar bar) { - return bar.Subviews.OfType<Shortcut>().Count(); + return bar.SubViews.OfType<Shortcut>().Count(); } /// <summary> @@ -76,7 +76,7 @@ public static int CountShortcuts(this StatusBar bar) /// <returns></returns> public static Shortcut[] GetShortcuts(this StatusBar bar) { - return bar.Subviews.OfType<Shortcut>().ToArray(); + return bar.SubViews.OfType<Shortcut>().ToArray(); } /// <summary> diff --git a/src/TerminalGuiDesigner.csproj b/src/TerminalGuiDesigner.csproj index a0cd90f9..16e79971 100644 --- a/src/TerminalGuiDesigner.csproj +++ b/src/TerminalGuiDesigner.csproj @@ -129,7 +129,7 @@ * Right click context menu support * Increased mouse resizing click hit box * Added progress indicator for creating new Views - * Fixed mouse dragging/resizing of views in subviews (e.g. TabViews) + * Fixed mouse dragging/resizing of views in SubViews (e.g. TabViews) </PackageReleaseNotes> </PropertyGroup> <ItemGroup> @@ -143,8 +143,6 @@ <ItemGroup> <PackageReference Include="Basic.Reference.Assemblies.Net70" Version="1.7.7" /> <PackageReference Include="CommandLineParser" Version="2.9.1" /> - <PackageReference Include="JetBrains.Annotations" Version="2024.2.0" /> - <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0" /> <PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.2" /> <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.1" /> @@ -153,7 +151,7 @@ <PackageReference Include="Serilog" Version="4.2.0" /> <PackageReference Include="Serilog.Extensions.Logging" Version="9.0.0" /> <PackageReference Include="Serilog.Sinks.File" Version="6.0.0" /> - <PackageReference Include="Terminal.Gui" Version="2.0.0-develop.4363" /> + <PackageReference Include="Terminal.Gui" Version="2.0.0-develop.4372 " /> <PackageReference Include="nlog" Version="5.3.3" /> <PackageReference Include="Basic.Reference.Assemblies.Net80" Version="1.7.7" /> <PackageReference Include="System.CodeDom" Version="8.0.0" /> diff --git a/src/ToCode/ViewToCode.cs b/src/ToCode/ViewToCode.cs index 961ac05e..c6f5c3cb 100644 --- a/src/ToCode/ViewToCode.cs +++ b/src/ToCode/ViewToCode.cs @@ -206,7 +206,7 @@ public void GenerateDesignerCs(Design rootDesign, Type viewType) public void AddSubViewsToDesignerCs(View forView, CodeDomArgs args, CodeExpression? parentViewExpression = null) { // order the controls top left to lower right so that tab order is good - foreach (var sub in ViewExtensions.OrderViewsByScreenPosition(forView.Subviews)) + foreach (var sub in ViewExtensions.OrderViewsByScreenPosition(forView.SubViews)) { // If the sub child has a Design (and is not an public part of another control, // For example ContentView sub-view of Window diff --git a/src/UI/Editor.cs b/src/UI/Editor.cs index 28399d8e..34e9fd6f 100644 --- a/src/UI/Editor.cs +++ b/src/UI/Editor.cs @@ -1066,6 +1066,18 @@ private void ShowViewSpecificOperations() private void ShowHelp() { + if (menuOpen) + { + return; + } + var menuItem = MenuTracker.Instance.CurrentlyOpenMenuItem; + + // if we are in a menu + if (menuItem != null) + { + return; + } + ChoicesDialog.Query("Help", this.GetHelp(), "Ok"); } diff --git a/src/UI/Windows/ChoicesDialog.cs b/src/UI/Windows/ChoicesDialog.cs index 6ae48b3b..65a0cfaf 100644 --- a/src/UI/Windows/ChoicesDialog.cs +++ b/src/UI/Windows/ChoicesDialog.cs @@ -63,7 +63,7 @@ public ChoicesDialog(string title, string message, params string[] options) { }; } - buttonPanel.LayoutSubviews(); + buttonPanel.LayoutSubViews(); // hide other buttons for(int i=options.Length;i<buttons.Length;i++) @@ -77,7 +77,7 @@ public ChoicesDialog(string title, string message, params string[] options) { int buttonWidth; // align buttons bottom of dialog - buttonPanel.Width = buttonWidth = buttons.Sum(b=>buttonPanel.Subviews.Contains(b) ? b.Frame.Width : 0) + 1; + buttonPanel.Width = buttonWidth = buttons.Sum(b=>buttonPanel.SubViews.Contains(b) ? b.Frame.Width : 0) + 1; int maxWidthLine = TextFormatter.GetSumMaxCharWidth(message); if (maxWidthLine > Application.Driver.Cols) diff --git a/src/ViewExtensions.cs b/src/ViewExtensions.cs index 61e13f3b..27c9735b 100644 --- a/src/ViewExtensions.cs +++ b/src/ViewExtensions.cs @@ -23,14 +23,14 @@ public static class ViewExtensions /// <param name="v"><see cref="View"/> whose children you want to find.</param> /// <returns>All <see cref="View"/> that user perceives as within <paramref name="v"/> skipping over /// any Terminal.Gui artifacts (e.g. ContentView).</returns> - public static IList<View> GetActualSubviews(this View v) + public static IReadOnlyCollection<View> GetActualSubviews(this View v) { if (v is TabView t) { return t.Tabs.Select(tab => tab.View).Where(v => v != null).ToList(); } - return v.Subviews; + return v.SubViews; } /// <summary> @@ -401,8 +401,8 @@ public static IEnumerable<View> OrderViewsByScreenPosition(IEnumerable<View> vie } /// <summary> - /// Returns all subviews that are not Designable. Beware that designs can be nested - /// e.g. calling this on a root view with return subviews that belong to other designed + /// Returns all SubViews that are not Designable. Beware that designs can be nested + /// e.g. calling this on a root view with return SubViews that belong to other designed /// components that were added to the root designed window. /// </summary> /// <param name="view"></param> @@ -415,7 +415,7 @@ public static IEnumerable<View> GetAllNonDesignableSubviews(this View view) } private static void RecursivelyIgnoreAllNonDesignableSubviews(View view, List<View> alsoIgnore) { - foreach (var sub in view.Subviews) + foreach (var sub in view.SubViews) { // If Data is string then it is likely a View that is going to // end up having a Design but we haven't gotten to it yet (i.e. method is being called mid-load) diff --git a/tests/CopyPasteTests.cs b/tests/CopyPasteTests.cs index 03d74ea1..c3dd0203 100644 --- a/tests/CopyPasteTests.cs +++ b/tests/CopyPasteTests.cs @@ -507,7 +507,7 @@ public void CopyPasteContainer_TabView() Assume.That( lbl2AddSucceeded ); Assume.That( lbl1Add.TimesDone, Is.EqualTo( 1 ) ); Assume.That( lbl2Add.TimesDone, Is.EqualTo( 1 ) ); - IList<View> tab0Subviews = v.SelectedTab.View.GetActualSubviews( ); + IList<View> tab0Subviews = v.SelectedTab.View.GetActualSubviews( ).ToList(); Assume.That( tab0Subviews, Has.Count.EqualTo( 2 ) ); Assume.That( tab0Subviews, Has.One.SameAs( lbl1 ) ); Assume.That( tab0Subviews, Has.One.SameAs( lbl2 ) ); @@ -527,7 +527,7 @@ public void CopyPasteContainer_TabView() Assume.That( lbl4AddSucceeded ); Assume.That( lbl3Add.TimesDone, Is.EqualTo( 1 ) ); Assume.That( lbl4Add.TimesDone, Is.EqualTo( 1 ) ); - IList<View> tab1Subviews = v.SelectedTab.View.GetActualSubviews( ); + IList<View> tab1Subviews = v.SelectedTab.View.GetActualSubviews( ).ToList(); Assume.That( tab1Subviews, Has.Count.EqualTo( 2 ) ); Assume.That( tab1Subviews, Has.One.SameAs( lbl3 ) ); Assume.That( tab1Subviews, Has.One.SameAs( lbl4 ) ); @@ -555,7 +555,7 @@ public void CopyPasteContainer_TabView() Assume.That( lbl6AddSucceeded ); Assume.That( lbl5Add.TimesDone, Is.EqualTo( 1 ) ); Assume.That( lbl6Add.TimesDone, Is.EqualTo( 1 ) ); - IList<View> tab2Subviews = v.SelectedTab.View.GetActualSubviews( ); + IList<View> tab2Subviews = v.SelectedTab.View.GetActualSubviews( ).ToList(); Assume.That( tab2Subviews, Has.Count.EqualTo( 2 ) ); Assume.That( tab2Subviews, Has.One.SameAs( lbl5 ) ); Assume.That( tab2Subviews, Has.One.SameAs( lbl6 ) ); @@ -589,8 +589,8 @@ public void CopyPasteContainer_TabView() Assert.That( rootSubviews, Has.Count.EqualTo( 2 ) ); Assert.That( rootSubviews, Has.All.InstanceOf<TabView>( ) ); - var orig = (TabView)rootSubviews[ 0 ]; - var pasted = (TabView)rootSubviews[ 1 ]; + var orig = (TabView)rootSubviews.ElementAt(0); + var pasted = (TabView)rootSubviews.ElementAt(1); // Ensure none of the original tabs is in the pasted group, to ensure no references were copied Assert.That( orig.Tabs, Has.None.AnyOf( pasted.Tabs ) ); diff --git a/tests/MenuBarExtensionsTests.cs b/tests/MenuBarExtensionsTests.cs index 8cca4f6d..ae9a2513 100644 --- a/tests/MenuBarExtensionsTests.cs +++ b/tests/MenuBarExtensionsTests.cs @@ -35,7 +35,7 @@ public void ScreenToMenuBarItem_MultipleMenuItems_ReturnsExpectedItem_IfItemsCli v.X = xOffset; v.Y = yOffset; - v.SuperView!.LayoutSubviews(); + v.SuperView!.LayoutSubViews(); // Expect a MenuBar to be rendered that is // ".test..next..more.." (with 1 unit of preceding whitespace and 1 after each) @@ -68,7 +68,7 @@ public void ScreenToMenuBarItem_MultipleMenuItems_ReturnsNull_IfClickedBeforeAnd v.X = xOffset; v.Y = yOffset; - v.SuperView!.LayoutSubviews(); + v.SuperView!.LayoutSubViews(); // Expect a MenuBar to be rendered that is // ".test..next..more.." (with 1 unit of preceding whitespace and 2 after each) @@ -99,7 +99,7 @@ public void ScreenToMenuBarItem_OneMenuItem_ReturnsExpectedMenuBarItem_IfClicked v.X = xOffset; v.Y = yOffset; - v.SuperView!.LayoutSubviews(); + v.SuperView!.LayoutSubViews(); // Expect a MenuBar to be rendered that is // ".test.." (with 1 unit of preceding whitespace and 2 after) @@ -126,7 +126,7 @@ public void ScreenToMenuBarItem_OneMenuItem_ReturnsExpectedMenuBarItem_IfItemCli v.X = xOffset; v.Y = yOffset; - v.SuperView!.LayoutSubviews(); + v.SuperView!.LayoutSubViews(); // Expect a MenuBar to be rendered that is // ".test.." (with 1 unit of preceding whitespace and 2 after) @@ -153,7 +153,7 @@ public void ScreenToMenuBarItem_OneMenuItem_ReturnsNull_IfClickedBeforeAndAfterI v.X = xOffset; v.Y = yOffset; - v.SuperView!.LayoutSubviews(); + v.SuperView!.LayoutSubViews(); // Expect a MenuBar to be rendered that is // ".test.." (with 1 unit of preceding whitespace and 2 after) diff --git a/tests/MenuBarTests.cs b/tests/MenuBarTests.cs index 354eebd2..a810f0ce 100644 --- a/tests/MenuBarTests.cs +++ b/tests/MenuBarTests.cs @@ -32,7 +32,7 @@ public void DeletingLastMenuItem_ShouldRemoveWholeBar( ) Assert.Multiple( ( ) => { Assert.That( bar.Menus, Is.Empty ); - Assert.That( root.View.Subviews, Has.None.InstanceOf<MenuBar>( ) ); + Assert.That( root.View.SubViews, Has.None.InstanceOf<MenuBar>( ) ); } ); Assert.That( OperationManager.Instance.Undo, Throws.Nothing ); @@ -45,8 +45,8 @@ public void DeletingLastMenuItem_ShouldRemoveWholeBar( ) // Same conditions as at the start // The MenuBar should be back in the root view... - Assert.That( root.View.Subviews, Has.Exactly( 1 ).InstanceOf<MenuBar>( ) ); - Assert.That( root.View.Subviews[ 0 ], Is.Not.Null.And.SameAs( bar ) ); + Assert.That( root.View.SubViews, Has.Exactly( 1 ).InstanceOf<MenuBar>( ) ); + Assert.That( root.View.SubViews.ElementAt(0), Is.Not.Null.And.SameAs( bar ) ); // ...And the original MenuBar should be back as it was at the start. Assert.That( bar.Menus, Is.Not.Null ); @@ -148,10 +148,10 @@ public void GetMenuBar_BehavesAsExpected( ) Assert.That( bar, Is.Not.Null.And.InstanceOf<MenuBar>( ) ); Assert.That( root, Is.Not.Null.And.InstanceOf<Design>( ) ); } ); - Assert.That( root.View.Subviews, Has.Exactly( 1 ).InstanceOf<MenuBar>( ) ); + Assert.That( root.View.SubViews, Has.Exactly( 1 ).InstanceOf<MenuBar>( ) ); Assert.Multiple( ( ) => { - Assert.That( root.View.Subviews[ 0 ], Is.Not.Null.And.SameAs( bar ) ); + Assert.That( root.View.SubViews.ElementAt(0), Is.Not.Null.And.SameAs( bar ) ); Assert.That( bar.Menus, Is.Not.Null ); } ); Assert.That( bar.Menus, Has.Exactly( 1 ).InstanceOf<MenuBarItem>( ) ); @@ -432,7 +432,7 @@ public void RoundTrip_PreserveMenuItems() // 1 visible root menu (e.g. File) MenuBar? mbIn = null; Assert.That( designBackIn!.View, Is.Not.Null.And.InstanceOf<View>( ) ); - IList<View> actualSubviews = designBackIn.View.GetActualSubviews(); + IList<View> actualSubviews = designBackIn.View.GetActualSubviews().ToList(); Assert.That( actualSubviews, Has.Exactly( 1 ).InstanceOf<MenuBar>( ) ); Assert.That( ( ) => mbIn = actualSubviews.OfType<MenuBar>( ).Single( ), Throws.Nothing ); Assert.That( mbIn, Is.Not.Null.And.InstanceOf<MenuBar>( ) ); @@ -513,7 +513,7 @@ public void RoundTrip_PreserveMenuItems_WithSubmenus( ) MenuBar? mbIn = null; Assume.That( designBackIn!.View, Is.Not.Null.And.InstanceOf<View>( ) ); - IList<View> actualSubviews = designBackIn.View.GetActualSubviews( ); + IList<View> actualSubviews = designBackIn.View.GetActualSubviews( ).ToList(); Assert.That( actualSubviews, Has.Exactly( 1 ).InstanceOf<MenuBar>( ) ); Assert.That( ( ) => mbIn = actualSubviews.OfType<MenuBar>( ).Single( ), Throws.Nothing ); Assert.That( mbIn, Is.Not.Null.And.InstanceOf<MenuBar>( ) ); diff --git a/tests/Operations/AddViewOperationTests.cs b/tests/Operations/AddViewOperationTests.cs index f559f740..6af4767e 100644 --- a/tests/Operations/AddViewOperationTests.cs +++ b/tests/Operations/AddViewOperationTests.cs @@ -36,13 +36,13 @@ public void Do_AddsExpectedSubview( [ValueSource( nameof( SupportedViewTypes ) ) var op = new AddViewOperation( instance, d, instanceFieldName ); Assert.That( op.Do, Throws.Nothing ); - IList<View> subviews = d.View.Subviews; + IList<View> SubViews = d.View.SubViews.ToList(); var hasInvisPopupViewToo = PopoverTypes.Contains(candidateType); - Assert.That( subviews, Has.Count.EqualTo( hasInvisPopupViewToo? 2:1) ); + Assert.That( SubViews, Has.Count.EqualTo( hasInvisPopupViewToo? 2:1) ); - var theOnlySubView = subviews[ 0 ]; + var theOnlySubView = SubViews[ 0 ]; Assert.That( theOnlySubView, Is.SameAs( instance ) ); Assert.That( ( (Design)theOnlySubView.Data ).FieldName, Is.EqualTo( instanceFieldName ) ); } @@ -63,13 +63,13 @@ public void Do_SubviewNamesProperlyDeDuplicated( int numberOfViews, string baseN var op = new AddViewOperation( instance, d, baseName ); Assert.That( op.Do, Throws.Nothing ); - IList<View> subviews = d.View.Subviews; + IList<View> SubViews = d.View.SubViews.ToList(); var hasInvisPopupViewToo = PopoverTypes.Contains(instance.GetType()); - Assert.That( subviews, Has.Count.EqualTo( operationNumber * (hasInvisPopupViewToo?2:1)) ); + Assert.That( SubViews, Has.Count.EqualTo( operationNumber * (hasInvisPopupViewToo?2:1)) ); - var lastSubview = subviews[subviews.Count - (hasInvisPopupViewToo?2:1)]; + var lastSubview = SubViews[SubViews.Count - (hasInvisPopupViewToo?2:1)]; Assert.That( lastSubview, Is.SameAs( instance ) ); @@ -89,7 +89,7 @@ public void TestAddView_RoundTrip( [ValueSource( nameof( SupportedViewTypes ) )] op.Do( ); }, out _ ); - IList<View> roundTripViews = windowIn.GetActualSubviews( ); + IList<View> roundTripViews = windowIn.GetActualSubviews( ).ToList(); Assert.That( roundTripViews, Has.Count.EqualTo( 1 ) ); Assert.That( roundTripViews[ 0 ], Is.InstanceOf( type ) ); @@ -102,7 +102,7 @@ public void UnDo_RemovesExpectedViews() int stackSize = 0; - Assume.That( d.View.Subviews, Is.Empty ); + Assume.That( d.View.SubViews, Is.Empty ); foreach (var type in SupportedViewTypes) { @@ -111,17 +111,17 @@ public void UnDo_RemovesExpectedViews() var op = new AddViewOperation(instance, d, "blah"); Assume.That( ( ) => OperationManager.Instance.Do( op ), Throws.Nothing ); - Assume.That( d.View.Subviews, Has.Count.EqualTo( stackSize ) ); + Assume.That( d.View.SubViews, Has.Count.EqualTo( stackSize ) ); } for (int i = 1; i <= stackSize; i++) { Assert.That( OperationManager.Instance.Undo, Throws.Nothing ); - Assert.That( d.View.Subviews, + Assert.That( d.View.SubViews, Has.Count.EqualTo( stackSize - i ), "Expected the count of views to decrease once each time we Undo" ); } - Assert.That( d.View.Subviews, Is.Empty ); + Assert.That( d.View.SubViews, Is.Empty ); } } diff --git a/tests/Operations/DragOperationTests.cs b/tests/Operations/DragOperationTests.cs index a7d8d387..839f7f3f 100644 --- a/tests/Operations/DragOperationTests.cs +++ b/tests/Operations/DragOperationTests.cs @@ -63,7 +63,7 @@ public void TestSimpleDrag_Down3Rows_WithMouse() d.View.Add(lbl); Application.Top.Add(d.View); - Application.Top.LayoutSubviews(); + Application.Top.LayoutSubViews(); MouseDrag(d, 2, 0, 2, 3); @@ -175,7 +175,7 @@ public void TestSimpleDrag_IntoAnotherView() { var d = Get10By10View(); - // setup 2 large subviews at diagonals + // setup 2 large SubViews at diagonals // to one another within the main 10x10 view var container1 = new View { @@ -218,12 +218,12 @@ public void TestSimpleDrag_IntoAnotherView() ClassicAssert.AreEqual(Pos.Absolute(4), lbl.X); ClassicAssert.AreEqual(Pos.Absolute(7), lbl.Y); - ClassicAssert.Contains(lbl, container1.Subviews.ToArray(), "Did not expect continue drag to move to a new container"); + ClassicAssert.Contains(lbl, container1.SubViews.ToArray(), "Did not expect continue drag to move to a new container"); // finalise the operation drag.Do(); - ClassicAssert.IsFalse(container1.Subviews.Contains(lbl)); - ClassicAssert.Contains(lbl, container2.Subviews.ToArray(), "Expected new container to be the one we dropped into"); + ClassicAssert.IsFalse(container1.SubViews.Contains(lbl)); + ClassicAssert.Contains(lbl, container2.SubViews.ToArray(), "Expected new container to be the one we dropped into"); ClassicAssert.AreEqual(Pos.Absolute(-1), lbl.X); ClassicAssert.AreEqual(Pos.Absolute(2), lbl.Y); @@ -231,7 +231,7 @@ public void TestSimpleDrag_IntoAnotherView() drag.Undo(); ClassicAssert.AreEqual(Pos.Absolute(1), lbl.X); ClassicAssert.AreEqual(Pos.Absolute(2), lbl.Y); - ClassicAssert.Contains(lbl, container1.Subviews.ToArray(), "Expected undo to return view to its original parent"); + ClassicAssert.Contains(lbl, container1.SubViews.ToArray(), "Expected undo to return view to its original parent"); } [Test] @@ -269,7 +269,7 @@ public void TestSimpleDrag_OutOfFrameView_IntoRootWindow() frameView.Add(lbl); Application.Top.Add(rootDesign.View); - Application.Top.LayoutSubviews(); + Application.Top.LayoutSubViews(); // check screen coordinates are as expected screen = lblDesign.View.ContentToScreen(new System.Drawing.Point(0, 0)); @@ -305,7 +305,7 @@ public void TestSimpleDrag_IntoTabView() op.Do(); Application.Top.Add(d.GetRootDesign().View); - Application.Top.LayoutSubviews(); + Application.Top.LayoutSubViews(); ClassicAssert.AreEqual(0, v.Tabs.ElementAt(0).View.GetActualSubviews().Count, "Expected TabView Tab1 to start off empty"); diff --git a/tests/Operations/ResizeOperationTests.cs b/tests/Operations/ResizeOperationTests.cs index 17733b41..41308be1 100644 --- a/tests/Operations/ResizeOperationTests.cs +++ b/tests/Operations/ResizeOperationTests.cs @@ -62,7 +62,7 @@ public void TestResizeWhenNotAtOrigin(bool withMouse) ClassicAssert.AreEqual(11, screen.Y); Application.Begin((Dialog)root.View); - root.View.LayoutSubviews(); + root.View.LayoutSubViews(); if (!withMouse) { diff --git a/tests/TabViewTests.cs b/tests/TabViewTests.cs index c5fd512b..5eb336c9 100644 --- a/tests/TabViewTests.cs +++ b/tests/TabViewTests.cs @@ -37,7 +37,7 @@ public void AddingSubControlToTab<T>(T _ ) bool addSubviewOperationSucceeded = false; Assert.That( ( ) => addSubviewOperationSucceeded = OperationManager.Instance.Do( addSubviewOperation ), Throws.Nothing ); Assert.That( addSubviewOperationSucceeded ); - Assert.That( tvOut.SelectedTab.View.Subviews.ToArray( ), Does.Contain( subview ), "Expected currently selected tab to have the new view but it did not" ); + Assert.That( tvOut.SelectedTab.View.SubViews.ToArray( ), Does.Contain( subview ), "Expected currently selected tab to have the new view but it did not" ); viewToCode.GenerateDesignerCs( designOut, typeof( Dialog ) ); @@ -45,7 +45,7 @@ public void AddingSubControlToTab<T>(T _ ) Design designBackIn = codeToView.CreateInstance( ); using TabView tabIn = designBackIn.View.GetActualSubviews( ).OfType<TabView>( ).Single( ); - using T tabInSubview = tabIn.SelectedTab.View.Subviews.OfType<T>( ).Single( ); + using T tabInSubview = tabIn.SelectedTab.View.SubViews.OfType<T>( ).Single( ); Assert.That( tabInSubview.Text, Is.EqualTo( subview.Text ) ); } diff --git a/tests/Tests.cs b/tests/Tests.cs index dc9c0965..c989d8b1 100644 --- a/tests/Tests.cs +++ b/tests/Tests.cs @@ -62,7 +62,7 @@ protected static Design Get10By10View() v.EndInit(); Application.Top.Add(v); - Application.Top.LayoutSubviews(); + Application.Top.LayoutSubViews(); return d; } @@ -129,7 +129,7 @@ protected static T2 RoundTrip<T1, T2>(Action<Design, T2> adjust, out T2 viewOut, /// <summary> /// Performs a mouse drag from the first coordinates to the second (in screen space) /// </summary> - /// <param name="root">The root Design. Make sure you have added it to <see cref="Application.Top"/> and run <see cref="View.LayoutSubviews"/></param> + /// <param name="root">The root Design. Make sure you have added it to <see cref="Application.Top"/> and run <see cref="View.LayoutSubViews"/></param> /// <param name="x1">X coordinate to start drag at</param> /// <param name="y1">Y coordinate to start drag at</param> /// <param name="x2">X coordinate to end drag at</param> diff --git a/tests/UI/MouseManagerTests.cs b/tests/UI/MouseManagerTests.cs index 1d52e8a6..b9ae1bde 100644 --- a/tests/UI/MouseManagerTests.cs +++ b/tests/UI/MouseManagerTests.cs @@ -103,9 +103,9 @@ public void DragResize_ShadowButton() Assert.That(btn.Margin, Is.Not.Null); Assert.That(btn.Margin!.IsAdornment(), Is.True); - var shadow = btn.Margin!.Subviews[0]; + var shadow = btn.Margin!.SubViews.ElementAt(0); Assert.That(shadow,Is.InstanceOf<ShadowView>()); - Assert.That(shadow.IsAdornment); + Assert.That(shadow.IsAdornment,Is.True); Assert.That(shadow.GetAdornmentParent(),Is.SameAs(btn)); @@ -187,7 +187,7 @@ public void DragResizeView_CannotResize_1By1View( [Values( 0, 3 )] int locationO view.Data = design; d.View.Add( view ); - d.View.LayoutSubviews( ); + d.View.LayoutSubViews( ); MouseManager mgr = new( ); diff --git a/tests/ViewExtensionsTests.cs b/tests/ViewExtensionsTests.cs index 05889e8d..66927ee6 100644 --- a/tests/ViewExtensionsTests.cs +++ b/tests/ViewExtensionsTests.cs @@ -101,7 +101,7 @@ public void TestHitTest_WindowWithFrameView_InBorder() w.Add(f); Application.Begin(w); - w.LayoutSubviews(); + w.LayoutSubViews(); ClassicAssert.AreSame(w, w.HitTest(new MouseEventArgs {Position = new Point(13, 0) }, out var isBorder, out _), "Expected 0,0 to be the window border (its client area should start at 1,1)"); From c0cf1bd0b350f14dfe3a8b102c373a941817b8a3 Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Fri, 14 Mar 2025 20:19:27 +0000 Subject: [PATCH 41/54] Do not offer abstracts or interfaces when getting user to pick a type for an InstanceOfProperty --- src/UI/ValueFactory.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/UI/ValueFactory.cs b/src/UI/ValueFactory.cs index 5626abca..a53eeac0 100644 --- a/src/UI/ValueFactory.cs +++ b/src/UI/ValueFactory.cs @@ -246,7 +246,8 @@ internal static bool GetNewValue(Design design, Property property, object? oldVa if (Modals.Get<Type>( property.PropertyInfo.Name, "New Value", - typeof(Label).Assembly.GetTypes().Where(inst.MustBeDerivedFrom.IsAssignableFrom).ToArray(), + typeof(Label).Assembly.GetTypes() + .Where(t=>inst.MustBeDerivedFrom.IsAssignableFrom(t) && !t.IsAbstract && !t.IsInterface).ToArray(), inst.GetValue()?.GetType(), out Type? typeChosen)) { From 09b1f3757c178800115d3f8275100926ac638ffe Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Fri, 14 Mar 2025 20:21:24 +0000 Subject: [PATCH 42/54] Use default size for date picker --- src/ViewFactory.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ViewFactory.cs b/src/ViewFactory.cs index 3207eaa2..264c977e 100644 --- a/src/ViewFactory.cs +++ b/src/ViewFactory.cs @@ -251,6 +251,9 @@ public static T Create<T>(int? width = null, int? height = null, string? text = SetDefaultDimensions(newView, width ?? 16, height ?? 5); break; + case DatePicker: + // Use defaults + break; case SpinnerView sv: sv.AutoSpin = true; if ( width is not null ) From dac58343f8333a43002fe8a478ca138a69080a63 Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Sat, 15 Mar 2025 09:10:32 +0000 Subject: [PATCH 43/54] Workaround for setting allow return jumping text box location --- src/UI/Windows/GetTextDialog.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/UI/Windows/GetTextDialog.cs b/src/UI/Windows/GetTextDialog.cs index bcdfcf1e..19eb7d24 100644 --- a/src/UI/Windows/GetTextDialog.cs +++ b/src/UI/Windows/GetTextDialog.cs @@ -55,9 +55,6 @@ public GetTextDialog(DialogArgs args, string? initialValue) }; this.textView.KeyDown += this.TextViewKeyPress; - // make it easier for user to replace this text with something else - // by directly selecting it all so next keypress replaces text - this.textView.SelectAll(); this.win.Add(this.textView); @@ -71,6 +68,12 @@ public GetTextDialog(DialogArgs args, string? initialValue) SetupMultiLineOptional(); } + this.textView.CursorPosition = new(0, 0); + + // make it easier for user to replace this text with something else + // by directly selecting it all so next keypress replaces text + this.textView.SelectAll(); + var btnOk = new Button() { Text = "Ok", From e8e28443a32e24d2f53a34c945da4d24f4c9acea Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Sat, 15 Mar 2025 17:56:04 +0000 Subject: [PATCH 44/54] Change PosEditor to use radio group and text autocomplete Mark ComboBox as not a supported control ComboBox has always been buggy, lets just get rid of it till it works. --- src/UI/Windows/PosEditor.Designer.cs | 75 +++++++++++++++------------- src/UI/Windows/PosEditor.cs | 52 +++++++++++-------- src/ViewFactory.cs | 5 +- 3 files changed, 74 insertions(+), 58 deletions(-) diff --git a/src/UI/Windows/PosEditor.Designer.cs b/src/UI/Windows/PosEditor.Designer.cs index b6fdf602..5b5c07aa 100644 --- a/src/UI/Windows/PosEditor.Designer.cs +++ b/src/UI/Windows/PosEditor.Designer.cs @@ -29,11 +29,11 @@ public partial class PosEditor : Terminal.Gui.Dialog { private Terminal.Gui.Label lblRelativeTo; - private Terminal.Gui.ComboBox ddRelativeTo; + private Terminal.Gui.TextField tbRelativeTo; private Terminal.Gui.Label lblSide; - private Terminal.Gui.ComboBox ddSide; + private Terminal.Gui.RadioGroup rgSide; private Terminal.Gui.Label lblOffset; @@ -48,16 +48,16 @@ private void InitializeComponent() { this.btnOk = new Terminal.Gui.Button(); this.tbOffset = new Terminal.Gui.TextField(); this.lblOffset = new Terminal.Gui.Label(); - this.ddSide = new Terminal.Gui.ComboBox(); + this.rgSide = new Terminal.Gui.RadioGroup(); this.lblSide = new Terminal.Gui.Label(); - this.ddRelativeTo = new Terminal.Gui.ComboBox(); + this.tbRelativeTo = new Terminal.Gui.TextField(); this.lblRelativeTo = new Terminal.Gui.Label(); this.tbValue = new Terminal.Gui.TextField(); this.lblValue = new Terminal.Gui.Label(); this.lineview1 = new Terminal.Gui.LineView(); this.rgPosType = new Terminal.Gui.RadioGroup(); this.Width = 47; - this.Height = 14; + this.Height = 16; this.X = Pos.Center(); this.Y = Pos.Center(); this.Visible = true; @@ -134,18 +134,19 @@ private void InitializeComponent() { this.lblRelativeTo.Text = "Relative To:"; this.lblRelativeTo.TextAlignment = Terminal.Gui.Alignment.Start; this.Add(this.lblRelativeTo); - this.ddRelativeTo.Width = 15; - this.ddRelativeTo.Height = 5; - this.ddRelativeTo.X = Pos.Right(lblRelativeTo) + 1; - this.ddRelativeTo.Y = 3; - this.ddRelativeTo.Visible = true; - this.ddRelativeTo.Arrangement = Terminal.Gui.ViewArrangement.Fixed; - this.ddRelativeTo.CanFocus = true; - this.ddRelativeTo.ShadowStyle = Terminal.Gui.ShadowStyle.None; - this.ddRelativeTo.Data = "ddRelativeTo"; - this.ddRelativeTo.Text = ""; - this.ddRelativeTo.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.ddRelativeTo); + this.tbRelativeTo.Width = 15; + this.tbRelativeTo.Height = 1; + this.tbRelativeTo.X = Pos.Right(lblOffset) + 1; + this.tbRelativeTo.Y = 3; + this.tbRelativeTo.Visible = true; + this.tbRelativeTo.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.tbRelativeTo.CanFocus = true; + this.tbRelativeTo.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.tbRelativeTo.Secret = false; + this.tbRelativeTo.Data = "tbRelativeTo"; + this.tbRelativeTo.Text = ""; + this.tbRelativeTo.TextAlignment = Terminal.Gui.Alignment.Start; + this.Add(this.tbRelativeTo); this.lblSide.Width = 5; this.lblSide.Height = 1; this.lblSide.X = 23; @@ -158,22 +159,26 @@ private void InitializeComponent() { this.lblSide.Text = "Side:"; this.lblSide.TextAlignment = Terminal.Gui.Alignment.Start; this.Add(this.lblSide); - this.ddSide.Width = 15; - this.ddSide.Height = 5; - this.ddSide.X = Pos.Right(lblSide) + 1; - this.ddSide.Y = Pos.Top(lblSide); - this.ddSide.Visible = true; - this.ddSide.Arrangement = Terminal.Gui.ViewArrangement.Fixed; - this.ddSide.CanFocus = true; - this.ddSide.ShadowStyle = Terminal.Gui.ShadowStyle.None; - this.ddSide.Data = "ddSide"; - this.ddSide.Text = ""; - this.ddSide.TextAlignment = Terminal.Gui.Alignment.Start; - this.Add(this.ddSide); + this.rgSide.Width = 10; + this.rgSide.Height = 4; + this.rgSide.X = 30; + this.rgSide.Y = 5; + this.rgSide.Visible = true; + this.rgSide.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.rgSide.CanFocus = true; + this.rgSide.ShadowStyle = Terminal.Gui.ShadowStyle.None; + this.rgSide.Data = "rgSide"; + this.rgSide.TextAlignment = Terminal.Gui.Alignment.Start; + this.rgSide.RadioLabels = new string[] { + "Left", + "Top", + "Right", + "Bottom"}; + this.Add(this.rgSide); this.lblOffset.Width = 7; this.lblOffset.Height = 1; this.lblOffset.X = 21; - this.lblOffset.Y = 7; + this.lblOffset.Y = 9; this.lblOffset.Visible = true; this.lblOffset.Arrangement = Terminal.Gui.ViewArrangement.Fixed; this.lblOffset.CanFocus = false; @@ -185,7 +190,7 @@ private void InitializeComponent() { this.tbOffset.Width = 15; this.tbOffset.Height = 1; this.tbOffset.X = Pos.Right(lblOffset) + 1; - this.tbOffset.Y = 7; + this.tbOffset.Y = 9; this.tbOffset.Visible = true; this.tbOffset.Arrangement = Terminal.Gui.ViewArrangement.Fixed; this.tbOffset.CanFocus = true; @@ -197,8 +202,8 @@ private void InitializeComponent() { this.Add(this.tbOffset); this.btnOk.Width = 8; this.btnOk.Height = Dim.Auto(); - this.btnOk.X = 11; - this.btnOk.Y = 9; + this.btnOk.X = 14; + this.btnOk.Y = 11; this.btnOk.Visible = true; this.btnOk.Arrangement = Terminal.Gui.ViewArrangement.Fixed; this.btnOk.CanFocus = true; @@ -210,8 +215,8 @@ private void InitializeComponent() { this.Add(this.btnOk); this.btnCancel.Width = 10; this.btnCancel.Height = Dim.Auto(); - this.btnCancel.X = 21; - this.btnCancel.Y = 9; + this.btnCancel.X = 23; + this.btnCancel.Y = 11; this.btnCancel.Visible = true; this.btnCancel.Arrangement = Terminal.Gui.ViewArrangement.Fixed; this.btnCancel.CanFocus = true; diff --git a/src/UI/Windows/PosEditor.cs b/src/UI/Windows/PosEditor.cs index 0304f1fe..63521b9e 100644 --- a/src/UI/Windows/PosEditor.cs +++ b/src/UI/Windows/PosEditor.cs @@ -23,6 +23,7 @@ namespace TerminalGuiDesigner.UI.Windows; public partial class PosEditor : Dialog, IValueGetterDialog { private Design design; + private readonly Dictionary<string, Design> _siblings; /// <summary> /// Users configured <see cref="Pos"/> (assembled from radio button @@ -57,13 +58,18 @@ public PosEditor(Design design, Pos oldValue) { Cancelled = true; Modal = true; - var siblings = design.GetSiblings().ToListObs(); + _siblings = design.GetSiblings().ToDictionary( + d=>d.FieldName, + d=>d); - ddRelativeTo.SetSource(siblings); - ddSide.SetSource(Enum.GetValues(typeof(Side)).Cast<Enum>().ToListObs()); + tbRelativeTo.Autocomplete.SuggestionGenerator = new SingleWordSuggestionGenerator() + { + AllSuggestions = _siblings.Keys.OrderBy(a => a).ToList() + }; var val = oldValue; - if(val.GetPosType(siblings,out var type,out var value,out var relativeTo,out var side, out var offset)) + if(val.GetPosType(_siblings.Values.ToList(), + out var type,out var value,out var relativeTo,out var side, out var offset)) { switch(type) { @@ -76,8 +82,8 @@ public PosEditor(Design design, Pos oldValue) { case PosType.Relative: rgPosType.SelectedItem = 2; if(relativeTo != null) - ddRelativeTo.SelectedItem = siblings.IndexOf(relativeTo); - ddSide.SelectedItem = (int)side; + tbRelativeTo.Text = relativeTo.FieldName; + rgSide.SelectedItem = (int)side; break; case PosType.Center: rgPosType.SelectedItem = 3; @@ -120,9 +126,9 @@ private void SetupForCurrentPosType() { case PosType.Percent: lblRelativeTo.Visible = false; - ddRelativeTo.Visible = false; + tbRelativeTo.Visible = false; lblSide.Visible = false; - ddSide.Visible = false; + rgSide.Visible = false; lblValue.Y = 1; lblValue.Visible = true; @@ -138,9 +144,9 @@ private void SetupForCurrentPosType() break; case PosType.Center: lblRelativeTo.Visible = false; - ddRelativeTo.Visible = false; + tbRelativeTo.Visible = false; lblSide.Visible = false; - ddSide.Visible = false; + rgSide.Visible = false; lblValue.Visible = false; tbValue.Visible = false; @@ -154,10 +160,10 @@ private void SetupForCurrentPosType() break; case PosType.Absolute: case PosType.AnchorEnd: - ddRelativeTo.Visible = false; + tbRelativeTo.Visible = false; lblRelativeTo.Visible = false; lblSide.Visible = false; - ddSide.Visible = false; + rgSide.Visible = false; lblValue.Y = 1; lblValue.Visible = true; @@ -170,23 +176,23 @@ private void SetupForCurrentPosType() case PosType.Relative: lblRelativeTo.Y = 1; lblRelativeTo.Visible = true; - ddRelativeTo.Y = 1; - ddRelativeTo.Visible = true; + tbRelativeTo.Y = 1; + tbRelativeTo.Visible = true; lblSide.Y = 3; lblSide.Visible = true; - ddSide.IsInitialized = false; - ddSide.Y = 3; - ddSide.Visible = true; - ddSide.IsInitialized = true; + rgSide.IsInitialized = false; + rgSide.Y = 3; + rgSide.Visible = true; + rgSide.IsInitialized = true; lblValue.Visible = false; tbValue.Visible = false; - lblOffset.Y = 5; + lblOffset.Y = 7; lblOffset.Visible = true; - tbOffset.Y = 5; + tbOffset.Y = 7; tbOffset.Visible = true; SetNeedsDraw(); break; @@ -249,7 +255,7 @@ private PosType GetPosType() private Side? GetSide() { - return ddSide.SelectedItem == -1 ? null : (Side)ddSide.Source.ToList()[ddSide.SelectedItem]; + return rgSide.SelectedItem == -1 ? null : (Side)rgSide.SelectedItem; } private bool GetOffset(out int offset) @@ -274,7 +280,9 @@ private bool GetOffset(out int offset) private bool BuildPosRelative(out Pos result) { - var relativeTo = ddRelativeTo.SelectedItem == -1 ? null : ddRelativeTo.Source.ToList()[ddRelativeTo.SelectedItem] as Design; + var key = tbRelativeTo.Text; + + var relativeTo = (!string.IsNullOrWhiteSpace(key)) && _siblings.TryGetValue(key, out var d) ? d : null; if (relativeTo != null) { diff --git a/src/ViewFactory.cs b/src/ViewFactory.cs index 264c977e..7fa4f890 100644 --- a/src/ViewFactory.cs +++ b/src/ViewFactory.cs @@ -53,7 +53,10 @@ public static class ViewFactory typeof(Menuv2), typeof(ScrollBar), typeof(ScrollSlider), - typeof(TileView) + typeof(TileView), + + // Terminal.Gui combo boxes do not really work properly + typeof(ComboBox) ]; /// <summary> From ff3107509717556cbd442eb6ede19cf54b2c17f5 Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Sat, 15 Mar 2025 19:54:30 +0000 Subject: [PATCH 45/54] Give all editors nice bold obvious colors --- src/UI/Windows/ArrayEditor.Designer.cs | 14 +++++++++++ src/UI/Windows/ColorPicker.Designer.cs | 3 +++ src/UI/Windows/ColorSchemeEditor.Designer.cs | 18 +++++++++++-- src/UI/Windows/DimEditor.Designer.cs | 14 +++++++++-- src/UI/Windows/LoadingDialog.Designer.cs | 9 ++++++- src/UI/Windows/PointEditor.Designer.cs | 12 +++++++-- src/UI/Windows/PosEditor.Designer.cs | 14 +++++++++-- src/UI/Windows/SizeEditor.Designer.cs | 15 ++++++++--- src/UI/Windows/SizeEditor.cs | 1 + src/UI/Windows/SliderOptionEditor.Designer.cs | 25 +++++++++++++++++++ 10 files changed, 113 insertions(+), 12 deletions(-) diff --git a/src/UI/Windows/ArrayEditor.Designer.cs b/src/UI/Windows/ArrayEditor.Designer.cs index 4e015ccf..0d82ce29 100644 --- a/src/UI/Windows/ArrayEditor.Designer.cs +++ b/src/UI/Windows/ArrayEditor.Designer.cs @@ -19,6 +19,10 @@ namespace TerminalGuiDesigner.UI.Windows { public partial class ArrayEditor : Terminal.Gui.Dialog { + private Terminal.Gui.ColorScheme dialogBackground; + + private Terminal.Gui.ColorScheme buttons; + private Terminal.Gui.FrameView frameView; private Terminal.Gui.ListView lvElements; @@ -50,12 +54,15 @@ private void InitializeComponent() { this.btnAddElement = new Terminal.Gui.Button(); this.lvElements = new Terminal.Gui.ListView(); this.frameView = new Terminal.Gui.FrameView(); + this.dialogBackground = new Terminal.Gui.ColorScheme(new Terminal.Gui.Attribute(4294967295u, 4285953654u), new Terminal.Gui.Attribute(4294967295u, 4285953654u), new Terminal.Gui.Attribute(4294967295u, 4285953654u), new Terminal.Gui.Attribute(4278190080u, 4278190080u), new Terminal.Gui.Attribute(4294967295u, 4285953654u)); + this.buttons = new Terminal.Gui.ColorScheme(new Terminal.Gui.Attribute(4285953654u, 4294967295u), new Terminal.Gui.Attribute(4294901760u, 4294967040u), new Terminal.Gui.Attribute(4278190080u, 4294967295u), new Terminal.Gui.Attribute(4278190080u, 4278190080u), new Terminal.Gui.Attribute(4278190080u, 4294967040u)); this.Width = Dim.Percent(85); this.Height = Dim.Percent(85); this.X = Pos.Center(); this.Y = Pos.Center(); this.Visible = true; this.Arrangement = (Terminal.Gui.ViewArrangement.Movable | Terminal.Gui.ViewArrangement.Overlapped); + this.ColorScheme = this.dialogBackground; this.CanFocus = true; this.ShadowStyle = Terminal.Gui.ShadowStyle.Transparent; this.Modal = true; @@ -96,6 +103,7 @@ private void InitializeComponent() { this.btnAddElement.Y = Pos.AnchorEnd(5); this.btnAddElement.Visible = true; this.btnAddElement.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnAddElement.ColorScheme = this.buttons; this.btnAddElement.CanFocus = true; this.btnAddElement.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; this.btnAddElement.Data = "btnAddElement"; @@ -109,6 +117,7 @@ private void InitializeComponent() { this.btnDelete.Y = Pos.AnchorEnd(5); this.btnDelete.Visible = true; this.btnDelete.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnDelete.ColorScheme = this.buttons; this.btnDelete.CanFocus = true; this.btnDelete.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; this.btnDelete.Data = "btnDelete"; @@ -122,6 +131,7 @@ private void InitializeComponent() { this.btnMoveUp.Y = Pos.AnchorEnd(5); this.btnMoveUp.Visible = true; this.btnMoveUp.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnMoveUp.ColorScheme = this.buttons; this.btnMoveUp.CanFocus = true; this.btnMoveUp.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; this.btnMoveUp.Data = "btnMoveUp"; @@ -135,6 +145,7 @@ private void InitializeComponent() { this.btnMoveDown.Y = Pos.AnchorEnd(5); this.btnMoveDown.Visible = true; this.btnMoveDown.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnMoveDown.ColorScheme = this.buttons; this.btnMoveDown.CanFocus = true; this.btnMoveDown.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; this.btnMoveDown.Data = "btnMoveDown"; @@ -148,6 +159,7 @@ private void InitializeComponent() { this.btnEdit.Y = Pos.AnchorEnd(5); this.btnEdit.Visible = true; this.btnEdit.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnEdit.ColorScheme = this.buttons; this.btnEdit.CanFocus = true; this.btnEdit.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; this.btnEdit.Data = "btnEdit"; @@ -174,6 +186,7 @@ private void InitializeComponent() { this.btnOk.Y = Pos.AnchorEnd(2); this.btnOk.Visible = true; this.btnOk.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnOk.ColorScheme = this.buttons; this.btnOk.CanFocus = true; this.btnOk.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; this.btnOk.Data = "btnOk"; @@ -187,6 +200,7 @@ private void InitializeComponent() { this.btnCancel.Y = Pos.AnchorEnd(2); this.btnCancel.Visible = true; this.btnCancel.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnCancel.ColorScheme = this.buttons; this.btnCancel.CanFocus = true; this.btnCancel.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; this.btnCancel.Data = "btnCancel"; diff --git a/src/UI/Windows/ColorPicker.Designer.cs b/src/UI/Windows/ColorPicker.Designer.cs index 12a7f890..9e930ffb 100644 --- a/src/UI/Windows/ColorPicker.Designer.cs +++ b/src/UI/Windows/ColorPicker.Designer.cs @@ -56,6 +56,7 @@ private void InitializeComponent() { this.Y = Pos.Center(); this.Visible = true; this.Arrangement = Terminal.Gui.ViewArrangement.Movable; + this.ColorScheme = this.dialogBackground; this.CanFocus = true; this.ShadowStyle = Terminal.Gui.ShadowStyle.Transparent; this.Modal = true; @@ -147,6 +148,7 @@ private void InitializeComponent() { this.btnOk.Y = 14; this.btnOk.Visible = true; this.btnOk.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnOk.ColorScheme = this.buttons; this.btnOk.CanFocus = true; this.btnOk.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; this.btnOk.Data = "btnOk"; @@ -160,6 +162,7 @@ private void InitializeComponent() { this.btnCancel.Y = 14; this.btnCancel.Visible = true; this.btnCancel.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnCancel.ColorScheme = this.buttons; this.btnCancel.CanFocus = true; this.btnCancel.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; this.btnCancel.Data = "btnCancel"; diff --git a/src/UI/Windows/ColorSchemeEditor.Designer.cs b/src/UI/Windows/ColorSchemeEditor.Designer.cs index deb5b3a2..2745ddba 100644 --- a/src/UI/Windows/ColorSchemeEditor.Designer.cs +++ b/src/UI/Windows/ColorSchemeEditor.Designer.cs @@ -19,6 +19,10 @@ namespace TerminalGuiDesigner.UI.Windows { public partial class ColorSchemeEditor : Terminal.Gui.Dialog { + private Terminal.Gui.ColorScheme dialogBackground; + + private Terminal.Gui.ColorScheme buttons; + private Terminal.Gui.Label label2; private Terminal.Gui.Label lblForegroundNormal; @@ -101,12 +105,15 @@ private void InitializeComponent() { this.label1 = new Terminal.Gui.Label(); this.lblForegroundNormal = new Terminal.Gui.Label(); this.label2 = new Terminal.Gui.Label(); + this.dialogBackground = new Terminal.Gui.ColorScheme(new Terminal.Gui.Attribute(4294967295u, 4285953654u), new Terminal.Gui.Attribute(4294967295u, 4285953654u), new Terminal.Gui.Attribute(4294967295u, 4285953654u), new Terminal.Gui.Attribute(4278190080u, 4278190080u), new Terminal.Gui.Attribute(4294967295u, 4285953654u)); + this.buttons = new Terminal.Gui.ColorScheme(new Terminal.Gui.Attribute(4285953654u, 4294967295u), new Terminal.Gui.Attribute(4294901760u, 4294967040u), new Terminal.Gui.Attribute(4278190080u, 4294967295u), new Terminal.Gui.Attribute(4278190080u, 4278190080u), new Terminal.Gui.Attribute(4278190080u, 4294967040u)); this.Width = 31; this.Height = 11; this.X = Pos.Center(); this.Y = Pos.Center(); this.Visible = true; this.Arrangement = (Terminal.Gui.ViewArrangement.Movable | Terminal.Gui.ViewArrangement.Overlapped); + this.ColorScheme = this.dialogBackground; this.CanFocus = true; this.ShadowStyle = Terminal.Gui.ShadowStyle.Transparent; this.Modal = true; @@ -166,6 +173,7 @@ private void InitializeComponent() { this.btnEditNormal.Y = 0; this.btnEditNormal.Visible = true; this.btnEditNormal.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnEditNormal.ColorScheme = this.buttons; this.btnEditNormal.CanFocus = true; this.btnEditNormal.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.btnEditNormal.Data = "btnEditNormal"; @@ -227,6 +235,7 @@ private void InitializeComponent() { this.btnEditHotNormal.Y = 1; this.btnEditHotNormal.Visible = true; this.btnEditHotNormal.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnEditHotNormal.ColorScheme = this.buttons; this.btnEditHotNormal.CanFocus = true; this.btnEditHotNormal.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.btnEditHotNormal.Data = "btnEditHotNormal"; @@ -288,6 +297,7 @@ private void InitializeComponent() { this.btnEditFocus.Y = 2; this.btnEditFocus.Visible = true; this.btnEditFocus.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnEditFocus.ColorScheme = this.buttons; this.btnEditFocus.CanFocus = true; this.btnEditFocus.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.btnEditFocus.Data = "btnEditFocus"; @@ -349,6 +359,7 @@ private void InitializeComponent() { this.btnEditHotFocus.Y = 3; this.btnEditHotFocus.Visible = true; this.btnEditHotFocus.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnEditHotFocus.ColorScheme = this.buttons; this.btnEditHotFocus.CanFocus = true; this.btnEditHotFocus.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.btnEditHotFocus.Data = "btnEditHotFocus"; @@ -410,6 +421,7 @@ private void InitializeComponent() { this.btnEditDisabled.Y = 4; this.btnEditDisabled.Visible = true; this.btnEditDisabled.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnEditDisabled.ColorScheme = this.buttons; this.btnEditDisabled.CanFocus = true; this.btnEditDisabled.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.btnEditDisabled.Data = "btnEditDisabled"; @@ -417,12 +429,13 @@ private void InitializeComponent() { this.btnEditDisabled.TextAlignment = Terminal.Gui.Alignment.Center; this.btnEditDisabled.IsDefault = false; this.Add(this.btnEditDisabled); - this.btnOk.Width = 6; + this.btnOk.Width = Dim.Auto(); this.btnOk.Height = Dim.Auto(); this.btnOk.X = 3; this.btnOk.Y = 6; this.btnOk.Visible = true; this.btnOk.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnOk.ColorScheme = this.buttons; this.btnOk.CanFocus = true; this.btnOk.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; this.btnOk.Data = "btnOk"; @@ -430,12 +443,13 @@ private void InitializeComponent() { this.btnOk.TextAlignment = Terminal.Gui.Alignment.Center; this.btnOk.IsDefault = false; this.Add(this.btnOk); - this.btnCancel.Width = 10; + this.btnCancel.Width = Dim.Auto(); this.btnCancel.Height = Dim.Auto(); this.btnCancel.X = 13; this.btnCancel.Y = 6; this.btnCancel.Visible = true; this.btnCancel.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnCancel.ColorScheme = this.buttons; this.btnCancel.CanFocus = true; this.btnCancel.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; this.btnCancel.Data = "btnCancel"; diff --git a/src/UI/Windows/DimEditor.Designer.cs b/src/UI/Windows/DimEditor.Designer.cs index cec4943a..e9ef9369 100644 --- a/src/UI/Windows/DimEditor.Designer.cs +++ b/src/UI/Windows/DimEditor.Designer.cs @@ -19,6 +19,10 @@ namespace TerminalGuiDesigner.UI.Windows { public partial class DimEditor : Terminal.Gui.Dialog { + private Terminal.Gui.ColorScheme dialogBackground; + + private Terminal.Gui.ColorScheme buttons; + private Terminal.Gui.RadioGroup rgDimType; private Terminal.Gui.LineView lineview1; @@ -44,12 +48,15 @@ private void InitializeComponent() { this.lblValue = new Terminal.Gui.Label(); this.lineview1 = new Terminal.Gui.LineView(); this.rgDimType = new Terminal.Gui.RadioGroup(); + this.dialogBackground = new Terminal.Gui.ColorScheme(new Terminal.Gui.Attribute(4294967295u, 4285953654u), new Terminal.Gui.Attribute(4294967295u, 4285953654u), new Terminal.Gui.Attribute(4294967295u, 4285953654u), new Terminal.Gui.Attribute(4278190080u, 4278190080u), new Terminal.Gui.Attribute(4294967295u, 4285953654u)); + this.buttons = new Terminal.Gui.ColorScheme(new Terminal.Gui.Attribute(4285953654u, 4294967295u), new Terminal.Gui.Attribute(4294901760u, 4294967040u), new Terminal.Gui.Attribute(4278190080u, 4294967295u), new Terminal.Gui.Attribute(4278190080u, 4278190080u), new Terminal.Gui.Attribute(4278190080u, 4294967040u)); this.Width = 40; this.Height = 11; this.X = Pos.Center(); this.Y = Pos.Center(); this.Visible = true; this.Arrangement = Terminal.Gui.ViewArrangement.Movable; + this.ColorScheme = this.dialogBackground; this.CanFocus = true; this.ShadowStyle = Terminal.Gui.ShadowStyle.Transparent; this.Modal = true; @@ -61,6 +68,7 @@ private void InitializeComponent() { this.rgDimType.Y = 1; this.rgDimType.Visible = true; this.rgDimType.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.rgDimType.ColorScheme = this.buttons; this.rgDimType.CanFocus = true; this.rgDimType.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.rgDimType.Data = "rgDimType"; @@ -134,12 +142,13 @@ private void InitializeComponent() { this.tbOffset.Text = ""; this.tbOffset.TextAlignment = Terminal.Gui.Alignment.Start; this.Add(this.tbOffset); - this.btnOk.Width = 8; + this.btnOk.Width = Dim.Auto(); this.btnOk.Height = Dim.Auto(); this.btnOk.X = 5; this.btnOk.Y = 6; this.btnOk.Visible = true; this.btnOk.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnOk.ColorScheme = this.buttons; this.btnOk.CanFocus = true; this.btnOk.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; this.btnOk.Data = "btnOk"; @@ -147,12 +156,13 @@ private void InitializeComponent() { this.btnOk.TextAlignment = Terminal.Gui.Alignment.Center; this.btnOk.IsDefault = true; this.Add(this.btnOk); - this.btnCancel.Width = 10; + this.btnCancel.Width = Dim.Auto(); this.btnCancel.Height = Dim.Auto(); this.btnCancel.X = 16; this.btnCancel.Y = 6; this.btnCancel.Visible = true; this.btnCancel.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnCancel.ColorScheme = this.buttons; this.btnCancel.CanFocus = true; this.btnCancel.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; this.btnCancel.Data = "btnCancel"; diff --git a/src/UI/Windows/LoadingDialog.Designer.cs b/src/UI/Windows/LoadingDialog.Designer.cs index 6812f777..ec05bb8c 100644 --- a/src/UI/Windows/LoadingDialog.Designer.cs +++ b/src/UI/Windows/LoadingDialog.Designer.cs @@ -20,7 +20,11 @@ namespace TerminalGuiDesigner { public partial class LoadingDialog : Terminal.Gui.Dialog { private Terminal.Gui.Label lblLoading; - + + private Terminal.Gui.ColorScheme dialogBackground; + + private Terminal.Gui.ColorScheme buttons; + private void InitializeComponent() { this.lblLoading = new Terminal.Gui.Label(); this.Width = 40; @@ -28,6 +32,9 @@ private void InitializeComponent() { this.X = Pos.Center(); this.Y = Pos.Center(); this.Visible = true; + this.dialogBackground = new Terminal.Gui.ColorScheme(new Terminal.Gui.Attribute(4294967295u, 4285953654u), new Terminal.Gui.Attribute(4294967295u, 4285953654u), new Terminal.Gui.Attribute(4294967295u, 4285953654u), new Terminal.Gui.Attribute(4278190080u, 4278190080u), new Terminal.Gui.Attribute(4294967295u, 4285953654u)); + this.buttons = new Terminal.Gui.ColorScheme(new Terminal.Gui.Attribute(4285953654u, 4294967295u), new Terminal.Gui.Attribute(4294901760u, 4294967040u), new Terminal.Gui.Attribute(4278190080u, 4294967295u), new Terminal.Gui.Attribute(4278190080u, 4278190080u), new Terminal.Gui.Attribute(4278190080u, 4294967040u)); + this.ColorScheme = this.dialogBackground; this.Arrangement = (Terminal.Gui.ViewArrangement.Movable | Terminal.Gui.ViewArrangement.Overlapped); this.CanFocus = true; this.ShadowStyle = Terminal.Gui.ShadowStyle.Transparent; diff --git a/src/UI/Windows/PointEditor.Designer.cs b/src/UI/Windows/PointEditor.Designer.cs index c51605db..d91cb286 100644 --- a/src/UI/Windows/PointEditor.Designer.cs +++ b/src/UI/Windows/PointEditor.Designer.cs @@ -19,6 +19,10 @@ namespace TerminalGuiDesigner { public partial class PointEditor : Terminal.Gui.Dialog { + private Terminal.Gui.ColorScheme dialogBackground; + + private Terminal.Gui.ColorScheme buttons; + private Terminal.Gui.Label lblX; private Terminal.Gui.TextField tbX; @@ -38,12 +42,15 @@ private void InitializeComponent() { this.lblY = new Terminal.Gui.Label(); this.tbX = new Terminal.Gui.TextField(); this.lblX = new Terminal.Gui.Label(); - this.Width = 23; + this.dialogBackground = new Terminal.Gui.ColorScheme(new Terminal.Gui.Attribute(4294967295u, 4285953654u), new Terminal.Gui.Attribute(4294967295u, 4285953654u), new Terminal.Gui.Attribute(4294967295u, 4285953654u), new Terminal.Gui.Attribute(4278190080u, 4278190080u), new Terminal.Gui.Attribute(4294967295u, 4285953654u)); + this.buttons = new Terminal.Gui.ColorScheme(new Terminal.Gui.Attribute(4285953654u, 4294967295u), new Terminal.Gui.Attribute(4294901760u, 4294967040u), new Terminal.Gui.Attribute(4278190080u, 4294967295u), new Terminal.Gui.Attribute(4278190080u, 4278190080u), new Terminal.Gui.Attribute(4278190080u, 4294967040u)); + this.Width = 25; this.Height = 10; this.X = Pos.Center(); this.Y = Pos.Center(); this.Visible = true; this.Arrangement = (Terminal.Gui.ViewArrangement.Movable | Terminal.Gui.ViewArrangement.Overlapped); + this.ColorScheme = this.dialogBackground; this.CanFocus = true; this.ShadowStyle = Terminal.Gui.ShadowStyle.Transparent; this.Modal = true; @@ -112,12 +119,13 @@ private void InitializeComponent() { this.btnOk.TextAlignment = Terminal.Gui.Alignment.Center; this.btnOk.IsDefault = true; this.Add(this.btnOk); - this.btnCancel.Width = 10; + this.btnCancel.Width = Dim.Auto(); this.btnCancel.Height = Dim.Auto(); this.btnCancel.X = 10; this.btnCancel.Y = 5; this.btnCancel.Visible = true; this.btnCancel.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnCancel.ColorScheme = this.dialogBackground; this.btnCancel.CanFocus = true; this.btnCancel.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; this.btnCancel.Data = "btnCancel"; diff --git a/src/UI/Windows/PosEditor.Designer.cs b/src/UI/Windows/PosEditor.Designer.cs index 5b5c07aa..09042998 100644 --- a/src/UI/Windows/PosEditor.Designer.cs +++ b/src/UI/Windows/PosEditor.Designer.cs @@ -19,6 +19,10 @@ namespace TerminalGuiDesigner.UI.Windows { public partial class PosEditor : Terminal.Gui.Dialog { + private Terminal.Gui.ColorScheme dialogBackground; + + private Terminal.Gui.ColorScheme buttons; + private Terminal.Gui.RadioGroup rgPosType; private Terminal.Gui.LineView lineview1; @@ -56,12 +60,15 @@ private void InitializeComponent() { this.lblValue = new Terminal.Gui.Label(); this.lineview1 = new Terminal.Gui.LineView(); this.rgPosType = new Terminal.Gui.RadioGroup(); + this.dialogBackground = new Terminal.Gui.ColorScheme(new Terminal.Gui.Attribute(4294967295u, 4285953654u), new Terminal.Gui.Attribute(4294967295u, 4285953654u), new Terminal.Gui.Attribute(4294967295u, 4285953654u), new Terminal.Gui.Attribute(4278190080u, 4278190080u), new Terminal.Gui.Attribute(4294967295u, 4285953654u)); + this.buttons = new Terminal.Gui.ColorScheme(new Terminal.Gui.Attribute(4285953654u, 4294967295u), new Terminal.Gui.Attribute(4294901760u, 4294967040u), new Terminal.Gui.Attribute(4278190080u, 4294967295u), new Terminal.Gui.Attribute(4278190080u, 4278190080u), new Terminal.Gui.Attribute(4278190080u, 4294967040u)); this.Width = 47; this.Height = 16; this.X = Pos.Center(); this.Y = Pos.Center(); this.Visible = true; this.Arrangement = (Terminal.Gui.ViewArrangement.Movable | Terminal.Gui.ViewArrangement.Overlapped); + this.ColorScheme = this.dialogBackground; this.CanFocus = true; this.ShadowStyle = Terminal.Gui.ShadowStyle.Transparent; this.Modal = true; @@ -73,6 +80,7 @@ private void InitializeComponent() { this.rgPosType.Y = 1; this.rgPosType.Visible = true; this.rgPosType.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.rgPosType.ColorScheme = this.buttons; this.rgPosType.CanFocus = true; this.rgPosType.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.rgPosType.Data = "rgPosType"; @@ -200,12 +208,13 @@ private void InitializeComponent() { this.tbOffset.Text = ""; this.tbOffset.TextAlignment = Terminal.Gui.Alignment.Start; this.Add(this.tbOffset); - this.btnOk.Width = 8; + this.btnOk.Width = Dim.Auto(); this.btnOk.Height = Dim.Auto(); this.btnOk.X = 14; this.btnOk.Y = 11; this.btnOk.Visible = true; this.btnOk.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnOk.ColorScheme = this.buttons; this.btnOk.CanFocus = true; this.btnOk.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; this.btnOk.Data = "btnOk"; @@ -213,12 +222,13 @@ private void InitializeComponent() { this.btnOk.TextAlignment = Terminal.Gui.Alignment.Center; this.btnOk.IsDefault = true; this.Add(this.btnOk); - this.btnCancel.Width = 10; + this.btnCancel.Width = Dim.Auto(); this.btnCancel.Height = Dim.Auto(); this.btnCancel.X = 23; this.btnCancel.Y = 11; this.btnCancel.Visible = true; this.btnCancel.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnCancel.ColorScheme = this.buttons; this.btnCancel.CanFocus = true; this.btnCancel.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; this.btnCancel.Data = "btnCancel"; diff --git a/src/UI/Windows/SizeEditor.Designer.cs b/src/UI/Windows/SizeEditor.Designer.cs index b11f5414..9a0eae50 100644 --- a/src/UI/Windows/SizeEditor.Designer.cs +++ b/src/UI/Windows/SizeEditor.Designer.cs @@ -19,6 +19,10 @@ namespace TerminalGuiDesigner.UI.Windows { public partial class SizeEditor : Terminal.Gui.Dialog { + private Terminal.Gui.ColorScheme dialogBackground; + + private Terminal.Gui.ColorScheme buttons; + private Terminal.Gui.Label label1; private Terminal.Gui.TextField tfWidth; @@ -38,12 +42,15 @@ private void InitializeComponent() { this.label12 = new Terminal.Gui.Label(); this.tfWidth = new Terminal.Gui.TextField(); this.label1 = new Terminal.Gui.Label(); - this.Width = 20; + this.dialogBackground = new Terminal.Gui.ColorScheme(new Terminal.Gui.Attribute(4294967295u, 4285953654u), new Terminal.Gui.Attribute(4294967295u, 4285953654u), new Terminal.Gui.Attribute(4294967295u, 4285953654u), new Terminal.Gui.Attribute(4278190080u, 4278190080u), new Terminal.Gui.Attribute(4294967295u, 4285953654u)); + this.buttons = new Terminal.Gui.ColorScheme(new Terminal.Gui.Attribute(4285953654u, 4294967295u), new Terminal.Gui.Attribute(4294901760u, 4294967040u), new Terminal.Gui.Attribute(4278190080u, 4294967295u), new Terminal.Gui.Attribute(4278190080u, 4278190080u), new Terminal.Gui.Attribute(4278190080u, 4294967040u)); + this.Width = 21; this.Height = 9; this.X = Pos.Center(); this.Y = Pos.Center(); this.Visible = true; this.Arrangement = (Terminal.Gui.ViewArrangement.Movable | Terminal.Gui.ViewArrangement.Overlapped); + this.ColorScheme = this.dialogBackground; this.CanFocus = true; this.ShadowStyle = Terminal.Gui.ShadowStyle.Transparent; this.Modal = true; @@ -99,12 +106,13 @@ private void InitializeComponent() { this.tfHeight.Text = ""; this.tfHeight.TextAlignment = Terminal.Gui.Alignment.Start; this.Add(this.tfHeight); - this.btnOk.Width = 6; + this.btnOk.Width = Dim.Auto(); this.btnOk.Height = Dim.Auto(); this.btnOk.X = 0; this.btnOk.Y = 4; this.btnOk.Visible = true; this.btnOk.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnOk.ColorScheme = this.buttons; this.btnOk.CanFocus = true; this.btnOk.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; this.btnOk.Data = "btnOk"; @@ -112,12 +120,13 @@ private void InitializeComponent() { this.btnOk.TextAlignment = Terminal.Gui.Alignment.Center; this.btnOk.IsDefault = false; this.Add(this.btnOk); - this.btnCancel.Width = 10; + this.btnCancel.Width = Dim.Auto(); this.btnCancel.Height = Dim.Auto(); this.btnCancel.X = 8; this.btnCancel.Y = 4; this.btnCancel.Visible = true; this.btnCancel.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnCancel.ColorScheme = this.buttons; this.btnCancel.CanFocus = true; this.btnCancel.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; this.btnCancel.Data = "btnCancel"; diff --git a/src/UI/Windows/SizeEditor.cs b/src/UI/Windows/SizeEditor.cs index 45149abf..7bc50092 100644 --- a/src/UI/Windows/SizeEditor.cs +++ b/src/UI/Windows/SizeEditor.cs @@ -17,6 +17,7 @@ namespace TerminalGuiDesigner.UI.Windows; public partial class SizeEditor : IValueGetterDialog { + /// <summary> /// The users edited <see cref="Size"/> /// </summary> diff --git a/src/UI/Windows/SliderOptionEditor.Designer.cs b/src/UI/Windows/SliderOptionEditor.Designer.cs index 1b18bd3f..6cf3d934 100644 --- a/src/UI/Windows/SliderOptionEditor.Designer.cs +++ b/src/UI/Windows/SliderOptionEditor.Designer.cs @@ -19,6 +19,10 @@ namespace TerminalGuiDesigner.UI.Windows { public partial class SliderOptionEditor : Terminal.Gui.Dialog { + private Terminal.Gui.ColorScheme dialogBackground; + + private Terminal.Gui.ColorScheme buttons; + private Terminal.Gui.ColorScheme redOnBlack; private Terminal.Gui.ColorScheme tgDefault; @@ -54,6 +58,8 @@ private void InitializeComponent() { this.label2 = new Terminal.Gui.Label(); this.tfLegend = new Terminal.Gui.TextField(); this.label = new Terminal.Gui.Label(); + this.dialogBackground = new Terminal.Gui.ColorScheme(new Terminal.Gui.Attribute(4294967295u, 4285953654u), new Terminal.Gui.Attribute(4294967295u, 4285953654u), new Terminal.Gui.Attribute(4294967295u, 4285953654u), new Terminal.Gui.Attribute(4278190080u, 4278190080u), new Terminal.Gui.Attribute(4294967295u, 4285953654u)); + this.buttons = new Terminal.Gui.ColorScheme(new Terminal.Gui.Attribute(4285953654u, 4294967295u), new Terminal.Gui.Attribute(4294901760u, 4294967040u), new Terminal.Gui.Attribute(4278190080u, 4294967295u), new Terminal.Gui.Attribute(4278190080u, 4278190080u), new Terminal.Gui.Attribute(4278190080u, 4294967040u)); this.redOnBlack = new Terminal.Gui.ColorScheme(new Terminal.Gui.Attribute(4291104543u, 4278979596u), new Terminal.Gui.Attribute(4291104543u, 4286595104u), new Terminal.Gui.Attribute(4293347414u, 4278979596u), new Terminal.Gui.Attribute(4291611852u, 4278979596u), new Terminal.Gui.Attribute(4293347414u, 4286595104u)); this.tgDefault = new Terminal.Gui.ColorScheme(new Terminal.Gui.Attribute(4294111986u, 4278204378u), new Terminal.Gui.Attribute(4278979596u, 4291611852u), new Terminal.Gui.Attribute(4284602070u, 4278204378u), new Terminal.Gui.Attribute(4286595104u, 4278204378u), new Terminal.Gui.Attribute(4282087679u, 4291611852u)); this.Width = 50; @@ -62,6 +68,9 @@ private void InitializeComponent() { this.Y = Pos.Center(); this.Visible = true; this.Arrangement = Terminal.Gui.ViewArrangement.Movable; + this.ColorScheme = this.dialogBackground; + this.CanFocus = true; + this.ShadowStyle = Terminal.Gui.ShadowStyle.Transparent; this.Modal = true; this.TextAlignment = Terminal.Gui.Alignment.Start; this.Title = "OptionEditor"; @@ -71,6 +80,8 @@ private void InitializeComponent() { this.label.Y = 0; this.label.Visible = true; this.label.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.label.CanFocus = false; + this.label.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.label.Data = "label"; this.label.Text = "Legend:"; this.label.TextAlignment = Terminal.Gui.Alignment.Start; @@ -81,6 +92,8 @@ private void InitializeComponent() { this.tfLegend.Y = 0; this.tfLegend.Visible = true; this.tfLegend.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.tfLegend.CanFocus = true; + this.tfLegend.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.tfLegend.Secret = false; this.tfLegend.Data = "tfLegend"; this.tfLegend.Text = ""; @@ -92,6 +105,8 @@ private void InitializeComponent() { this.label2.Y = 1; this.label2.Visible = true; this.label2.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.label2.CanFocus = false; + this.label2.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.label2.Data = "label2"; this.label2.Text = "Abbreviation:"; this.label2.TextAlignment = Terminal.Gui.Alignment.Start; @@ -102,6 +117,8 @@ private void InitializeComponent() { this.tfLegendAbbr.Y = 1; this.tfLegendAbbr.Visible = true; this.tfLegendAbbr.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.tfLegendAbbr.CanFocus = true; + this.tfLegendAbbr.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.tfLegendAbbr.Secret = false; this.tfLegendAbbr.Data = "tfLegendAbbr"; this.tfLegendAbbr.Text = ""; @@ -113,6 +130,8 @@ private void InitializeComponent() { this.lblOneChar.Y = 2; this.lblOneChar.Visible = true; this.lblOneChar.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.lblOneChar.CanFocus = false; + this.lblOneChar.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.lblOneChar.Data = "lblOneChar"; this.lblOneChar.Text = "(Single Char) "; this.lblOneChar.TextAlignment = Terminal.Gui.Alignment.Center; @@ -123,6 +142,8 @@ private void InitializeComponent() { this.label3.Y = 3; this.label3.Visible = true; this.label3.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.label3.CanFocus = false; + this.label3.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.label3.Data = "label3"; this.label3.Text = "Data:"; this.label3.TextAlignment = Terminal.Gui.Alignment.Start; @@ -133,6 +154,8 @@ private void InitializeComponent() { this.tfData.Y = 3; this.tfData.Visible = true; this.tfData.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.tfData.CanFocus = true; + this.tfData.ShadowStyle = Terminal.Gui.ShadowStyle.None; this.tfData.Secret = false; this.tfData.Data = "tfData"; this.tfData.Text = ""; @@ -156,6 +179,7 @@ private void InitializeComponent() { this.btnOk.Y = 5; this.btnOk.Visible = true; this.btnOk.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnOk.ColorScheme = this.buttons; this.btnOk.CanFocus = true; this.btnOk.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; this.btnOk.Data = "btnOk"; @@ -169,6 +193,7 @@ private void InitializeComponent() { this.btnCancel.Y = 5; this.btnCancel.Visible = true; this.btnCancel.Arrangement = Terminal.Gui.ViewArrangement.Fixed; + this.btnCancel.ColorScheme = this.buttons; this.btnCancel.CanFocus = true; this.btnCancel.ShadowStyle = Terminal.Gui.ShadowStyle.Opaque; this.btnCancel.Data = "btnCancel"; From c22c4ef48ae62a030e76365e596d7891016ad7e4 Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Sat, 15 Mar 2025 20:03:28 +0000 Subject: [PATCH 46/54] Make open/save also use obvious color scheme --- src/UI/Editor.cs | 4 +++- src/UI/ValueFactory.cs | 1 + src/UI/Windows/SizeEditor.Designer.cs | 1 - src/ViewExtensions.cs | 22 ++++++++++++++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/UI/Editor.cs b/src/UI/Editor.cs index 34e9fd6f..c8a03175 100644 --- a/src/UI/Editor.cs +++ b/src/UI/Editor.cs @@ -1137,7 +1137,8 @@ private void Open() { Title = "Open", AllowedTypes = new List<IAllowedType>(new[] { new AllowedType("View", SourceCodeFile.ExpectedExtension) }) - }; + }; + ofd.SetupNiceColorSchemes(); Application.Run(ofd, this.ErrorHandler); @@ -1218,6 +1219,7 @@ private void New() AllowedTypes = new List<IAllowedType>() { new AllowedType("C# File", ".cs") }, Path = "MyView.cs", }; + ofd.SetupNiceColorSchemes(); Application.Run(ofd); diff --git a/src/UI/ValueFactory.cs b/src/UI/ValueFactory.cs index a53eeac0..50917f4c 100644 --- a/src/UI/ValueFactory.cs +++ b/src/UI/ValueFactory.cs @@ -191,6 +191,7 @@ internal static bool GetNewValue(string propertyName, Design design, Type type, if (type == typeof(FileSystemInfo)) { var fd = new FileDialog(); + fd.SetupNiceColorSchemes(); fd.AllowsMultipleSelection = false; int answer = ChoicesDialog.Query(propertyName, $"Directory or File?", "Directory", "File", "Cancel"); diff --git a/src/UI/Windows/SizeEditor.Designer.cs b/src/UI/Windows/SizeEditor.Designer.cs index 9a0eae50..bcc9a6c5 100644 --- a/src/UI/Windows/SizeEditor.Designer.cs +++ b/src/UI/Windows/SizeEditor.Designer.cs @@ -34,7 +34,6 @@ public partial class SizeEditor : Terminal.Gui.Dialog { private Terminal.Gui.Button btnOk; private Terminal.Gui.Button btnCancel; - private void InitializeComponent() { this.btnCancel = new Terminal.Gui.Button(); this.btnOk = new Terminal.Gui.Button(); diff --git a/src/ViewExtensions.cs b/src/ViewExtensions.cs index 27c9735b..8f8fb135 100644 --- a/src/ViewExtensions.cs +++ b/src/ViewExtensions.cs @@ -497,4 +497,26 @@ public static bool AnySuperViewIs<T>(this View v) where T : View return null; } + + public static void SetupNiceColorSchemes(this Dialog v) + { + + ColorScheme dialogBackground; + ColorScheme buttons; + dialogBackground = new Terminal.Gui.ColorScheme(new Terminal.Gui.Attribute(4294967295u, 4285953654u), new Terminal.Gui.Attribute(4294967295u, 4285953654u), new Terminal.Gui.Attribute(4294967295u, 4285953654u), new Terminal.Gui.Attribute(4278190080u, 4278190080u), new Terminal.Gui.Attribute(4294967295u, 4285953654u)); + buttons = new Terminal.Gui.ColorScheme(new Terminal.Gui.Attribute(4285953654u, 4294967295u), new Terminal.Gui.Attribute(4294901760u, 4294967040u), new Terminal.Gui.Attribute(4278190080u, 4294967295u), new Terminal.Gui.Attribute(4278190080u, 4278190080u), new Terminal.Gui.Attribute(4278190080u, 4294967040u)); + + v.ColorScheme = dialogBackground; + + void ApplyScheme(View view) + { + if (view is Button or TableView) + view.ColorScheme = buttons; + + foreach (var subView in view.SubViews) + ApplyScheme(subView); + } + + ApplyScheme(v); + } } From 8f6195ef1b3f4c20cc1ee3df58106919179a8c58 Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Sat, 15 Mar 2025 23:44:59 +0000 Subject: [PATCH 47/54] Fix TimeField default size and add launch settings --- src/Properties/launchSettings.json | 13 +++++++++++-- src/ViewFactory.cs | 4 ++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Properties/launchSettings.json b/src/Properties/launchSettings.json index 0ba7ea9b..dc17da51 100644 --- a/src/Properties/launchSettings.json +++ b/src/Properties/launchSettings.json @@ -1,7 +1,16 @@ { "profiles": { - "TerminalGuiDesigner": { - "commandName": "Project" + "WSL": { + "commandName": "WSL2", + "distributionName": "" + }, + "v2net": { + "commandName": "Project", + "commandLineArgs": "-d v2net" + }, + "v2win": { + "commandName": "Project", + "commandLineArgs": "-d v2win" } } } \ No newline at end of file diff --git a/src/ViewFactory.cs b/src/ViewFactory.cs index 7fa4f890..65d06845 100644 --- a/src/ViewFactory.cs +++ b/src/ViewFactory.cs @@ -144,6 +144,9 @@ public static T Create<T>(int? width = null, int? height = null, string? text = switch ( newView ) { + case TimeField: + SetDefaultDimensions(newView, width ?? 9, height ?? 1); + break; case Button: case CheckBox: case ComboBox: @@ -323,6 +326,7 @@ public static View Create( Type requestedType ) return requestedType switch { null => throw new ArgumentNullException( nameof( requestedType ) ), + { } t when t == typeof(TimeField) => Create<TimeField>(), { } t when t == typeof( DateField ) => Create<DateField>( ), { } t when t == typeof( Button ) => Create<Button>( ), { } t when t == typeof( ComboBox ) => Create<ComboBox>( ), From dc5a1a6fab2ecbf9d2ab3e5bead63f782277612b Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Sun, 16 Mar 2025 00:04:31 +0000 Subject: [PATCH 48/54] Fix null references in set StatusBar shortcuts --- .../StatusBarOperations/SetShortcutOperation.cs | 8 ++++---- src/ViewFactory.cs | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Operations/StatusBarOperations/SetShortcutOperation.cs b/src/Operations/StatusBarOperations/SetShortcutOperation.cs index bfc589a4..38cc6608 100644 --- a/src/Operations/StatusBarOperations/SetShortcutOperation.cs +++ b/src/Operations/StatusBarOperations/SetShortcutOperation.cs @@ -11,7 +11,7 @@ namespace TerminalGuiDesigner.Operations.StatusBarOperations public class SetShortcutOperation : GenericArrayElementOperation<StatusBar, Shortcut> { private Key originalShortcut; - private Key? shortcut; + private Key shortcut; /// <summary> /// Initializes a new instance of the <see cref="SetShortcutOperation"/> class. @@ -27,14 +27,14 @@ public SetShortcutOperation(Design design, Shortcut statusItem, Key? shortcut) design, statusItem) { - this.shortcut = shortcut; + this.shortcut = shortcut ?? Key.Empty; this.originalShortcut = statusItem.Key; } /// <inheritdoc/> protected override void RedoImpl() { - if (this.shortcut == null) + if (this.shortcut == Key.Empty) { return; } @@ -51,7 +51,7 @@ protected override void UndoImpl() /// <inheritdoc/> protected override bool DoImpl() { - if (this.shortcut == null) + if (this.shortcut == Key.Empty) { this.shortcut = Modals.GetShortcut(); } diff --git a/src/ViewFactory.cs b/src/ViewFactory.cs index 65d06845..0a82f48e 100644 --- a/src/ViewFactory.cs +++ b/src/ViewFactory.cs @@ -47,7 +47,6 @@ public static class ViewFactory typeof(Shortcut), typeof(Tab), - typeof(Bar), typeof(CharMap), typeof(LegendAnnotation), typeof(Menuv2), From 7223de505763aacb6419f048cac19ac643219126 Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Sun, 16 Mar 2025 00:24:46 +0000 Subject: [PATCH 49/54] Fix drag resize not correct in some situations --- src/UI/Editor.cs | 2 ++ src/UI/ValueFactory.cs | 1 + src/ViewExtensions.cs | 8 +++----- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/UI/Editor.cs b/src/UI/Editor.cs index c8a03175..de16a5a5 100644 --- a/src/UI/Editor.cs +++ b/src/UI/Editor.cs @@ -1139,6 +1139,7 @@ private void Open() AllowedTypes = new List<IAllowedType>(new[] { new AllowedType("View", SourceCodeFile.ExpectedExtension) }) }; ofd.SetupNiceColorSchemes(); + ofd.Layout(); Application.Run(ofd, this.ErrorHandler); @@ -1219,6 +1220,7 @@ private void New() AllowedTypes = new List<IAllowedType>() { new AllowedType("C# File", ".cs") }, Path = "MyView.cs", }; + ofd.Layout(); ofd.SetupNiceColorSchemes(); Application.Run(ofd); diff --git a/src/UI/ValueFactory.cs b/src/UI/ValueFactory.cs index 50917f4c..ce9daa9f 100644 --- a/src/UI/ValueFactory.cs +++ b/src/UI/ValueFactory.cs @@ -193,6 +193,7 @@ internal static bool GetNewValue(string propertyName, Design design, Type type, var fd = new FileDialog(); fd.SetupNiceColorSchemes(); fd.AllowsMultipleSelection = false; + fd.Layout(); int answer = ChoicesDialog.Query(propertyName, $"Directory or File?", "Directory", "File", "Cancel"); diff --git a/src/ViewExtensions.cs b/src/ViewExtensions.cs index 8f8fb135..3690271c 100644 --- a/src/ViewExtensions.cs +++ b/src/ViewExtensions.cs @@ -256,8 +256,6 @@ public static bool IsBorderlessContainerView(this View v) { v.Visible = false; } - - var point = w.ScreenToContent(m.Position); var hit = ViewExtensions.FindDeepestView(m.Position); @@ -269,10 +267,10 @@ public static bool IsBorderlessContainerView(this View v) { var screenFrame = hit.FrameToScreen(); - if (point != new Point(screenFrame.X, screenFrame.Y)) + if (m.Position != new Point(screenFrame.X, screenFrame.Y)) { - isLowerRight = Math.Abs(screenFrame.X + screenFrame.Width - point.X) <= resizeBoxArea - && Math.Abs(screenFrame.Y + screenFrame.Height - point.Y) <= resizeBoxArea; + isLowerRight = Math.Abs(screenFrame.X + screenFrame.Width - m.Position.X) <= resizeBoxArea + && Math.Abs(screenFrame.Y + screenFrame.Height - m.Position.Y) <= resizeBoxArea; } else { From 74212af254000ec656824c5e4a822c8eeb92ab2d Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Sun, 16 Mar 2025 09:41:37 +0000 Subject: [PATCH 50/54] Update to latest nuget package --- Showcase/Showcase.csproj | 2 +- src/TerminalGuiDesigner.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Showcase/Showcase.csproj b/Showcase/Showcase.csproj index 40d4982a..8dcf2590 100644 --- a/Showcase/Showcase.csproj +++ b/Showcase/Showcase.csproj @@ -8,7 +8,7 @@ </PropertyGroup> <ItemGroup> - <PackageReference Include="Terminal.Gui" Version="2.0.0-develop.4372" /> + <PackageReference Include="Terminal.Gui" Version="2.0.0-develop.4373" /> </ItemGroup> </Project> diff --git a/src/TerminalGuiDesigner.csproj b/src/TerminalGuiDesigner.csproj index 16e79971..12dbe8c6 100644 --- a/src/TerminalGuiDesigner.csproj +++ b/src/TerminalGuiDesigner.csproj @@ -151,7 +151,7 @@ <PackageReference Include="Serilog" Version="4.2.0" /> <PackageReference Include="Serilog.Extensions.Logging" Version="9.0.0" /> <PackageReference Include="Serilog.Sinks.File" Version="6.0.0" /> - <PackageReference Include="Terminal.Gui" Version="2.0.0-develop.4372 " /> + <PackageReference Include="Terminal.Gui" Version="2.0.0-develop.4373" /> <PackageReference Include="nlog" Version="5.3.3" /> <PackageReference Include="Basic.Reference.Assemblies.Net80" Version="1.7.7" /> <PackageReference Include="System.CodeDom" Version="8.0.0" /> From 16c077ea5097de74fb87a19dfbf09a4846d6592b Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Mon, 17 Mar 2025 08:26:21 +0000 Subject: [PATCH 51/54] Update to 'latest' nuget package see https://github.com/gui-cs/Terminal.Gui/issues/3779 --- Showcase/Showcase.csproj | 2 +- src/TerminalGuiDesigner.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Showcase/Showcase.csproj b/Showcase/Showcase.csproj index 8dcf2590..8efc6d9b 100644 --- a/Showcase/Showcase.csproj +++ b/Showcase/Showcase.csproj @@ -8,7 +8,7 @@ </PropertyGroup> <ItemGroup> - <PackageReference Include="Terminal.Gui" Version="2.0.0-develop.4373" /> + <PackageReference Include="Terminal.Gui" Version="2.0.0-develop.1616" /> </ItemGroup> </Project> diff --git a/src/TerminalGuiDesigner.csproj b/src/TerminalGuiDesigner.csproj index 12dbe8c6..318a2716 100644 --- a/src/TerminalGuiDesigner.csproj +++ b/src/TerminalGuiDesigner.csproj @@ -151,7 +151,7 @@ <PackageReference Include="Serilog" Version="4.2.0" /> <PackageReference Include="Serilog.Extensions.Logging" Version="9.0.0" /> <PackageReference Include="Serilog.Sinks.File" Version="6.0.0" /> - <PackageReference Include="Terminal.Gui" Version="2.0.0-develop.4373" /> + <PackageReference Include="Terminal.Gui" Version="2.0.0-develop.1616" /> <PackageReference Include="nlog" Version="5.3.3" /> <PackageReference Include="Basic.Reference.Assemblies.Net80" Version="1.7.7" /> <PackageReference Include="System.CodeDom" Version="8.0.0" /> From 86d9b16aceb3f0901989c21f5bc94d78704b2231 Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Mon, 17 Mar 2025 18:10:13 +0000 Subject: [PATCH 52/54] Target 4387 --- Showcase/Showcase.csproj | 2 +- src/TerminalGuiDesigner.csproj | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Showcase/Showcase.csproj b/Showcase/Showcase.csproj index 8efc6d9b..8d274616 100644 --- a/Showcase/Showcase.csproj +++ b/Showcase/Showcase.csproj @@ -8,7 +8,7 @@ </PropertyGroup> <ItemGroup> - <PackageReference Include="Terminal.Gui" Version="2.0.0-develop.1616" /> + <PackageReference Include="Terminal.Gui" Version="2.0.0-develop.4387" /> </ItemGroup> </Project> diff --git a/src/TerminalGuiDesigner.csproj b/src/TerminalGuiDesigner.csproj index 318a2716..b9782ee1 100644 --- a/src/TerminalGuiDesigner.csproj +++ b/src/TerminalGuiDesigner.csproj @@ -20,7 +20,7 @@ <PackageOutputPath>./nupkg</PackageOutputPath> <ImplicitUsings>enable</ImplicitUsings> <PackageId>TerminalGuiDesigner</PackageId> - <Version>2.0.0-alpha.2203</Version> + <Version>2.0.0-alpha.4387</Version> <Authors>Thomas Nind</Authors> <Nullable>enable</Nullable> <PackageLicenseExpression>MIT</PackageLicenseExpression> @@ -33,6 +33,8 @@ <PackageIcon>logo.png</PackageIcon> <PackageReadmeFile>README.md</PackageReadmeFile> <PackageReleaseNotes> + 2.0.0-alpha.4387 + * V2 driver support 2.0.0-alpha.2203 * True color `ColorPicker` 2.0.0-alpha.2189 @@ -151,7 +153,7 @@ <PackageReference Include="Serilog" Version="4.2.0" /> <PackageReference Include="Serilog.Extensions.Logging" Version="9.0.0" /> <PackageReference Include="Serilog.Sinks.File" Version="6.0.0" /> - <PackageReference Include="Terminal.Gui" Version="2.0.0-develop.1616" /> + <PackageReference Include="Terminal.Gui" Version="2.0.0-develop.4387" /> <PackageReference Include="nlog" Version="5.3.3" /> <PackageReference Include="Basic.Reference.Assemblies.Net80" Version="1.7.7" /> <PackageReference Include="System.CodeDom" Version="8.0.0" /> From fb9d87f484935de2fd6b3a89da1eb4705ca04326 Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Fri, 21 Mar 2025 08:25:38 +0000 Subject: [PATCH 53/54] Update to latest nuget package --- Showcase/Showcase.csproj | 2 +- src/TerminalGuiDesigner.csproj | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Showcase/Showcase.csproj b/Showcase/Showcase.csproj index 8d274616..273199f7 100644 --- a/Showcase/Showcase.csproj +++ b/Showcase/Showcase.csproj @@ -8,7 +8,7 @@ </PropertyGroup> <ItemGroup> - <PackageReference Include="Terminal.Gui" Version="2.0.0-develop.4387" /> + <PackageReference Include="Terminal.Gui" Version="2.0.0-develop.4400" /> </ItemGroup> </Project> diff --git a/src/TerminalGuiDesigner.csproj b/src/TerminalGuiDesigner.csproj index b9782ee1..c017b260 100644 --- a/src/TerminalGuiDesigner.csproj +++ b/src/TerminalGuiDesigner.csproj @@ -20,7 +20,7 @@ <PackageOutputPath>./nupkg</PackageOutputPath> <ImplicitUsings>enable</ImplicitUsings> <PackageId>TerminalGuiDesigner</PackageId> - <Version>2.0.0-alpha.4387</Version> + <Version>2.0.0-develop.4400</Version> <Authors>Thomas Nind</Authors> <Nullable>enable</Nullable> <PackageLicenseExpression>MIT</PackageLicenseExpression> @@ -33,7 +33,7 @@ <PackageIcon>logo.png</PackageIcon> <PackageReadmeFile>README.md</PackageReadmeFile> <PackageReleaseNotes> - 2.0.0-alpha.4387 + 2.0.0-alpha.4400 * V2 driver support 2.0.0-alpha.2203 * True color `ColorPicker` From 6235c746dea45471a26554f0d06ccc4aeb4d4b2a Mon Sep 17 00:00:00 2001 From: tznind <tznind@dundee.ac.uk> Date: Fri, 21 Mar 2025 20:27:27 +0000 Subject: [PATCH 54/54] Fix wrong version of dependency --- src/TerminalGuiDesigner.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TerminalGuiDesigner.csproj b/src/TerminalGuiDesigner.csproj index c017b260..d0f2b0f0 100644 --- a/src/TerminalGuiDesigner.csproj +++ b/src/TerminalGuiDesigner.csproj @@ -153,7 +153,7 @@ <PackageReference Include="Serilog" Version="4.2.0" /> <PackageReference Include="Serilog.Extensions.Logging" Version="9.0.0" /> <PackageReference Include="Serilog.Sinks.File" Version="6.0.0" /> - <PackageReference Include="Terminal.Gui" Version="2.0.0-develop.4387" /> + <PackageReference Include="Terminal.Gui" Version="2.0.0-develop.4400" /> <PackageReference Include="nlog" Version="5.3.3" /> <PackageReference Include="Basic.Reference.Assemblies.Net80" Version="1.7.7" /> <PackageReference Include="System.CodeDom" Version="8.0.0" />