Skip to content

Commit

Permalink
Merge pull request #403 from ppizarror/vfill-widget
Browse files Browse the repository at this point in the history
Vfill widget
  • Loading branch information
ppizarror authored Apr 4, 2022
2 parents 9c09143 + 1678b13 commit 5709842
Show file tree
Hide file tree
Showing 38 changed files with 450 additions and 166 deletions.
26 changes: 26 additions & 0 deletions docs/_source/add_widgets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,32 @@ more options, take a look at the ``ToggleSwitch`` widget class.
.. automethod:: pygame_menu._widgetmanager.WidgetManager.toggle_switch


Add a vertical fill
-------------------

A vertical fill adds a vertical margin to fill the menu height. It depends on other
vertical fillers in the same column, i.e., if three vertical fillers are in the same
column, them will take a third of the available vertical space.

**Example:**

.. image:: ../_static/widget_vfill.png
:scale: 75%
:align: center

.. code-block:: python
menu = pygame_menu.Menu(...)
menu.add.vertical_fill()
menu.add.button('Button 1')
menu.add.vertical_fill()
menu.add.button('Button 2')
menu.add.vertical_fill()
.. automethod:: pygame_menu._widgetmanager.WidgetManager.vertical_fill


Add a vertical spacer
---------------------

Expand Down
3 changes: 3 additions & 0 deletions docs/_source/contributors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ Other contributors:
- `ironsmile <https://github.com/ironsmile>`_
- `jwllee <https://github.com/jwllee>`_
- `maditnerd <https://github.com/maditnerd>`_
- `MayuSakurai <https://github.com/MayuSakurai>`_
- `mrkprdo <https://github.com/mrkprdo>`_
- `notrurs <https://github.com/notrurs>`_
- `NullP01nt <https://github.com/NullP01nt>`_
- `PandaRoux8 <https://github.com/PandaRoux8>`_
- `Rifqi31 <https://github.com/rifqi31>`_
- `ThePeeps191 <https://github.com/ThePeeps191>`_
- `thisIsMikeKane <https://github.com/thisIsMikeKane>`_
- `vnmabus <https://github.com/vnmabus>`_
- `werdeil <https://github.com/werdeil>`_
- `zPaw <https://github.com/zPaw>`_

