Repository: MyreMylar/pygame_gui (python)

Issue:
Make starting layer height params consistent
Just a small UX issue. In `UIPanel` the param is `starting_layer_height` but in `UIElement` it's `starting_height`, while in `UITextBox` it's `layer_starting_height`.

**Expected behaviour**
Preferably these would all be the same param name, unless you have a particular design reason for them not to be (in which case maybe clarify in the documentation?).


Pull request description:
Unify name for starting height parameter across codebase
fixes #407

Patch:
diff --git a/pygame_gui/elements/ui_button.py b/pygame_gui/elements/ui_button.py
index 494a4a3..29841a3 100644
--- a/pygame_gui/elements/ui_button.py
+++ b/pygame_gui/elements/ui_button.py
@@ -225,7 +225,8 @@ class UIButton(UIElement):
         if self.held:
             return self.in_hold_range((hover_x, hover_y))
         else:
-            return super().hover_point(hover_x, hover_y)
+            return (self.drawable_shape.collide_point((hover_x, hover_y)) and
+                    bool(self.ui_container.rect.collidepoint(hover_x, hover_y)))
 
     def can_hover(self) -> bool:
         """
@@ -300,21 +301,6 @@ class UIButton(UIElement):
                       'ui_object_id': self.most_specific_combined_id}
         pygame.event.post(pygame.event.Event(UI_BUTTON_ON_UNHOVERED, event_data))
 
-    def _get_appropriate_state_name(self):
-        """
-        Returns a string representing the appropriate state for the widgets DrawableShapes.
-        Currently only returns either 'normal' or 'disabled' based on is_enabled.
-        """
-
-        if self.is_enabled:
-            if self.is_selected:
-                return "selected"
-            elif self.hovered:
-                return "hovered"
-            else:
-                return "normal"
-        return "disabled"
-
     def update(self, time_delta: float):
         """
         Sets the pressed state for an update cycle if we've pressed this button recently.
diff --git a/pygame_gui/elements/ui_drop_down_menu.py b/pygame_gui/elements/ui_drop_down_menu.py
index 9ad8314..889e846 100644
--- a/pygame_gui/elements/ui_drop_down_menu.py
+++ b/pygame_gui/elements/ui_drop_down_menu.py
@@ -934,6 +934,22 @@ class UIDropDownMenu(UIContainer):
         """
         self._set_image(self.drawable_shape.get_fresh_surface())
 
+    def hover_point(self, hover_x: float, hover_y: float) -> bool:
+        """
+        Test if a given point counts as 'hovering' this UI element. Normally that is a
+        straightforward matter of seeing if a point is inside the rectangle. Occasionally it
+        will also check if we are in a wider zone around a UI element once it is already active,
+        this makes it easier to move scroll bars and the like.
+
+        :param hover_x: The x (horizontal) position of the point.
+        :param hover_y: The y (vertical) position of the point.
+
+        :return: Returns True if we are hovering this element.
+
+        """
+        return (bool(self.rect.collidepoint(hover_x, hover_y)) and
+                bool(self.ui_container.rect.collidepoint(hover_x, hover_y)))
+
     def disable(self):
         """
         Disables the button so that it is no longer interactive.
diff --git a/pygame_gui/elements/ui_panel.py b/pygame_gui/elements/ui_panel.py
index 9394f81..dcd216c 100644
--- a/pygame_gui/elements/ui_panel.py
+++ b/pygame_gui/elements/ui_panel.py
@@ -23,7 +23,7 @@ class UIPanel(UIElement, IContainerLikeInterface):
 
     :param relative_rect: The positioning and sizing rectangle for the panel. See the layout
                           guide for details.
-    :param starting_layer_height: How many layers above its container to place this panel on.
+    :param starting_height: How many layers above its container to place this panel on.
     :param manager: The GUI manager that handles drawing and updating the UI and interactions
                     between elements. If not provided or set to None,
                     it will try to use the first UIManager that was created by your application.
