Skip to content

Commit 208461f

Browse files
committed
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
2 parents a500cc5 + 4664481 commit 208461f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+6644
-7864
lines changed

Terminal.Gui/Drawing/Glyphs.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ public class GlyphDefinitions
7979
/// <summary>Continuous block meter segment (e.g. for <see cref="ProgressBar"/>).</summary>
8080
public Rune ContinuousMeterSegment { get; set; } = (Rune)'█';
8181

82-
/// <summary>Stipple pattern (e.g. for <see cref="ScrollBarView"/>). Default is Light Shade (U+2591) - ░.</summary>
82+
/// <summary>Stipple pattern (e.g. for <see cref="ScrollBar"/>). Default is Light Shade (U+2591) - ░.</summary>
8383
public Rune Stipple { get; set; } = (Rune)'░';
8484

85-
/// <summary>Diamond (e.g. for <see cref="ScrollBarView"/>. Default is Lozenge (U+25CA) - ◊.</summary>
85+
/// <summary>Diamond. Default is Lozenge (U+25CA) - ◊.</summary>
8686
public Rune Diamond { get; set; } = (Rune)'◊';
8787

8888
/// <summary>Close. Default is Heavy Ballot X (U+2718) - ✘.</summary>

Terminal.Gui/Drawing/Thickness.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ public Rectangle GetInside (Rectangle rect)
236236
}
237237

238238
/// <summary>
239-
/// Gets the total width of the left and right sides of the rectangle. Sets the width of the left and rigth sides
239+
/// Gets the total width of the left and right sides of the rectangle. Sets the width of the left and right sides
240240
/// of the rectangle to half the specified value.
241241
/// </summary>
242242
public int Horizontal

Terminal.Gui/Input/Responder.cs

Lines changed: 0 additions & 89 deletions
This file was deleted.

Terminal.Gui/Terminal.Gui.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@
109109
<LastGenOutput>Strings.Designer.cs</LastGenOutput>
110110
</EmbeddedResource>
111111
</ItemGroup>
112-
<ItemGroup>
113-
<Folder Include="Views\Scroll\" />
114-
</ItemGroup>
115112
<!-- =================================================================== -->
116113
<!-- Nuget -->
117114
<!-- =================================================================== -->

Terminal.Gui/View/View.Content.cs

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ private void SetViewport (Rectangle viewport)
312312
//SetSubViewNeedsDraw();
313313
}
314314

315-
OnViewportChanged (new (IsInitialized ? Viewport : Rectangle.Empty, oldViewport));
315+
RaiseViewportChangedEvent (oldViewport);
316316

317317
return;
318318
}
@@ -325,6 +325,10 @@ private void SetViewport (Rectangle viewport)
325325
Size = newSize
326326
};
327327

328+
// Note, setting the Frame will cause ViewportChanged to be raised.
329+
330+
return;
331+
328332
void ApplySettings (ref Rectangle newViewport)
329333
{
330334
if (!ViewportSettings.HasFlag (ViewportSettings.AllowXGreaterThanContentWidth))
@@ -344,6 +348,14 @@ void ApplySettings (ref Rectangle newViewport)
344348
}
345349
}
346350

351+
if (!ViewportSettings.HasFlag (ViewportSettings.AllowNegativeXWhenWidthGreaterThanContentWidth))
352+
{
353+
if (Viewport.Width > GetContentSize ().Width)
354+
{
355+
newViewport.X = 0;
356+
}
357+
}
358+
347359
if (!ViewportSettings.HasFlag (ViewportSettings.AllowYGreaterThanContentHeight))
348360
{
349361
if (newViewport.Y >= GetContentSize ().Height)
@@ -352,6 +364,14 @@ void ApplySettings (ref Rectangle newViewport)
352364
}
353365
}
354366

367+
if (!ViewportSettings.HasFlag (ViewportSettings.AllowNegativeYWhenHeightGreaterThanContentHeight))
368+
{
369+
if (Viewport.Height > GetContentSize ().Height)
370+
{
371+
newViewport.Y = 0;
372+
}
373+
}
374+
355375
// IMPORTANT: Check for negative location AFTER checking for location greater than content width
356376
if (!ViewportSettings.HasFlag (ViewportSettings.AllowNegativeY))
357377
{
@@ -363,6 +383,13 @@ void ApplySettings (ref Rectangle newViewport)
363383
}
364384
}
365385