Expand Down
2 changes: 1 addition & 1 deletion docs/_source/widgets_button.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ Button
:members:
:show-inheritance:
:inherited-members:
:exclude-members: draw_after_if_selected, set_onchange, change, set_default_value, set_value, reset_value, get_value, value_changed
:exclude-members: change, draw_after_if_selected, get_value, reset_value, set_default_value, set_onchange, set_value, value_changed
2 changes: 1 addition & 1 deletion docs/_source/widgets_colorinput.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ ColorInput
:members:
:show-inheritance:
:inherited-members:
:exclude-members: draw_after_if_selected, rotate, scale, set_max_width, set_max_height, resize
:exclude-members: draw_after_if_selected, resize, rotate, scale, set_max_height, set_max_width
2 changes: 1 addition & 1 deletion docs/_source/widgets_dropselect.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ DropSelect
:members:
:show-inheritance:
:inherited-members:
:exclude-members: rotate, scale, set_max_width, set_max_height, resize, flip
:exclude-members: flip, resize, rotate, scale, set_max_height, set_max_width
2 changes: 1 addition & 1 deletion docs/_source/widgets_dropselect_multiple.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ DropSelectMultiple
:members:
:show-inheritance:
:inherited-members:
:exclude-members: rotate, scale, set_max_width, set_max_height, resize, flip
:exclude-members: flip, resize, rotate, scale, set_max_height, set_max_width
2 changes: 1 addition & 1 deletion docs/_source/widgets_frame.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ Frame
:members:
:show-inheritance:
:inherited-members:
:exclude-members: draw_after_if_selected, get_sound, get_selection_effect, get_selected_time, get_value, set_onreturn, set_onchange, set_default_value, reset_value, value_changed, is_selected, background_inflate_to_selection_effect, get_font_color_status, set_onselect, set_selection_effect, apply, change, flip, set_max_width, set_max_height, scale, rotate, select, set_shadow, set_sound, set_value
:exclude-members: apply, background_inflate_to_selection_effect, change, draw_after_if_selected, flip, get_font_color_status, get_selected_time, get_selection_effect, get_sound, get_value, is_selected, reset_value, rotate, scale, select, set_default_value, set_max_height, set_max_width, set_onchange, set_onreturn, set_onselect, set_selection_effect, set_shadow, set_sound, set_value, value_changed
2 changes: 1 addition & 1 deletion docs/_source/widgets_hmargin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ HMargin
:members:
:show-inheritance:
:inherited-members:
:exclude-members: set_tab_size, set_font_shadow, set_margin, get_margin, get_surface, get_sound, get_selection_effect, get_selected_time, get_padding, get_font_info, get_value, set_onreturn, set_onmouseover, set_onmouseleave, set_onchange, set_default_value, reset_value, value_changed, mouseover, mouseleave, is_selected, get_title, background_inflate_to_selection_effect, get_font_color_status, set_onselect, set_padding, set_title, set_background_color, set_selection_effect, apply, change, set_font, update_font, set_position, flip, set_max_width, set_max_height, scale, resize, translate, rotate, set_alignment, select, set_shadow, set_sound, set_cursor, set_controls, set_value, set_border, get_border, draw_after_if_selected
:exclude-members: add_self_to_kwargs, apply, background_inflate_to_selection_effect, change, draw_after_if_selected, flip, get_border, get_focus_rect, get_font_color_status, get_font_info, get_height, get_margin, get_padding, get_rect, get_selected_time, get_selection_effect, get_size, get_sound, get_surface, get_title, get_translate, get_value, get_width, is_selected, mouseleave, mouseover, render, reset_value, resize, rotate, scale, select, set_background_color, set_border, set_controls, set_cursor, set_default_value, set_font, set_font_shadow, set_margin, set_max_height, set_max_width, set_onchange, set_onmouseleave, set_onmouseover, set_onreturn, set_onselect, set_padding, set_position, set_selection_effect, set_shadow, set_sound, set_tab_size, set_title, set_value, shadow, translate, update_font, value_changed, update
2 changes: 1 addition & 1 deletion docs/_source/widgets_image.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ Image
:members:
:show-inheritance:
:inherited-members:
:exclude-members: set_font, get_font_info, draw_after_if_selected, set_sound, get_sound, get_font_color_status, get_value, value_changed, set_tab_size, set_font_shadow, update_font, set_title, get_title, update, set_onchange, set_onreturn, change, apply, set_default_value, set_value, reset_value
:exclude-members: apply, change, draw_after_if_selected, get_font_color_status, get_font_info, get_sound, get_title, get_value, reset_value, set_default_value, set_font, set_font_shadow, set_onchange, set_onreturn, set_sound, set_tab_size, set_title, set_value, update, update_font, value_changed
2 changes: 1 addition & 1 deletion docs/_source/widgets_label.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ Label
:members:
:show-inheritance:
:inherited-members:
:exclude-members: draw_after_if_selected, update, set_onchange, set_onreturn, change, apply, set_default_value, set_value, reset_value, get_value, value_changed, get_sound, set_sound
:exclude-members: apply, change, draw_after_if_selected, get_sound, get_value, reset_value, set_default_value, set_onchange, set_onreturn, set_sound, set_value, update, value_changed
2 changes: 1 addition & 1 deletion docs/_source/widgets_menubar.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ MenuBar
:members:
:show-inheritance:
:inherited-members:
:exclude-members: get_value, select, set_onselect, change, set_onchange, set_padding, scale, resize, set_max_height, set_max_width, set_selection_effect, set_border, flip, rotate, set_default_value, set_value, reset_value, draw_after_if_selected, value_changed
:exclude-members: change, draw_after_if_selected, flip, get_value, reset_value, resize, rotate, scale, select, set_border, set_default_value, set_max_height, set_max_width, set_onchange, set_onselect, set_padding, set_selection_effect, set_value, value_changed
2 changes: 1 addition & 1 deletion docs/_source/widgets_menulink.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ MenuLink
:members:
:show-inheritance:
:inherited-members:
:exclude-members: add_self_to_kwargs, add_draw_callback, apply_draw_callbacks, remove_draw_callback, get_alignment, get_border, get_decorator, get_frame, get_frame_depth, set_frame, get_focus_rect, get_height, get_margin, get_position, get_size, get_translate, get_width, set_float, draw_after_if_selected, set_tab_size, set_font_shadow, get_surface, get_sound, get_selection_effect, get_selected_time, get_padding, get_font_info, get_value, set_onreturn, set_onmouseover, set_onmouseleave, set_onchange, value_changed, set_default_value, reset_value, mouseover, mouseleave, is_selected, get_title, background_inflate_to_selection_effect, get_font_color_status, set_onselect, set_padding, set_title, get_rect, set_background_color, set_selection_effect, apply, change, set_margin, set_font, update_font, set_position, flip, set_max_width, set_max_height, scale, resize, translate, rotate, set_alignment, select, set_shadow, set_sound, set_cursor, set_controls, set_value, update, add_update_callback, remove_update_callback, apply_update_callbacks, set_border, draw
:exclude-members: add_draw_callback, add_self_to_kwargs, add_update_callback, apply, apply_draw_callbacks, apply_update_callbacks, background_inflate_to_selection_effect, change, draw, draw_after_if_selected, flip, get_alignment, get_border, get_decorator, get_focus_rect, get_font_color_status, get_font_info, get_frame, get_frame_depth, get_height, get_margin, get_padding, get_position, get_rect, get_selected_time, get_selection_effect, get_size, get_sound, get_surface, get_title, get_translate, get_value, get_width, is_selected, mouseleave, mouseover, remove_draw_callback, remove_update_callback, reset_value, resize, rotate, scale, select, set_alignment, set_background_color, set_border, set_controls, set_cursor, set_default_value, set_float, set_font, set_font_shadow, set_frame, set_margin, set_max_height, set_max_width, set_onchange, set_onmouseleave, set_onmouseover, set_onreturn, set_onselect, set_padding, set_position, set_selection_effect, set_shadow, set_sound, set_tab_size, set_title, set_value, translate, update, update_font, value_changed
2 changes: 1 addition & 1 deletion docs/_source/widgets_none.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ NoneWidget
:members:
:show-inheritance:
:inherited-members:
:exclude-members: get_surface, get_sound, get_selection_effect, get_selected_time, get_padding, get_font_info, get_value, set_onreturn, set_onmouseover, set_onmouseleave, set_onchange, set_default_value, value_changed, reset_value, mouseover, mouseleave, is_selected, get_title, background_inflate_to_selection_effect, get_font_color_status, set_onselect, set_padding, set_title, get_rect, set_background_color, set_selection_effect, apply, change, set_margin, set_font, update_font, set_position, flip, set_max_width, set_max_height, scale, resize, translate, rotate, set_alignment, select, set_shadow, set_sound, set_cursor, set_controls, set_value, set_border, set_font_shadow, get_border, draw_after_if_selected, get_height, get_width, get_size, get_margin
:exclude-members: add_self_to_kwargs, apply, background_inflate_to_selection_effect, change, draw_after_if_selected, flip, get_border, get_focus_rect, get_font_color_status, get_font_info, get_height, get_margin, get_padding, get_rect, get_selected_time, get_selection_effect, get_size, get_sound, get_surface, get_title, get_translate, get_value, get_width, is_selected, mouseleave, mouseover, render, reset_value, resize, rotate, scale, select, set_background_color, set_border, set_controls, set_cursor, set_default_value, set_font, set_font_shadow, set_margin, set_max_height, set_max_width, set_onchange, set_onmouseleave, set_onmouseover, set_onreturn, set_onselect, set_padding, set_position, set_selection_effect, set_shadow, set_sound, set_tab_size, set_title, set_value, shadow, translate, update_font, value_changed, update
2 changes: 1 addition & 1 deletion docs/_source/widgets_progressbar.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ ProgressBar
:members:
:show-inheritance:
:inherited-members:
:exclude-members: scale, resize, set_max_width, set_max_height, rotate, flip, draw_after_if_selected, change, apply, add_self_to_kwargs, get_sound, set_sound, set_onchange, set_onreturn
:exclude-members: add_self_to_kwargs, apply, change, draw_after_if_selected, flip, get_sound, resize, rotate, scale, set_max_height, set_max_width, set_onchange, set_onreturn, set_sound
2 changes: 1 addition & 1 deletion docs/_source/widgets_rangeslider.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ RangeSlider
:members:
:show-inheritance:
:inherited-members:
:exclude-members: scale, resize, set_max_width, set_max_height, rotate, flip,
:exclude-members: flip, resize, rotate, scale, set_max_height, set_max_width
2 changes: 1 addition & 1 deletion docs/_source/widgets_scrollbar.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ ScrollBar
:members:
:show-inheritance:
:inherited-members:
:exclude-members: set_selection_effect, background_inflate_to_selection_effect, get_selected_time, get_selection_effect, get_font_color_status, set_font, apply, set_onreturn, set_onselect, select, draw_after_if_selected, set_title, set_font_shadow, update_font, set_padding, scale, resize, set_max_width, set_max_height, rotate, flip
:exclude-members: apply, background_inflate_to_selection_effect, draw_after_if_selected, flip, get_font_color_status, get_selected_time, get_selection_effect, resize, rotate, scale, select, set_font, set_font_shadow, set_max_height, set_max_width, set_onreturn, set_onselect, set_padding, set_selection_effect, set_title, update_font
2 changes: 1 addition & 1 deletion docs/_source/widgets_surface.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ SurfaceWidget
:members:
:show-inheritance:
:inherited-members:
:exclude-members: set_controls, set_onchange, get_font_color_status, get_font_info, set_font, set_sound, get_sound, set_onreturn, draw_after_if_selected, get_value, set_value, get_title, reset_value, value_changed, set_title, apply, change, update_font, set_padding, scale, resize, set_max_width, set_max_height, rotate, flip, set_default_value, set_font_shadow, set_tab_size
:exclude-members: apply, change, draw_after_if_selected, flip, get_font_color_status, get_font_info, get_sound, get_title, get_value, reset_value, resize, rotate, scale, set_controls, set_default_value, set_font, set_font_shadow, set_max_height, set_max_width, set_onchange, set_onreturn, set_padding, set_sound, set_tab_size, set_title, set_value, update_font, value_changed
2 changes: 1 addition & 1 deletion docs/_source/widgets_table.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ Table
:members:
:show-inheritance:
:inherited-members:
:exclude-members: update_indices, contains_widget, get_scroll_value_percentage, scrollh, scrollv, get_index, get_indices, make_scrollarea, sort_menu_update_frames, set_title, remove_title, add_title_generic_button, add_title_button, get_title, pack, unpack, get_sound, get_selection_effect, get_selected_time, get_value, value_changed, set_onreturn, set_onchange, set_default_value, reset_value, is_selected, background_inflate_to_selection_effect, set_onselect, set_selection_effect, apply, change, flip, set_max_width, set_max_height, scale, rotate, select, set_shadow, set_sound, set_value, set_tab_size, draw_after_if_selected
:exclude-members: add_title_button, add_title_generic_button, apply, background_inflate_to_selection_effect, change, contains_widget, draw_after_if_selected, flip, get_index, get_indices, get_scroll_value_percentage, get_selected_time, get_selection_effect, get_sound, get_title, get_value, is_selected, make_scrollarea, pack, remove_title, reset_value, rotate, scale, scrollh, scrollv, select, set_default_value, set_max_height, set_max_width, set_onchange, set_onreturn, set_onselect, set_selection_effect, set_shadow, set_sound, set_tab_size, set_title, set_value, sort_menu_update_frames, unpack, update_indices, value_changed
2 changes: 1 addition & 1 deletion docs/_source/widgets_textinput.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ TextInput
:members:
:show-inheritance:
:inherited-members:
:exclude-members: rotate, scale, set_max_width, set_max_height, resize, draw_after_if_selected
:exclude-members: draw_after_if_selected, resize, rotate, scale, set_max_height, set_max_width
2 changes: 1 addition & 1 deletion docs/_source/widgets_toggleswitch.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ ToggleSwitch
:members:
:show-inheritance:
:inherited-members:
:exclude-members: scale, resize, set_max_width, set_max_height, rotate, flip, draw_after_if_selected
:exclude-members: draw_after_if_selected, flip, resize, rotate, scale, set_max_height, set_max_width
12 changes: 12 additions & 0 deletions docs/_source/widgets_vfill.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

