Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #2558. MenuBar positions wrong in some situations. #2561

Closed
wants to merge 7 commits into from

Conversation

BDisp
Copy link
Collaborator

@BDisp BDisp commented Apr 17, 2023

menu-on-savedialog
Fixes #2558 - Application.Top added by the Application.Init must always be added to the toplevels stack and initialized. If a toplevel is a IsOverlappedContainer then the Application.Top must be set to the OverlappedTop.

Pull Request checklist:

  • I've named my PR in the form of "Fixes #issue. Terse description."
  • My code follows the style guidelines of Terminal.Gui - if you use Visual Studio, hit CTRL-K-D to automatically reformat your files before committing.
  • My code follows the Terminal.Gui library design guidelines
  • I ran dotnet test before commit
  • I have made corresponding changes to the API documentation (using /// style comments)
  • My changes generate no new warnings
  • I have checked my code and corrected any poor grammar or misspellings
  • I conducted basic QA to assure all features are working

@BDisp BDisp requested review from migueldeicaza and tig as code owners April 17, 2023 00:19
@BDisp BDisp marked this pull request as draft April 17, 2023 10:59
@BDisp BDisp marked this pull request as ready for review April 17, 2023 17:26
Nutzzz and others added 3 commits April 17, 2023 18:26
* Add many styles to SpinnerView

* Add SpinnerStyles as a nested class

* Allow zero as valid spinner delay value

* Change from BorderStyle to LineStyle

* Rename SpinDelayInMilliseconds to just SpinDelay

---------

Co-authored-by: Tig <[email protected]>
@BDisp
Copy link
Collaborator Author

BDisp commented Apr 17, 2023

@tig I'm tying to re-enabling some unit tests that are commented. One is the Dialog_In_Window_Without_Size_One_Button_Aligns where you have this comment:
// BUGBUG: This seems wrong; is it a bug in Dim.Percent(85)??
and this output:

┌┌───────────────┐─┐
││               │ │
││     [ Ok ]    │ │
│└───────────────┘ │
└──────────────────┘

As you can see the height of the Window is 5. The available height inside is 5-2=3. The proportion is 3/5=0.6x100=60%. This is the ideal percentage for a Dialog, 60% and not 85%. In this case the new dimension is 5x60%=3. If you use the current value the dimension will be 5x85%=4.25, almost 5 which is the same size of the Window. So, I propose to change the Dialog percentage to 60%, at least for the height and the result is this:

┌──────────────────┐
│   ┌──────────┐   │
│   │  [ Ok ]  │   │
│   └──────────┘   │
└──────────────────┘

@BDisp
Copy link
Collaborator Author

BDisp commented Apr 17, 2023

@tig we can use the Math.Ceiling on Percent to round up or create an option to that.

internal override int Anchor (int width)
	{
		return (int)Math.Ceiling (width * factor);
	}

See the differences for height of 7:
Expected:

┌──────────────────┐
│   ┌──────────┐   │
│   │          │   │
│   │  [ Ok ]  │   │
│   └──────────┘   │
│                  │
└──────────────────┘
But Was:
┌──────────────────┐
│   ┌──────────┐   │
│   │          │   │
│   │          │   │
│   │  [ Ok ]  │   │
│   └──────────┘   │
└──────────────────┘

@tig
Copy link
Collaborator

tig commented Apr 18, 2023

This is the ideal percentage for a Dialog, 60% and not 85%. In this case the new dimension is 5x60%=3. So, I propose to change the Dialog percentage to 60%, at least for the height and the result is this:

I don't have an issue with this; lots of unit tests will break because we way over-use Dialog for tests that have nothing to do with Dialog, but that's fixable.

@tig we can use the Math.Ceiling on Percent to round up or create an option to that.

This makes sense to me, but again, it'll probably break a lot of unit tests that will need to be fixed.

@BDisp BDisp marked this pull request as draft April 18, 2023 16:17
@BDisp BDisp marked this pull request as ready for review April 18, 2023 22:39
Copy link
Collaborator

@tig tig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this fix takes Menubar in the wrong direction: It makes it an even more "special" view. IMO, MenuBar (and StatusBar) has too many special cases baked into Application and Toplevel that should all be removed. It should be possible to use Menubar in any View and it should be possible for devs to build other Views that can be used instead of Menubar (or StatusBar).

@@ -368,6 +368,72 @@ public static Toplevel Create ()
/// </summary>
public bool IsLoaded { get; private set; }

/// <inheritdoc/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oooh. Making Height/Width virtual is a HUGE change.

Is this absolutely necessary to fix this Issue?

Subclasses of View that override these need to be coded very carefully. I fear this could be a real bugfarm in the future.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also will make it harder for us to get rid of Toplevel (#2502), and allow any view to act in an overlapping manner.

@BDisp BDisp marked this pull request as draft April 19, 2023 16:16
@tig tig closed this Apr 25, 2023
@BDisp BDisp deleted the v2_application.top-fix_2558 branch May 12, 2023 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants