examples/target-disk-mode: Simplify interface implementation
And also add notes when in simulator mode...
module GUI
class MainWindow < LVGUI::BaseWindow
+ include LVGUI::BaseUIElements
include LVGUI::ButtonPalette
def run(*cmd)
@@ -9,17 +10,19 @@ module GUI
def initialize()
super()
+ add_main_text("Your device should act as a USB mass storage.\n\nEject it from your system before rebooting.")
- LVGL::LVLabel.new(@container).tap do |label|
- label.set_long_mode(LVGL::LABEL_LONG::BREAK)
- label.set_text("Your device should act as a USB mass storage.\n\nEject it from your system before rebooting.")
- label.set_align(LVGL::LABEL_ALIGN::CENTER)
- label.set_width(@container.get_width_fit)
+ # A reminder for simulator users
+ if LVGL::Introspection.simulator?
+ add_main_text("\n(Since this is running in the simulator, this actually does nothing...)\n")
end
- # TODO: At some point, allow selecting the storage device to present.
- # Though, this will need better coordination with a "gadget mode tool" system
- # that will be able to re-do the USB gadget work.
+ # The exit options
+ if LVGL::Introspection.simulator?
+ add_buttons([
+ ["Exit", ->() { exit 0 }],
+ ])
+ else
add_buttons([
["Reboot", ->() { run("reboot") }],
["Reboot to recovery", ->() { run("reboot recovery") }],
@@ -29,3 +32,4 @@ module GUI
end
end
end
+end
