Skip to content

Commit b639b2c

Browse files
committed
Added ViewportSettigs Editor
1 parent 4d6913b commit b639b2c

File tree

5 files changed

+400
-13
lines changed

5 files changed

+400
-13
lines changed

Terminal.Gui/View/View.Drawing.cs

+5-4
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@ public void Draw ()
6262
}
6363
else
6464
{
65-
// Set the clip to be just the thicknesses
66-
Region? clipAdornments = Border!.Thickness.AsRegion (Border!.FrameToScreen ());
65+
// Set the clip to be just the thicknesses of the adornments
66+
// TODO: Put this union logic in a method on View?
67+
Region? clipAdornments = Margin!.Thickness.AsRegion (Margin!.FrameToScreen ());
68+
clipAdornments?.Union (Border!.Thickness.AsRegion (Border!.FrameToScreen ()));
6769
clipAdornments?.Union (Padding!.Thickness.AsRegion (Padding!.FrameToScreen ()));
6870
clipAdornments?.Intersect (originalClip);
6971
SetClip (clipAdornments);
@@ -150,10 +152,9 @@ public void Draw ()
150152
borderFrame = Border.FrameToScreen ();
151153
}
152154

153-
// TODO: This flag may not be needed. Just returning true from OnClearViewport may be sufficient.
154155
if (ViewportSettings.HasFlag (ViewportSettings.Transparent) && contentClip is { })
155156
{
156-
Region? saved = originalClip.Clone ();
157+
Region? saved = originalClip!.Clone ();
157158

158159
saved.Exclude (Border!.Thickness.AsRegion (Border!.FrameToScreen ()));
159160
saved.Exclude (Padding!.Thickness.AsRegion (Padding!.FrameToScreen ()));

Terminal.Gui/Views/CharMap/CharMap.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ public CharMap ()
9797
};
9898

9999
// Set up the vertical scrollbar. Turn off AutoShow since it's always visible.
100-
VerticalScrollBar.AutoShow = false;
101-
VerticalScrollBar.Visible = true; // Force always visible
100+
VerticalScrollBar.AutoShow = true;
101+
VerticalScrollBar.Visible = false; // Force always visible
102102
VerticalScrollBar.X = Pos.AnchorEnd ();
103103
VerticalScrollBar.Y = HEADER_HEIGHT; // Header
104104
}

UICatalog/Scenarios/AllViewsTester.cs

+21-6
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ public class AllViewsTester : Scenario
1818
private Dictionary<string, Type>? _viewClasses;
1919
private ListView? _classListView;
2020
private AdornmentsEditor? _adornmentsEditor;
21-
2221
private ArrangementEditor? _arrangementEditor;
23-
2422
private LayoutEditor? _layoutEditor;
23+
private ViewportSettingsEditor? _viewportSettingsEditor;
2524
private FrameView? _settingsPane;
2625
private RadioGroup? _orientation;
2726
private string _demoText = "This, that, and the other thing.";
@@ -133,13 +132,27 @@ public override void Main ()
133132
AutoSelectAdornments = false,
134133
SuperViewRendersLineCanvas = true
135134
};
136-
_layoutEditor.Border!.Thickness = new (1);
135+
_layoutEditor.Border!.Thickness = new (1, 1, 1, 0);
136+
137+
_viewportSettingsEditor = new ()
138+
{
139+
Title = "ViewportSettings [_5]",
140+
X = Pos.Right (_arrangementEditor) - 1,
141+
Y = Pos.Bottom (_layoutEditor) - Pos.Func (() => _layoutEditor.Frame.Height == 1 ? 0 : 1),
142+
Width = Dim.Width (_layoutEditor),
143+
Height = Dim.Auto (),
144+
CanFocus = true,
145+
AutoSelectViewToEdit = false,
146+
AutoSelectAdornments = false,
147+
SuperViewRendersLineCanvas = true
148+
};
149+
_viewportSettingsEditor.Border!.Thickness = new (1, 1, 1, 1);
137150

138151
_settingsPane = new ()
139152
{
140-
Title = "Settings [_5]",
153+
Title = "Misc Settings [_6]",
141154
X = Pos.Right (_adornmentsEditor) - 1,
142-
Y = Pos.Bottom (_layoutEditor) - Pos.Func (() => _layoutEditor.Frame.Height == 1 ? 0 : 1),
155+
Y = Pos.Bottom (_viewportSettingsEditor) - Pos.Func (() => _viewportSettingsEditor.Frame.Height == 1 ? 0 : 1),
143156
Width = Dim.Width (_layoutEditor),
144157
Height = Dim.Auto (),
145158
CanFocus = true,
@@ -237,7 +250,7 @@ public override void Main ()
237250
_hostPane.Padding.Diagnostics = ViewDiagnosticFlags.Ruler;
238251
_hostPane.Padding.ColorScheme = app.ColorScheme;
239252

240-
app.Add (_classListView, _adornmentsEditor, _arrangementEditor, _layoutEditor, _settingsPane, _eventLog, _hostPane);
253+
app.Add (_classListView, _adornmentsEditor, _arrangementEditor, _layoutEditor, _viewportSettingsEditor, _settingsPane, _eventLog, _hostPane);
241254

242255
app.Initialized += App_Initialized;
243256

@@ -306,6 +319,7 @@ private void CreateCurrentView (Type type)
306319

307320
_hostPane!.Add (_curView);
308321
_layoutEditor!.ViewToEdit = _curView;
322+
_viewportSettingsEditor!.ViewToEdit = _curView;
309323
_arrangementEditor!.ViewToEdit = _curView;
310324
_curView.SetNeedsLayout ();
311325
}
@@ -318,6 +332,7 @@ private void DisposeCurrentView ()
318332
_curView.SubviewsLaidOut -= CurrentView_LayoutComplete;
319333
_hostPane!.Remove (_curView);
320334
_layoutEditor!.ViewToEdit = null;
335+
_viewportSettingsEditor!.ViewToEdit = null;
321336
_arrangementEditor!.ViewToEdit = null;
322337

323338
_curView.Dispose ();

0 commit comments

Comments
 (0)