From ecf347c70fd0d83b57b7c00a389d8982ccfe3a03 Mon Sep 17 00:00:00 2001 From: Dan Lawrence Date: Sun, 3 Nov 2024 18:06:57 +0000 Subject: [PATCH 1/2] minor fixes to horizontal slider --- pygame_gui/core/drawable_shapes/drawable_shape.py | 2 +- pygame_gui/data/default_theme.json | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/pygame_gui/core/drawable_shapes/drawable_shape.py b/pygame_gui/core/drawable_shapes/drawable_shape.py index 8ec5c7fe..affaa062 100644 --- a/pygame_gui/core/drawable_shapes/drawable_shape.py +++ b/pygame_gui/core/drawable_shapes/drawable_shape.py @@ -494,7 +494,7 @@ def build_text_layout(self): containing_rect_when_text_built = self.containing_rect.copy() # Draw any text if 'text' in self.theming and 'font' in self.theming and self.theming['text'] is not None: - # we need two rectangles for the text. One is has actual area the + # we need two rectangles for the text. One has actual area the # text surface takes up, which may be larger than the displayed area, # and its position on the final surface. The other is the amount of # area of the text surface which we blit from, which may be much smaller diff --git a/pygame_gui/data/default_theme.json b/pygame_gui/data/default_theme.json index d0bd6516..25e6e690 100644 --- a/pygame_gui/data/default_theme.json +++ b/pygame_gui/data/default_theme.json @@ -101,15 +101,18 @@ { "prototype": "#no_frills_button" }, + "horizontal_slider.@arrow_button": + { + "font": { + "name": "fira_code_symbols", + "size": "14" + } + }, "horizontal_slider.#left_button": { "misc": { "text_horiz_alignment_method": "left_triangle" - }, - "font": { - "name": "fira_code_symbols", - "size": "14" } }, "horizontal_slider.#right_button": @@ -117,10 +120,6 @@ "misc": { "text_horiz_alignment_method": "right_triangle" - }, - "font": { - "name": "fira_code_symbols", - "size": "14" } }, "horizontal_slider.#sliding_button": From 677383139c0266421591be0e4b9f608e8db9a9cf Mon Sep 17 00:00:00 2001 From: Dan Lawrence Date: Sun, 3 Nov 2024 18:13:37 +0000 Subject: [PATCH 2/2] minor fixes to slider/scrollbar --- pygame_gui/elements/ui_horizontal_scroll_bar.py | 6 ++++-- pygame_gui/elements/ui_horizontal_slider.py | 7 +++++-- pygame_gui/elements/ui_vertical_scroll_bar.py | 6 ++++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/pygame_gui/elements/ui_horizontal_scroll_bar.py b/pygame_gui/elements/ui_horizontal_scroll_bar.py index 3e558554..35ef557c 100644 --- a/pygame_gui/elements/ui_horizontal_scroll_bar.py +++ b/pygame_gui/elements/ui_horizontal_scroll_bar.py @@ -81,6 +81,8 @@ def __init__(self, self.drawable_shape = None self.shape = 'rectangle' + self.left_arrow_text = '◀' + self.right_arrow_text = '▶' self.background_rect = None # type: Union[None, pygame.Rect] @@ -179,7 +181,7 @@ def rebuild(self): self.left_button = UIButton(pygame.Rect((0, 0), (self.arrow_button_width, self.background_rect.height)), - '◀', self.ui_manager, + self.left_arrow_text, self.ui_manager, container=self.button_container, starting_height=1, parent_element=self, @@ -195,7 +197,7 @@ def rebuild(self): self.right_button = UIButton(pygame.Rect((-self.arrow_button_width, 0), (self.arrow_button_width, self.background_rect.height)), - '▶', self.ui_manager, + self.right_arrow_text, self.ui_manager, container=self.button_container, starting_height=1, parent_element=self, diff --git a/pygame_gui/elements/ui_horizontal_slider.py b/pygame_gui/elements/ui_horizontal_slider.py index 179c13ff..9487741c 100644 --- a/pygame_gui/elements/ui_horizontal_slider.py +++ b/pygame_gui/elements/ui_horizontal_slider.py @@ -65,6 +65,9 @@ def __init__(self, self.left_limit_position = 0.0 self.starting_grab_x_difference = 0 + self.left_arrow_text = '◀' + self.right_arrow_text = '▶' + if (isinstance(start_value, int) and isinstance(value_range[0], int) and isinstance(value_range[1], int)): @@ -181,7 +184,7 @@ def rebuild(self): self.left_button = UIButton(pygame.Rect((0, 0), (self.arrow_button_width, self.background_rect.height)), - '◀', self.ui_manager, + self.left_arrow_text, self.ui_manager, container=self.button_container, starting_height=1, parent_element=self, @@ -197,7 +200,7 @@ def rebuild(self): self.right_button = UIButton(pygame.Rect((-self.arrow_button_width, 0), (self.arrow_button_width, self.background_rect.height)), - '▶', self.ui_manager, + self.right_arrow_text, self.ui_manager, container=self.button_container, starting_height=1, parent_element=self, diff --git a/pygame_gui/elements/ui_vertical_scroll_bar.py b/pygame_gui/elements/ui_vertical_scroll_bar.py index bf5d26ba..8289fef8 100644 --- a/pygame_gui/elements/ui_vertical_scroll_bar.py +++ b/pygame_gui/elements/ui_vertical_scroll_bar.py @@ -91,6 +91,8 @@ def __init__(self, self.bottom_button = None self.sliding_button = None self.enable_arrow_buttons = True + self.top_arrow_text = '▲' + self.bottom_arrow_text = '▼' self.rebuild_from_changed_theme_data() @@ -175,7 +177,7 @@ def rebuild(self): self.top_button = UIButton(pygame.Rect((0, 0), (self.background_rect.width, self.arrow_button_height)), - '▲', self.ui_manager, + self.top_arrow_text, self.ui_manager, container=self.button_container, starting_height=1, parent_element=self, @@ -191,7 +193,7 @@ def rebuild(self): self.bottom_button = UIButton(pygame.Rect((0, -self.arrow_button_height), (self.background_rect.width, self.arrow_button_height)), - '▼', self.ui_manager, + self.bottom_arrow_text, self.ui_manager, container=self.button_container, starting_height=1, parent_element=self,