mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-21 08:14:00 +08:00
raylib: implement calibration description (#36300)
* this is all cursor * also cursor * inline reset calib * calib desc * way better * huh * clean up * rcvr * stash changes to change params * Revert "stash changes to change params" This reverts commit ee998f04c4235ed20493b83e35c9f28e182d89b0.
This commit is contained in:
@@ -78,12 +78,12 @@ class ConfirmDialog(Widget):
|
||||
self._confirm_button.render(confirm_button)
|
||||
self._cancel_button.render(cancel_button)
|
||||
else:
|
||||
centered_button_x = dialog_rect.x + (dialog_rect.width - button_width) / 2
|
||||
centered_confirm_button = rl.Rectangle(centered_button_x, button_y, button_width, BUTTON_HEIGHT)
|
||||
self._confirm_button.render(centered_confirm_button)
|
||||
full_button_width = dialog_rect.width - 2 * MARGIN
|
||||
full_confirm_button = rl.Rectangle(dialog_rect.x + MARGIN, button_y, full_button_width, BUTTON_HEIGHT)
|
||||
self._confirm_button.render(full_confirm_button)
|
||||
|
||||
return self._dialog_result
|
||||
|
||||
|
||||
def alert_dialog(message: str, button_text: str = "OK"):
|
||||
def alert_dialog(message: str, button_text: str = "Ok"):
|
||||
return ConfirmDialog(message, button_text, cancel_text="")
|
||||
|
||||
@@ -268,6 +268,7 @@ class ListItem(Widget):
|
||||
self._description = description
|
||||
self.description_visible = description_visible
|
||||
self.callback = callback
|
||||
self.description_opened_callback: Callable | None = None
|
||||
self.action_item = action_item
|
||||
|
||||
self.set_rect(rl.Rectangle(0, 0, ITEM_BASE_WIDTH, ITEM_BASE_HEIGHT))
|
||||
@@ -280,6 +281,9 @@ class ListItem(Widget):
|
||||
# Cached properties for performance
|
||||
self._prev_description: str | None = self.description
|
||||
|
||||
def set_description_opened_callback(self, callback: Callable) -> None:
|
||||
self.description_opened_callback = callback
|
||||
|
||||
def set_touch_valid_callback(self, touch_callback: Callable[[], bool]) -> None:
|
||||
super().set_touch_valid_callback(touch_callback)
|
||||
if self.action_item:
|
||||
@@ -302,6 +306,10 @@ class ListItem(Widget):
|
||||
|
||||
if self.description:
|
||||
self.description_visible = not self.description_visible
|
||||
# do callback first in case receiver changes description
|
||||
if self.description_visible and self.description_opened_callback is not None:
|
||||
self.description_opened_callback()
|
||||
|
||||
content_width = int(self._rect.width - ITEM_PADDING * 2)
|
||||
self._rect.height = self.get_item_height(self._font, content_width)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user