mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-01 16:59:35 +01:00
* touching publish.yml * ColorScheme->Scheme * ColorScheme->Scheme 2 * Prototype of GetAttributeForRole * Badly broke CM * Further Badly broke CM * Refactored CM big-time. View still broken * All unit test pass again. Tons added. CM is still WIP, but Schemes is not mostly refactored and working. * Actually: All unit test pass again. Tons added. CM is still WIP, but Schemes is not mostly refactored and working. * Bug fixes. DeepMemberWiseClone cleanup * Further cleanup of Scope<T>, ConfigProperty, etc. * Made ConfigManager thread safe. * WIP: Broken * WIP: new deep clone impl * WIP: new deep clone impl is done. Now fixing CM * WIP: - config.md - Working on AOT clean up - Core CM is broken; but known. * WIP * Merged. Removed CM from Application.Init * WIP * More WIP; Less broke * All CM unit tests pass... Not sure if it actually works though * All unit tests pass... Themes are broken though in UI Cat * CM Ready for review? * Fixed failures due to TextStyles PR * Working on Scheme/Attribute * Working on Scheme/Attribute 2 * Working on Scheme/Attribute 3 * Working on Scheme/Attribute 4 * Working on Scheme/Attribute 5 * Working on Scheme/Attribute 6 * Added test to show how awful memory usage is * Improved schema. Updated config.json * Nade Scope<T> concurrentdictionary and added test to prove * Made Themes ConcrurrentDictionary. Added bunches of tests * Code cleanup * Code cleanup 2 * Code cleanup 3 * Tweaking Scheme * ClearJsonErrors * ClearJsonErrors2 * Updated Attribute API * It all (mostly) works! * Skip odd unit test * Messed with Themes * Theme tweaks * Code reorg. New .md stuff * Fixed Enabled. Added mock driver * Fixed a bunch of View.Enabled related issues * Scheme -> Get/SetScheme() * Cleanup * Cleanup2 * Broke something * Fixed everything * Made CM.Enable better * Text Style Scenario * Added comments * Fixed UI Catalog Theme Changing * Fixed more dynamic CM update stuff * Warning cleanup * New Default Theme * fixed unit test * Refactoring Scheme and Attribute to fix inheritance * more unit tests * ConfigProperty is not updating schemes correctly * All unit tests pass. Code cleanup * All unit tests pass. Code cleanup2 * Fixed unit tests * Upgraded TextField and TextView * Fixed TextView !Enabled bug * More updates to TextView. More unit tests for SchemeManager * Upgraded CharMap * API docs * Fixe HexView API * upgrade HexView * Fixed shortcut KeyView * Fixed more bugs. Added new themes * updated themes * upgraded Border * Fixed themes memory usage...mostly * Fixed themes memory usage...mostly2 * Fixed themes memory usage...2 * Fixed themes memory usage...3 * Added new colors * Fixed GetHardCodedConfig bug * Added Themes Scenario - WIP * Added Themes Scenario * Tweaked Themes Scenario * Code cleanup * Fixed json schmea * updated deepdives * updated deepdives * Tweaked Themes Scenario * Made Schemes a concurrent dict * Test cleanup * Thread safe ConfigProperty tests * trying to make things more thread safe * more trying to make things more thread safe * Fixing bugs in shadowview * Fixing bugs in shadowview 2 * Refactored GetViewsUnderMouse to GetViewsUnderLocation etc... * Fixed dupe unit tests? * Added better description of layout and coordiantes to deep dive * Added better description of layout and coordiantes to deep dive * Modified tests that call v2.AddTimeout; they were returning true which means restart the timer! This was causing mac/linux unit test failures. I think * Fixed auto scheme. Broke TextView/TextField selection * Realized Attribute.IsExplicitlySet is stupid; just use nullable * Fixed Attribute. Simplified. MOre theme testing * Updated themes again * GetViewsUnderMouse to GetViewsUnderLocation broke TransparentMouse. * Fixing mouseunder bugs * rewriting... * All working again. Shadows are now slick as snot. GetViewsUnderLocation is rewritten to actually work and be readable. Tons more low-level unit tests. Margin is now actually ViewportSettings.Transparent. * Code cleanup * Code cleanup * Code cleanup of color apis * Fixed Hover/Highlight * Update Examples/UICatalog/Scenarios/AllViewsTester.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Examples/UICatalog/Scenarios/CharacterMap/CharacterMap.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Examples/UICatalog/Scenarios/Clipping.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fixed race condition? * reverted * Simplified Attribute API by removing events from SetAttributeForRole * Removed recursion from GetViewsAtLocation * Removed unneeded code * Code clean up. Fixed Scheme bug. * reverted temporary disable * Adjusted scheme algo * Upgraded TextValidateField * Fixed TextValidate bugs * Tweaks * Frameview rounded border by default * API doc cleanup * Readme fix * Addressed tznind feeback * Fixed more unit test issues by protecting Application statics from being set if Application.Initialized is not true * Fixed more unit test issues by protecting Application statics from being set if Application.Initialized is not true 2 * cleanup --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
354 lines
11 KiB
C#
354 lines
11 KiB
C#
using System.Collections.Generic;
|
|
using Terminal.Gui;
|
|
using Timer = System.Timers.Timer;
|
|
|
|
namespace UICatalog.Scenarios;
|
|
|
|
[ScenarioMetadata ("Arrangement", "Arrangement Tester")]
|
|
[ScenarioCategory ("Mouse and Keyboard")]
|
|
[ScenarioCategory ("Layout")]
|
|
[ScenarioCategory ("Arrangement")]
|
|
public class Arrangement : Scenario
|
|
{
|
|
private int _hotkeyCount;
|
|
|
|
public override void Main ()
|
|
{
|
|
Application.Init ();
|
|
|
|
Window app = new ()
|
|
{
|
|
Title = GetQuitKeyAndName (),
|
|
TabStop = TabBehavior.TabGroup,
|
|
ShadowStyle = ShadowStyle.None
|
|
};
|
|
|
|
var adornmentsEditor = new AdornmentsEditor
|
|
{
|
|
X = 0,
|
|
Y = 0,
|
|
AutoSelectViewToEdit = true,
|
|
TabStop = TabBehavior.NoStop,
|
|
ShowViewIdentifier = true
|
|
};
|
|
|
|
app.Add (adornmentsEditor);
|
|
|
|
adornmentsEditor!.ExpanderButton!.Orientation = Orientation.Horizontal;
|
|
|
|
// adornmentsEditor.ExpanderButton!.Collapsed = true;
|
|
|
|
var arrangementEditor = new ArrangementEditor
|
|
{
|
|
X = Pos.Right (adornmentsEditor),
|
|
Y = 0,
|
|
AutoSelectViewToEdit = true,
|
|
TabStop = TabBehavior.NoStop
|
|
};
|
|
app.Add (arrangementEditor);
|
|
|
|
FrameView testFrame = new ()
|
|
{
|
|
Title = "_1 Test Frame",
|
|
Text = "This is the text of the Test Frame.\nLine 2.\nLine 3.",
|
|
X = Pos.Right (arrangementEditor),
|
|
Y = 0,
|
|
Width = Dim.Fill (),
|
|
Height = Dim.Fill ()
|
|
};
|
|
testFrame.TextAlignment = Alignment.Center;
|
|
testFrame.VerticalTextAlignment = Alignment.Center;
|
|
|
|
app.Add (testFrame);
|
|
|
|
View tiledView1 = CreateTiledView (0, 2, 1);
|
|
View tiledView2 = CreateTiledView (1, Pos.Right (tiledView1) - 1, Pos.Top (tiledView1));
|
|
tiledView2.Height = Dim.Height (tiledView1);
|
|
View tiledView3 = CreateTiledView (2, Pos.Right (tiledView2) - 1, Pos.Top (tiledView2));
|
|
tiledView3.Height = Dim.Height (tiledView1);
|
|
View tiledView4 = CreateTiledView (3, Pos.Left (tiledView1), Pos.Bottom (tiledView1) - 1);
|
|
tiledView4.Width = Dim.Func (() => tiledView3.Frame.Width + tiledView2.Frame.Width + tiledView1.Frame.Width - 2);
|
|
|
|
View movableSizeableWithProgress = CreateOverlappedView (2, 10, 8);
|
|
movableSizeableWithProgress.Title = "Movable _& Sizable";
|
|
View tiledSubView = CreateTiledView (4, 0, 2);
|
|
tiledSubView.Arrangement = ViewArrangement.Fixed;
|
|
movableSizeableWithProgress.Add (tiledSubView);
|
|
tiledSubView = CreateTiledView (5, Pos.Right (tiledSubView), Pos.Top (tiledSubView));
|
|
tiledSubView.Arrangement = ViewArrangement.Fixed;
|
|
movableSizeableWithProgress.Add (tiledSubView);
|
|
|
|
ProgressBar progressBar = new ()
|
|
{
|
|
Y = Pos.AnchorEnd (),
|
|
Width = Dim.Fill (),
|
|
Id = "progressBar"
|
|
};
|
|
movableSizeableWithProgress.Add (progressBar);
|
|
|
|
Timer timer = new (10)
|
|
{
|
|
AutoReset = true
|
|
};
|
|
|
|
timer.Elapsed += (o, args) =>
|
|
{
|
|
if (progressBar!.Fraction == 1.0)
|
|
{
|
|
progressBar.Fraction = 0;
|
|
}
|
|
|
|
progressBar.Fraction += 0.01f;
|
|
|
|
Application.Wakeup ();
|
|
|
|
progressBar.SetNeedsDraw ();
|
|
};
|
|
timer.Start ();
|
|
|
|
View overlappedView2 = CreateOverlappedView (3, 4, 15);
|
|
overlappedView2.Title = "_Not Movable";
|
|
overlappedView2.Arrangement = ViewArrangement.Overlapped | ViewArrangement.Resizable;
|
|
|
|
View overlappedInOverlapped1 = CreateOverlappedView (4, 1, 4);
|
|
overlappedView2.Add (overlappedInOverlapped1);
|
|
|
|
View overlappedInOverlapped2 = CreateOverlappedView (5, 10, 7);
|
|
overlappedView2.Add (overlappedInOverlapped2);
|
|
|
|
StatusBar statusBar = new ();
|
|
|
|
statusBar.Add (
|
|
new Shortcut
|
|
{
|
|
Title = "Hide",
|
|
Text = "Hotkey",
|
|
Key = Key.F4,
|
|
Action = () =>
|
|
{
|
|
// TODO: move this logic into `View.ShowHide()` or similar
|
|
overlappedView2.Visible = false;
|
|
overlappedView2.Enabled = overlappedView2.Visible;
|
|
}
|
|
});
|
|
|
|
statusBar.Add (
|
|
new Shortcut
|
|
{
|
|
Title = "Toggle Hide",
|
|
Text = "App",
|
|
BindKeyToApplication = true,
|
|
Key = Key.F4.WithCtrl,
|
|
Action = () =>
|
|
{
|
|
// TODO: move this logic into `View.ShowHide()` or similar
|
|
overlappedView2.Visible = !overlappedView2.Visible;
|
|
overlappedView2.Enabled = overlappedView2.Visible;
|
|
|
|
if (overlappedView2.Visible)
|
|
{
|
|
overlappedView2.SetFocus ();
|
|
}
|
|
}
|
|
});
|
|
overlappedView2.Add (statusBar);
|
|
|
|
ColorPicker colorPicker = new ()
|
|
{
|
|
Y = 12,
|
|
Width = Dim.Fill (),
|
|
Id = "colorPicker",
|
|
Style = new ()
|
|
{
|
|
ShowTextFields = true,
|
|
ShowColorName = true
|
|
}
|
|
};
|
|
colorPicker.ApplyStyleChanges ();
|
|
|
|
colorPicker.SelectedColor = testFrame.GetAttributeForRole (VisualRole.Normal).Background;
|
|
colorPicker.ColorChanged += ColorPickerColorChanged;
|
|
overlappedView2.Add (colorPicker);
|
|
overlappedView2.Width = 50;
|
|
|
|
DatePicker datePicker = new ()
|
|
{
|
|
X = 30,
|
|
Y = 17,
|
|
Id = "datePicker",
|
|
Title = "Not _Sizeable",
|
|
ShadowStyle = ShadowStyle.Transparent,
|
|
BorderStyle = LineStyle.Double,
|
|
TabStop = TabBehavior.TabGroup,
|
|
Arrangement = ViewArrangement.Movable | ViewArrangement.Overlapped
|
|
};
|
|
|
|
datePicker.SetScheme (new Scheme (
|
|
new Attribute (
|
|
SchemeManager.GetScheme (Schemes.Toplevel).Normal.Foreground.GetBrighterColor (),
|
|
SchemeManager.GetScheme (Schemes.Toplevel).Normal.Background.GetBrighterColor (),
|
|
SchemeManager.GetScheme (Schemes.Toplevel).Normal.Style)));
|
|
|
|
TransparentView transparentView = new ()
|
|
{
|
|
Title = "Transparent",
|
|
ViewportSettings = Terminal.Gui.ViewportSettings.Transparent,
|
|
X = 30,
|
|
Y = 5,
|
|
Width = 35,
|
|
Height = 15
|
|
};
|
|
|
|
testFrame.Add (tiledView4, tiledView3, tiledView2, tiledView1);
|
|
testFrame.Add (overlappedView2);
|
|
testFrame.Add (datePicker);
|
|
testFrame.Add (movableSizeableWithProgress);
|
|
testFrame.Add (transparentView);
|
|
|
|
|
|
testFrame.Add (new TransparentView ()
|
|
{
|
|
Title = "Transparent|TransparentMouse",
|
|
ViewportSettings = Terminal.Gui.ViewportSettings.TransparentMouse | Terminal.Gui.ViewportSettings.Transparent
|
|
});
|
|
|
|
adornmentsEditor.AutoSelectSuperView = testFrame;
|
|
arrangementEditor.AutoSelectSuperView = testFrame;
|
|
|
|
testFrame.SetFocus ();
|
|
|
|
Application.Run (app);
|
|
timer.Close ();
|
|
app.Dispose ();
|
|
Application.Shutdown ();
|
|
|
|
return;
|
|
|
|
void ColorPickerColorChanged (object sender, ColorEventArgs e)
|
|
{
|
|
testFrame.SetScheme (testFrame.GetScheme () with { Normal = new (testFrame.GetAttributeForRole (VisualRole.Normal).Foreground, e.CurrentValue) });
|
|
}
|
|
}
|
|
|
|
private View CreateOverlappedView (int id, Pos x, Pos y)
|
|
{
|
|
var overlapped = new View
|
|
{
|
|
X = x,
|
|
Y = y,
|
|
Width = Dim.Auto (minimumContentDim: 15),
|
|
Height = Dim.Auto (minimumContentDim: 3),
|
|
Title = $"Overlapped{id} _{GetNextHotKey ()}",
|
|
SchemeName = SchemeManager.SchemesToSchemeName (Schemes.Toplevel),
|
|
Id = $"Overlapped{id}",
|
|
ShadowStyle = ShadowStyle.Transparent,
|
|
BorderStyle = LineStyle.Double,
|
|
CanFocus = true,
|
|
TabStop = TabBehavior.TabGroup,
|
|
Arrangement = ViewArrangement.Movable | ViewArrangement.Overlapped | ViewArrangement.Resizable
|
|
};
|
|
|
|
return overlapped;
|
|
}
|
|
|
|
private View CreateTiledView (int id, Pos x, Pos y)
|
|
{
|
|
var tiled = new View
|
|
{
|
|
X = x,
|
|
Y = y,
|
|
Width = Dim.Auto (minimumContentDim: 15),
|
|
Height = Dim.Auto (minimumContentDim: 3),
|
|
Title = $"Tiled{id} _{GetNextHotKey ()}",
|
|
Id = $"Tiled{id}",
|
|
BorderStyle = LineStyle.Single,
|
|
CanFocus = true,
|
|
TabStop = TabBehavior.TabStop,
|
|
Arrangement = ViewArrangement.Resizable
|
|
};
|
|
|
|
return tiled;
|
|
}
|
|
|
|
private char GetNextHotKey () { return (char)('A' + _hotkeyCount++); }
|
|
|
|
public override List<Key> GetDemoKeyStrokes ()
|
|
{
|
|
var keys = new List<Key> ();
|
|
|
|
// Select view with progress bar
|
|
keys.Add ((Key)'&');
|
|
|
|
keys.Add (Application.ArrangeKey);
|
|
|
|
for (int i = 0; i < 8; i++)
|
|
{
|
|
keys.Add (Key.CursorUp);
|
|
}
|
|
|
|
for (int i = 0; i < 25; i++)
|
|
{
|
|
keys.Add (Key.CursorRight);
|
|
}
|
|
|
|
keys.Add (Application.ArrangeKey);
|
|
|
|
keys.Add (Key.S);
|
|
|
|
keys.Add (Application.ArrangeKey);
|
|
|
|
for (int i = 0; i < 10; i++)
|
|
{
|
|
keys.Add (Key.CursorUp);
|
|
}
|
|
|
|
for (int i = 0; i < 25; i++)
|
|
{
|
|
keys.Add (Key.CursorLeft);
|
|
}
|
|
|
|
keys.Add (Application.ArrangeKey);
|
|
|
|
// Select view with progress bar
|
|
keys.Add ((Key)'&');
|
|
|
|
keys.Add (Application.ArrangeKey);
|
|
|
|
keys.Add (Key.Tab);
|
|
|
|
for (int i = 0; i < 10; i++)
|
|
{
|
|
keys.Add (Key.CursorRight);
|
|
keys.Add (Key.CursorDown);
|
|
}
|
|
|
|
return keys;
|
|
}
|
|
|
|
public class TransparentView : FrameView
|
|
{
|
|
public TransparentView ()
|
|
{
|
|
Title = "Transparent";
|
|
Text = "TransparentView Text";
|
|
X = 0;
|
|
Y = 0;
|
|
Width = 30;
|
|
Height = 10;
|
|
Arrangement = ViewArrangement.Overlapped | ViewArrangement.Resizable | ViewArrangement.Movable;
|
|
ViewportSettings |= Terminal.Gui.ViewportSettings.Transparent | Terminal.Gui.ViewportSettings.TransparentMouse;
|
|
|
|
Padding!.Thickness = new Thickness (1);
|
|
|
|
Add (
|
|
new Button ()
|
|
{
|
|
Title = "_Hi",
|
|
X = Pos.Center (),
|
|
Y = Pos.Center ()
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|