.. module:: pygame_menu.widgets.widget.vfill

=====
VFill
=====

.. autoclass:: pygame_menu.widgets.VFill
:members:
:show-inheritance:
:inherited-members:
:exclude-members: add_self_to_kwargs, apply, background_inflate_to_selection_effect, change, draw_after_if_selected, flip, get_border, get_focus_rect, get_font_color_status, get_font_info, get_height, get_margin, get_padding, get_rect, get_selected_time, get_selection_effect, get_size, get_sound, get_surface, get_title, get_translate, get_value, get_width, is_selected, mouseleave, mouseover, render, reset_value, resize, rotate, scale, select, set_background_color, set_border, set_controls, set_cursor, set_default_value, set_font, set_font_shadow, set_margin, set_max_height, set_max_width, set_onchange, set_onmouseleave, set_onmouseover, set_onreturn, set_onselect, set_padding, set_position, set_selection_effect, set_shadow, set_sound, set_tab_size, set_title, set_value, shadow, translate, update_font, value_changed, update
2 changes: 1 addition & 1 deletion docs/_source/widgets_vmargin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ VMargin
:members:
:show-inheritance:
:inherited-members:
:exclude-members: render, get_translate, get_size, get_width, add_self_to_kwargs, set_margin, get_margin, get_surface, get_sound, get_selection_effect, get_selected_time, get_padding, get_font_info, get_value, set_onreturn, set_onmouseover, set_onmouseleave, set_onchange, set_default_value, value_changed, reset_value, mouseover, mouseleave, is_selected, get_title, background_inflate_to_selection_effect, get_font_color_status, set_onselect, set_padding, set_title, set_background_color, set_selection_effect, apply, change, set_font, update_font, set_position, flip, set_max_width, set_max_height, scale, resize, translate, rotate, set_alignment, select, set_shadow, set_sound, set_cursor, set_controls, set_value, set_border, set_font_shadow, set_tab_size, get_border, draw_after_if_selected
:exclude-members: add_self_to_kwargs, apply, background_inflate_to_selection_effect, change, draw_after_if_selected, flip, get_border, get_focus_rect, get_font_color_status, get_font_info, get_height, get_margin, get_padding, get_rect, get_selected_time, get_selection_effect, get_size, get_sound, get_surface, get_title, get_translate, get_value, get_width, is_selected, mouseleave, mouseover, render, reset_value, resize, rotate, scale, select, set_background_color, set_border, set_controls, set_cursor, set_default_value, set_font, set_font_shadow, set_margin, set_max_height, set_max_width, set_onchange, set_onmouseleave, set_onmouseover, set_onreturn, set_onselect, set_padding, set_position, set_selection_effect, set_shadow, set_sound, set_tab_size, set_title, set_value, shadow, translate, update_font, value_changed, update
Binary file added docs/_static/widget_vfill.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 10 additions & 1 deletion docs/add_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
pygame.display.set_icon(icon)

