ppizarror / pygame-menu

A menu for pygame. Simple, and easy to use
https://pygame-menu.readthedocs.io/
Other
544 stars 141 forks source link

Disable scrollbars? #396

Closed vnmabus closed 2 years ago

vnmabus commented 2 years ago

I am trying to adjust the size of the menu to its contents. In order to do that, I am using the following code:

widgets_size = menu.get_size(widget=True)
menu.resize(*widgets_size)

The problem is that the scrollbars appear and hide part of the widgets. I tried using

menu.get_scrollarea().hide_scrollbars(pygame_menu.locals.ORIENTATION_HORIZONTAL)
menu.get_scrollarea().hide_scrollbars(pygame_menu.locals.ORIENTATION_VERTICAL)

to get rid of those, but they still appear. I also tried to set the scrollbar thickness to 0 in the theme, but that causes an exception.

Is there a way to disable scrollbars in a particular menu or theme?

ppizarror commented 2 years ago

Hi @vnmabus, I found what the error was. The scrollbars were hidden after you called these functions, but the menu updated the rect size shortly after, dynamically changing the scrollbar's visibility.

To solve this issue, I introduced the force param on .show() and .hide() scrollbar methods. Thus, hide_scrollbars call .hide with force=True.

Also, I've improved Scrollarea.get_view_rect method and added SCROLLAREA_POSITION_NONE as a valid position for theme.scrollarea_position.

See #397 for more details. Let me know if this solves your issue.

vnmabus commented 2 years ago

It looks like both options work!

ppizarror commented 2 years ago

I'll merge asap. If you encounter any other issue please let me know. If you need a new PyPI version I'll release v4.2.7

vnmabus commented 2 years ago

Thank you!