Skip to content

Commit

Permalink
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
Browse files Browse the repository at this point in the history
  • Loading branch information
tig committed Nov 19, 2024
2 parents a500cc5 + 4664481 commit 208461f
Show file tree
Hide file tree
Showing 73 changed files with 6,644 additions and 7,864 deletions.
4 changes: 2 additions & 2 deletions Terminal.Gui/Drawing/Glyphs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ public class GlyphDefinitions
/// <summary>Continuous block meter segment (e.g. for <see cref="ProgressBar"/>).</summary>
public Rune ContinuousMeterSegment { get; set; } = (Rune)'█';

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

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

/// <summary>Close. Default is Heavy Ballot X (U+2718) - ✘.</summary>
Expand Down
2 changes: 1 addition & 1 deletion Terminal.Gui/Drawing/Thickness.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public Rectangle GetInside (Rectangle rect)
}

/// <summary>
/// Gets the total width of the left and right sides of the rectangle. Sets the width of the left and rigth sides
/// Gets the total width of the left and right sides of the rectangle. Sets the width of the left and right sides
/// of the rectangle to half the specified value.
/// </summary>
public int Horizontal
Expand Down
89 changes: 0 additions & 89 deletions Terminal.Gui/Input/Responder.cs

This file was deleted.

3 changes: 0 additions & 3 deletions Terminal.Gui/Terminal.Gui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@
<LastGenOutput>Strings.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Folder Include="Views\Scroll\" />
</ItemGroup>
<!-- =================================================================== -->
<!-- Nuget -->
<!-- =================================================================== -->
Expand Down
31 changes: 29 additions & 2 deletions Terminal.Gui/View/View.Content.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ private void SetViewport (Rectangle viewport)
//SetSubViewNeedsDraw();
}

OnViewportChanged (new (IsInitialized ? Viewport : Rectangle.Empty, oldViewport));
RaiseViewportChangedEvent (oldViewport);

return;
}
Expand All @@ -325,6 +325,10 @@ private void SetViewport (Rectangle viewport)
Size = newSize
};

// Note, setting the Frame will cause ViewportChanged to be raised.

return;

void ApplySettings (ref Rectangle newViewport)
{
if (!ViewportSettings.HasFlag (ViewportSettings.AllowXGreaterThanContentWidth))
Expand All @@ -344,6 +348,14 @@ void ApplySettings (ref Rectangle newViewport)
}
}

if (!ViewportSettings.HasFlag (ViewportSettings.AllowNegativeXWhenWidthGreaterThanContentWidth))
{
if (Viewport.Width > GetContentSize ().Width)
{
newViewport.X = 0;
}
}

if (!ViewportSettings.HasFlag (ViewportSettings.AllowYGreaterThanContentHeight))
{
if (newViewport.Y >= GetContentSize ().Height)
Expand All @@ -352,6 +364,14 @@ void ApplySettings (ref Rectangle newViewport)
}
}

if (!ViewportSettings.HasFlag (ViewportSettings.AllowNegativeYWhenHeightGreaterThanContentHeight))
{
if (Viewport.Height > GetContentSize ().Height)
{
newViewport.Y = 0;
}
}

// IMPORTANT: Check for negative location AFTER checking for location greater than content width
if (!ViewportSettings.HasFlag (ViewportSettings.AllowNegativeY))
{
Expand All @@ -363,6 +383,13 @@ void ApplySettings (ref Rectangle newViewport)
}
}

private void RaiseViewportChangedEvent (Rectangle oldViewport)
{
var args = new DrawEventArgs (IsInitialized ? Viewport : Rectangle.Empty, oldViewport);
OnViewportChanged (args);
ViewportChanged?.Invoke (this, args);
}