# Set example, only this should change
EXAMPLE = 'PROGRESSBAR'
EXAMPLE = 'VERTICALFILL'

# Create example
menu: 'pygame_menu.Menu'
Expand Down Expand Up @@ -385,6 +385,15 @@ def open_link(*args) -> None:
menu.add.url('https://github.com/ppizarror/pygame-menu', 'The best menu ever')
menu.add.url('https://pygame-menu.readthedocs.io/en/master/', 'pygame-menu documentation')

elif EXAMPLE == 'VERTICALFILL':
menu = make_menu(pygame_menu.themes.THEME_DEFAULT, 'Vertical fill')

menu.add.vertical_fill()
menu.add.button('Button 1')
menu.add.vertical_fill()
menu.add.button('Button 2')
menu.add.vertical_fill()

elif EXAMPLE == 'VERTICALMARGIN':
menu = make_menu(pygame_menu.themes.THEME_DEFAULT, 'Vertical spacer')

Expand Down
2 changes: 2 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ class. The currently existing classes are:
- :py:class:`~pygame_menu.widgets.Table`
- :py:class:`~pygame_menu.widgets.TextInput`
- :py:class:`~pygame_menu.widgets.ToggleSwitch`
- :py:class:`~pygame_menu.widgets.VFill`
- :py:class:`~pygame_menu.widgets.VMargin`

