mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-22 00:33:44 +08:00
BigUI WIP: Russian Nesting Tiles
This commit is contained in:
@@ -45,7 +45,7 @@ def _install_aethergrid_stubs():
|
||||
draw_triangle=lambda *a, **k: None,
|
||||
draw_texture_pro=lambda *a, **k: None,
|
||||
draw_text_ex=lambda *a, **k: None,
|
||||
check_collision_point_rec=lambda *a, **k: False,
|
||||
check_collision_point_rec=lambda p, r: (r.x <= p.x <= r.x + r.width) and (r.y <= p.y <= r.y + r.height),
|
||||
get_frame_time=lambda: 0.016,
|
||||
get_mouse_position=lambda: types.SimpleNamespace(x=0, y=0),
|
||||
)
|
||||
@@ -100,6 +100,11 @@ def _install_aethergrid_stubs():
|
||||
self._parent_rect = None
|
||||
self._enabled = True
|
||||
self.is_pressed = False
|
||||
self._children = []
|
||||
|
||||
def _child(self, widget):
|
||||
self._children.append(widget)
|
||||
return widget
|
||||
|
||||
@property
|
||||
def enabled(self):
|
||||
@@ -118,6 +123,9 @@ def _install_aethergrid_stubs():
|
||||
def set_click_callback(self, callback):
|
||||
self.on_click = callback
|
||||
|
||||
def set_touch_valid_callback(self, callback):
|
||||
self._touch_valid_callback = callback
|
||||
|
||||
def set_enabled(self, enabled):
|
||||
self._enabled = enabled
|
||||
|
||||
@@ -520,6 +528,46 @@ class TestAethergridContracts(unittest.TestCase):
|
||||
except OverflowError:
|
||||
self.fail("OverflowError raised with extreme glow values")
|
||||
|
||||
def test_aether_category_tile_view(self):
|
||||
mod = _import_aethergrid()
|
||||
controller_mock = MagicMock()
|
||||
|
||||
toggle_visible = True
|
||||
rows = [
|
||||
mod.SettingRow("toggle_row", "toggle", "Toggle Title", subtitle="Toggle Subtitle",
|
||||
get_state=lambda: True, set_state=lambda v: None,
|
||||
visible=lambda: toggle_visible),
|
||||
mod.SettingRow("value_row", "value", "Value Title", subtitle="Value Subtitle",
|
||||
get_value=lambda: "Value", on_click=lambda: None),
|
||||
mod.SettingRow("action_row", "action", "Action Title", action_text="Run", on_click=lambda: None),
|
||||
]
|
||||
|
||||
view = mod.AetherCategoryTileView(controller_mock, "Category Title", rows, color="#FF0000", subtitle="Category Description")
|
||||
|
||||
self.assertEqual(len(view._row_to_tile_map), 3)
|
||||
self.assertIsInstance(view._row_to_tile_map["toggle_row"], mod.RowToggleTile)
|
||||
self.assertIsInstance(view._row_to_tile_map["value_row"], mod.RowPanelTile)
|
||||
self.assertIsInstance(view._row_to_tile_map["action_row"], mod.RowPanelTile)
|
||||
|
||||
view._update_visible_tiles()
|
||||
self.assertEqual(len(view._tile_grid.tiles), 3)
|
||||
|
||||
toggle_visible = False
|
||||
view._update_visible_tiles()
|
||||
self.assertEqual(len(view._tile_grid.tiles), 2)
|
||||
self.assertNotIn(view._row_to_tile_map["toggle_row"], view._tile_grid.tiles)
|
||||
|
||||
view._back_btn_rect = mod.rl.Rectangle(196, 56, 68, 68)
|
||||
|
||||
self.assertEqual(view._target_at(mod.rl.Vector2(200, 60)), "static:back")
|
||||
self.assertNotEqual(view._target_at(mod.rl.Vector2(0, 0)), "static:back")
|
||||
|
||||
app_mod = sys.modules["openpilot.system.ui.lib.application"]
|
||||
app_mod.gui_app.pop_widget = MagicMock()
|
||||
|
||||
view._activate_target("static:back")
|
||||
app_mod.gui_app.pop_widget.assert_called_once()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user