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 #2489. Create new ScrollBar based on a new Scroll and remove ScrollBarView/ScrollView #3498

Closed
wants to merge 105 commits into from

Conversation

BDisp
Copy link
Collaborator

@BDisp BDisp commented May 23, 2024

Fixes

Proposed Changes/Todos

  • Add Scroll class and unit tests
  • Add ScrollSlider class and unit tests
  • Add ScrolBar class and unit tests
  • Add ScrollButton class
  • Add @tig View.ScrollBars
  • Remove ScrollBarView
  • Remove ScrollView

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 a review from tig as a code owner May 23, 2024 21:46
@BDisp BDisp marked this pull request as draft May 23, 2024 21:46
@BDisp
Copy link
Collaborator Author

BDisp commented May 23, 2024

I would appreciate the Scroll class being reviewed before moving forward with the ScollBar class. Thanks.

@tig
Copy link
Collaborator

tig commented May 23, 2024

Ooooh! I'm super excited to review this! Will do asap.

@BDisp
Copy link
Collaborator Author

BDisp commented May 24, 2024

The width/height of the Scroll is not limited to 1 but only to what the user wants.

WindowsTerminal_or6sJpC3c5

@BDisp
Copy link
Collaborator Author

BDisp commented May 24, 2024

@tig how about you creating a new Content or Viewport box in the AdornmentsEditor to set the foreground and background colors. Instead of using Top, Right, Bottom and Left, it can use the Axis, ContentSize or whatever. What do you think?

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.

Really slick!!

I've got a PR with some changes that you might like. I'll submit it vs. making a lot of comments.

Terminal.Gui/Views/Scroll.cs Outdated Show resolved Hide resolved
Terminal.Gui/Views/Scroll.cs Outdated Show resolved Hide resolved
Terminal.Gui/Views/Scroll.cs Outdated Show resolved Hide resolved
@tig
Copy link
Collaborator

tig commented May 24, 2024

@tig how about you creating a new Content or Viewport box in the AdornmentsEditor to set the foreground and background colors. Instead of using Top, Right, Bottom and Left, it can use the Axis, ContentSize or whatever. What do you think?

You mean being able to set the Normal.Background/Forground color for the View itself? Like the colorpicker in Content Scrolling does?

image

@BDisp
Copy link
Collaborator Author

BDisp commented May 24, 2024

You mean being able to set the Normal.Background/Forground color for the View itself? Like the colorpicker in Content Scrolling does?

Yes or for the view passed on the ViewToEdit property. That's more or less the idea.

@BDisp
Copy link
Collaborator Author

BDisp commented May 25, 2024

@tig did you reorganize by placing the backfields before the properties by hand, or through some automatic system? I normally use R#'s Ctrl+E+C and it's not reformatting that way.

@tig
Copy link
Collaborator

tig commented May 25, 2024

@tig did you reorganize by placing the backfields before the properties by hand, or through some automatic system? I normally use R#'s Ctrl+E+C and it's not reformatting that way.

By hand. It's still broken.

@tig
Copy link
Collaborator

tig commented May 25, 2024

You mean being able to set the Normal.Background/Forground color for the View itself? Like the colorpicker in Content Scrolling does?

Yes or for the view passed on the ViewToEdit property. That's more or less the idea.

Greet idea. I'll do it as part of #3376 where I've already completely re-done AdornmentEditor. I'm going to rename it to ViewEditor as well. I also want to integrate ViewEditor into AllViewsTester because I use that a lot to audit view behaviors and being able to tweak settings live is super useful.

I also added the abilty to just click on any view in the Scenario and ViewToEdit will be set to that view.

Terminal.Gui/Views/Scroll.cs Outdated Show resolved Hide resolved
Terminal.Gui/Views/Scroll.cs Outdated Show resolved Hide resolved
@tig
Copy link
Collaborator

tig commented May 25, 2024

I just submitted another PR with quesitons / comments inline.

@tig
Copy link
Collaborator

tig commented May 25, 2024