For advanced programmers, those classes can be used to design custom menus or windows.
Expand Down Expand Up @@ -177,6 +178,7 @@ to display large custom surfaces.
_source/widgets_table
_source/widgets_textinput
_source/widgets_toggleswitch
_source/widgets_vfill
_source/widgets_vmargin


Expand Down
3 changes: 3 additions & 0 deletions pygame_menu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,15 @@
'ironsmile',
'jwllee',
'maditnerd',
'MayuSakurai',
'mrkprdo',
'notrurs',
'NullP01nt',
'PandaRoux8',
'Rifqi31',
'ThePeeps191',
'thisIsMikeKane',
'vnmabus',
'werdeil',
'zPaw'

Expand Down
2 changes: 2 additions & 0 deletions pygame_menu/_widgetmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from pygame_menu.widgets.widget.table import TableManager
from pygame_menu.widgets.widget.textinput import TextInputManager
from pygame_menu.widgets.widget.toggleswitch import ToggleSwitchManager
from pygame_menu.widgets.widget.vfill import VFillManager
from pygame_menu.widgets.widget.vmargin import VMarginManager

from pygame_menu._types import Any, Dict, PaddingInstance
Expand All @@ -60,6 +61,7 @@ class WidgetManager(
TableManager,
TextInputManager,
ToggleSwitchManager,
VFillManager,
VMarginManager
):
"""
Expand Down
Loading

0 comments on commit 5709842

Please sign in to comment.