mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +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>
236 lines
7.0 KiB
C#
236 lines
7.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Terminal.Gui;
|
|
|
|
namespace UICatalog.Scenarios;
|
|
|
|
[ScenarioMetadata ("DimAuto", "Demonstrates Dim.Auto")]
|
|
[ScenarioCategory ("Layout")]
|
|
public class DimAutoDemo : Scenario
|
|
{
|
|
public override void Main ()
|
|
{
|
|
Application.Init ();
|
|
|
|
// Setup - Create a top-level application window and configure it.
|
|
Window appWindow = new ()
|
|
{
|
|
Title = GetQuitKeyAndName (),
|
|
};
|
|
|
|
// For diagnostics
|
|
appWindow.Padding.Thickness = new Thickness (1);
|
|
|
|
FrameView dimAutoFrameView = CreateDimAutoContentFrameView ();
|
|
|
|
//FrameView sliderFrameView = CreateSliderFrameView ();
|
|
//sliderFrameView.X = Pos.Right(dimAutoFrameView) + 1;
|
|
//sliderFrameView.Width = Dim.Fill ();
|
|
//sliderFrameView.Height = Dim.Fill ();
|
|
|
|
|
|
////var dlgButton = new Button
|
|
////{
|
|
//// Text = "Open Test _Dialog",
|
|
//// X = Pos.Right (dimAutoFrameView),
|
|
//// Y = Pos.Top (dimAutoFrameView)
|
|
////};
|
|
////dlgButton.Accept += DlgButton_Clicked;
|
|
|
|
appWindow.Add (dimAutoFrameView/*, sliderFrameView dlgButton*/);
|
|
|
|
// Run - Start the application.
|
|
Application.Run (appWindow);
|
|
appWindow.Dispose ();
|
|
|
|
// Shutdown - Calling Application.Shutdown is required.
|
|
Application.Shutdown ();
|
|
}
|
|
|
|
private static FrameView CreateDimAutoContentFrameView ()
|
|
{
|
|
var dimAutoFrameView = new FrameView
|
|
{
|
|
Title = "Type to make View grow",
|
|
X = 0,
|
|
Y = 0,
|
|
Width = Dim.Auto (DimAutoStyle.Content, minimumContentDim: Dim.Percent (25)),
|
|
Height = Dim.Auto (DimAutoStyle.Content, minimumContentDim: 10)
|
|
};
|
|
dimAutoFrameView.Margin.Thickness = new Thickness (1);
|
|
dimAutoFrameView.ValidatePosDim = true;
|
|
|
|
var textEdit = new TextView
|
|
{
|
|
Text = "",
|
|
X = 0, Y = 0, Width = 20, Height = 4
|
|
};
|
|
dimAutoFrameView.Add (textEdit);
|
|
|
|
var vlabel = new Label
|
|
{
|
|
Text = textEdit.Text,
|
|
X = Pos.Left (textEdit),
|
|
Y = Pos.Bottom (textEdit) + 1,
|
|
Width = Dim.Auto (DimAutoStyle.Text, 1),
|
|
Height = Dim.Auto (DimAutoStyle.Text, 8),
|
|
SchemeName = "Error",
|
|
TextDirection = TextDirection.TopBottom_LeftRight
|
|
};
|
|
vlabel.Id = "vlabel";
|
|
dimAutoFrameView.Add (vlabel);
|
|
|
|
var hlabel = new Label
|
|
{
|
|
Text = textEdit.Text,
|
|
X = Pos.Right (vlabel) + 1,
|
|
Y = Pos.Bottom (textEdit),
|
|
Width = Dim.Auto (DimAutoStyle.Text, 20),
|
|
Height = Dim.Auto (DimAutoStyle.Text, 1),
|
|
SchemeName = "Error"
|
|
};
|
|
hlabel.Id = "hlabel";
|
|
dimAutoFrameView.Add (hlabel);
|
|
|
|
var heightAuto = new View
|
|
{
|
|
X = Pos.Right (vlabel) + 1,
|
|
Y = Pos.Bottom (hlabel) + 1,
|
|
Width = 20,
|
|
Height = Dim.Auto (),
|
|
SchemeName = "Error",
|
|
Title = "W: 20, H: Auto",
|
|
BorderStyle = LineStyle.Rounded
|
|
};
|
|
heightAuto.Id = "heightAuto";
|
|
dimAutoFrameView.Add (heightAuto);
|
|
|
|
var widthAuto = new View
|
|
{
|
|
X = Pos.Right (heightAuto) + 1,
|
|
Y = Pos.Bottom (hlabel) + 1,
|
|
Width = Dim.Auto (),
|
|
Height = 5,
|
|
SchemeName = "Error",
|
|
Title = "W: Auto, H: 5",
|
|
BorderStyle = LineStyle.Rounded
|
|
};
|
|
widthAuto.Id = "widthAuto";
|
|
dimAutoFrameView.Add (widthAuto);
|
|
|
|
var bothAuto = new View
|
|
{
|
|
X = Pos.Right (widthAuto) + 1,
|
|
Y = Pos.Bottom (hlabel) + 1,
|
|
Width = Dim.Auto (),
|
|
Height = Dim.Auto (),
|
|
SchemeName = "Error",
|
|
Title = "W: Auto, H: Auto",
|
|
BorderStyle = LineStyle.Rounded
|
|
};
|
|
bothAuto.Id = "bothAuto";
|
|
dimAutoFrameView.Add (bothAuto);
|
|
|
|
textEdit.ContentsChanged += (s, e) =>
|
|
{
|
|
hlabel.Text = textEdit.Text;
|
|
vlabel.Text = textEdit.Text;
|
|
heightAuto.Text = textEdit.Text;
|
|
widthAuto.Text = textEdit.Text;
|
|
bothAuto.Text = textEdit.Text;
|
|
};
|
|
|
|
//var movingButton = new Button
|
|
//{
|
|
// Text = "_Click\nTo Move\nDown",
|
|
// X = Pos.Right (vlabel),
|
|
// Y = Pos.Bottom (vlabel)
|
|
//};
|
|
//movingButton.Accept += (s, e) => { movingButton.Y = movingButton.Frame.Y + 1; };
|
|
//dimAutoFrameView.Add (movingButton);
|
|
|
|
var resetButton = new Button
|
|
{
|
|
Text = "_Reset Button (AnchorEnd)",
|
|
X = Pos.AnchorEnd (),
|
|
Y = Pos.AnchorEnd ()
|
|
};
|
|
|
|
resetButton.Accepting += (s, e) =>
|
|
{
|
|
//movingButton.Y = Pos.Bottom (hlabel);
|
|
//movingButton.X = 0;
|
|
};
|
|
dimAutoFrameView.Add (resetButton);
|
|
|
|
|
|
var radioGroup = new RadioGroup ()
|
|
{
|
|
RadioLabels = ["One", "Two", "Three"],
|
|
X = 0,
|
|
Y = Pos.AnchorEnd (),
|
|
Title = "Radios",
|
|
BorderStyle = LineStyle.Dotted
|
|
};
|
|
dimAutoFrameView.Add (radioGroup);
|
|
return dimAutoFrameView;
|
|
}
|
|
|
|
private static FrameView CreateSliderFrameView ()
|
|
{
|
|
var sliderFrameView = new FrameView
|
|
{
|
|
Title = "Slider - Example of a DimAuto View",
|
|
};
|
|
|
|
List<object> options = new () { "One", "Two", "Three", "Four" };
|
|
Slider slider = new (options)
|
|
{
|
|
X = 0,
|
|
Y = 0,
|
|
Type = SliderType.Multiple,
|
|
AllowEmpty = false,
|
|
BorderStyle = LineStyle.Double,
|
|
Title = "_Slider"
|
|
};
|
|
sliderFrameView.Add (slider);
|
|
|
|
return sliderFrameView;
|
|
}
|
|
|
|
private void DlgButton_Clicked (object sender, EventArgs e)
|
|
{
|
|
var dlg = new Dialog
|
|
{
|
|
Title = "Test Dialog",
|
|
Width = Dim.Auto (minimumContentDim: Dim.Percent (10))
|
|
|
|
//Height = Dim.Auto (min: Dim.Percent (50))
|
|
};
|
|
var text = new TextField
|
|
{
|
|
ValidatePosDim = true,
|
|
Text = "TextField: X=1; Y=Pos.Bottom (label)+1, Width=Dim.Fill (0); Height=1",
|
|
TextFormatter = new () { WordWrap = true },
|
|
X = 0,
|
|
Y = 0, //Pos.Bottom (label) + 1,
|
|
Width = Dim.Fill (10),
|
|
Height = 1
|
|
};
|
|
|
|
//var btn = new Button
|
|
//{
|
|
// Text = "AnchorEnd", Y = Pos.AnchorEnd (1)
|
|
//};
|
|
|
|
//// TODO: We should really fix AnchorEnd to do this automatically.
|
|
//btn.X = Pos.AnchorEnd () - (Pos.Right (btn) - Pos.Left (btn));
|
|
//dlg.Add (label);
|
|
dlg.Add (text);
|
|
|
|
//dlg.Add (btn);
|
|
Application.Run (dlg);
|
|
dlg.Dispose ();
|
|
}
|
|
}
|