Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
MyreMylar committed May 6, 2024
2 parents 55bd3a8 + 6029235 commit 0727655
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion docs/source/quick_start.rst
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ we can just compare the event's ui_element attribute with our hello_button varia
Try running the code again and clicking on the button. If it's all worked you should see 'Hello World!' printed to the
python console each time you click the button.

Now that we've got the basics of the code up and running, let's try experimenting with a custom them file in part 2 of
Now that we've got the basics of the code up and running, let's try experimenting with a custom theme file in part 2 of
this quick start guide:

Quick Start Guides
Expand Down
6 changes: 3 additions & 3 deletions docs/source/theme_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ within the colours block you can start to set individual colours by their IDs. I
* - HSL
- Degree, 2 Percentage Values
- :example-hsl:`hsl(190deg, 40%, .5)`
- Hue, Saturation, Luminence
- Hue, Saturation, Luminance
* - HSLA
- Degree, 3 Percentage Values
- :example-hsla:`hsla(10deg, 40%, .5, 0.7)`
- Hue, Saturation, Luminence, Alpha
- Hue, Saturation, Luminance, Alpha
* - HSV
- Degree, 2 Percentage Values
- :example-hsv:`hsv(282deg, 63%, 92%)`
Expand All @@ -150,7 +150,7 @@ within the colours block you can start to set individual colours by their IDs. I
* - CMY
- 3 percentage values
- :example-cmy:`cmy(.3, .5, .7)`
- Cyan, Magneta, Yellow
- Cyan, Magenta, Yellow

.. list-table:: Value Types
:widths: 10 40 20 20 20
Expand Down
2 changes: 1 addition & 1 deletion docs/source/theme_reference/theme_progress_bar.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Colours
:class:`UIProgressBar <pygame_gui.elements.UIProgressBar>` makes use of these colour parameters in a 'colours' block. Most of these colours can
also be a colour gradient:

- "**normal_text**" - The colour/gradient of the health bars's text.
- "**normal_text**" - The colour/gradient of the health bar's text.
- "**text_shadow**" - The colour of the shadow behind the text (so it stands out better).
- "**normal_border**" - The colour/gradient of the border around the health bar.
- "**filled_bar**" - The colour/gradient of the actual bar itself, of the portion of it that is still full.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Colours
:class:`UIScreenSpaceHealthBar <pygame_gui.elements.UIScreenSpaceHealthBar>` makes use of these colour parameters in a 'colours' block. Most of these colours can
also be a colour gradient:

- "**normal_text**" - The colour/gradient of the health bars's text.
- "**normal_text**" - The colour/gradient of the health bar's text.
- "**text_shadow**" - The colour of the shadow behind the text (so it stands out better).
- "**normal_border**" - The colour/gradient of the border around the health bar.
- "**filled_bar**" - The colour/gradient of the actual bar itself, of the portion of it that is still full.
Expand Down
18 changes: 8 additions & 10 deletions pygame_gui/elements/ui_scrolling_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def __init__(self,
# scroll bars so that it resizes automatically as the scroll bars are added and "removed".

# this contains the scroll bars and the 'view' container
self._root_container = UIContainer(relative_rect=relative_rect,
self._root_container = UIContainer(relative_rect=self.relative_rect,
manager=manager,
starting_height=starting_height,
container=container,
Expand All @@ -106,7 +106,7 @@ def __init__(self,
self.vert_scroll_bar = None
if self.allow_scroll_y:

scroll_bar_rect = pygame.Rect(-20, 0, 20, relative_rect.height)
scroll_bar_rect = pygame.Rect(-20, 0, 20, self.relative_rect.height)
self.vert_scroll_bar = UIVerticalScrollBar(relative_rect=scroll_bar_rect,
visible_percentage=1.0,
manager=self.ui_manager,
Expand All @@ -117,15 +117,15 @@ def __init__(self,
'top': 'top',
'bottom': 'bottom'})

self.vert_scroll_bar.set_dimensions((0, relative_rect.height)) # TODO: Remove these when anchoring is fixed
self.vert_scroll_bar.set_dimensions((0, self.relative_rect.height)) # TODO: Remove these when anchoring is fixed
self.vert_scroll_bar.set_relative_position((0, 0)) # Without this, they look off-centered
self.join_focus_sets(self.vert_scroll_bar)

view_container_anchors['right_target'] = self.vert_scroll_bar

self.horiz_scroll_bar = None
if self.allow_scroll_x:
scroll_bar_rect = pygame.Rect(0, -20, relative_rect.width, 20)
scroll_bar_rect = pygame.Rect(0, -20, self.relative_rect.width, 20)
self.horiz_scroll_bar = UIHorizontalScrollBar(relative_rect=scroll_bar_rect,
visible_percentage=1.0,
manager=self.ui_manager,
Expand All @@ -136,15 +136,15 @@ def __init__(self,
'top': 'bottom',
'bottom': 'bottom'})

self.horiz_scroll_bar.set_dimensions((relative_rect.width, 0))
self.horiz_scroll_bar.set_dimensions((self.relative_rect.width, 0))
self.horiz_scroll_bar.set_relative_position((0, 0))
self.join_focus_sets(self.horiz_scroll_bar)

view_container_anchors['bottom_target'] = self.horiz_scroll_bar

# This container is the view on to the scrollable container it's size is determined by
# the size of the root container and whether there are any scroll bars or not.
view_rect = pygame.Rect(0, 0, relative_rect.width, relative_rect.height)
view_rect = pygame.Rect(0, 0, self.relative_rect.width, self.relative_rect.height)
self._view_container = UIContainer(relative_rect=view_rect,
manager=manager,
starting_height=1,
Expand All @@ -158,7 +158,7 @@ def __init__(self,
# This container is what we actually put other stuff in.
# It is aligned to the top left corner but that isn't that important for a container that
# can be much larger than it's view
scrollable_rect = pygame.Rect(0, 0, relative_rect.width, relative_rect.height)
scrollable_rect = pygame.Rect(0, 0, self.relative_rect.width, self.relative_rect.height)
scrollable_anchors = {'left': 'left',
'right': 'left',
'top': 'top',
Expand Down Expand Up @@ -415,9 +415,7 @@ def _sort_out_element_container_scroll_bars(self):
self.vert_scroll_bar.set_visible_percentage(vis_percent)
self.vert_scroll_bar.set_relative_position((-self.scroll_bar_width, 0))

# This is important as horiz scroll bar's dimensions are evaluated after. If horizontal scrollbar is not
# needed, then scroll bar height is 0.
height = self._view_container.rect.height - self.scroll_bar_height
height = self._view_container.rect.height
self.vert_scroll_bar.set_dimensions((self.scroll_bar_width,
height))
else:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_elements/test_ui_scrolling_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def test_update(self, _init_pygame, default_ui_manager,

container.update(0.02)

assert container.get_container().get_relative_rect().y == -12
assert container.get_container().get_relative_rect().y == -11

container.horiz_scroll_bar.scroll_wheel_moved = True
container.horiz_scroll_bar.scroll_wheel_amount = -5.0
Expand Down

0 comments on commit 0727655

Please sign in to comment.