mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-01 00:46:39 +01:00
Merge branch 'v2_develop' into copilot/enable-menubar-replacement
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
"Themes": [
|
||||
{
|
||||
"Hot Dog Stand": {
|
||||
"Glyphs.WideGlyphReplacement": "①",
|
||||
"Schemes": [
|
||||
{
|
||||
"Runnable": {
|
||||
@@ -134,7 +135,7 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"UI Catalog Theme": {
|
||||
"UI Catalog": {
|
||||
"Window.DefaultShadow": "Transparent",
|
||||
"Button.DefaultShadow": "None",
|
||||
"CheckBox.DefaultHighlightStates": "In, Pressed, PressedOutside",
|
||||
|
||||
@@ -19,6 +19,7 @@ public class Adornments : Scenario
|
||||
|
||||
var editor = new AdornmentsEditor
|
||||
{
|
||||
BorderStyle = LineStyle.Single,
|
||||
AutoSelectViewToEdit = true,
|
||||
|
||||
// This is for giggles, to show that the editor can be moved around.
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
|
||||
namespace UICatalog.Scenarios;
|
||||
|
||||
/// <summary>
|
||||
@@ -57,11 +55,13 @@ public class AdornmentEditor : EditorBase
|
||||
_bottomEdit!.Value = _adornment.Thickness.Bottom;
|
||||
_rightEdit!.Value = _adornment.Thickness.Right;
|
||||
|
||||
_adornment.Initialized += (sender, args) =>
|
||||
_adornment.Initialized += (_, _) =>
|
||||
{
|
||||
Scheme? cs = _adornment.GetScheme ();
|
||||
_foregroundColorPicker.SelectedColor = _adornment.GetAttributeForRole (VisualRole.Normal).Foreground.GetClosestNamedColor16 ();
|
||||
_backgroundColorPicker.SelectedColor = _adornment.GetAttributeForRole (VisualRole.Normal).Background.GetClosestNamedColor16 ();
|
||||
_foregroundColorPicker.SelectedColor =
|
||||
_adornment.GetAttributeForRole (VisualRole.Normal).Foreground.GetClosestNamedColor16 ();
|
||||
|
||||
_backgroundColorPicker.SelectedColor =
|
||||
_adornment.GetAttributeForRole (VisualRole.Normal).Background.GetClosestNamedColor16 ();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -125,12 +125,12 @@ public class AdornmentEditor : EditorBase
|
||||
_bottomEdit.ValueChanging += Bottom_ValueChanging;
|
||||
Add (_bottomEdit);
|
||||
|
||||
var copyTop = new Button
|
||||
Button copyTop = new ()
|
||||
{
|
||||
X = Pos.Center (), Y = Pos.Bottom (_bottomEdit), Text = "Cop_y Top"
|
||||
};
|
||||
|
||||
copyTop.Accepting += (s, e) =>
|
||||
copyTop.Accepting += (_, _) =>
|
||||
{
|
||||
AdornmentToEdit!.Thickness = new (_topEdit.Value);
|
||||
_leftEdit.Value = _rightEdit.Value = _bottomEdit.Value = _topEdit.Value;
|
||||
@@ -168,9 +168,9 @@ public class AdornmentEditor : EditorBase
|
||||
_diagThicknessCheckBox.CheckedState = Diagnostics.FastHasFlags (ViewDiagnosticFlags.Thickness) ? CheckState.Checked : CheckState.UnChecked;
|
||||
}
|
||||
|
||||
_diagThicknessCheckBox.CheckedStateChanging += (s, e) =>
|
||||
_diagThicknessCheckBox.CheckedStateChanging += (_, args) =>
|
||||
{
|
||||
if (e.Result == CheckState.Checked)
|
||||
if (args.Result == CheckState.Checked)
|
||||
{
|
||||
AdornmentToEdit!.Diagnostics |= ViewDiagnosticFlags.Thickness;
|
||||
}
|
||||
@@ -194,9 +194,9 @@ public class AdornmentEditor : EditorBase
|
||||
_diagRulerCheckBox.CheckedState = Diagnostics.FastHasFlags (ViewDiagnosticFlags.Ruler) ? CheckState.Checked : CheckState.UnChecked;
|
||||
}
|
||||
|
||||
_diagRulerCheckBox.CheckedStateChanging += (s, e) =>
|
||||
_diagRulerCheckBox.CheckedStateChanging += (_, args) =>
|
||||
{
|
||||
if (e.Result == CheckState.Checked)
|
||||
if (args.Result == CheckState.Checked)
|
||||
{
|
||||
AdornmentToEdit!.Diagnostics |= ViewDiagnosticFlags.Ruler;
|
||||
}
|
||||
@@ -212,18 +212,19 @@ public class AdornmentEditor : EditorBase
|
||||
|
||||
private EventHandler<ResultEventArgs<Color>> ColorPickerColorChanged ()
|
||||
{
|
||||
return (o, a) =>
|
||||
return (_, _) =>
|
||||
{
|
||||
if (AdornmentToEdit is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AdornmentToEdit.SetScheme (new (AdornmentToEdit.GetScheme ())
|
||||
{
|
||||
Normal = new (_foregroundColorPicker.SelectedColor, _backgroundColorPicker.SelectedColor)
|
||||
})
|
||||
;
|
||||
AdornmentToEdit.SetScheme (
|
||||
new (AdornmentToEdit.GetScheme ())
|
||||
{
|
||||
Normal = new (_foregroundColorPicker.SelectedColor, _backgroundColorPicker.SelectedColor)
|
||||
})
|
||||
;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,6 @@ public class AdornmentsEditor : EditorBase
|
||||
|
||||
TabStop = TabBehavior.TabGroup;
|
||||
|
||||
ExpanderButton!.Orientation = Orientation.Horizontal;
|
||||
|
||||
Initialized += AdornmentsEditor_Initialized;
|
||||
|
||||
SchemeName = "Dialog";
|
||||
@@ -28,8 +26,6 @@ public class AdornmentsEditor : EditorBase
|
||||
/// <inheritdoc/>
|
||||
protected override void OnViewToEditChanged ()
|
||||
{
|
||||
//Enabled = ViewToEdit is not Adornment;
|
||||
|
||||
if (MarginEditor is { })
|
||||
{
|
||||
MarginEditor.AdornmentToEdit = ViewToEdit?.Margin ?? null;
|
||||
@@ -47,7 +43,7 @@ public class AdornmentsEditor : EditorBase
|
||||
|
||||
if (Padding is { })
|
||||
{
|
||||
Padding.Text = $"View: {GetIdentifyingString (ViewToEdit)}";
|
||||
Padding.Text = GetIdentifyingString (ViewToEdit);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,12 +88,17 @@ public class AdornmentsEditor : EditorBase
|
||||
|
||||
private void AdornmentsEditor_Initialized (object? sender, EventArgs e)
|
||||
{
|
||||
if (ExpanderButton is { })
|
||||
{
|
||||
ExpanderButton.Orientation = Orientation.Horizontal;
|
||||
}
|
||||
|
||||
MarginEditor = new ()
|
||||
{
|
||||
X = -1,
|
||||
Y = 0,
|
||||
SuperViewRendersLineCanvas = true,
|
||||
BorderStyle = LineStyle.Single
|
||||
BorderStyle = BorderStyle
|
||||
};
|
||||
MarginEditor.Border!.Thickness = MarginEditor.Border!.Thickness with { Bottom = 0 };
|
||||
Add (MarginEditor);
|
||||
@@ -107,7 +108,7 @@ public class AdornmentsEditor : EditorBase
|
||||
X = Pos.Left (MarginEditor),
|
||||
Y = Pos.Bottom (MarginEditor),
|
||||
SuperViewRendersLineCanvas = true,
|
||||
BorderStyle = LineStyle.Single
|
||||
BorderStyle = BorderStyle
|
||||
};
|
||||
BorderEditor.Border!.Thickness = BorderEditor.Border!.Thickness with { Bottom = 0 };
|
||||
Add (BorderEditor);
|
||||
@@ -117,7 +118,7 @@ public class AdornmentsEditor : EditorBase
|
||||
X = Pos.Left (BorderEditor),
|
||||
Y = Pos.Bottom (BorderEditor),
|
||||
SuperViewRendersLineCanvas = true,
|
||||
BorderStyle = LineStyle.Single
|
||||
BorderStyle = BorderStyle
|
||||
};
|
||||
PaddingEditor.Border!.Thickness = PaddingEditor.Border!.Thickness with { Bottom = 0 };
|
||||
Add (PaddingEditor);
|
||||
|
||||
@@ -77,7 +77,7 @@ public class AllViewsView : View
|
||||
|
||||
View? previousView = null;
|
||||
|
||||
foreach (Type? type in allClasses)
|
||||
foreach (Type type in allClasses)
|
||||
{
|
||||
View? view = CreateView (type);
|
||||
|
||||
@@ -118,15 +118,8 @@ public class AllViewsView : View
|
||||
// Check if the generic parameter has constraints
|
||||
Type [] constraints = arg.GetGenericParameterConstraints ();
|
||||
|
||||
if (constraints.Length > 0)
|
||||
{
|
||||
// Use the first constraint type to satisfy the constraint
|
||||
typeArguments.Add (constraints [0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
typeArguments.Add (typeof (object));
|
||||
}
|
||||
// Use the first constraint type to satisfy the constraint
|
||||
typeArguments.Add (constraints.Length > 0 ? constraints [0] : typeof (object));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,17 +186,17 @@ public class AllViewsView : View
|
||||
return;
|
||||
}
|
||||
|
||||
if (view.Width == Dim.Absolute (0) || view.Width is null)
|
||||
if (view.Width == Dim.Absolute (0))
|
||||
{
|
||||
view.Width = Dim.Fill ();
|
||||
}
|
||||
|
||||
if (view.Height == Dim.Absolute (0) || view.Height is null)
|
||||
if (view.Height == Dim.Absolute (0))
|
||||
{
|
||||
view.Height = MAX_VIEW_FRAME_HEIGHT - 2;
|
||||
}
|
||||
|
||||
if (!view.Width!.Has<DimAuto> (out _))
|
||||
if (!view.Width.Has<DimAuto> (out _))
|
||||
{
|
||||
view.Width = Dim.Fill ();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Terminal.Gui.ViewBase;
|
||||
|
||||
namespace UICatalog.Scenarios;
|
||||
|
||||
@@ -33,10 +32,10 @@ public class BorderEditor : AdornmentEditor
|
||||
|
||||
Y = Pos.Bottom (SubViews.ToArray () [^1]),
|
||||
Width = Dim.Fill (),
|
||||
Value = ((Border)AdornmentToEdit!)?.LineStyle ?? LineStyle.None,
|
||||
Value = (AdornmentToEdit as Border)?.LineStyle ?? LineStyle.None,
|
||||
BorderStyle = LineStyle.Single,
|
||||
Title = "Border St_yle",
|
||||
SuperViewRendersLineCanvas = true,
|
||||
SuperViewRendersLineCanvas = true
|
||||
};
|
||||
Add (_osBorderStyle);
|
||||
|
||||
@@ -49,7 +48,7 @@ public class BorderEditor : AdornmentEditor
|
||||
|
||||
CheckedState = CheckState.Checked,
|
||||
SuperViewRendersLineCanvas = true,
|
||||
Text = "Title",
|
||||
Text = "Title"
|
||||
};
|
||||
|
||||
_ckbTitle.CheckedStateChanging += OnCkbTitleOnToggle;
|
||||
@@ -62,7 +61,7 @@ public class BorderEditor : AdornmentEditor
|
||||
|
||||
CheckedState = CheckState.Checked,
|
||||
SuperViewRendersLineCanvas = true,
|
||||
Text = "Gradient",
|
||||
Text = "Gradient"
|
||||
};
|
||||
|
||||
_ckbGradient.CheckedStateChanging += OnCkbGradientOnToggle;
|
||||
@@ -72,51 +71,55 @@ public class BorderEditor : AdornmentEditor
|
||||
|
||||
void OnRbBorderStyleOnValueChanged (object? s, EventArgs<LineStyle?> args)
|
||||
{
|
||||
LineStyle prevBorderStyle = AdornmentToEdit!.BorderStyle;
|
||||
if (AdornmentToEdit is not Border border)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Value is { })
|
||||
{
|
||||
((Border)AdornmentToEdit).LineStyle = (LineStyle)args.Value;
|
||||
border.LineStyle = (LineStyle)args.Value;
|
||||
}
|
||||
|
||||
if (((Border)AdornmentToEdit).LineStyle == LineStyle.None)
|
||||
{
|
||||
((Border)AdornmentToEdit).Thickness = new (0);
|
||||
}
|
||||
else if (prevBorderStyle == LineStyle.None && ((Border)AdornmentToEdit).LineStyle != LineStyle.None)
|
||||
{
|
||||
((Border)AdornmentToEdit).Thickness = new (1);
|
||||
}
|
||||
|
||||
((Border)AdornmentToEdit).SetNeedsDraw ();
|
||||
border.SetNeedsDraw ();
|
||||
SetNeedsLayout ();
|
||||
}
|
||||
|
||||
void OnCkbTitleOnToggle (object? _, ResultEventArgs<CheckState> args)
|
||||
{
|
||||
if (AdornmentToEdit is not Border border)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Result == CheckState.Checked)
|
||||
|
||||
{
|
||||
((Border)AdornmentToEdit!).Settings |= BorderSettings.Title;
|
||||
border.Settings |= BorderSettings.Title;
|
||||
}
|
||||
else
|
||||
|
||||
{
|
||||
((Border)AdornmentToEdit!).Settings &= ~BorderSettings.Title;
|
||||
border.Settings &= ~BorderSettings.Title;
|
||||
}
|
||||
}
|
||||
|
||||
void OnCkbGradientOnToggle (object? _, ResultEventArgs<CheckState> args)
|
||||
{
|
||||
if (AdornmentToEdit is not Border border)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Result == CheckState.Checked)
|
||||
|
||||
{
|
||||
((Border)AdornmentToEdit!).Settings |= BorderSettings.Gradient;
|
||||
border.Settings |= BorderSettings.Gradient;
|
||||
}
|
||||
else
|
||||
|
||||
{
|
||||
((Border)AdornmentToEdit!).Settings &= ~BorderSettings.Gradient;
|
||||
border.Settings &= ~BorderSettings.Gradient;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
||||
namespace UICatalog.Scenarios;
|
||||
|
||||
@@ -21,7 +18,7 @@ public class DimEditor : EditorBase
|
||||
private OptionSelector? _dimOptionSelector;
|
||||
private TextField? _valueEdit;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <inheritdoc/>
|
||||
protected override void OnViewToEditChanged ()
|
||||
{
|
||||
if (ViewToEdit is { })
|
||||
@@ -39,12 +36,11 @@ public class DimEditor : EditorBase
|
||||
return;
|
||||
}
|
||||
|
||||
Dim? dim;
|
||||
dim = Dimension == Dimension.Width ? ViewToEdit.Width : ViewToEdit.Height;
|
||||
Dim dim = Dimension == Dimension.Width ? ViewToEdit.Width : ViewToEdit.Height;
|
||||
|
||||
try
|
||||
{
|
||||
_dimOptionSelector!.Value = _dimNames.IndexOf (_dimNames.First (s => dim!.ToString ().StartsWith (s)));
|
||||
_dimOptionSelector!.Value = _dimNames.IndexOf (_dimNames.First (s => dim.ToString ().StartsWith (s)));
|
||||
}
|
||||
catch (InvalidOperationException e)
|
||||
{
|
||||
@@ -53,31 +49,37 @@ public class DimEditor : EditorBase
|
||||
}
|
||||
|
||||
_valueEdit!.Enabled = false;
|
||||
|
||||
switch (dim)
|
||||
{
|
||||
case DimAbsolute absolute:
|
||||
_valueEdit.Enabled = true;
|
||||
_value = absolute.Size;
|
||||
_valueEdit!.Text = _value.ToString ();
|
||||
|
||||
break;
|
||||
case DimFill fill:
|
||||
var margin = fill.Margin as DimAbsolute;
|
||||
_valueEdit.Enabled = margin is { };
|
||||
_value = margin?.Size ?? 0;
|
||||
_valueEdit!.Text = _value.ToString ();
|
||||
|
||||
break;
|
||||
case DimFunc func:
|
||||
_valueEdit.Enabled = true;
|
||||
_value = func.Fn (null);
|
||||
_valueEdit!.Text = _value.ToString ();
|
||||
|
||||
break;
|
||||
case DimPercent percent:
|
||||
_valueEdit.Enabled = true;
|
||||
_value = percent.Percentage;
|
||||
_valueEdit!.Text = _value.ToString ();
|
||||
|
||||
break;
|
||||
default:
|
||||
_valueEdit!.Text = dim!.ToString ();
|
||||
_valueEdit!.Text = dim.ToString ();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -94,6 +96,7 @@ public class DimEditor : EditorBase
|
||||
Add (label);
|
||||
_dimOptionSelector = new () { X = 0, Y = Pos.Bottom (label), Labels = _optionLabels };
|
||||
_dimOptionSelector.ValueChanged += OnOptionSelectorOnValueChanged;
|
||||
|
||||
_valueEdit = new ()
|
||||
{
|
||||
X = Pos.Right (label) + 1,
|
||||
@@ -102,30 +105,30 @@ public class DimEditor : EditorBase
|
||||
Text = $"{_value}"
|
||||
};
|
||||
|
||||
_valueEdit.Accepting += (s, args) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
_value = int.Parse (_valueEdit.Text);
|
||||
DimChanged ();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
args.Handled = true;
|
||||
};
|
||||
_valueEdit.Accepting += (_, args) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
_value = int.Parse (_valueEdit.Text);
|
||||
DimChanged ();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
args.Handled = true;
|
||||
};
|
||||
Add (_valueEdit);
|
||||
|
||||
Add (_dimOptionSelector);
|
||||
|
||||
}
|
||||
|
||||
private void OnOptionSelectorOnValueChanged (object? s, EventArgs<int?> selected) { DimChanged (); }
|
||||
|
||||
// These need to have same order
|
||||
private readonly List<string> _dimNames = ["Absolute", "Auto", "Fill", "Func", "Percent",];
|
||||
private readonly string [] _optionLabels = ["Absolute(n)", "Auto", "Fill(n)", "Func(()=>n)", "Percent(n)",];
|
||||
// These need to have same order
|
||||
private readonly List<string> _dimNames = ["Absolute", "Auto", "Fill", "Func", "Percent"];
|
||||
private readonly string [] _optionLabels = ["Absolute(n)", "Auto", "Fill(n)", "Func(()=>n)", "Percent(n)"];
|
||||
|
||||
private void DimChanged ()
|
||||
{
|
||||
@@ -136,15 +139,15 @@ public class DimEditor : EditorBase
|
||||
|
||||
try
|
||||
{
|
||||
Dim? dim = _dimOptionSelector!.Value switch
|
||||
{
|
||||
0 => Dim.Absolute (_value),
|
||||
1 => Dim.Auto (),
|
||||
2 => Dim.Fill (_value),
|
||||
3 => Dim.Func (_ => _value),
|
||||
4 => Dim.Percent (_value),
|
||||
_ => Dimension == Dimension.Width ? ViewToEdit.Width : ViewToEdit.Height
|
||||
};
|
||||
Dim dim = _dimOptionSelector!.Value switch
|
||||
{
|
||||
0 => Dim.Absolute (_value),
|
||||
1 => Dim.Auto (),
|
||||
2 => Dim.Fill (_value),
|
||||
3 => Dim.Func (_ => _value),
|
||||
4 => Dim.Percent (_value),
|
||||
_ => Dimension == Dimension.Width ? ViewToEdit.Width : ViewToEdit.Height
|
||||
};
|
||||
|
||||
if (Dimension == Dimension.Width)
|
||||
{
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
||||
namespace UICatalog.Scenarios;
|
||||
|
||||
public abstract class EditorBase : View
|
||||
@@ -19,36 +15,21 @@ public abstract class EditorBase : View
|
||||
Orientation = Orientation.Vertical
|
||||
};
|
||||
|
||||
|
||||
TabStop = TabBehavior.TabStop;
|
||||
|
||||
Initialized += OnInitialized;
|
||||
|
||||
void OnInitialized (object? sender, EventArgs e)
|
||||
{
|
||||
if (Border is { })
|
||||
{
|
||||
Border.Add (ExpanderButton);
|
||||
|
||||
if (ExpanderButton.Orientation == Orientation.Vertical)
|
||||
{
|
||||
ExpanderButton.X = Pos.AnchorEnd () - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ExpanderButton.Y = Pos.AnchorEnd () - 1;
|
||||
}
|
||||
}
|
||||
|
||||
Application.MouseEvent += ApplicationOnMouseEvent;
|
||||
Application.Navigation!.FocusedChanged += NavigationOnFocusedChanged;
|
||||
Border?.Add (ExpanderButton);
|
||||
|
||||
App!.Mouse.MouseEvent += ApplicationOnMouseEvent;
|
||||
App!.Navigation!.FocusedChanged += NavigationOnFocusedChanged;
|
||||
}
|
||||
|
||||
AddCommand (Command.Accept, () => true);
|
||||
|
||||
SchemeName = "Dialog";
|
||||
|
||||
}
|
||||
|
||||
private readonly ExpanderButton? _expanderButton;
|
||||
@@ -58,15 +39,16 @@ public abstract class EditorBase : View
|
||||
get => _expanderButton;
|
||||
init
|
||||
{
|
||||
if (_expanderButton == value)
|
||||
if (ReferenceEquals (_expanderButton, value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_expanderButton = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool UpdatingLayoutSettings { get; private set; } = false;
|
||||
public bool UpdatingLayoutSettings { get; private set; }
|
||||
|
||||
private void View_LayoutComplete (object? sender, LayoutEventArgs e)
|
||||
{
|
||||
@@ -77,7 +59,6 @@ public abstract class EditorBase : View
|
||||
UpdatingLayoutSettings = false;
|
||||
}
|
||||
|
||||
|
||||
private View? _viewToEdit;
|
||||
|
||||
public View? ViewToEdit
|
||||
@@ -90,7 +71,6 @@ public abstract class EditorBase : View
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (value is null && _viewToEdit is { })
|
||||
{
|
||||
_viewToEdit.SubViewsLaidOut -= View_LayoutComplete;
|
||||
@@ -127,7 +107,6 @@ public abstract class EditorBase : View
|
||||
/// </summary>
|
||||
public bool AutoSelectAdornments { get; set; }
|
||||
|
||||
|
||||
private void NavigationOnFocusedChanged (object? sender, EventArgs e)
|
||||
{
|
||||
if (AutoSelectSuperView is null)
|
||||
@@ -135,17 +114,17 @@ public abstract class EditorBase : View
|
||||
return;
|
||||
}
|
||||
|
||||
if (ApplicationNavigation.IsInHierarchy (this, Application.Navigation!.GetFocused ()))
|
||||
if (ApplicationNavigation.IsInHierarchy (this, App?.Navigation?.GetFocused ()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ApplicationNavigation.IsInHierarchy (AutoSelectSuperView, Application.Navigation!.GetFocused ()))
|
||||
if (!ApplicationNavigation.IsInHierarchy (AutoSelectSuperView, App?.Navigation?.GetFocused ()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ViewToEdit = Application.Navigation!.GetFocused ();
|
||||
ViewToEdit = App!.Navigation!.GetFocused ();
|
||||
}
|
||||
|
||||
private void ApplicationOnMouseEvent (object? sender, MouseEventArgs e)
|
||||
@@ -177,4 +156,16 @@ public abstract class EditorBase : View
|
||||
ViewToEdit = view;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose (bool disposing)
|
||||
{
|
||||
if (disposing && App is {})
|
||||
{
|
||||
App.Navigation!.FocusedChanged -= NavigationOnFocusedChanged;
|
||||
App.Mouse.MouseEvent -= ApplicationOnMouseEvent;
|
||||
}
|
||||
|
||||
base.Dispose (disposing);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace UICatalog.Scenarios;
|
||||
@@ -19,8 +18,7 @@ public class EventLog : ListView
|
||||
X = Pos.AnchorEnd ();
|
||||
Y = 0;
|
||||
|
||||
Width = Dim.Func (
|
||||
_ =>
|
||||
Width = Dim.Func (_ =>
|
||||
{
|
||||
if (!IsInitialized)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace UICatalog.Scenarios;
|
||||
@@ -43,14 +42,11 @@ public class ExpanderButton : Button
|
||||
|
||||
Orientation = Orientation.Vertical;
|
||||
|
||||
HighlightStates = Terminal.Gui.ViewBase.MouseState.None;
|
||||
HighlightStates = MouseState.In;
|
||||
|
||||
Initialized += ExpanderButton_Initialized;
|
||||
|
||||
EnabledChanged += (sender, args) =>
|
||||
{
|
||||
ShowHide ();
|
||||
};
|
||||
EnabledChanged += (_, _) => { ShowHide (); };
|
||||
}
|
||||
|
||||
private void ShowHide ()
|
||||
@@ -85,7 +81,7 @@ public class ExpanderButton : Button
|
||||
|
||||
if (SuperView is Border { } border)
|
||||
{
|
||||
border.ThicknessChanged += (o, args) => ShowHide ();
|
||||
border.ThicknessChanged += (_, _) => ShowHide ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +107,7 @@ public class ExpanderButton : Button
|
||||
/// <returns>True of the event was cancelled.</returns>
|
||||
protected virtual bool OnOrientationChanging (Orientation newOrientation)
|
||||
{
|
||||
CancelEventArgs<Orientation> args = new CancelEventArgs<Orientation> (in _orientation, ref newOrientation);
|
||||
CancelEventArgs<Orientation> args = new (in _orientation, ref newOrientation);
|
||||
OrientationChanging?.Invoke (this, args);
|
||||
|
||||
if (!args.Cancel)
|
||||
@@ -120,7 +116,7 @@ public class ExpanderButton : Button
|
||||
|
||||
if (Orientation == Orientation.Vertical)
|
||||
{
|
||||
X = Pos.AnchorEnd ();
|
||||
X = Pos.AnchorEnd () - 1;
|
||||
Y = 0;
|
||||
CollapseGlyph = new ('\u21d1'); // ⇑
|
||||
ExpandGlyph = new ('\u21d3'); // ⇓
|
||||
@@ -128,7 +124,7 @@ public class ExpanderButton : Button
|
||||
else
|
||||
{
|
||||
X = 0;
|
||||
Y = Pos.AnchorEnd ();
|
||||
Y = Pos.AnchorEnd () - 1;
|
||||
CollapseGlyph = new ('\u21d0'); // ⇐
|
||||
ExpandGlyph = new ('\u21d2'); // ⇒
|
||||
}
|
||||
@@ -222,12 +218,12 @@ public class ExpanderButton : Button
|
||||
// Collapse
|
||||
if (Orientation == Orientation.Vertical)
|
||||
{
|
||||
_previousDim = superView!.Height!;
|
||||
_previousDim = superView.Height;
|
||||
superView.Height = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_previousDim = superView!.Width!;
|
||||
_previousDim = superView.Width;
|
||||
superView.Width = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace UICatalog.Scenarios;
|
||||
|
||||
/// <summary>
|
||||
@@ -64,7 +60,6 @@ public class LayoutEditor : EditorBase
|
||||
X = Pos.Right (_xEditor) + 1
|
||||
};
|
||||
|
||||
|
||||
_widthEditor = new ()
|
||||
{
|
||||
Title = "_Width",
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
|
||||
namespace UICatalog.Scenarios;
|
||||
|
||||
public class MarginEditor : AdornmentEditor
|
||||
@@ -34,7 +32,7 @@ public class MarginEditor : AdornmentEditor
|
||||
_optionsShadow = new ()
|
||||
{
|
||||
X = 0,
|
||||
Y = Pos.Bottom (SubViews.ElementAt(SubViews.Count-1)),
|
||||
Y = Pos.Bottom (SubViews.ElementAt (SubViews.Count - 1)),
|
||||
|
||||
SuperViewRendersLineCanvas = true,
|
||||
Title = "_Shadow",
|
||||
@@ -51,14 +49,14 @@ public class MarginEditor : AdornmentEditor
|
||||
|
||||
Add (_optionsShadow);
|
||||
|
||||
_flagSelectorTransparent = new FlagSelector<ViewportSettingsFlags> ()
|
||||
_flagSelectorTransparent = new FlagSelector<ViewportSettingsFlags>
|
||||
{
|
||||
X = 0,
|
||||
Y = Pos.Bottom (_optionsShadow),
|
||||
|
||||
SuperViewRendersLineCanvas = true,
|
||||
Title = "_ViewportSettings",
|
||||
BorderStyle = LineStyle.Single,
|
||||
BorderStyle = LineStyle.Single
|
||||
};
|
||||
_flagSelectorTransparent.Values = [(int)ViewportSettingsFlags.Transparent, (int)ViewportSettingsFlags.TransparentMouse];
|
||||
_flagSelectorTransparent.Labels = ["Transparent", "TransparentMouse"];
|
||||
@@ -71,11 +69,6 @@ public class MarginEditor : AdornmentEditor
|
||||
_flagSelectorTransparent.Value = (int)((Margin)AdornmentToEdit).ViewportSettings;
|
||||
}
|
||||
|
||||
_flagSelectorTransparent.ValueChanged += (_, args) =>
|
||||
{
|
||||
((Margin)AdornmentToEdit!).ViewportSettings = (ViewportSettingsFlags)args.Value!;
|
||||
};
|
||||
|
||||
|
||||
_flagSelectorTransparent.ValueChanged += (_, args) => { ((Margin)AdornmentToEdit!).ViewportSettings = (ViewportSettingsFlags)args.Value!; };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
||||
namespace UICatalog.Scenarios;
|
||||
|
||||
@@ -102,7 +99,7 @@ public class PosEditor : EditorBase
|
||||
Text = $"{_value}"
|
||||
};
|
||||
|
||||
_valueEdit.Accepting += (s, args) =>
|
||||
_valueEdit.Accepting += (_, args) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -123,7 +120,7 @@ public class PosEditor : EditorBase
|
||||
|
||||
private void OnOptionSelectorOnValueChanged (object? s, EventArgs<int?> selected) { PosChanged (); }
|
||||
|
||||
// These need to have same order
|
||||
// These need to have same order
|
||||
private readonly List<string> _posNames = ["Absolute", "Align", "AnchorEnd", "Center", "Func", "Percent"];
|
||||
private readonly string [] _optionLabels = ["Absolute(n)", "Align", "AnchorEnd", "Center", "Func(()=>n)", "Percent(n)"];
|
||||
|
||||
@@ -136,7 +133,7 @@ public class PosEditor : EditorBase
|
||||
|
||||
try
|
||||
{
|
||||
Pos? pos = _posOptionSelector!.Value switch
|
||||
Pos pos = _posOptionSelector!.Value switch
|
||||
{
|
||||
0 => Pos.Absolute (_value),
|
||||
1 => Pos.Align (Alignment.Start),
|
||||
|
||||
@@ -20,7 +20,7 @@ public class ViewPropertiesEditor : EditorBase
|
||||
CheckedState = ViewToEdit is { } ? ViewToEdit.CanFocus ? CheckState.Checked : CheckState.UnChecked : CheckState.UnChecked
|
||||
};
|
||||
|
||||
_canFocusCheckBox.CheckedStateChanged += (s, args) =>
|
||||
_canFocusCheckBox.CheckedStateChanged += (_, _) =>
|
||||
{
|
||||
if (ViewToEdit is { })
|
||||
{
|
||||
@@ -37,7 +37,7 @@ public class ViewPropertiesEditor : EditorBase
|
||||
CheckedState = ViewToEdit is { } ? ViewToEdit.Enabled ? CheckState.Checked : CheckState.UnChecked : CheckState.UnChecked
|
||||
};
|
||||
|
||||
_enabledCheckBox.CheckedStateChanged += (s, args) =>
|
||||
_enabledCheckBox.CheckedStateChanged += (_, _) =>
|
||||
{
|
||||
if (ViewToEdit is { })
|
||||
{
|
||||
@@ -55,13 +55,13 @@ public class ViewPropertiesEditor : EditorBase
|
||||
Orientation = Orientation.Horizontal
|
||||
};
|
||||
|
||||
_orientationOptionSelector.ValueChanged += (s, selected) =>
|
||||
{
|
||||
if (ViewToEdit is IOrientation orientatedView)
|
||||
{
|
||||
orientatedView.Orientation = _orientationOptionSelector.Value!.Value;
|
||||
}
|
||||
};
|
||||
_orientationOptionSelector.ValueChanged += (_, _) =>
|
||||
{
|
||||
if (ViewToEdit is IOrientation orientatedView)
|
||||
{
|
||||
orientatedView.Orientation = _orientationOptionSelector.Value!.Value;
|
||||
}
|
||||
};
|
||||
Add (label, _orientationOptionSelector);
|
||||
|
||||
label = new () { X = 0, Y = Pos.Bottom (_orientationOptionSelector), Text = "Text:" };
|
||||
@@ -75,7 +75,7 @@ public class ViewPropertiesEditor : EditorBase
|
||||
Text = "This is demo text"
|
||||
};
|
||||
|
||||
_text.ContentsChanged += (s, e) =>
|
||||
_text.ContentsChanged += (_, _) =>
|
||||
{
|
||||
if (ViewToEdit is { })
|
||||
{
|
||||
@@ -90,15 +90,7 @@ public class ViewPropertiesEditor : EditorBase
|
||||
|
||||
public string DemoText
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_text is null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return _text!.Text;
|
||||
}
|
||||
get => _text is null ? string.Empty : _text!.Text;
|
||||
set => _text!.Text = value;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
|
||||
namespace UICatalog.Scenarios;
|
||||
|
||||
/// <summary>
|
||||
@@ -60,8 +58,8 @@ public sealed class ViewportSettingsEditor : EditorBase
|
||||
: CheckState.UnChecked;
|
||||
|
||||
_cbTransparentMouse!.CheckedState = ViewToEdit.ViewportSettings.HasFlag (ViewportSettingsFlags.TransparentMouse)
|
||||
? CheckState.Checked
|
||||
: CheckState.UnChecked;
|
||||
? CheckState.Checked
|
||||
: CheckState.UnChecked;
|
||||
|
||||
_cbVerticalScrollBar!.CheckedState = ViewToEdit.VerticalScrollBar.Visible ? CheckState.Checked : CheckState.UnChecked;
|
||||
_cbAutoShowVerticalScrollBar!.CheckedState = ViewToEdit.VerticalScrollBar.AutoShow ? CheckState.Checked : CheckState.UnChecked;
|
||||
@@ -115,27 +113,27 @@ public sealed class ViewportSettingsEditor : EditorBase
|
||||
|
||||
Add (_cbAllowXGreaterThanContentWidth);
|
||||
|
||||
void AllowNegativeXToggle (object? sender, ResultEventArgs<CheckState> e)
|
||||
void AllowNegativeXToggle (object? sender, ResultEventArgs<CheckState> rea)
|
||||
{
|
||||
if (e.Result == CheckState.Checked)
|
||||
if (rea.Result == CheckState.Checked)
|
||||
{
|
||||
ViewToEdit!.ViewportSettings |= Terminal.Gui.ViewBase.ViewportSettingsFlags.AllowNegativeX;
|
||||
ViewToEdit!.ViewportSettings |= ViewportSettingsFlags.AllowNegativeX;
|
||||
}
|
||||
else
|
||||
{
|
||||
ViewToEdit!.ViewportSettings &= ~Terminal.Gui.ViewBase.ViewportSettingsFlags.AllowNegativeX;
|
||||
ViewToEdit!.ViewportSettings &= ~ViewportSettingsFlags.AllowNegativeX;
|
||||
}
|
||||
}
|
||||
|
||||
void AllowXGreaterThanContentWidthToggle (object? sender, ResultEventArgs<CheckState> e)
|
||||
void AllowXGreaterThanContentWidthToggle (object? sender, ResultEventArgs<CheckState> rea)
|
||||
{
|
||||
if (e.Result == CheckState.Checked)
|
||||
if (rea.Result == CheckState.Checked)
|
||||
{
|
||||
ViewToEdit!.ViewportSettings |= Terminal.Gui.ViewBase.ViewportSettingsFlags.AllowXGreaterThanContentWidth;
|
||||
ViewToEdit!.ViewportSettings |= ViewportSettingsFlags.AllowXGreaterThanContentWidth;
|
||||
}
|
||||
else
|
||||
{
|
||||
ViewToEdit!.ViewportSettings &= ~Terminal.Gui.ViewBase.ViewportSettingsFlags.AllowXGreaterThanContentWidth;
|
||||
ViewToEdit!.ViewportSettings &= ~ViewportSettingsFlags.AllowXGreaterThanContentWidth;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,27 +151,27 @@ public sealed class ViewportSettingsEditor : EditorBase
|
||||
|
||||
Add (_cbAllowYGreaterThanContentHeight);
|
||||
|
||||
void AllowNegativeYToggle (object? sender, ResultEventArgs<CheckState> e)
|
||||
void AllowNegativeYToggle (object? sender, ResultEventArgs<CheckState> rea)
|
||||
{
|
||||
if (e.Result == CheckState.Checked)
|
||||
if (rea.Result == CheckState.Checked)
|
||||
{
|
||||
ViewToEdit!.ViewportSettings |= Terminal.Gui.ViewBase.ViewportSettingsFlags.AllowNegativeY;
|
||||
ViewToEdit!.ViewportSettings |= ViewportSettingsFlags.AllowNegativeY;
|
||||
}
|
||||
else
|
||||
{
|
||||
ViewToEdit!.ViewportSettings &= ~Terminal.Gui.ViewBase.ViewportSettingsFlags.AllowNegativeY;
|
||||
ViewToEdit!.ViewportSettings &= ~ViewportSettingsFlags.AllowNegativeY;
|
||||
}
|
||||
}
|
||||
|
||||
void AllowYGreaterThanContentHeightToggle (object? sender, ResultEventArgs<CheckState> e)
|
||||
void AllowYGreaterThanContentHeightToggle (object? sender, ResultEventArgs<CheckState> rea)
|
||||
{
|
||||
if (e.Result == CheckState.Checked)
|
||||
if (rea.Result == CheckState.Checked)
|
||||
{
|
||||
ViewToEdit!.ViewportSettings |= Terminal.Gui.ViewBase.ViewportSettingsFlags.AllowYGreaterThanContentHeight;
|
||||
ViewToEdit!.ViewportSettings |= ViewportSettingsFlags.AllowYGreaterThanContentHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
ViewToEdit!.ViewportSettings &= ~Terminal.Gui.ViewBase.ViewportSettingsFlags.AllowYGreaterThanContentHeight;
|
||||
ViewToEdit!.ViewportSettings &= ~ViewportSettingsFlags.AllowYGreaterThanContentHeight;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,17 +191,16 @@ public sealed class ViewportSettingsEditor : EditorBase
|
||||
};
|
||||
_contentSizeWidth.ValueChanging += ContentSizeWidthValueChanged;
|
||||
|
||||
void ContentSizeWidthValueChanged (object? sender, CancelEventArgs<int> e)
|
||||
void ContentSizeWidthValueChanged (object? sender, CancelEventArgs<int> cea)
|
||||
{
|
||||
if (e.NewValue < 0)
|
||||
if (cea.NewValue < 0)
|
||||
{
|
||||
e.Cancel = true;
|
||||
cea.Cancel = true;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// BUGBUG: set_ContentSize is supposed to be `protected`.
|
||||
ViewToEdit!.SetContentSize (ViewToEdit.GetContentSize () with { Width = e.NewValue });
|
||||
ViewToEdit!.SetContentSize (ViewToEdit.GetContentSize () with { Width = cea.NewValue });
|
||||
}
|
||||
|
||||
var labelComma = new Label
|
||||
@@ -221,17 +218,16 @@ public sealed class ViewportSettingsEditor : EditorBase
|
||||
};
|
||||
_contentSizeHeight.ValueChanging += ContentSizeHeightValueChanged;
|
||||
|
||||
void ContentSizeHeightValueChanged (object? sender, CancelEventArgs<int> e)
|
||||
void ContentSizeHeightValueChanged (object? sender, CancelEventArgs<int> cea)
|
||||
{
|
||||
if (e.NewValue < 0)
|
||||
if (cea.NewValue < 0)
|
||||
{
|
||||
e.Cancel = true;
|
||||
cea.Cancel = true;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// BUGBUG: set_ContentSize is supposed to be `protected`.
|
||||
ViewToEdit?.SetContentSize (ViewToEdit.GetContentSize () with { Height = e.NewValue });
|
||||
ViewToEdit?.SetContentSize (ViewToEdit.GetContentSize () with { Height = cea.NewValue });
|
||||
}
|
||||
|
||||
_cbClearContentOnly = new ()
|
||||
@@ -243,15 +239,15 @@ public sealed class ViewportSettingsEditor : EditorBase
|
||||
};
|
||||
_cbClearContentOnly.CheckedStateChanging += ClearContentOnlyToggle;
|
||||
|
||||
void ClearContentOnlyToggle (object? sender, ResultEventArgs<CheckState> e)
|
||||
void ClearContentOnlyToggle (object? sender, ResultEventArgs<CheckState> rea)
|
||||
{
|
||||
if (e.Result == CheckState.Checked)
|
||||
if (rea.Result == CheckState.Checked)
|
||||
{
|
||||
ViewToEdit!.ViewportSettings |= Terminal.Gui.ViewBase.ViewportSettingsFlags.ClearContentOnly;
|
||||
ViewToEdit!.ViewportSettings |= ViewportSettingsFlags.ClearContentOnly;
|
||||
}
|
||||
else
|
||||
{
|
||||
ViewToEdit!.ViewportSettings &= ~Terminal.Gui.ViewBase.ViewportSettingsFlags.ClearContentOnly;
|
||||
ViewToEdit!.ViewportSettings &= ~ViewportSettingsFlags.ClearContentOnly;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,15 +260,15 @@ public sealed class ViewportSettingsEditor : EditorBase
|
||||
};
|
||||
_cbClipContentOnly.CheckedStateChanging += ClipContentOnlyToggle;
|
||||
|
||||
void ClipContentOnlyToggle (object? sender, ResultEventArgs<CheckState> e)
|
||||
void ClipContentOnlyToggle (object? sender, ResultEventArgs<CheckState> rea)
|
||||
{
|
||||
if (e.Result == CheckState.Checked)
|
||||
if (rea.Result == CheckState.Checked)
|
||||
{
|
||||
ViewToEdit!.ViewportSettings |= Terminal.Gui.ViewBase.ViewportSettingsFlags.ClipContentOnly;
|
||||
ViewToEdit!.ViewportSettings |= ViewportSettingsFlags.ClipContentOnly;
|
||||
}
|
||||
else
|
||||
{
|
||||
ViewToEdit!.ViewportSettings &= ~Terminal.Gui.ViewBase.ViewportSettingsFlags.ClipContentOnly;
|
||||
ViewToEdit!.ViewportSettings &= ~ViewportSettingsFlags.ClipContentOnly;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,15 +281,15 @@ public sealed class ViewportSettingsEditor : EditorBase
|
||||
};
|
||||
_cbTransparent.CheckedStateChanging += TransparentToggle;
|
||||
|
||||
void TransparentToggle (object? sender, ResultEventArgs<CheckState> e)
|
||||
void TransparentToggle (object? sender, ResultEventArgs<CheckState> rea)
|
||||
{
|
||||
if (e.Result == CheckState.Checked)
|
||||
if (rea.Result == CheckState.Checked)
|
||||
{
|
||||
ViewToEdit!.ViewportSettings |= Terminal.Gui.ViewBase.ViewportSettingsFlags.Transparent;
|
||||
ViewToEdit!.ViewportSettings |= ViewportSettingsFlags.Transparent;
|
||||
}
|
||||
else
|
||||
{
|
||||
ViewToEdit!.ViewportSettings &= ~Terminal.Gui.ViewBase.ViewportSettingsFlags.Transparent;
|
||||
ViewToEdit!.ViewportSettings &= ~ViewportSettingsFlags.Transparent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,15 +302,15 @@ public sealed class ViewportSettingsEditor : EditorBase
|
||||
};
|
||||
_cbTransparentMouse.CheckedStateChanging += TransparentMouseToggle;
|
||||
|
||||
void TransparentMouseToggle (object? sender, ResultEventArgs<CheckState> e)
|
||||
void TransparentMouseToggle (object? sender, ResultEventArgs<CheckState> rea)
|
||||
{
|
||||
if (e.Result == CheckState.Checked)
|
||||
if (rea.Result == CheckState.Checked)
|
||||
{
|
||||
ViewToEdit!.ViewportSettings |= Terminal.Gui.ViewBase.ViewportSettingsFlags.TransparentMouse;
|
||||
ViewToEdit!.ViewportSettings |= ViewportSettingsFlags.TransparentMouse;
|
||||
}
|
||||
else
|
||||
{
|
||||
ViewToEdit!.ViewportSettings &= ~Terminal.Gui.ViewBase.ViewportSettingsFlags.TransparentMouse;
|
||||
ViewToEdit!.ViewportSettings &= ~ViewportSettingsFlags.TransparentMouse;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -327,9 +323,9 @@ public sealed class ViewportSettingsEditor : EditorBase
|
||||
};
|
||||
_cbVerticalScrollBar.CheckedStateChanging += VerticalScrollBarToggle;
|
||||
|
||||
void VerticalScrollBarToggle (object? sender, ResultEventArgs<CheckState> e)
|
||||
void VerticalScrollBarToggle (object? sender, ResultEventArgs<CheckState> rea)
|
||||
{
|
||||
ViewToEdit!.VerticalScrollBar.Visible = e.Result == CheckState.Checked;
|
||||
ViewToEdit!.VerticalScrollBar.Visible = rea.Result == CheckState.Checked;
|
||||
}
|
||||
|
||||
_cbAutoShowVerticalScrollBar = new ()
|
||||
@@ -341,9 +337,9 @@ public sealed class ViewportSettingsEditor : EditorBase
|
||||
};
|
||||
_cbAutoShowVerticalScrollBar.CheckedStateChanging += AutoShowVerticalScrollBarToggle;
|
||||
|
||||
void AutoShowVerticalScrollBarToggle (object? sender, ResultEventArgs<CheckState> e)
|
||||
void AutoShowVerticalScrollBarToggle (object? sender, ResultEventArgs<CheckState> rea)
|
||||
{
|
||||
ViewToEdit!.VerticalScrollBar.AutoShow = e.Result == CheckState.Checked;
|
||||
ViewToEdit!.VerticalScrollBar.AutoShow = rea.Result == CheckState.Checked;
|
||||
}
|
||||
|
||||
_cbHorizontalScrollBar = new ()
|
||||
@@ -355,9 +351,9 @@ public sealed class ViewportSettingsEditor : EditorBase
|
||||
};
|
||||
_cbHorizontalScrollBar.CheckedStateChanging += HorizontalScrollBarToggle;
|
||||
|
||||
void HorizontalScrollBarToggle (object? sender, ResultEventArgs<CheckState> e)
|
||||
void HorizontalScrollBarToggle (object? sender, ResultEventArgs<CheckState> rea)
|
||||
{
|
||||
ViewToEdit!.HorizontalScrollBar.Visible = e.Result == CheckState.Checked;
|
||||
ViewToEdit!.HorizontalScrollBar.Visible = rea.Result == CheckState.Checked;
|
||||
}
|
||||
|
||||
_cbAutoShowHorizontalScrollBar = new ()
|
||||
@@ -369,9 +365,9 @@ public sealed class ViewportSettingsEditor : EditorBase
|
||||
};
|
||||
_cbAutoShowHorizontalScrollBar.CheckedStateChanging += AutoShowHorizontalScrollBarToggle;
|
||||
|
||||
void AutoShowHorizontalScrollBarToggle (object? sender, ResultEventArgs<CheckState> e)
|
||||
void AutoShowHorizontalScrollBarToggle (object? sender, ResultEventArgs<CheckState> rea)
|
||||
{
|
||||
ViewToEdit!.HorizontalScrollBar.AutoShow = e.Result == CheckState.Checked;
|
||||
ViewToEdit!.HorizontalScrollBar.AutoShow = rea.Result == CheckState.Checked;
|
||||
}
|
||||
|
||||
Add (
|
||||
|
||||
@@ -62,6 +62,22 @@ public class ShadowStyles : Scenario
|
||||
shadowWindow.Add (buttonInWin);
|
||||
app.Add (shadowWindow);
|
||||
|
||||
Window shadowWindow2 = new ()
|
||||
{
|
||||
|
||||
Id = "shadowWindow2",
|
||||
X = Pos.Right (editor) + 10,
|
||||
Y = 10,
|
||||
Width = Dim.Percent (30),
|
||||
Height = Dim.Percent (30),
|
||||
Title = "Shadow Window #2",
|
||||
Arrangement = ViewArrangement.Movable | ViewArrangement.Overlapped,
|
||||
BorderStyle = LineStyle.Double,
|
||||
ShadowStyle = ShadowStyle.Transparent,
|
||||
};
|
||||
app.Add (shadowWindow2);
|
||||
|
||||
|
||||
var button = new Button
|
||||
{
|
||||
Id = "button",
|
||||
@@ -69,6 +85,7 @@ public class ShadowStyles : Scenario
|
||||
Y = Pos.Center (), Text = "Button",
|
||||
ShadowStyle = ShadowStyle.Opaque
|
||||
};
|
||||
button.Accepting += ButtonOnAccepting;
|
||||
|
||||
ColorPicker colorPicker = new ()
|
||||
{
|
||||
@@ -77,12 +94,12 @@ public class ShadowStyles : Scenario
|
||||
Id = "colorPicker16",
|
||||
X = Pos.Center (),
|
||||
Y = Pos.AnchorEnd (),
|
||||
Width = Dim.Percent(80),
|
||||
Width = Dim.Percent (80),
|
||||
};
|
||||
colorPicker.ColorChanged += (sender, args) =>
|
||||
{
|
||||
var normal = app.GetScheme ().Normal;
|
||||
app.SetScheme (app.GetScheme() with {Normal = new Attribute(normal.Foreground, args.Result)});
|
||||
app.SetScheme (app.GetScheme () with { Normal = new Attribute (normal.Foreground, args.Result) });
|
||||
};
|
||||
app.Add (button, colorPicker);
|
||||
|
||||
@@ -96,4 +113,10 @@ public class ShadowStyles : Scenario
|
||||
Application.Shutdown ();
|
||||
|
||||
}
|
||||
|
||||
private void ButtonOnAccepting (object sender, CommandEventArgs e)
|
||||
{
|
||||
MessageBox.Query ((sender as View)?.App, "Hello", "You pushed the button!");
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,6 +108,7 @@ public class ViewportSettings : Scenario
|
||||
|
||||
var adornmentsEditor = new AdornmentsEditor
|
||||
{
|
||||
BorderStyle = LineStyle.Single,
|
||||
X = Pos.AnchorEnd (),
|
||||
AutoSelectViewToEdit = true,
|
||||
ShowViewIdentifier = true
|
||||
@@ -224,6 +225,7 @@ public class ViewportSettings : Scenario
|
||||
view.Initialized += (s, e) =>
|
||||
{
|
||||
viewportSettingsEditor.ViewToEdit = view;
|
||||
adornmentsEditor.ViewToEdit = view;
|
||||
};
|
||||
view.SetFocus ();
|
||||
Application.Run (app);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#nullable enable
|
||||
#nullable enable
|
||||
|
||||
using System.Text;
|
||||
|
||||
@@ -24,6 +24,27 @@ public sealed class WideGlyphs : Scenario
|
||||
BorderStyle = LineStyle.None
|
||||
};
|
||||
|
||||
// Add Editors
|
||||
|
||||
AdornmentsEditor adornmentsEditor = new ()
|
||||
{
|
||||
BorderStyle = LineStyle.Single,
|
||||
X = Pos.AnchorEnd (),
|
||||
AutoSelectViewToEdit = true,
|
||||
AutoSelectAdornments = false,
|
||||
ShowViewIdentifier = true
|
||||
};
|
||||
appWindow.Add (adornmentsEditor);
|
||||
|
||||
ViewportSettingsEditor viewportSettingsEditor = new ()
|
||||
{
|
||||
BorderStyle = LineStyle.Single,
|
||||
Y = Pos.AnchorEnd (),
|
||||
X = Pos.AnchorEnd (),
|
||||
AutoSelectViewToEdit = true,
|
||||
};
|
||||
appWindow.Add (viewportSettingsEditor);
|
||||
|
||||
// Build the array of codepoints once when subviews are laid out
|
||||
appWindow.SubViewsLaidOut += (s, _) =>
|
||||
{
|
||||
@@ -53,7 +74,7 @@ public sealed class WideGlyphs : Scenario
|
||||
// Fill the window with the pre-built codepoints array
|
||||
// For detailed documentation on the draw code flow from Application.Run to this event,
|
||||
// see WideGlyphs.DrawFlow.md in this directory
|
||||
appWindow.DrawingContent += (s, _) =>
|
||||
appWindow.DrawingContent += (s, e) =>
|
||||
{
|
||||
View? view = s as View;
|
||||
if (view is null || _codepoints is null)
|
||||
@@ -69,28 +90,16 @@ public sealed class WideGlyphs : Scenario
|
||||
Rune codepoint = _codepoints [r, c];
|
||||
if (codepoint != default (Rune))
|
||||
{
|
||||
view.AddRune (c, r, codepoint);
|
||||
view.Move (c, r);
|
||||
Attribute attr = view.GetAttributeForRole (VisualRole.Normal);
|
||||
view.SetAttribute (attr with { Background = attr.Background + (r * 5) });
|
||||
view.AddRune (codepoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
e.DrawContext?.AddDrawnRectangle (view.Viewport);
|
||||
};
|
||||
|
||||
Line verticalLineAtEven = new ()
|
||||
{
|
||||
X = 10,
|
||||
Orientation = Orientation.Vertical,
|
||||
Length = Dim.Fill ()
|
||||
};
|
||||
appWindow.Add (verticalLineAtEven);
|
||||
|
||||
Line verticalLineAtOdd = new ()
|
||||
{
|
||||
X = 25,
|
||||
Orientation = Orientation.Vertical,
|
||||
Length = Dim.Fill ()
|
||||
};
|
||||
appWindow.Add (verticalLineAtOdd);
|
||||
|
||||
View arrangeableViewAtEven = new ()
|
||||
{
|
||||
CanFocus = true,
|
||||
@@ -99,16 +108,19 @@ public sealed class WideGlyphs : Scenario
|
||||
Y = 5,
|
||||
Width = 15,
|
||||
Height = 5,
|
||||
//BorderStyle = LineStyle.Dashed,
|
||||
//BorderStyle = LineStyle.Dashed
|
||||
};
|
||||
|
||||
arrangeableViewAtEven.SetScheme (new () { Normal = new (Color.Black, Color.Green) });
|
||||
|
||||
// Proves it's not LineCanvas related
|
||||
arrangeableViewAtEven!.Border!.Thickness = new (1);
|
||||
arrangeableViewAtEven.Border.Add(new View () { Height = Dim.Auto(), Width = Dim.Auto(), Text = "Even" });
|
||||
arrangeableViewAtEven.Border.Add (new View () { Height = Dim.Auto (), Width = Dim.Auto (), Text = "Even" });
|
||||
appWindow.Add (arrangeableViewAtEven);
|
||||
|
||||
View arrangeableViewAtOdd = new ()
|
||||
Button arrangeableViewAtOdd = new ()
|
||||
{
|
||||
Title = $"你 {Glyphs.Apple}",
|
||||
CanFocus = true,
|
||||
Arrangement = ViewArrangement.Movable | ViewArrangement.Resizable,
|
||||
X = 31,
|
||||
@@ -116,7 +128,12 @@ public sealed class WideGlyphs : Scenario
|
||||
Width = 15,
|
||||
Height = 5,
|
||||
BorderStyle = LineStyle.Dashed,
|
||||
SchemeName = "error"
|
||||
};
|
||||
arrangeableViewAtOdd.Accepting += (sender, args) =>
|
||||
{
|
||||
MessageBox.Query ((sender as View)?.App, "Button Pressed", "You Pressed it!");
|
||||
};
|
||||
appWindow.Add (arrangeableViewAtOdd);
|
||||
|
||||
var superView = new View
|
||||
@@ -124,11 +141,14 @@ public sealed class WideGlyphs : Scenario
|
||||
CanFocus = true,
|
||||
X = 30, // on an even column to start
|
||||
Y = Pos.Center (),
|
||||
Width = Dim.Auto () + 4,
|
||||
Height = Dim.Auto () + 1,
|
||||
Width = Dim.Auto (),
|
||||
Height = Dim.Auto (),
|
||||
BorderStyle = LineStyle.Single,
|
||||
Arrangement = ViewArrangement.Movable | ViewArrangement.Resizable
|
||||
Arrangement = ViewArrangement.Movable | ViewArrangement.Resizable,
|
||||
ShadowStyle = ShadowStyle.Transparent,
|
||||
};
|
||||
superView.Margin!.ShadowSize = superView.Margin!.ShadowSize with { Width = 2 };
|
||||
|
||||
|
||||
Rune codepoint = Glyphs.Apple;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user