Add ability to disable AutoSize

This commit is contained in:
tznind
2024-04-13 15:04:30 +01:00
parent f1bc42aaa5
commit aa72a97cd6
4 changed files with 10 additions and 3 deletions

View File

@@ -35,6 +35,13 @@ public enum LayoutStyle
public partial class View
{
/// <summary>
/// Determines the default usage of <see cref="View.AutoSize"/> in views
/// that support it (e.g. <see cref="Button"/>. Set to false if you frequently
/// get Exceptions about changing Width when AutoSize is true.
/// </summary>
public static bool DefaultAutoSize = true;
#region Frame
private Rectangle _frame;

View File

@@ -52,7 +52,7 @@ public class Button : View
Height = 1;
CanFocus = true;
AutoSize = true;
AutoSize = View.DefaultAutoSize;
HighlightStyle |= HighlightStyle.Pressed;
#if HOVER
HighlightStyle |= HighlightStyle.Hover;

View File

@@ -24,7 +24,7 @@ public class CheckBox : View
Height = 1;
CanFocus = true;
AutoSize = true;
AutoSize = View.DefaultAutoSize;
// Things this view knows how to do
AddCommand (Command.Accept, OnToggled);

View File

@@ -16,7 +16,7 @@ public class Label : View
public Label ()
{
Height = 1;
AutoSize = true;
AutoSize = View.DefaultAutoSize;
// Things this view knows how to do
AddCommand (Command.HotKey, FocusNext);