Skip to content

Commit

Permalink
Revert "Illustrates gui-cs#2331 (Scrollview not respecting clip) does…
Browse files Browse the repository at this point in the history
… not reproduce (gui-cs#2332)"

This reverts commit c85ff95.
  • Loading branch information
tig committed Feb 20, 2023
1 parent c85ff95 commit 6bb90ed
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 620 deletions.
4 changes: 1 addition & 3 deletions Terminal.Gui/Core/TextFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1190,9 +1190,7 @@ public void Draw (Rect bounds, Attribute normalColor, Attribute hotColor, Rect c
for (int line = 0; line < linesFormated.Count; line++) {
if ((isVertical && line > bounds.Width) || (!isVertical && line > bounds.Height))
continue;
if ((isVertical && line >= maxBounds.Left + maxBounds.Width - 1)
|| (!isVertical && line >= maxBounds.Top + maxBounds.Height - 1))

if ((isVertical && line > maxBounds.Left + maxBounds.Width - bounds.X) || (!isVertical && line > maxBounds.Top + maxBounds.Height - bounds.Y))
break;

var runes = lines [line].ToRunes ();
Expand Down
26 changes: 11 additions & 15 deletions Terminal.Gui/Core/View.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1105,8 +1105,15 @@ public void BringSubviewForward (View subview)
/// </remarks>
public void Clear ()
{
var h = Frame.Height;
var w = Frame.Width;
Rect containerBounds = GetContainerBounds ();
Rect viewBounds = Bounds;
if (!containerBounds.IsEmpty) {
viewBounds.Width = Math.Min (viewBounds.Width, containerBounds.Width);
viewBounds.Height = Math.Min (viewBounds.Height, containerBounds.Height);
}

var h = viewBounds.Height;
var w = viewBounds.Width;
for (var line = 0; line < h; line++) {
Move (0, line);
for (var col = 0; col < w; col++)
Expand Down Expand Up @@ -1518,13 +1525,13 @@ public virtual void Redraw (Rect bounds)
}

if (!ustring.IsNullOrEmpty (TextFormatter.Text)) {
Rect containerBounds = GetContainerBounds ();
Clear (ViewToScreen (GetNeedDisplay (containerBounds)));
Clear ();
SetChildNeedsDisplay ();
// Draw any Text
if (TextFormatter != null) {
TextFormatter.NeedsFormat = true;
}
Rect containerBounds = GetContainerBounds ();
TextFormatter?.Draw (ViewToScreen (Bounds), HasFocus ? ColorScheme.Focus : GetNormalColor (),
HasFocus ? ColorScheme.HotFocus : Enabled ? ColorScheme.HotNormal : ColorScheme.Disabled,
containerBounds);
Expand Down Expand Up @@ -1562,17 +1569,6 @@ public virtual void Redraw (Rect bounds)
ClearNeedsDisplay ();
}

Rect GetNeedDisplay (Rect containerBounds)
{
Rect rect = NeedDisplay;
if (!containerBounds.IsEmpty) {
rect.Width = Math.Min (NeedDisplay.Width, containerBounds.Width);
rect.Height = Math.Min (NeedDisplay.Height, containerBounds.Height);
}

return rect;
}

Rect GetContainerBounds ()
{
var containerBounds = SuperView == null ? default : SuperView.ViewToScreen (SuperView.Bounds);
Expand Down
313 changes: 0 additions & 313 deletions UICatalog/Scenarios/ASCIICustomButton.cs

This file was deleted.

Loading

0 comments on commit 6bb90ed

Please sign in to comment.