Skip to content

Commit

Permalink
Fixes gui-cs#2882. TabView: 'Frame.DrawFrame(Rect, bool)' is obsolete…
Browse files Browse the repository at this point in the history
…: 'This method is obsolete in v2. Use use LineCanvas or Frame (gui-cs#2980)

* Fixes gui-cs#2882. TabView: 'Frame.DrawFrame(Rect, bool)' is obsolete: 'This method is obsolete in v2. Use use LineCanvas or Frame

* Trying fix this unit test that sometimes fail.

* Fixes gui-cs#2983. View need a alternative DrawFrame for the v2.

* Use new DrawFrame method.

* Change _lines field to Lines property.

* Add TabWindow unit test.

* Add DrawIncompleteFrame method and unit tests.

* Add more unit tests to LineCanvas.

* Fix newline conflict errors.

* Revert "Change _lines field to Lines property."

This reverts commit ab6c5f3.

* Add DrawIncompleteFrame method and unit tests.

* Add more unit tests to LineCanvas.

* Fix newline conflict errors.

* Force render immediately instead of join.

* I will never rely on zero-location-based unit test again.

* Fix TestTreeViewColor unit test fail.

* Using location of 3 to avoid be divisible by 2 and so avoiding bugs.

* Revert "Using location of 3 to avoid be divisible by 2 and so avoiding bugs."

This reverts commit dd3df13.

* Revert "I will never rely on zero-location-based unit test again."

This reverts commit 62adf6f.

* Revert "Fix newline conflict errors."

This reverts commit 4acf726.

* Revert "Add more unit tests to LineCanvas."

This reverts commit 66bc6f5.

* Revert "Add DrawIncompleteFrame method and unit tests."

This reverts commit 680ba26.

* Resolving merge conflicts.

* Revert "Use new DrawFrame method."

This reverts commit 69a7f17.

* Revert "Fixes gui-cs#2983. View need a alternative DrawFrame for the v2."

This reverts commit dade9fd.

* Reverting this changes to start a new one.

* Add horizontal and vertical support for combining glyphs.

* Fix text and auto size behavior.

* Add TabWidth property.

* Add unit test for WordWrap.

* Fixes gui-cs#3017. View TextDirection returns incorrect size on a vertical direction instance with AutoSize as false.

* Using Frame to force read from the get method.

* Fix some issues with AutoSize and ForceValidatePosDim.

* Fixing broken unit tests.

* Restoring code I've broken.

* Removing forgotten code.

* Only LayoutStyle.Computed can change the Frame.

* DateField and TimeField depends on LayoutStyle.Computed.

* Fix unit tests related with LayoutStyle.

* Implements tabs, left and right arrows as View.

* Draws a minimum full border.

* Adds missing XML parameter.

* Adds assert tests for Frame.

* Removes duplicates InlineData.

* Adds more unit tests for minimum full border without Left and Right thickness.

* Trying to fix the TestTreeViewColor unit test fail.

* Prevents a user to set TextDirection to -1.

* Prevents any invalid TextDirection value.

* Removes (TextDirection)(-1).

* Removes unnecessary TextDirection initialization.

* Removes LayoutStyle.

* Fixing unit tests with border.

* Trying to fix TestTreeViewColor again.

* Revert "Trying to fix TestTreeViewColor again."

This reverts commit c2efa8e.

* Trying to fix TestTreeViewColor again.

* Fix merge errors.

* Fix merge errors.

* Restoring unit test.

* Restores the right XML comment.

* Fix Disposing unit tests that sometimes throws because some instances aren't cleared on others unit tests classes.

* Fix Disposing unit tests that sometimes throws because some instances aren't cleared on others unit tests classes.

* Only call OnResizeNeeded if it's LayoutStyle.Computed.

* Fix merge errors.

* Fix merge errors.

* Fix unit tests fail.

* Reformat.

* Again.

* Rename to OnDrawAdornments.

* Fix failing unit tests.

