Tweaked Adornments scenario to have editor movable

This commit is contained in:
Tig
2024-05-27 12:42:01 -06:00
parent cf24f835ea
commit b9c5797726
4 changed files with 19 additions and 12 deletions

View File

@@ -252,7 +252,6 @@ public partial class View : Responder, ISupportInitializeNotification
}
Initialized?.Invoke (this, EventArgs.Empty);
LayoutSubviews();
}
#endregion Constructors and Initialization

View File

@@ -18,15 +18,21 @@ public class Adornments : Scenario
var editor = new AdornmentsEditor
{
AutoSelectViewToEdit = true
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 Thickness (1, 3, 1, 1);
app.Add (editor);
var window = new Window
{
Title = "The _Window",
Arrangement = ViewArrangement.Movable,
X = Pos.Right (editor),
// X = Pos.Center (),
Width = Dim.Percent (60),
Height = Dim.Percent (80)
};
@@ -98,7 +104,7 @@ public class Adornments : Scenario
window.Padding.Add (labelInPadding);
var textFieldInPadding = new TextField
{ X = Pos.Right (labelInPadding) + 1, Y = Pos.Top (labelInPadding), Width = 15, Text = "some text" };
{ X = Pos.Right (labelInPadding) + 1, Y = Pos.Top (labelInPadding), Width = 15, Text = "some text" };
textFieldInPadding.Accept += (s, e) => MessageBox.Query (20, 7, "TextField", textFieldInPadding.Text, "Ok");
window.Padding.Add (textFieldInPadding);

View File

@@ -24,13 +24,12 @@ public class AdornmentsEditor : View
public AdornmentsEditor ()
{
ColorScheme = Colors.ColorSchemes ["Dialog"];
//ColorScheme = Colors.ColorSchemes ["Dialog"];
Title = $"AdornmentsEditor";
Width = Dim.Auto (DimAutoStyle.Content);
Height = Dim.Auto (DimAutoStyle.Content);
BorderStyle = LineStyle.Double;
//SuperViewRendersLineCanvas = true;
Application.MouseEvent += Application_MouseEvent;
@@ -45,6 +44,8 @@ public class AdornmentsEditor : View
private void AdornmentsEditor_Initialized (object sender, EventArgs e)
{
BorderStyle = LineStyle.Dotted;
ExpanderButton expandButton = new ExpanderButton ()
{
Orientation = Orientation.Horizontal
@@ -124,6 +125,9 @@ public class AdornmentsEditor : View
Add (_diagRulerCheckBox);
_diagRulerCheckBox.Y = Pos.Bottom (_diagPaddingCheckBox);
// BUGBUG: This should not be needed. There's some bug in the layout system that doesn't update the layout.
SuperView.LayoutSubviews();
}
private void Application_MouseEvent (object sender, MouseEvent e)

View File

@@ -15,7 +15,8 @@ namespace UICatalog.Scenarios;
/// <para>
/// If <see cref="Orientation"/> is set to <see cref="Terminal.Gui.Orientation.Vertical"/>, the button will appear
/// at the top/right.
/// If <see cref="Orientation"/> is set to <see cref="Orientation.Horizontal"/>, the button will appear at the
/// If <see cref="Orientation"/> is set to <see cref="Terminal.Gui.Orientation.Horizontal"/>, the button will
/// appear at the
/// bottom/left.
/// </para>
/// </remarks>
@@ -118,7 +119,7 @@ public class ExpanderButton : Button
/// </summary>
public Rune ExpandedGlyph { get; set; }
private bool _collapsed = false;
private bool _collapsed;
/// <summary>
/// Gets or sets a value indicating whether the view is collapsed.
@@ -144,7 +145,6 @@ public class ExpanderButton : Button
ExpandOrCollapse (_collapsed);
View superView = SuperView;
if (superView is Adornment adornment)
{
superView = adornment.Parent;
@@ -160,7 +160,6 @@ public class ExpanderButton : Button
superView.SuperView?.LayoutSubviews ();
}
return args.Cancel;
}
@@ -169,7 +168,7 @@ public class ExpanderButton : Button
/// <see cref="OrientationEventArgs.Cancel"/> to true.
/// </summary>
public event EventHandler<StateEventArgs<bool>> CollapsedChanging;
/// <summary>
/// Collapses or Expands the view.
/// </summary>
@@ -186,7 +185,6 @@ public class ExpanderButton : Button
private void ExpandOrCollapse (bool collapse)
{
View superView = SuperView;
if (superView is Adornment adornment)
{
superView = adornment.Parent;