diff options
Diffstat (limited to 'screen_ui.h')
-rw-r--r-- | screen_ui.h | 63 |
1 files changed, 58 insertions, 5 deletions
diff --git a/screen_ui.h b/screen_ui.h index 726a9957..389d8c42 100644 --- a/screen_ui.h +++ b/screen_ui.h @@ -24,9 +24,35 @@ #include "ui.h" +#define MAX_MENU_ITEMS 32 + // From minui/minui.h. struct GRSurface; +class ScreenMenuItem { + public: + ScreenMenuItem() : icon_(nullptr), icon_sel_(nullptr) {} + explicit ScreenMenuItem(const MenuItem& mi) : + text_(mi.text()), + icon_name_(mi.icon_name()), + icon_(nullptr), + icon_name_sel_(mi.icon_name_sel()), + icon_sel_(nullptr) {} + ~ScreenMenuItem(); + + const std::string& text() const { return text_; } + GRSurface* icon(); + GRSurface* icon_sel(); + + private: + std::string text_; + std::string icon_name_; + GRSurface* icon_; + std::string icon_name_sel_; + GRSurface* icon_sel_; +}; +typedef std::vector<ScreenMenuItem> ScreenMenuItemVector; + // Implementation of RecoveryUI appropriate for devices with a screen // (shows an icon + a progress bar, text logging, menu, etc.) class ScreenRecoveryUI : public RecoveryUI { @@ -55,19 +81,29 @@ class ScreenRecoveryUI : public RecoveryUI { // printing messages void Print(const char* fmt, ...) override __printflike(2, 3); void PrintOnScreenOnly(const char* fmt, ...) override __printflike(2, 3); - void ShowFile(const char* filename) override; + int ShowFile(const char* filename) override; // menu display - void StartMenu(const char* const* headers, const char* const* items, + void StartMenu(bool is_main, + menu_type_t type, + const char* const* headers, + const MenuItemVector& items, int initial_selection) override; int SelectMenu(int sel) override; + int SelectMenu(const Point& point) override; void EndMenu() override; + bool MenuShowing() const { return show_menu; } + bool MenuScrollable() const { return (menu_type_ == MT_LIST); } + int MenuItemStart() const { return menu_start_y_; } + int MenuItemHeight() const { return (3 * menu_char_height_); } + void KeyLongPress(int) override; void Redraw(); enum UIElement { + STATUSBAR, HEADER, MENU, MENU_SEL_BG, @@ -96,6 +132,10 @@ class ScreenRecoveryUI : public RecoveryUI { // The layout to use. int layout_; + GRSurface* logo_image; + GRSurface* ic_back; + GRSurface* ic_back_sel; + GRSurface* error_icon; GRSurface* erasing_text; @@ -128,10 +168,15 @@ class ScreenRecoveryUI : public RecoveryUI { bool show_text; bool show_text_ever; // has show_text ever been true? - char** menu_; + bool menu_is_main_; + menu_type_t menu_type_; const char* const* menu_headers_; + ScreenMenuItemVector menu_items_; + int menu_start_y_; bool show_menu; - int menu_items, menu_sel; + int menu_show_start; + int menu_show_count; + int menu_sel; // An alternate text screen, swapped with 'text_' when we're viewing a log file. char** file_viewer_text_; @@ -150,12 +195,19 @@ class ScreenRecoveryUI : public RecoveryUI { int char_width_; int char_height_; + int menu_char_width_; + int menu_char_height_; + pthread_mutex_t updateMutex; virtual bool InitTextParams(); virtual void draw_background_locked(); virtual void draw_foreground_locked(); + virtual void draw_statusbar_locked(); + virtual void draw_header_locked(int& y); + virtual void draw_text_menu_locked(int& y); + virtual void draw_grid_menu_locked(int& y); virtual void draw_screen_locked(); virtual void update_screen_locked(); virtual void update_progress_locked(); @@ -166,13 +218,14 @@ class ScreenRecoveryUI : public RecoveryUI { static void* ProgressThreadStartRoutine(void* data); void ProgressThreadLoop(); - virtual void ShowFile(FILE*); + virtual int ShowFile(FILE*); virtual void PrintV(const char*, bool, va_list); void PutChar(char); void ClearText(); void LoadAnimation(); void LoadBitmap(const char* filename, GRSurface** surface); + void FreeBitmap(GRSurface* surface); void LoadLocalizedBitmap(const char* filename, GRSurface** surface); int PixelsFromDp(int dp) const; |