ScrollArea¶
The ScrollArea class provides a scrolling view managing up to 4 scroll bars.
A scroll area is used to display the contents of a child surface (
world
). If the surface exceeds the size of the drawing surface, the view provide scroll bars so that the entire area of the child surface can be viewed.- Parameters
area_color (tuple, list,
pygame_menu.baseimage.BaseImage
, None) – Background color, it can be a color or an imageextend_x (int, float) – Px to extend the surface in x axis (px) from left
extend_y (int, float) – Px to extend the surface in y axis (px) from top
scrollbar_slider_pad (int, float) – Space between slider and scrollbars borders
shadow (bool) – Indicate if a shadow is drawn on each scrollbar
shadow_position (str) – Position of shadow
world (
pygame.Surface
, None) – Surface to draw and scroll
If user event collides a widget within the scroll area respect to the relative position.
- Parameters
widget (
pygame_menu.widgets.core.widget.Widget
) – Widgetevent (
pygame.event.Event
) – Pygame event
- Returns
True if collide
- Return type
Called by end user to draw state to the surface.
- Parameters
surface (
pygame.Surface
) – Surface to render the area- Returns
None
Return the total height out of the bounds of the viewable area. Zero is returned if the world height is lower than the viewable area.
Return the total width out of the bounds of the viewable area. Zero is returned if the world width is lower than the viewable area.
Return the menu reference (if exists).
- Returns
Menu reference
- Return type
pygame_menu.Menu
, None
Return the offset introduced by the scrollbars in the world.
- Returns
ScrollArea offset (x, y)
- Return type
Return the Rect object.
- Returns
Pygame.Rect object
- Return type
Return the scroll thickness of the area. If it’s hidden return zero.
Subtract width of scrollbars from area with the given size and return the viewable area.
The viewable area depends on the world size, because scroll bars may or may not be displayed.
- Returns
View rect object
Return the world size.
- Returns
Width, height in pixels
- Return type
Return true if the user is scrolling.
- Returns
True if user scrolls
- Return type
Ensure that the given rect is in the viewable area.
- Parameters
rect (
pygame.Rect
) – Rect in the world surface reference
- Returns
None
Set the menu reference.
- Parameters
menu (
pygame_menu.Menu
) – Menu object- Returns
None
Set the position.
Update the scrolled surface.
- Parameters
surface (
pygame.Surface
) – New world surface- Returns
None
Return the real position/Rect according to the scroll area origin of a position/Rect in the world surface reference.
- Parameters
virtual (
pygame.Rect
, tuple, list) – Position/Rect in the world surface referencevisible (bool) – If a rect is given, return only the visible width/height
- Returns
Real rect or real position
- Return type
pygame.Rect
, tuple
Return the position/Rect in the world surface reference of a real position/Rect according to the scroll area origin.
- Parameters
real (
pygame.Rect
, tuple, list) – Position/Rect according scroll area origin- Returns
Rect in world or position in world
- Return type
pygame.Rect
, tuple