@@ -42,7 +42,7 @@ class UIPanel(UIElement, IContainerLikeInterface):
     """
     def __init__(self,
                  relative_rect: pygame.Rect,
-                 starting_layer_height: int = 1,
+                 starting_height: int = 1,
                  manager: Optional[IUIManagerInterface] = None,
                  *,
                  element_id: str = 'panel',
@@ -57,7 +57,7 @@ class UIPanel(UIElement, IContainerLikeInterface):
         super().__init__(relative_rect,
                          manager,
                          container,
-                         starting_height=starting_layer_height,
+                         starting_height=starting_height,
                          layer_thickness=1,
                          anchors=anchors,
                          visible=visible)
@@ -93,7 +93,7 @@ class UIPanel(UIElement, IContainerLikeInterface):
                                                                   self.container_margins['bottom']))
 
         self.panel_container = UIContainer(container_rect, manager,
-                                           starting_height=starting_layer_height,
+                                           starting_height=starting_height,
                                            container=container,
                                            parent_element=self,
                                            object_id=ObjectID(object_id='#panel_container',
diff --git a/pygame_gui/elements/ui_text_box.py b/pygame_gui/elements/ui_text_box.py
index d514d00..afcdf43 100644
--- a/pygame_gui/elements/ui_text_box.py
+++ b/pygame_gui/elements/ui_text_box.py
@@ -67,7 +67,7 @@ class UITextBox(UIElement, IUITextOwnerInterface):
                     it will try to use the first UIManager that was created by your application.
     :param wrap_to_height: False by default, if set to True the box will increase in height to
                            match the text within.
-    :param layer_starting_height: Sets the height, above its container, to start placing the text
+    :param starting_height: Sets the height, above its container, to start placing the text
                                   box at.
     :param container: The container that this element is within. If not provided or set to None
                       will be the root window's container.
@@ -86,7 +86,7 @@ class UITextBox(UIElement, IUITextOwnerInterface):
                  relative_rect: Union[pygame.Rect, Tuple[int, int, int, int]],
                  manager: Optional[IUIManagerInterface] = None,
                  wrap_to_height: bool = False,
-                 layer_starting_height: int = 1,
+                 starting_height: int = 1,
                  container: Optional[IContainerLikeInterface] = None,
                  parent_element: Optional[UIElement] = None,
                  object_id: Optional[Union[ObjectID, str]] = None,
@@ -100,7 +100,7 @@ class UITextBox(UIElement, IUITextOwnerInterface):
                  should_html_unescape_input_text: bool = False):
 
         super().__init__(relative_rect, manager, container,
-                         starting_height=layer_starting_height,
+                         starting_height=starting_height,
                          layer_thickness=2,
                          anchors=anchors,
                          visible=visible
@@ -587,7 +587,7 @@ class UITextBox(UIElement, IUITextOwnerInterface):
         """
         if self.rect.width <= 0 or self.rect.height <= 0:
             return