IMO, View sub-classes should not have the word "View" in them as a general principle. `

ScrollBarView should be ScrollBar.

@BDisp
Copy link
Collaborator Author

BDisp commented Sep 5, 2024

I think it's working much better now. When you have time please test it. Thanks.

@tig
Copy link
Collaborator

tig commented Sep 7, 2024

image

I would like to maintaining the ShowScrollIndicator property because it will indicates that the visibility is false due the AutoHideScrollBar is true (visible if size is greater than the content size or invisible otherwise) and thus this check get => _showScrollIndicator && Visible; is crucial to to get the real state if the scroll visibility. If you don't agree please let me know.

I think ShowScrollIndicator is misnamed. "Indicator" should be "Bar", and "Show" is a verb, not a noun, so it's very confusing.

I do think you're correct that we need something more than just using Visible as I did in my prototype.

Here's a suggestion:

Add to ViewportSettings:

public enum ViewportSettings
{
...
    /// <summary>
    ///     If set, the vertical scroll bar (see <see cref="View.HorizontalScrollBar"/>) will be enabled and automatically made visible
    ///     when the dimension of the <see cref="View.Viewport"/> is smaller than the dimension of <see cref="View.GetContentSize()"/>.
    /// </summary>
    EnableHorizontalScrollBar = 64,

    /// <summary>
    ///     If set, the vertical scroll bar (see <see cref="View.VerticalScrollBar"/>) will be enabled and automatically made visible
    ///     when the dimension of the <see cref="View.Viewport"/> is smaller than the dimension of <see cref="View.GetContentSize()"/>.
    /// </summary>
    EnableVerticalScrollBar = 128,

    /// <summary>
    ///     If set, the horizontal and vertical scroll bars (see cref="View.HorizontalScrollBar"/> and <see cref="View.VerticalScrollBar"/>)
    ///     will be enabled and automatically made visible when the dimension of the <see cref="View.Viewport"/> is smaller than the
    ///     dimension of <see cref="View.GetContentSize()"/>.
    /// </summary>
    EnableScrollBars = EnableHorizontalScrollBar | EnableVerticalScrollBar

This moves the automatic behavior out of ScrollBar and into View and encapsulates that logic in View.ScrollBars.cs and consolodates content scrolling functionality.

If these flags are NOT set, then the developer can use view.Horizontal/VerticalScrollbar = true/false to manage visibility themselves.

What do you think of this idea?

@tig
Copy link
Collaborator

tig commented Sep 9, 2024

Can I just say how much I love the work @BDisp is doing in this PR? Love. Love. Love.

@tig tig mentioned this pull request Sep 9, 2024
2 tasks
@tig
Copy link
Collaborator

tig commented Sep 9, 2024

@BDisp see my comment here:

When you nuke the old ScrollView etc..., can you please take care of IsOverriden too?

@tig
Copy link
Collaborator

tig commented Oct 23, 2024

@BDisp what's the status of this PR?

In #3761 I'm fighting with the old hackyScrollView and ScrollBarView code that does a lot of unnatural things w.r.t. drawing and layout. Instead of spending time & energy fixing those things (and views that depend on them), i'd much rather have us spend time getting the new classes working well.

Thanks.

@BDisp
Copy link
Collaborator Author

BDisp commented Oct 23, 2024

@BDisp what's the status of this PR?

In #3761 I'm fighting with the old hackyScrollView and ScrollBarView code that does a lot of unnatural things w.r.t. drawing and layout. Instead of spending time & energy fixing those things (and views that depend on them), i'd much rather have us spend time getting the new classes working well.

Thanks.

Sorry, I never worked on it again. I'm busy with some other stuff. But I'll get back to it as soon as I can.

@tig
Copy link
Collaborator

tig commented Nov 7, 2024

@BDisp what's the status of this PR?
In #3761 I'm fighting with the old hackyScrollView and ScrollBarView code that does a lot of unnatural things w.r.t. drawing and layout. Instead of spending time & energy fixing those things (and views that depend on them), i'd much rather have us spend time getting the new classes working well.
Thanks.

Sorry, I never worked on it again. I'm busy with some other stuff. But I'll get back to it as soon as I can.

No problem. I'm working on it right now on top of the branch I'm using for #3798 .

@BDisp
Copy link
Collaborator Author

BDisp commented Nov 7, 2024

No problem. I'm working on it right now on top of the branch I'm using for #3798 .

Thanks for the help. Then I'll focused on others things, ok?

@tig
Copy link
Collaborator

tig commented Nov 8, 2024

Yep. Love the driver work you're doing!

@BDisp
Copy link
Collaborator Author

BDisp commented Nov 8, 2024

I've a branch where I already removed the old scroll bars and starting the implementation with the views that were use them. But a long time ago I already have done that before and I had some tedious working on this again. But I'll see if I can reanime again to work with it.

@tig
Copy link
Collaborator

tig commented Nov 10, 2024

New PR based on this great work: #3811.

Closing this one.

@tig tig closed this Nov 10, 2024
@BDisp BDisp deleted the v2_2489_scroll-scrollbar-new branch November 18, 2024 15:22
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.

Create new ScrollBar based on a new Scroll and remove ScrollBarView/ScrollView
3 participants