mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-24 01:33:46 +08:00
ui: fix settings close button shape and press state (#35469)
fix button rounding and pressed state display in settings
This commit is contained in:
@@ -50,8 +50,6 @@ class SettingsLayout:
|
||||
def __init__(self):
|
||||
self._params = Params()
|
||||
self._current_panel = PanelType.DEVICE
|
||||
self._close_btn_pressed = False
|
||||
self._scroll_offset = 0.0
|
||||
self._max_scroll = 0.0
|
||||
|
||||
# Panel configuration
|
||||
@@ -93,12 +91,15 @@ class SettingsLayout:
|
||||
rect.x + (rect.width - CLOSE_BTN_SIZE) / 2, rect.y + 45, CLOSE_BTN_SIZE, CLOSE_BTN_SIZE
|
||||
)
|
||||
|
||||
close_color = CLOSE_BTN_PRESSED if self._close_btn_pressed else CLOSE_BTN_COLOR
|
||||
rl.draw_rectangle_rounded(close_btn_rect, 0.5, 20, close_color)
|
||||
pressed = (rl.is_mouse_button_down(rl.MouseButton.MOUSE_BUTTON_LEFT) and
|
||||
rl.check_collision_point_rec(rl.get_mouse_position(), close_btn_rect))
|
||||
close_color = CLOSE_BTN_PRESSED if pressed else CLOSE_BTN_COLOR
|
||||
rl.draw_rectangle_rounded(close_btn_rect, 1.0, 20, close_color)
|
||||
|
||||
close_text_size = rl.measure_text_ex(self._font_bold, SETTINGS_CLOSE_TEXT, 140, 0)
|
||||
close_text_pos = rl.Vector2(
|
||||
close_btn_rect.x + (close_btn_rect.width - close_text_size.x) / 2,
|
||||
close_btn_rect.y + (close_btn_rect.height - close_text_size.y) / 2 - 20,
|
||||
close_btn_rect.y + (close_btn_rect.height - close_text_size.y) / 2,
|
||||
)
|
||||
rl.draw_text_ex(self._font_bold, SETTINGS_CLOSE_TEXT, close_text_pos, 140, 0, TEXT_SELECTED)
|
||||
|
||||
@@ -121,7 +122,6 @@ class SettingsLayout:
|
||||
# Button styling
|
||||
is_selected = panel_type == self._current_panel
|
||||
text_color = TEXT_SELECTED if is_selected else TEXT_NORMAL
|
||||
|
||||
# Draw button text (right-aligned)
|
||||
text_size = rl.measure_text_ex(self._font_medium, panel_info.name, 65, 0)
|
||||
text_pos = rl.Vector2(
|
||||
@@ -155,7 +155,6 @@ class SettingsLayout:
|
||||
def handle_mouse_release(self, mouse_pos: rl.Vector2) -> bool:
|
||||
# Check close button
|
||||
if rl.check_collision_point_rec(mouse_pos, self._close_btn_rect):
|
||||
self._close_btn_pressed = True
|
||||
if self._close_callback:
|
||||
self._close_callback()
|
||||
return True
|
||||
@@ -171,9 +170,6 @@ class SettingsLayout:
|
||||
def _switch_to_panel(self, panel_type: PanelType):
|
||||
if panel_type != self._current_panel:
|
||||
self._current_panel = panel_type
|
||||
self._scroll_offset = 0.0 # Reset scroll when switching panels
|
||||
self._transition_progress = 0.0
|
||||
self._transitioning = True
|
||||
|
||||
def set_current_panel(self, index: int, param: str = ""):
|
||||
panel_types = list(self._panels.keys())
|
||||
|
||||
Reference in New Issue
Block a user