From e91f5ec3d04852ca4e6cd198777de60dc0b4a28f Mon Sep 17 00:00:00 2001 From: Charlie Kindel Date: Wed, 20 May 2020 11:37:12 -0600 Subject: [PATCH] UI catalog (#387) * key down/up support * line endings? * line endings * KeyDown/Up support * line endings * line endings * Revert "Drop NuGet restore" This reverts commit 5c7a0d05f077755943ec66e6a82db890a24cd056. * Revert "Revert "Drop NuGet restore"" This reverts commit 2dc5fce8654ffeb6f3e570b0bdefcc6a5b6a6d2b. * updated demo * defined styles * Smarter StatusBar bottom tracking. * Prepping for https://github.com/migueldeicaza/gui.cs/issues/376 * Oops. * Fixed StatusBar 'snap to bottom' * line endings * Revert "Fixed StatusBar 'snap to bottom'" This reverts commit 9a91c957e2ed40f5b36c301eda3d107366aebb3d. * started UICatalog project * Initial working POC. * Fix newlines * merge * textalignment demo tweaks * textalignment demo tweaks * Unicode Menu Scenario * not sure why this keeps changing * re-added project to .sln file * re-enabled status bar * moved scenarios to dir * building a dim and pos demo * terminal.sln * progress...barely * fixed exit * progress with some underlying fixes to Label * added readme * fixes build issue * launch * made default colors readable on Windows * major UI Catalog upgrade * added more demos and updated readme * refactored and added more tests * added ref to Issue #437 * added OnKeyUp support to Curses and Net drivers * more tweaks - grab PR #438 first * Added a OpenSelectedItem event to the ListView #429 * updates * moved KeyUpHandler out of special ESC stuff * more tweaks & improvements * testing top window bug * supported OpenSelectedItem * lots of updates * fixed regression, fixed #444 * better button scenario * tweaks * add Ready event to Toplevel * dotfx .gitignroe * ready for ready * updated colors based on feedback; consolodated config code * tweaked readme * readme * Added Editor demonstrating TextView * Added Editor demonstrating TextView * added hexeditor scenario Co-authored-by: Miguel de Icaza Co-authored-by: BDisp --- Terminal.Gui/Drivers/WindowsDriver.cs | 2 + UICatalog/Scenarios/DimAndPosLayout.cs | 82 ++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 UICatalog/Scenarios/DimAndPosLayout.cs diff --git a/Terminal.Gui/Drivers/WindowsDriver.cs b/Terminal.Gui/Drivers/WindowsDriver.cs index 0576071e3..1a1863ee9 100644 --- a/Terminal.Gui/Drivers/WindowsDriver.cs +++ b/Terminal.Gui/Drivers/WindowsDriver.cs @@ -677,6 +677,8 @@ namespace Terminal.Gui { keyHandler (new KeyEvent (map)); keyDownHandler (new KeyEvent (map)); } else { + // Key Up - Fire KeyDown Event and KeyStroke (ProcessKey) Event + keyHandler (new KeyEvent (map)); keyUpHandler (new KeyEvent (map)); } } diff --git a/UICatalog/Scenarios/DimAndPosLayout.cs b/UICatalog/Scenarios/DimAndPosLayout.cs new file mode 100644 index 000000000..f1f543a57 --- /dev/null +++ b/UICatalog/Scenarios/DimAndPosLayout.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Terminal.Gui; + +namespace UICatalog { + /// + /// This Scenario demonstrates how to use Termina.gui's Dim and Pos Layout System. + /// [x] - Using Dim.Fill to fill a window + /// [x] - Using Dim.Fill and Dim.Pos to automatically align controls based on an initial control + /// [ ] - ... + /// + [ScenarioMetadata (Name: "DimAndPosLayout", Description: "Demonstrates using the Dim and Pos Layout System")] + [ScenarioCategory ("Layout")] + class DimAndPosLayout : Scenario { + + public override void Setup () + { + Top.LayoutStyle = LayoutStyle.Computed; + // Demonstrate using Dim to create a ruler that always measures the top-level window's width + // BUGBUG: Dim.Fill returns too big a value sometimes. + //const string rule = "|123456789"; + //var labelRuler = new Label ("ruler") { + // X = 0, + // Y = 0, + // Width = Dim.Fill (1), // BUGBUG: I don't think this should be needed; DimFill() should respect container's frame. X does. + // ColorScheme = Colors.Error + //}; + + //Application.OnResized += () => { + // labelRuler.Text = rule.Repeat ((int)Math.Ceiling((double)(labelRuler.Bounds.Width) / (double)rule.Length))[0..(labelRuler.Bounds.Width)]; + //}; + + //win.Add (labelRuler); + + // Demonstrate using Dim to create a window that fills the parent with a margin + int margin = 20; + var subWin = new Window ($"Sub Windoww with {margin} character margin") { + X = margin, + Y = 2, + Width = Dim.Fill (margin), + Height = Dim.Fill () + }; + Win.Add (subWin); + + int i = 1; + string txt = "Hello world, how are you doing today"; + var labelList = new List