mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
* Fixes #4208. MainLoopSyncContext doesn't work with the v2 drivers * Fixes #3951. Add DimFuncWithView with a View dependency * Revert to iteration which will handle the necessary processes * Revert "Revert to iteration which will handle the necessary processes" This reverts commit50015ac6da. * Layout and draw before position cursor * Add optional View parameter and property to the DimFunc and PosFunc * Trying fix unit test error * Revert layout changes * Fixes #4216. Legacy drivers aren't refreshing the screen correctly on view drag * Add assertion proving NeedsLayout is always false before call OnSubViewsLaidOut * Fix unit test error * Increasing time to abort * Revert "Increasing time to abort" This reverts commitd7306e72f3. * Trying fix integration tests * Still trying fix integrations unit tests * Revert comment * Layout is performed during the iteration * Using Dim.Func with status bar view * Still trying fix integrations tests by locking _subviews * Still trying fix integrations tests by locking _subviews * Add internal SnapshotSubviews method * Remove lock from SnapshotSubviews method * Using SnapshotSubviews method in the DrawSubViews method * Remove lock from SnapshotSubviews method * Using SnapshotSubviews method in the DrawSubViews method * Using SnapshotSubviews * Prevent new app if the previous wasn't yet finished * Replace SnapshotSubviews method with ViewCollectionHelpers class * Lock entire GuiTestContext constructor * Using Snapshot in the ordered field * Fixes #4221 Extra modifiers f1 to f4 in v2net (#4220) * Assume we are running in a terminal that supports true color by default unless user explicitly forces 16 * Add support for extra modifiers for F1 to F4 keys * Revert "Assume we are running in a terminal that supports true color by default unless user explicitly forces 16" This reverts commit4cc2530de0. * Cleanup * Update comments * Code cleanup --------- Co-authored-by: Tig <tig@users.noreply.github.com> * Move ViewCollectionHelpers class to a separate file * Remove Border.Layout call in the DoDrawAdornmentsSubViews method. * Remove adornments layout call within the draw --------- Co-authored-by: Tig <tig@users.noreply.github.com> Co-authored-by: Thomas Nind <31306100+tznind@users.noreply.github.com>
164 lines
6.8 KiB
C#
164 lines
6.8 KiB
C#
using System;
|
|
|
|
namespace UICatalog.Scenarios;
|
|
|
|
[ScenarioMetadata ("Adornments Demo", "Demonstrates Margin, Border, and Padding on Views.")]
|
|
[ScenarioCategory ("Layout")]
|
|
[ScenarioCategory ("Adornments")]
|
|
public class Adornments : Scenario
|
|
{
|
|
public override void Main ()
|
|
{
|
|
Application.Init ();
|
|
|
|
Window app = new ()
|
|
{
|
|
Title = GetQuitKeyAndName (),
|
|
BorderStyle = LineStyle.None
|
|
};
|
|
|
|
var editor = new AdornmentsEditor
|
|
{
|
|
AutoSelectViewToEdit = true,
|
|
|
|
// This is for giggles, to show that the editor can be moved around.
|
|
Arrangement = ViewArrangement.Movable,
|
|
X = Pos.AnchorEnd ()
|
|
};
|
|
|
|
editor.Border.Thickness = new (1, 2, 1, 1);
|
|
|
|
app.Add (editor);
|
|
|
|
var window = new Window
|
|
{
|
|
Title = "The _Window",
|
|
Arrangement = ViewArrangement.Overlapped | ViewArrangement.Movable,
|
|
|
|
Width = Dim.Fill (Dim.Func (_ => editor.Frame.Width)),
|
|
Height = Dim.Fill ()
|
|
};
|
|
app.Add (window);
|
|
|
|
var tf1 = new TextField { Width = 10, Text = "TextField" };
|
|
var color = new ColorPicker16 { Title = "BG", BoxHeight = 1, BoxWidth = 1, X = Pos.AnchorEnd () };
|
|
color.BorderStyle = LineStyle.RoundedDotted;
|
|
|
|
color.ColorChanged += (s, e) =>
|
|
{
|
|
color.SuperView!.SetScheme (
|
|
new (color.SuperView.GetScheme ())
|
|
{
|
|
Normal = new (
|
|
color.SuperView.GetAttributeForRole (VisualRole.Normal).Foreground,
|
|
e.Result,
|
|
color.SuperView.GetAttributeForRole (VisualRole.Normal).Style
|
|
)
|
|
});
|
|
};
|
|
|
|
var button = new Button { X = Pos.Center (), Y = Pos.Center (), Text = "Press me!" };
|
|
|
|
button.Accepting += (s, e) =>
|
|
MessageBox.Query (20, 7, "Hi", $"Am I a {window.GetType ().Name}?", "Yes", "No");
|
|
|
|
var label = new TextView
|
|
{
|
|
X = Pos.Center (),
|
|
Y = Pos.Bottom (button),
|
|
Title = "Title",
|
|
Text = "I have a 3 row top border.\nMy border inherits from the SuperView.",
|
|
Width = 40,
|
|
Height = 6 // TODO: Use Dim.Auto
|
|
};
|
|
label.Border.Thickness = new (1, 3, 1, 1);
|
|
|
|
var btnButtonInWindow = new Button { X = Pos.AnchorEnd (), Y = Pos.AnchorEnd (), Text = "Button" };
|
|
|
|
var labelAnchorEnd = new Label
|
|
{
|
|
Y = Pos.AnchorEnd (),
|
|
Width = 40,
|
|
Height = Dim.Percent (20),
|
|
Text = "Label\nY=AnchorEnd(),Height=Dim.Percent(10)",
|
|
SchemeName = "Dialog"
|
|
};
|
|
|
|
window.Margin.Data = "Margin";
|
|
window.Margin.Text = "Margin Text";
|
|
window.Margin.Thickness = new (0);
|
|
|
|
window.Border.Data = "Border";
|
|
window.Border.Text = "Border Text";
|
|
window.Border.Thickness = new (0);
|
|
|
|
window.Padding.Data = "Padding";
|
|
window.Padding.Text = "Padding Text line 1\nPadding Text line 3\nPadding Text line 3\nPadding Text line 4\nPadding Text line 5";
|
|
window.Padding.Thickness = new (3);
|
|
window.Padding.SchemeName = "Error";
|
|
window.Padding.CanFocus = true;
|
|
|
|
var longLabel = new Label
|
|
{
|
|
X = 40, Y = 5, Title = "This is long text (in a label) that should clip."
|
|
};
|
|
longLabel.TextFormatter.WordWrap = true;
|
|
window.Add (tf1, color, button, label, btnButtonInWindow, labelAnchorEnd, longLabel);
|
|
|
|
window.Initialized += (s, e) =>
|
|
{
|
|
editor.ViewToEdit = window;
|
|
|
|
editor.ShowViewIdentifier = true;
|
|
|
|
var labelInPadding = new Label { X = 0, Y = 1, Title = "_Text:" };
|
|
window.Padding.Add (labelInPadding);
|
|
|
|
var textFieldInPadding = new TextField
|
|
{
|
|
X = Pos.Right (labelInPadding) + 1,
|
|
Y = Pos.Top (labelInPadding), Width = 10,
|
|
Text = "text (Y = 1)",
|
|
CanFocus = true
|
|
};
|
|
textFieldInPadding.Accepting += (s, e) => MessageBox.Query (20, 7, "TextField", textFieldInPadding.Text, "Ok");
|
|
window.Padding.Add (textFieldInPadding);
|
|
|
|
var btnButtonInPadding = new Button
|
|
{
|
|
X = Pos.Center (),
|
|
Y = 1,
|
|
Text = "_Button in Padding Y = 1",
|
|
CanFocus = true,
|
|
HighlightStates = MouseState.None,
|
|
};
|
|
btnButtonInPadding.Accepting += (s, e) => MessageBox.Query (20, 7, "Hi", "Button in Padding Pressed!", "Ok");
|
|
btnButtonInPadding.BorderStyle = LineStyle.Dashed;
|
|
btnButtonInPadding.Border.Thickness = new (1, 1, 1, 1);
|
|
window.Padding.Add (btnButtonInPadding);
|
|
|
|
#if SUBVIEW_BASED_BORDER
|
|
btnButtonInPadding.Border.CloseButton.Visible = true;
|
|
|
|
view.Border.CloseButton.Visible = true;
|
|
view.Border.CloseButton.Accept += (s, e) =>
|
|
{
|
|
MessageBox.Query (20, 7, "Hi", "Window Close Button Pressed!", "Ok");
|
|
e.Handled = true;
|
|
};
|
|
|
|
view.Accept += (s, e) => MessageBox.Query (20, 7, "Hi", "Window Close Button Pressed!", "Ok");
|
|
#endif
|
|
};
|
|
|
|
editor.AutoSelectViewToEdit = true;
|
|
editor.AutoSelectSuperView = window;
|
|
editor.AutoSelectAdornments = true;
|
|
|
|
Application.Run (app);
|
|
app.Dispose ();
|
|
|
|
Application.Shutdown ();
|
|
}
|
|
}
|