/// <summary>
/// Fired when the <see cref="Viewport"/> changes. This event is fired after the <see cref="Viewport"/> has been
/// updated.
Expand All @@ -373,7 +400,7 @@ void ApplySettings (ref Rectangle newViewport)
/// Called when the <see cref="Viewport"/> changes. Invokes the <see cref="ViewportChanged"/> event.
/// </summary>
/// <param name="e"></param>
protected virtual void OnViewportChanged (DrawEventArgs e) { ViewportChanged?.Invoke (this, e); }
protected virtual void OnViewportChanged (DrawEventArgs e) { }

/// <summary>
/// Converts a <see cref="Viewport"/>-relative location and size to a screen-relative location and size.
Expand Down
2 changes: 1 addition & 1 deletion Terminal.Gui/View/View.Drawing.Clipping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public static void SetClip (Region? region)
if (this is Adornment adornment && adornment.Thickness != Thickness.Empty)
{
// Ensure adornments can't draw outside their thickness
frameRegion.Exclude (adornment.Thickness.GetInside (Frame));
frameRegion.Exclude (adornment.Thickness.GetInside (FrameToScreen()));
}

SetClip (frameRegion);
Expand Down
8 changes: 0 additions & 8 deletions Terminal.Gui/View/View.Drawing.Primitives.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ public partial class View
/// <summary>Moves the drawing cursor to the specified <see cref="Viewport"/>-relative location in the view.</summary>
/// <remarks>
/// <para>
/// If the provided coordinates are outside the visible content area, this method does nothing.
/// </para>
/// <para>
/// The top-left corner of the visible content area is <c>ViewPort.Location</c>.
/// </para>
/// </remarks>
Expand All @@ -22,11 +19,6 @@ public bool Move (int col, int row)
return false;
}

if (col < 0 || row < 0 || col >= Viewport.Width || row >= Viewport.Height)
{
return false;
}

Point screen = ViewportToScreen (new Point (col, row));
Driver?.Move (screen.X, screen.Y);

Expand Down
4 changes: 2 additions & 2 deletions Terminal.Gui/View/View.Hierarchy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public virtual void OnRemoved (SuperViewChangedEventArgs e)
/// <para>
/// Normally Subviews will be disposed when this View is disposed. Removing a Subview causes ownership of the
/// Subview's
/// lifecycle to be transferred to the caller; the caller muse call <see cref="Dispose"/>.
/// lifecycle to be transferred to the caller; the caller must call <see cref="Dispose()"/>.
/// </para>
/// </remarks>
/// <returns>
Expand Down Expand Up @@ -214,7 +214,7 @@ public virtual void OnRemoved (SuperViewChangedEventArgs e)
/// <para>
/// Normally Subviews will be disposed when this View is disposed. Removing a Subview causes ownership of the
/// Subview's
/// lifecycle to be transferred to the caller; the caller must call <see cref="Dispose"/> on any Views that were
/// lifecycle to be transferred to the caller; the caller must call <see cref="Dispose()"/> on any Views that were
/// added.
/// </para>
/// </remarks>
Expand Down
19 changes: 18 additions & 1 deletion Terminal.Gui/View/View.Layout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,28 @@ private bool SetFrame (in Rectangle frame)
SetNeedsLayout ();

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

if (oldViewport != Viewport)
{
RaiseViewportChangedEvent (oldViewport);
}
return true;
}

/// <summary>
/// Called when <see cref="Frame"/> changes.
/// </summary>
/// <param name="frame">The new Frame.</param>
protected virtual void OnFrameChanged (in Rectangle frame) { }

/// <summary>
/// Raised when the <see cref="Frame"/> changes. This event is raised after the <see cref="Frame"/> has been
/// updated.
/// </summary>
public event EventHandler<EventArgs<Rectangle>>? FrameChanged;

/// <summary>Gets the <see cref="Frame"/> with a screen-relative location.</summary>
/// <returns>The location and size of the view in screen-relative coordinates.</returns>
public virtual Rectangle FrameToScreen ()
Expand Down
Loading

0 comments on commit 208461f

Please sign in to comment.