mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-30 09:47:58 +01:00
Code cleanup
This commit is contained in:
@@ -868,8 +868,7 @@ public partial class View
|
||||
|
||||
internal void CollectAll (View from, ref HashSet<View> nNodes, ref HashSet<(View, View)> nEdges)
|
||||
{
|
||||
// BUGBUG: This should really only work on initialized subviews
|
||||
foreach (View v in from.InternalSubviews /*.Where(v => v.IsInitialized)*/)
|
||||
foreach (View v in from.InternalSubviews)
|
||||
{
|
||||
nNodes.Add (v);
|
||||
|
||||
|
||||
@@ -329,44 +329,6 @@ public partial class View
|
||||
return new (_viewportLocation, Frame.Size);
|
||||
}
|
||||
|
||||
//// BUGBUG: This is a hack. Viewport_get should not have side effects.
|
||||
//if (Frame.Size == Size.Empty)
|
||||
//{
|
||||
// // The Frame has not been set yet (e.g. the view has not been added to a SuperView yet).
|
||||
// //
|
||||
// // Use _width & _height instead of Width & Height to avoid debug spew
|
||||
// DimAuto widthAuto = _width as DimAuto;
|
||||
// DimAuto heightAuto = _height as DimAuto;
|
||||
|
||||
// if ((widthAuto is { } && widthAuto._style.HasFlag (DimAutoStyle.Text))
|
||||
// || (heightAuto is { } && heightAuto._style.HasFlag (DimAutoStyle.Text)))
|
||||
// {
|
||||
// //if (TextFormatter.NeedsFormat)
|
||||
// {
|
||||
// // We always use TF in autosize = false mode
|
||||
// TextFormatter.AutoSize = false;
|
||||
|
||||
// var size = TextFormatter.GetAutoSize ();
|
||||
// if (widthAuto is null || !widthAuto._style.HasFlag (DimAutoStyle.Text))
|
||||
// {
|
||||
// size.Width = _width.Anchor (0);
|
||||
// }
|
||||
|
||||
// if (heightAuto is null || !heightAuto._style.HasFlag (DimAutoStyle.Text))
|
||||
// {
|
||||
// size.Height = _height.Anchor (0);
|
||||
// }
|
||||
|
||||
// // Whenever DimAutoStyle.Text is set, ContentSize will match TextFormatter.Size.
|
||||
// //ContentSize = size;//TextFormatter.Size == Size.Empty ? null : TextFormatter.Size;
|
||||
// TextFormatter.Size = size; ;
|
||||
|
||||
// // Whenever DimAutoStyle.Text is set, ContentSize will match TextFormatter.Size.
|
||||
// ContentSize = TextFormatter.Size == Size.Empty ? null : TextFormatter.Size;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
Thickness thickness = GetAdornmentsThickness ();
|
||||
return new (
|
||||
_viewportLocation,
|
||||
|
||||
@@ -605,6 +605,7 @@ public class ComboBox : View
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: Upgrade Combobox to use Dim.Auto instead of all this stuff.
|
||||
private void ProcessLayout ()
|
||||
{
|
||||
if (Viewport.Height < _minimumHeight && (Height is null || Height is DimAbsolute))
|
||||
|
||||
@@ -206,7 +206,7 @@ public class DatePicker : View
|
||||
{
|
||||
X = Pos.Right (_dateLabel),
|
||||
Y = 0,
|
||||
Width = 12,//Dim.Width (_calendar) - Dim.Width(_dateLabel), // BUGBUG: Fix when Dim.Auto(subviews) fully works
|
||||
Width = Dim.Width (_calendar) - Dim.Width (_dateLabel),
|
||||
Height = 1,
|
||||
Culture = Culture
|
||||
};
|
||||
@@ -236,7 +236,7 @@ public class DatePicker : View
|
||||
Y = Pos.Bottom (_calendar) - 1,
|
||||
Height = 1,
|
||||
Width = 2,
|
||||
Text = GetForwardButtonText(),
|
||||
Text = GetForwardButtonText (),
|
||||
WantContinuousButtonPressed = true,
|
||||
NoPadding = true,
|
||||
NoDecorations = true
|
||||
@@ -277,7 +277,7 @@ public class DatePicker : View
|
||||
Width = Dim.Auto ();
|
||||
|
||||
// BUGBUG: Remove when Dim.Auto(subviews) fully works
|
||||
SetContentSize(new (_calendar.Style.ColumnStyles.Sum (c => c.Value.MinWidth) + 7, _calendar.Frame.Height + 1));
|
||||
SetContentSize (new (_calendar.Style.ColumnStyles.Sum (c => c.Value.MinWidth) + 7, _calendar.Frame.Height + 1));
|
||||
|
||||
_dateField.DateChanged += DateField_DateChanged;
|
||||
|
||||
@@ -287,35 +287,35 @@ public class DatePicker : View
|
||||
private static string StandardizeDateFormat (string format)
|
||||
{
|
||||
return format switch
|
||||
{
|
||||
"MM/dd/yyyy" => "MM/dd/yyyy",
|
||||
"yyyy-MM-dd" => "yyyy-MM-dd",
|
||||
"yyyy/MM/dd" => "yyyy/MM/dd",
|
||||
"dd/MM/yyyy" => "dd/MM/yyyy",
|
||||
"d?/M?/yyyy" => "dd/MM/yyyy",
|
||||
"dd.MM.yyyy" => "dd.MM.yyyy",
|
||||
"dd-MM-yyyy" => "dd-MM-yyyy",
|
||||
"dd/MM yyyy" => "dd/MM/yyyy",
|
||||
"d. M. yyyy" => "dd.MM.yyyy",
|
||||
"yyyy.MM.dd" => "yyyy.MM.dd",
|
||||
"g yyyy/M/d" => "yyyy/MM/dd",
|
||||
"d/M/yyyy" => "dd/MM/yyyy",
|
||||
"d?/M?/yyyy g" => "dd/MM/yyyy",
|
||||
"d-M-yyyy" => "dd-MM-yyyy",
|
||||
"d.MM.yyyy" => "dd.MM.yyyy",
|
||||
"d.MM.yyyy '?'." => "dd.MM.yyyy",
|
||||
"M/d/yyyy" => "MM/dd/yyyy",
|
||||
"d. M. yyyy." => "dd.MM.yyyy",
|
||||
"d.M.yyyy." => "dd.MM.yyyy",
|
||||
"g yyyy-MM-dd" => "yyyy-MM-dd",
|
||||
"d.M.yyyy" => "dd.MM.yyyy",
|
||||
"d/MM/yyyy" => "dd/MM/yyyy",
|
||||
"yyyy/M/d" => "yyyy/MM/dd",
|
||||
"dd. MM. yyyy." => "dd.MM.yyyy",
|
||||
"yyyy. MM. dd." => "yyyy.MM.dd",
|
||||
"yyyy. M. d." => "yyyy.MM.dd",
|
||||
"d. MM. yyyy" => "dd.MM.yyyy",
|
||||
_ => "dd/MM/yyyy"
|
||||
};
|
||||
{
|
||||
"MM/dd/yyyy" => "MM/dd/yyyy",
|
||||
"yyyy-MM-dd" => "yyyy-MM-dd",
|
||||
"yyyy/MM/dd" => "yyyy/MM/dd",
|
||||
"dd/MM/yyyy" => "dd/MM/yyyy",
|
||||
"d?/M?/yyyy" => "dd/MM/yyyy",
|
||||
"dd.MM.yyyy" => "dd.MM.yyyy",
|
||||
"dd-MM-yyyy" => "dd-MM-yyyy",
|
||||
"dd/MM yyyy" => "dd/MM/yyyy",
|
||||
"d. M. yyyy" => "dd.MM.yyyy",
|
||||
"yyyy.MM.dd" => "yyyy.MM.dd",
|
||||
"g yyyy/M/d" => "yyyy/MM/dd",
|
||||
"d/M/yyyy" => "dd/MM/yyyy",
|
||||
"d?/M?/yyyy g" => "dd/MM/yyyy",
|
||||
"d-M-yyyy" => "dd-MM-yyyy",
|
||||
"d.MM.yyyy" => "dd.MM.yyyy",
|
||||
"d.MM.yyyy '?'." => "dd.MM.yyyy",
|
||||
"M/d/yyyy" => "MM/dd/yyyy",
|
||||
"d. M. yyyy." => "dd.MM.yyyy",
|
||||
"d.M.yyyy." => "dd.MM.yyyy",
|
||||
"g yyyy-MM-dd" => "yyyy-MM-dd",
|
||||
"d.M.yyyy" => "dd.MM.yyyy",
|
||||
"d/MM/yyyy" => "dd/MM/yyyy",
|
||||
"yyyy/M/d" => "yyyy/MM/dd",
|
||||
"dd. MM. yyyy." => "dd.MM.yyyy",
|
||||
"yyyy. MM. dd." => "yyyy.MM.dd",
|
||||
"yyyy. M. d." => "yyyy.MM.dd",
|
||||
"d. MM. yyyy" => "dd.MM.yyyy",
|
||||
_ => "dd/MM/yyyy"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -610,7 +610,7 @@ public class Slider<T> : View
|
||||
/// <summary>Adjust the dimensions of the Slider to the best value.</summary>
|
||||
public void SetContentSizeBestFit ()
|
||||
{
|
||||
if (!IsInitialized || /*!(Height is DimAuto && Width is DimAuto) || */_options.Count == 0)
|
||||
if (/*!IsInitialized ||*/ /*!(Height is DimAuto && Width is DimAuto) || */_options.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -397,7 +397,7 @@ namespace Terminal.Gui
|
||||
/// </summary>
|
||||
public TextValidateField ()
|
||||
{
|
||||
Height = 1; // BUGBUG: Views should avoid setting Height as doing so implies Frame.Size == ContentSize
|
||||
Height = Dim.Auto (minimumContentDim: 1);
|
||||
CanFocus = true;
|
||||
|
||||
// Things this view knows how to do
|
||||
@@ -533,7 +533,7 @@ namespace Terminal.Gui
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected internal override bool OnMouseEvent (MouseEvent mouseEvent)
|
||||
protected internal override bool OnMouseEvent (MouseEvent mouseEvent)
|
||||
{
|
||||
if (mouseEvent.Flags.HasFlag (MouseFlags.Button1Pressed))
|
||||
{
|
||||
|
||||
@@ -275,7 +275,7 @@ public class Buttons : Scenario
|
||||
X = Pos.Left (absoluteFrame) + 1,
|
||||
Y = Pos.Bottom (radioGroup) + 1,
|
||||
Height = 1,
|
||||
Width = Dim.Width (absoluteFrame) - 2, // BUGBUG: Not always the width isn't calculated correctly.
|
||||
Width = Dim.Width (absoluteFrame) - 2,
|
||||
ColorScheme = Colors.ColorSchemes ["TopLevel"],
|
||||
Text = muhkb
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user