386+
private void RaiseViewportChangedEvent (Rectangle oldViewport)
387+
{
388+
var args = new DrawEventArgs (IsInitialized ? Viewport : Rectangle.Empty, oldViewport);
389+
OnViewportChanged (args);
390+
ViewportChanged?.Invoke (this, args);
391+
}
392+
366393
/// <summary>
367394
/// Fired when the <see cref="Viewport"/> changes. This event is fired after the <see cref="Viewport"/> has been
368395
/// updated.
@@ -373,7 +400,7 @@ void ApplySettings (ref Rectangle newViewport)
373400
/// Called when the <see cref="Viewport"/> changes. Invokes the <see cref="ViewportChanged"/> event.
374401
/// </summary>
375402
/// <param name="e"></param>
376-
protected virtual void OnViewportChanged (DrawEventArgs e) { ViewportChanged?.Invoke (this, e); }
403+
protected virtual void OnViewportChanged (DrawEventArgs e) { }
377404

378405
/// <summary>
379406
/// Converts a <see cref="Viewport"/>-relative location and size to a screen-relative location and size.

Terminal.Gui/View/View.Drawing.Clipping.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public static void SetClip (Region? region)
104104
if (this is Adornment adornment && adornment.Thickness != Thickness.Empty)
105105
{
106106
// Ensure adornments can't draw outside their thickness
107-
frameRegion.Exclude (adornment.Thickness.GetInside (Frame));
107+
frameRegion.Exclude (adornment.Thickness.GetInside (FrameToScreen()));
108108
}
109109

110110
SetClip (frameRegion);

Terminal.Gui/View/View.Drawing.Primitives.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ public partial class View
77
/// <summary>Moves the drawing cursor to the specified <see cref="Viewport"/>-relative location in the view.</summary>
88
/// <remarks>
99
/// <para>
10-
/// If the provided coordinates are outside the visible content area, this method does nothing.
11-
/// </para>
12-
/// <para>
1310
/// The top-left corner of the visible content area is <c>ViewPort.Location</c>.
1411
/// </para>
1512
/// </remarks>
@@ -22,11 +19,6 @@ public bool Move (int col, int row)
2219
return false;
2320
}
2421

25-
if (col < 0 || row < 0 || col >= Viewport.Width || row >= Viewport.Height)
26-
{
27-
return false;
28-
}
29-
3022
Point screen = ViewportToScreen (new Point (col, row));
3123
Driver?.Move (screen.X, screen.Y);
3224

Terminal.Gui/View/View.Hierarchy.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public virtual void OnRemoved (SuperViewChangedEventArgs e)
145145
/// <para>
146146
/// Normally Subviews will be disposed when this View is disposed. Removing a Subview causes ownership of the
147147
/// Subview's
148-
/// lifecycle to be transferred to the caller; the caller muse call <see cref="Dispose"/>.
148+
/// lifecycle to be transferred to the caller; the caller must call <see cref="Dispose()"/>.
149149
/// </para>
150150
/// </remarks>
151151
/// <returns>
@@ -214,7 +214,7 @@ public virtual void OnRemoved (SuperViewChangedEventArgs e)
214214
/// <para>
215215
/// Normally Subviews will be disposed when this View is disposed. Removing a Subview causes ownership of the
216216
/// Subview's
217-
/// lifecycle to be transferred to the caller; the caller must call <see cref="Dispose"/> on any Views that were
217+
/// lifecycle to be transferred to the caller; the caller must call <see cref="Dispose()"/> on any Views that were
218218
/// added.
219219
/// </para>
220220
/// </remarks>

Terminal.Gui/View/View.Layout.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,28 @@ private bool SetFrame (in Rectangle frame)
9696
SetNeedsLayout ();
9797

9898
// BUGBUG: When SetFrame is called from Frame_set, this event gets raised BEFORE OnResizeNeeded. Is that OK?
99-
OnViewportChanged (new (IsInitialized ? Viewport : Rectangle.Empty, oldViewport));
99+
OnFrameChanged (in frame);
100+
FrameChanged?.Invoke (this, new (in frame));
100101

102+
if (oldViewport != Viewport)
103+
{
104+
RaiseViewportChangedEvent (oldViewport);
105+
}
101106
return true;
102107
}
103108

109+
/// <summary>
110+
/// Called when <see cref="Frame"/> changes.
111+
/// </summary>
112+
/// <param name="frame">The new Frame.</param>
113+
protected virtual void OnFrameChanged (in Rectangle frame) { }
114+
115+
/// <summary>
116+
/// Raised when the <see cref="Frame"/> changes. This event is raised after the <see cref="Frame"/> has been
117+
/// updated.
118+
/// </summary>
119+
public event EventHandler<EventArgs<Rectangle>>? FrameChanged;
120+
104121
/// <summary>Gets the <see cref="Frame"/> with a screen-relative location.</summary>
105122
/// <returns>The location and size of the view in screen-relative coordinates.</returns>
106123
public virtual Rectangle FrameToScreen ()

0 commit comments

Comments
 (0)