* Reduces indentation and cleanup code.

* Cleanup code.

* Fix bug done when cleanup.

* Replace FrameHandledMouseEvent to AdornmentHandledMouseEvent.

* Removes Tab constructor parameters.

---------

Co-authored-by: Tig <tig@users.noreply.github.com>
  • Loading branch information
BDisp and tig committed Jan 16, 2024
1 parent 1033c8a commit 5ace62b
Show file tree
Hide file tree
Showing 14 changed files with 2,956 additions and 2,302 deletions.
8 changes: 4 additions & 4 deletions Terminal.Gui/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1251,7 +1251,7 @@ public static void OnMouseEvent (MouseEventEventArgs a)
}
}

bool FrameHandledMouseEvent (Adornment frame)
bool AdornmentHandledMouseEvent(Adornment frame)
{
if (frame?.Thickness.Contains (frame.FrameToScreen (), a.MouseEvent.X, a.MouseEvent.Y) ?? false) {
var boundsPoint = frame.ScreenToBounds (a.MouseEvent.X, a.MouseEvent.Y);
Expand All @@ -1272,10 +1272,10 @@ bool FrameHandledMouseEvent (Adornment frame)
if (view != null) {
// Work inside-out (Padding, Border, Margin)
// TODO: Debate whether inside-out or outside-in is the right strategy
if (FrameHandledMouseEvent (view?.Padding)) {
if (AdornmentHandledMouseEvent(view?.Padding)) {
return;
}
if (FrameHandledMouseEvent (view?.Border)) {
if (AdornmentHandledMouseEvent(view?.Border)) {
if (view is Toplevel) {
// TODO: This is a temporary hack to work around the fact that
// drag handling is handled in Toplevel (See Issue #2537)
Expand Down Expand Up @@ -1314,7 +1314,7 @@ bool FrameHandledMouseEvent (Adornment frame)
return;
}

if (FrameHandledMouseEvent (view?.Margin)) {
if (AdornmentHandledMouseEvent(view?.Margin)) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions Terminal.Gui/Drawing/Thickness.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ public int Horizontal {
/// the rectangle described by <see cref="GetInside(Rect)"/>.
/// </summary>
/// <param name="outside">Describes the location and size of the rectangle that contains the thickness.</param>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="x">The x coord to check.</param>
/// <param name="y">The y coord to check.</param>
/// <returns><see langword="true"/> if the specified coordinate is within the thickness; <see langword="false"/> otherwise.</returns>
public bool Contains (Rect outside, int x, int y)
{
Expand Down
28 changes: 9 additions & 19 deletions Terminal.Gui/Views/Tab.cs
Original file line number Diff line number Diff line change
@@ -1,39 +1,29 @@
namespace Terminal.Gui;

/// <summary>
/// A single tab in a <see cref="TabView"/>
/// A single tab in a <see cref="TabView"/>.
/// </summary>
public class Tab {
private string text;
public class Tab : View {
private string _displayText;

/// <summary>
/// The text to display in a <see cref="TabView"/>
/// The text to display in a <see cref="TabView"/>.
/// </summary>
/// <value></value>
public string Text { get => text ?? "Unamed"; set => text = value; }
public string DisplayText { get => _displayText ?? "Unamed"; set => _displayText = value; }

/// <summary>
/// The control to display when the tab is selected
/// The control to display when the tab is selected.
/// </summary>
/// <value></value>
public View View { get; set; }

/// <summary>
/// Creates a new unamed tab with no controls inside
/// Creates a new unamed tab with no controls inside.
/// </summary>
public Tab ()
{

}

/// <summary>
/// Creates a new tab with the given text hosting a view
/// </summary>
/// <param name="text"></param>
/// <param name="view"></param>
public Tab (string text, View view)
{
this.Text = text;
this.View = view;
BorderStyle = LineStyle.Rounded;
CanFocus = true;
}
}
Loading

0 comments on commit 5ace62b

Please sign in to comment.