-        if (self.scroll_bar is None and
+        if (self.scroll_bar is None and (self.text_wrap_rect[3] != -1) and
                 (self.text_box_layout.layout_rect.height > self.text_wrap_rect[3])):
             self.rebuild()
         else:
diff --git a/pygame_gui/elements/ui_tool_tip.py b/pygame_gui/elements/ui_tool_tip.py
index e2464b5..714d772 100644
--- a/pygame_gui/elements/ui_tool_tip.py
+++ b/pygame_gui/elements/ui_tool_tip.py
@@ -66,7 +66,7 @@ class UITooltip(UIElement, IUITooltipInterface):
         self.text_block = UITextBox(html_text,
                                     pygame.Rect(0, 0, self.rect_width, -1),
                                     manager=self.ui_manager,
-                                    layer_starting_height=self._layer,
+                                    starting_height=self._layer,
                                     parent_element=self,
                                     text_kwargs=text_kwargs)
 


Test patch:
diff --git a/tests/test_elements/test_ui_panel.py b/tests/test_elements/test_ui_panel.py
index 89ec1ce..2fdbc37 100644
--- a/tests/test_elements/test_ui_panel.py
+++ b/tests/test_elements/test_ui_panel.py
@@ -15,12 +15,12 @@ class TestUIPanel:
 
     def test_creation(self, _init_pygame, _display_surface_return_none, default_ui_manager):
         UIPanel(relative_rect=pygame.Rect(50, 50, 150, 400),
-                starting_layer_height=5,
+                starting_height=5,
                 manager=default_ui_manager)
 
     def test_creation_with_margins(self, _init_pygame, _display_surface_return_none, default_ui_manager):
         UIPanel(relative_rect=pygame.Rect(50, 50, 150, 400),
-                starting_layer_height=5,
+                starting_height=5,
                 manager=default_ui_manager,
                 margins={'left': 10,
                          'right': 10,
@@ -29,7 +29,7 @@ class TestUIPanel:
 
     def test_update(self, _init_pygame, _display_surface_return_none, default_ui_manager):
         panel = UIPanel(relative_rect=pygame.Rect(50, 50, 150, 400),
-                        starting_layer_height=5,
+                        starting_height=5,
                         manager=default_ui_manager,
                         margins={'left': 10,
                                  'right': 10,
@@ -45,7 +45,7 @@ class TestUIPanel:
 
     def test_add_button(self, _init_pygame, _display_surface_return_none, default_ui_manager):
         panel = UIPanel(relative_rect=pygame.Rect(50, 50, 150, 400),
-                        starting_layer_height=5,
+                        starting_height=5,
                         manager=default_ui_manager,
                         margins={'left': 10,
                                  'right': 10,
@@ -68,7 +68,7 @@ class TestUIPanel:
 
     def test_process_event(self, _init_pygame, _display_surface_return_none, default_ui_manager):
         panel = UIPanel(relative_rect=pygame.Rect(50, 50, 150, 400),
-                        starting_layer_height=5,
+                        starting_height=5,
                         manager=default_ui_manager,
                         margins={'left': 10,
                                  'right': 10,
@@ -91,7 +91,7 @@ class TestUIPanel:
 
     def test_kill(self, _init_pygame, _display_surface_return_none, default_ui_manager: IUIManagerInterface):
         panel = UIPanel(relative_rect=pygame.Rect(50, 50, 150, 400),
-                        starting_layer_height=5,
+                        starting_height=5,
                         manager=default_ui_manager,
                         margins={'left': 10,
                                  'right': 10,
@@ -123,7 +123,7 @@ class TestUIPanel:
         element_1 = UIPanel(relative_rect=pygame.Rect(0, 0, 50, 50),
                             manager=default_ui_manager,
                             container=test_container,
-                            starting_layer_height=5,
+                            starting_height=5,
                             anchors={'left': 'left',
                                      'right': 'left',
                                      'top': 'top',
@@ -137,7 +137,7 @@ class TestUIPanel:
         element_2 = UIPanel(relative_rect=pygame.Rect(0, 0, 50, 50),
                             manager=default_ui_manager,
                             container=test_container,
-                            starting_layer_height=5,
+                            starting_height=5,
                             anchors={'left': 'right',
                                      'right': 'right',
                                      'top': 'top',
@@ -151,7 +151,7 @@ class TestUIPanel:
         element_3 = UIPanel(relative_rect=pygame.Rect(0, 0, 50, 50),
                             manager=default_ui_manager,
                             container=test_container,
-                            starting_layer_height=5,
+                            starting_height=5,
                             anchors={'left': 'right',
                                      'right': 'right',
                                      'top': 'bottom',
@@ -165,7 +165,7 @@ class TestUIPanel:
         element_4 = UIPanel(relative_rect=pygame.Rect(0, 0, 50, 50),
                             manager=default_ui_manager,
                             container=test_container,
-                            starting_layer_height=5,
+                            starting_height=5,
                             anchors={'left': 'left',
                                      'right': 'left',
                                      'top': 'bottom',
@@ -179,7 +179,7 @@ class TestUIPanel:
         element_5 = UIPanel(relative_rect=pygame.Rect(0, 0, 50, 50),
                             manager=default_ui_manager,
                             container=test_container,
-                            starting_layer_height=5,
+                            starting_height=5,
                             anchors={'left': 'left',
                                      'right': 'right',
                                      'top': 'top',
@@ -201,7 +201,7 @@ class TestUIPanel:
         element = UIPanel(relative_rect=pygame.Rect(100, 100, 50, 50),
                           manager=default_ui_manager,
                           container=test_container,
-                          starting_layer_height=5)
+                          starting_height=5)
 
         element.set_position((150, 30))
 
@@ -210,7 +210,7 @@ class TestUIPanel:
         element_1 = UIPanel(relative_rect=pygame.Rect(0, 0, 50, 50),
                             manager=default_ui_manager,
                             container=test_container,
-                            starting_layer_height=5,
+                            starting_height=5,
                             anchors={'left': 'left',
                                      'right': 'left',
                                      'top': 'top',
@@ -224,7 +224,7 @@ class TestUIPanel:
         element_2 = UIPanel(relative_rect=pygame.Rect(0, 0, 50, 50),
                             manager=default_ui_manager,
                             container=test_container,
-                            starting_layer_height=5,
+                            starting_height=5,
                             anchors={'left': 'right',
                                      'right': 'right',
                                      'top': 'top',
@@ -238,7 +238,7 @@ class TestUIPanel:
         element_3 = UIPanel(relative_rect=pygame.Rect(0, 0, 50, 50),
                             manager=default_ui_manager,
                             container=test_container,
-                            starting_layer_height=5,
+                            starting_height=5,
                             anchors={'left': 'right',
                                      'right': 'right',
                                      'top': 'bottom',
@@ -252,7 +252,7 @@ class TestUIPanel:
         element_4 = UIPanel(relative_rect=pygame.Rect(0, 0, 50, 50),
                             manager=default_ui_manager,
                             container=test_container,
-                            starting_layer_height=5,
+                            starting_height=5,
                             anchors={'left': 'left',
                                      'right': 'left',
                                      'top': 'bottom',
@@ -266,7 +266,7 @@ class TestUIPanel:
         element_5 = UIPanel(relative_rect=pygame.Rect(0, 0, 50, 50),
                             manager=default_ui_manager,
                             container=test_container,
-                            starting_layer_height=5,
+                            starting_height=5,
                             anchors={'left': 'left',
                                      'right': 'right',
                                      'top': 'top',
@@ -289,7 +289,7 @@ class TestUIPanel:
         element_1 = UIPanel(relative_rect=pygame.Rect(30, 30, 50, 50),
                             manager=default_ui_manager,
                             container=test_container,
-                            starting_layer_height=5,
+                            starting_height=5,
                             anchors={'left': 'left',
                                      'right': 'left',
                                      'top': 'top',
@@ -310,7 +310,7 @@ class TestUIPanel:
         element_2 = UIPanel(relative_rect=pygame.Rect(-60, 10, 50, 50),
                             manager=default_ui_manager,
                             container=test_container,
-                            starting_layer_height=5,
+                            starting_height=5,
                             anchors={'left': 'right',
                                      'right': 'right',
                                      'top': 'top',
@@ -331,7 +331,7 @@ class TestUIPanel:
         element_3 = UIPanel(relative_rect=pygame.Rect(-70, -70, 50, 50),
                             manager=default_ui_manager,
                             container=test_container,
-                            starting_layer_height=5,
+                            starting_height=5,
                             anchors={'left': 'right',
                                      'right': 'right',
                                      'top': 'bottom',
@@ -352,7 +352,7 @@ class TestUIPanel:
         element_4 = UIPanel(relative_rect=pygame.Rect(50, -50, 50, 50),
                             manager=default_ui_manager,
                             container=test_container,
-                            starting_layer_height=5,
+                            starting_height=5,
                             anchors={'left': 'left',
                                      'right': 'left',
                                      'top': 'bottom',
@@ -374,7 +374,7 @@ class TestUIPanel:
         element_5 = UIPanel(relative_rect=pygame.Rect(10, 10, 50, 50),
                             manager=default_ui_manager,
                             container=test_container,
-                            starting_layer_height=5,
+                            starting_height=5,
                             anchors={'left': 'left',
                                      'right': 'right',
                                      'top': 'top',
@@ -416,7 +416,7 @@ class TestUIPanel:
         manager = UIManager((800, 600), os.path.join("tests", "data",
                                                      "themes", "ui_panel_non_default.json"))
         panel = UIPanel(relative_rect=pygame.Rect(50, 50, 150, 400),
-                        starting_layer_height=5,
+                        starting_height=5,
                         manager=manager,
                         margins={'left': 10,
                                  'right': 10,
@@ -435,7 +435,7 @@ class TestUIPanel:
         manager = UIManager((800, 600), os.path.join("tests", "data", "themes",
                                                      "ui_panel_bad_values.json"))
         panel = UIPanel(relative_rect=pygame.Rect(50, 50, 150, 400),
-                        starting_layer_height=5,
+                        starting_height=5,
                         manager=manager,
                         margins={'left': 10,
                                  'right': 10,
@@ -447,7 +447,7 @@ class TestUIPanel:
     def test_disable(self, _init_pygame: None, default_ui_manager: UIManager,
                      _display_surface_return_none: None):
         panel = UIPanel(relative_rect=pygame.Rect(0, 0, 150, 400),
-                        starting_layer_height=5,
+                        starting_height=5,
                         manager=default_ui_manager)
         button_1 = UIButton(relative_rect=pygame.Rect(10, 10, 150, 30),
                             text="Test Button",
@@ -481,7 +481,7 @@ class TestUIPanel:
     def test_enable(self, _init_pygame: None, default_ui_manager: UIManager,
                     _display_surface_return_none: None):
         panel = UIPanel(relative_rect=pygame.Rect(0, 0, 150, 400),
-                        starting_layer_height=5,
+                        starting_height=5,
                         manager=default_ui_manager)
         button_1 = UIButton(relative_rect=pygame.Rect(10, 10, 150, 30),
                             text="Test Button",
@@ -515,7 +515,7 @@ class TestUIPanel:
 
     def test_panel_children_inheriting_hidden_status(self, _init_pygame, default_ui_manager: IUIManagerInterface,
                                                      _display_surface_return_none):
-        panel = UIPanel(pygame.Rect(100, 100, 200, 200), manager=default_ui_manager, visible=0, starting_layer_height=5)
+        panel = UIPanel(pygame.Rect(100, 100, 200, 200), manager=default_ui_manager, visible=0, starting_height=5)
         button = UIButton(relative_rect=pygame.Rect(0, 0, 50, 50), text="",
                           manager=default_ui_manager, container=panel, visible=1)
         assert panel.visible == 0
@@ -523,7 +523,7 @@ class TestUIPanel:
 
     def test_hidden_panel_children_behaviour_on_show(self, _init_pygame, default_ui_manager: IUIManagerInterface,
                                                      _display_surface_return_none):
-        panel = UIPanel(pygame.Rect(100, 100, 200, 200), manager=default_ui_manager, visible=0, starting_layer_height=5)
+        panel = UIPanel(pygame.Rect(100, 100, 200, 200), manager=default_ui_manager, visible=0, starting_height=5)
         button = UIButton(relative_rect=pygame.Rect(0, 0, 50, 50), text="",
                           manager=default_ui_manager, container=panel)
         assert panel.visible == 0
@@ -536,7 +536,7 @@ class TestUIPanel:
                                                       default_ui_manager: IUIManagerInterface,
                                                       _display_surface_return_none):
         panel = UIPanel(pygame.Rect(100, 100, 200, 200), manager=default_ui_manager,
-                        visible=1, starting_layer_height=5)
+                        visible=1, starting_height=5)
         button = UIButton(relative_rect=pygame.Rect(0, 0, 50, 50), text="",
                           manager=default_ui_manager, container=panel, visible=0)
         assert panel.visible == 1
@@ -549,7 +549,7 @@ class TestUIPanel:
                                                       default_ui_manager: IUIManagerInterface,
                                                       _display_surface_return_none):
         panel = UIPanel(pygame.Rect(100, 100, 200, 200), manager=default_ui_manager,
-                        visible=1, starting_layer_height=5)
+                        visible=1, starting_height=5)
         button = UIButton(relative_rect=pygame.Rect(0, 0, 50, 50), text="",
                           manager=default_ui_manager, container=panel)
         assert panel.visible == 1
@@ -562,7 +562,7 @@ class TestUIPanel:
                                                      default_ui_manager: IUIManagerInterface,
                                                      _display_surface_return_none):
         panel = UIPanel(pygame.Rect(100, 100, 200, 200), manager=default_ui_manager,
-                        visible=0, starting_layer_height=5)
+                        visible=0, starting_height=5)
         button = UIButton(relative_rect=pygame.Rect(0, 0, 50, 50), text="",
                           manager=default_ui_manager, container=panel)
         button.show()
@@ -580,7 +580,7 @@ class TestUIPanel:
         surface = empty_surface.copy()
         manager = UIManager(resolution)
 
-        panel = UIPanel(pygame.Rect(25, 25, 375, 150), manager=manager, visible=0, starting_layer_height=1)
+        panel = UIPanel(pygame.Rect(25, 25, 375, 150), manager=manager, visible=0, starting_height=1)
         UIButton(relative_rect=pygame.Rect(0, 0, 50, 50), text="",
                  manager=manager, container=panel)
 
diff --git a/tests/test_elements/test_ui_text_box.py b/tests/test_elements/test_ui_text_box.py
index 7319519..943d9bd 100644
--- a/tests/test_elements/test_ui_text_box.py
+++ b/tests/test_elements/test_ui_text_box.py
@@ -675,7 +675,7 @@ class TestUITextBox:
                              relative_rect=rect,
                              manager=default_ui_manager,
                              wrap_to_height=True,
-                             layer_starting_height=100,
+                             starting_height=100,
                              object_id="screen_message")
 
         assert text_box.rect.height != 10
@@ -692,7 +692,7 @@ class TestUITextBox:
                              relative_rect=rect,
                              manager=default_ui_manager,
                              wrap_to_height=True,
-                             layer_starting_height=100,
+                             starting_height=100,
                              object_id="screen_message")
 
         assert text_box.rect.height != 0
@@ -775,7 +775,7 @@ class TestUITextBox:
                              relative_rect=rect,
                              manager=default_ui_manager,
                              wrap_to_height=False,
-                             layer_starting_height=100,
+                             starting_height=100,
                              object_id="screen_message",
                              visible=0)
 
@@ -802,7 +802,7 @@ class TestUITextBox:
                              relative_rect=rect,
                              manager=default_ui_manager,
                              wrap_to_height=False,
-                             layer_starting_height=100,
+                             starting_height=100,
                              object_id="screen_message",
                              visible=0)
 
@@ -837,7 +837,7 @@ class TestUITextBox:
                              relative_rect=rect,
                              manager=default_ui_manager,
                              wrap_to_height=False,
-                             layer_starting_height=100,
+                             starting_height=100,
                              object_id="screen_message")
 
         assert text_box.visible == 1
@@ -863,7 +863,7 @@ class TestUITextBox:
                              relative_rect=rect,
                              manager=default_ui_manager,
                              wrap_to_height=False,
-                             layer_starting_height=100,
+                             starting_height=100,
                              object_id="screen_message")
 
         assert text_box.visible == 1
@@ -895,7 +895,7 @@ class TestUITextBox:
                              relative_rect=pygame.Rect(100, 100, 400, 400),
                              manager=manager,
                              wrap_to_height=False,
-                             layer_starting_height=100,
+                             starting_height=100,
                              object_id="screen_message",
                              visible=0)
         manager.update(0.01)