Doug Zongker | 211aebc | 2011-10-28 15:13:10 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef RECOVERY_SCREEN_UI_H |
| 18 | #define RECOVERY_SCREEN_UI_H |
| 19 | |
Elliott Hughes | 95fc63e | 2015-04-10 19:12:01 -0700 | [diff] [blame] | 20 | #include <stdio.h> |
Doug Zongker | 211aebc | 2011-10-28 15:13:10 -0700 | [diff] [blame] | 21 | |
Tao Bao | 26ea959 | 2018-05-09 16:32:02 -0700 | [diff] [blame] | 22 | #include <atomic> |
Tao Bao | 3aec696 | 2018-04-20 09:24:58 -0700 | [diff] [blame] | 23 | #include <functional> |
Tianjie Xu | 5fe5eb6 | 2018-03-20 16:07:39 -0700 | [diff] [blame] | 24 | #include <memory> |
Tao Bao | 736d59c | 2017-01-03 10:15:33 -0800 | [diff] [blame] | 25 | #include <string> |
Tao Bao | 26ea959 | 2018-05-09 16:32:02 -0700 | [diff] [blame] | 26 | #include <thread> |
Tao Bao | e15d7a5 | 2017-09-07 13:38:51 -0700 | [diff] [blame] | 27 | #include <vector> |
Tao Bao | 736d59c | 2017-01-03 10:15:33 -0800 | [diff] [blame] | 28 | |
Doug Zongker | 211aebc | 2011-10-28 15:13:10 -0700 | [diff] [blame] | 29 | #include "ui.h" |
Tao Bao | 0ecbd76 | 2017-01-16 21:16:58 -0800 | [diff] [blame] | 30 | |
| 31 | // From minui/minui.h. |
Tao Bao | 92bdb5a | 2018-10-21 12:12:37 -0700 | [diff] [blame] | 32 | class GRSurface; |
Doug Zongker | 211aebc | 2011-10-28 15:13:10 -0700 | [diff] [blame] | 33 | |
Tianjie Xu | 66dbf63 | 2018-10-11 16:54:50 -0700 | [diff] [blame] | 34 | enum class UIElement { |
| 35 | HEADER, |
| 36 | MENU, |
| 37 | MENU_SEL_BG, |
| 38 | MENU_SEL_BG_ACTIVE, |
| 39 | MENU_SEL_FG, |
| 40 | LOG, |
| 41 | TEXT_FILL, |
| 42 | INFO |
| 43 | }; |
| 44 | |
| 45 | // Interface to draw the UI elements on the screen. |
| 46 | class DrawInterface { |
| 47 | public: |
| 48 | virtual ~DrawInterface() = default; |
| 49 | |
| 50 | // Sets the color to the predefined value for |element|. |
| 51 | virtual void SetColor(UIElement element) const = 0; |
| 52 | |
| 53 | // Draws a highlight bar at (x, y) - (x + width, y + height). |
| 54 | virtual void DrawHighlightBar(int x, int y, int width, int height) const = 0; |
| 55 | |
| 56 | // Draws a horizontal rule at Y. Returns the offset it should be moving along Y-axis. |
| 57 | virtual int DrawHorizontalRule(int y) const = 0; |
| 58 | |
| 59 | // Draws a line of text. Returns the offset it should be moving along Y-axis. |
| 60 | virtual int DrawTextLine(int x, int y, const std::string& line, bool bold) const = 0; |
| 61 | |
| 62 | // Draws surface portion (sx, sy, w, h) at screen location (dx, dy). |
| 63 | virtual void DrawSurface(GRSurface* surface, int sx, int sy, int w, int h, int dx, |
| 64 | int dy) const = 0; |
| 65 | |
| 66 | // Draws rectangle at (x, y) - (x + w, y + h). |
| 67 | virtual void DrawFill(int x, int y, int w, int h) const = 0; |
| 68 | |
| 69 | // Draws given surface (surface->pixel_bytes = 1) as text at (x, y). |
| 70 | virtual void DrawTextIcon(int x, int y, GRSurface* surface) const = 0; |
| 71 | |
| 72 | // Draws multiple text lines. Returns the offset it should be moving along Y-axis. |
| 73 | virtual int DrawTextLines(int x, int y, const std::vector<std::string>& lines) const = 0; |
| 74 | |
| 75 | // Similar to DrawTextLines() to draw multiple text lines, but additionally wraps long lines. It |
| 76 | // keeps symmetrical margins of 'x' at each end of a line. Returns the offset it should be moving |
| 77 | // along Y-axis. |
| 78 | virtual int DrawWrappedTextLines(int x, int y, const std::vector<std::string>& lines) const = 0; |
| 79 | }; |
| 80 | |
| 81 | // Interface for classes that maintain the menu selection and display. |
Tianjie Xu | 5fe5eb6 | 2018-03-20 16:07:39 -0700 | [diff] [blame] | 82 | class Menu { |
| 83 | public: |
Tianjie Xu | 66dbf63 | 2018-10-11 16:54:50 -0700 | [diff] [blame] | 84 | virtual ~Menu() = default; |
| 85 | // Returns the current menu selection. |
| 86 | size_t selection() const; |
| 87 | // Sets the current selection to |sel|. Handle the overflow cases depending on if the menu is |
| 88 | // scrollable. |
| 89 | virtual int Select(int sel) = 0; |
| 90 | // Displays the menu headers on the screen at offset x, y |
| 91 | virtual int DrawHeader(int x, int y) const = 0; |
| 92 | // Iterates over the menu items and displays each of them at offset x, y. |
| 93 | virtual int DrawItems(int x, int y, int screen_width, bool long_press) const = 0; |
| 94 | |
| 95 | protected: |
| 96 | Menu(size_t initial_selection, const DrawInterface& draw_func); |
| 97 | // Current menu selection. |
| 98 | size_t selection_; |
| 99 | // Reference to the class that implements all the draw functions. |
| 100 | const DrawInterface& draw_funcs_; |
| 101 | }; |
| 102 | |
| 103 | // This class uses strings as the menu header and items. |
| 104 | class TextMenu : public Menu { |
| 105 | public: |
Tao Bao | e02a5b2 | 2018-05-02 15:46:11 -0700 | [diff] [blame] | 106 | // Constructs a Menu instance with the given |headers|, |items| and properties. Sets the initial |
| 107 | // selection to |initial_selection|. |
Tianjie Xu | 66dbf63 | 2018-10-11 16:54:50 -0700 | [diff] [blame] | 108 | TextMenu(bool scrollable, size_t max_items, size_t max_length, |
| 109 | const std::vector<std::string>& headers, const std::vector<std::string>& items, |
| 110 | size_t initial_selection, int char_height, const DrawInterface& draw_funcs); |
| 111 | |
| 112 | int Select(int sel) override; |
| 113 | int DrawHeader(int x, int y) const override; |
| 114 | int DrawItems(int x, int y, int screen_width, bool long_press) const override; |
Tianjie Xu | 5fe5eb6 | 2018-03-20 16:07:39 -0700 | [diff] [blame] | 115 | |
| 116 | bool scrollable() const { |
| 117 | return scrollable_; |
| 118 | } |
| 119 | |
Tianjie Xu | 5fe5eb6 | 2018-03-20 16:07:39 -0700 | [diff] [blame] | 120 | // Returns count of menu items. |
| 121 | size_t ItemsCount() const; |
Tao Bao | e02a5b2 | 2018-05-02 15:46:11 -0700 | [diff] [blame] | 122 | |
Tianjie Xu | 5fe5eb6 | 2018-03-20 16:07:39 -0700 | [diff] [blame] | 123 | // Returns the index of the first menu item. |
| 124 | size_t MenuStart() const; |
Tao Bao | e02a5b2 | 2018-05-02 15:46:11 -0700 | [diff] [blame] | 125 | |
Tianjie Xu | 5fe5eb6 | 2018-03-20 16:07:39 -0700 | [diff] [blame] | 126 | // Returns the index of the last menu item + 1. |
| 127 | size_t MenuEnd() const; |
| 128 | |
| 129 | // Menu example: |
| 130 | // info: Android Recovery |
| 131 | // .... |
| 132 | // help messages: Swipe up/down to move |
| 133 | // Swipe left/right to select |
| 134 | // empty line (horizontal rule): |
| 135 | // menu headers: Select file to view |
| 136 | // menu items: /cache/recovery/last_log |
| 137 | // /cache/recovery/last_log.1 |
| 138 | // /cache/recovery/last_log.2 |
| 139 | // ... |
Tao Bao | 1fe1afe | 2018-05-01 15:56:05 -0700 | [diff] [blame] | 140 | const std::vector<std::string>& text_headers() const; |
Tianjie Xu | 5fe5eb6 | 2018-03-20 16:07:39 -0700 | [diff] [blame] | 141 | std::string TextItem(size_t index) const; |
| 142 | |
| 143 | // Checks if the menu items fit vertically on the screen. Returns true and set the |
| 144 | // |cur_selection_str| if the items exceed the screen limit. |
| 145 | bool ItemsOverflow(std::string* cur_selection_str) const; |
| 146 | |
Tianjie Xu | 5fe5eb6 | 2018-03-20 16:07:39 -0700 | [diff] [blame] | 147 | private: |
| 148 | // The menu is scrollable to display more items. Used on wear devices who have smaller screens. |
| 149 | const bool scrollable_; |
| 150 | // The max number of menu items to fit vertically on a screen. |
| 151 | const size_t max_display_items_; |
| 152 | // The length of each item to fit horizontally on a screen. |
| 153 | const size_t max_item_length_; |
Tao Bao | 1fe1afe | 2018-05-01 15:56:05 -0700 | [diff] [blame] | 154 | // The menu headers. |
| 155 | std::vector<std::string> text_headers_; |
| 156 | // The actual menu items trimmed to fit the given properties. |
Tianjie Xu | 5fe5eb6 | 2018-03-20 16:07:39 -0700 | [diff] [blame] | 157 | std::vector<std::string> text_items_; |
Tianjie Xu | 5fe5eb6 | 2018-03-20 16:07:39 -0700 | [diff] [blame] | 158 | // The first item to display on the screen. |
| 159 | size_t menu_start_; |
Tianjie Xu | 66dbf63 | 2018-10-11 16:54:50 -0700 | [diff] [blame] | 160 | |
| 161 | // Height in pixels of each character. |
| 162 | int char_height_; |
| 163 | }; |
| 164 | |
| 165 | // This class uses GRSurfaces* as the menu header and items. |
| 166 | class GraphicMenu : public Menu { |
| 167 | public: |
| 168 | // Constructs a Menu instance with the given |headers|, |items| and properties. Sets the initial |
| 169 | // selection to |initial_selection|. |
| 170 | GraphicMenu(size_t max_width, size_t max_height, GRSurface* graphic_headers, |
| 171 | const std::vector<GRSurface*>& graphic_items, size_t initial_selection, |
| 172 | const DrawInterface& draw_funcs); |
| 173 | |
| 174 | int Select(int sel) override; |
| 175 | int DrawHeader(int x, int y) const override; |
| 176 | int DrawItems(int x, int y, int screen_width, bool long_press) const override; |
| 177 | |
| 178 | // Checks if all the header and items are valid GRSurfaces; and that they can fit in the area |
| 179 | // defined by |max_width_| and |max_height_|. |
| 180 | bool Validate() const; |
| 181 | |
| 182 | private: |
| 183 | // Returns true if |surface| fits on the screen with a vertical offset |y|. |
| 184 | bool ValidateGraphicSurface(int y, const GRSurface* surface) const; |
| 185 | |
| 186 | const size_t max_width_; |
| 187 | const size_t max_height_; |
| 188 | |
| 189 | // Pointers to the menu headers and items in graphic icons. This class does not have the ownership |
| 190 | // of the these objects. |
| 191 | GRSurface* graphic_headers_; |
| 192 | std::vector<GRSurface*> graphic_items_; |
Tianjie Xu | 5fe5eb6 | 2018-03-20 16:07:39 -0700 | [diff] [blame] | 193 | }; |
| 194 | |
Doug Zongker | 211aebc | 2011-10-28 15:13:10 -0700 | [diff] [blame] | 195 | // Implementation of RecoveryUI appropriate for devices with a screen |
| 196 | // (shows an icon + a progress bar, text logging, menu, etc.) |
Tianjie Xu | 66dbf63 | 2018-10-11 16:54:50 -0700 | [diff] [blame] | 197 | class ScreenRecoveryUI : public RecoveryUI, public DrawInterface { |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 198 | public: |
| 199 | ScreenRecoveryUI(); |
Tianjie Xu | 5fe5eb6 | 2018-03-20 16:07:39 -0700 | [diff] [blame] | 200 | explicit ScreenRecoveryUI(bool scrollable_menu); |
Tao Bao | 26ea959 | 2018-05-09 16:32:02 -0700 | [diff] [blame] | 201 | ~ScreenRecoveryUI() override; |
Doug Zongker | 211aebc | 2011-10-28 15:13:10 -0700 | [diff] [blame] | 202 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 203 | bool Init(const std::string& locale) override; |
Tao Bao | 551d2c3 | 2018-05-09 20:53:13 -0700 | [diff] [blame] | 204 | std::string GetLocale() const override; |
Doug Zongker | 211aebc | 2011-10-28 15:13:10 -0700 | [diff] [blame] | 205 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 206 | // overall recovery state ("background image") |
Tao Bao | 99b2d77 | 2017-06-23 22:47:03 -0700 | [diff] [blame] | 207 | void SetBackground(Icon icon) override; |
| 208 | void SetSystemUpdateText(bool security_update) override; |
Doug Zongker | 211aebc | 2011-10-28 15:13:10 -0700 | [diff] [blame] | 209 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 210 | // progress indicator |
| 211 | void SetProgressType(ProgressType type) override; |
| 212 | void ShowProgress(float portion, float seconds) override; |
| 213 | void SetProgress(float fraction) override; |
Doug Zongker | 211aebc | 2011-10-28 15:13:10 -0700 | [diff] [blame] | 214 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 215 | void SetStage(int current, int max) override; |
Doug Zongker | c87bab1 | 2013-11-25 13:53:25 -0800 | [diff] [blame] | 216 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 217 | // text log |
| 218 | void ShowText(bool visible) override; |
| 219 | bool IsTextVisible() override; |
| 220 | bool WasTextEverVisible() override; |
Doug Zongker | 211aebc | 2011-10-28 15:13:10 -0700 | [diff] [blame] | 221 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 222 | // printing messages |
Tao Bao | 99b2d77 | 2017-06-23 22:47:03 -0700 | [diff] [blame] | 223 | void Print(const char* fmt, ...) override __printflike(2, 3); |
| 224 | void PrintOnScreenOnly(const char* fmt, ...) override __printflike(2, 3); |
Tao Bao | 1d156b9 | 2018-05-02 12:43:18 -0700 | [diff] [blame] | 225 | void ShowFile(const std::string& filename) override; |
Doug Zongker | 211aebc | 2011-10-28 15:13:10 -0700 | [diff] [blame] | 226 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 227 | // menu display |
Tao Bao | 1fe1afe | 2018-05-01 15:56:05 -0700 | [diff] [blame] | 228 | size_t ShowMenu(const std::vector<std::string>& headers, const std::vector<std::string>& items, |
| 229 | size_t initial_selection, bool menu_only, |
| 230 | const std::function<int(int, bool)>& key_handler) override; |
Jerry Zhang | 0e577ee | 2018-05-07 11:21:10 -0700 | [diff] [blame] | 231 | void SetTitle(const std::vector<std::string>& lines) override; |
Doug Zongker | 211aebc | 2011-10-28 15:13:10 -0700 | [diff] [blame] | 232 | |
Tao Bao | 99b2d77 | 2017-06-23 22:47:03 -0700 | [diff] [blame] | 233 | void KeyLongPress(int) override; |
Elliott Hughes | 642aaa7 | 2015-04-10 12:47:46 -0700 | [diff] [blame] | 234 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 235 | void Redraw(); |
Doug Zongker | c0441d1 | 2013-07-31 11:28:24 -0700 | [diff] [blame] | 236 | |
Tao Bao | 39c4918 | 2018-05-07 22:50:33 -0700 | [diff] [blame] | 237 | // Checks the background text image, for debugging purpose. It iterates the locales embedded in |
| 238 | // the on-device resource files and shows the localized text, for manual inspection. |
| 239 | void CheckBackgroundTextImages(); |
Tianjie Xu | 29d5575 | 2017-09-20 17:53:46 -0700 | [diff] [blame] | 240 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 241 | protected: |
| 242 | // The margin that we don't want to use for showing texts (e.g. round screen, or screen with |
| 243 | // rounded corners). |
Tao Bao | 0bc88de | 2018-07-31 14:53:16 -0700 | [diff] [blame] | 244 | const int margin_width_; |
| 245 | const int margin_height_; |
Tao Bao | 4521b70 | 2017-06-20 18:11:21 -0700 | [diff] [blame] | 246 | |
Tao Bao | 0470cee | 2017-08-02 17:11:04 -0700 | [diff] [blame] | 247 | // Number of frames per sec (default: 30) for both parts of the animation. |
Tao Bao | 0bc88de | 2018-07-31 14:53:16 -0700 | [diff] [blame] | 248 | const int animation_fps_; |
Tao Bao | 0470cee | 2017-08-02 17:11:04 -0700 | [diff] [blame] | 249 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 250 | // The scale factor from dp to pixels. 1.0 for mdpi, 4.0 for xxxhdpi. |
Tao Bao | 0bc88de | 2018-07-31 14:53:16 -0700 | [diff] [blame] | 251 | const float density_; |
Tao Bao | 7577965 | 2017-09-10 11:28:32 -0700 | [diff] [blame] | 252 | |
| 253 | virtual bool InitTextParams(); |
| 254 | |
Tao Bao | 3aec696 | 2018-04-20 09:24:58 -0700 | [diff] [blame] | 255 | // Displays some header text followed by a menu of items, which appears at the top of the screen |
| 256 | // (in place of any scrolling ui_print() output, if necessary). |
Tao Bao | 1fe1afe | 2018-05-01 15:56:05 -0700 | [diff] [blame] | 257 | virtual void StartMenu(const std::vector<std::string>& headers, |
| 258 | const std::vector<std::string>& items, size_t initial_selection); |
Tao Bao | 3aec696 | 2018-04-20 09:24:58 -0700 | [diff] [blame] | 259 | |
| 260 | // Sets the menu highlight to the given index, wrapping if necessary. Returns the actual item |
| 261 | // selected. |
| 262 | virtual int SelectMenu(int sel); |
| 263 | |
| 264 | // Ends menu mode, resetting the text overlay so that ui_print() statements will be displayed. |
| 265 | virtual void EndMenu(); |
| 266 | |
Tao Bao | 7577965 | 2017-09-10 11:28:32 -0700 | [diff] [blame] | 267 | virtual void draw_background_locked(); |
| 268 | virtual void draw_foreground_locked(); |
| 269 | virtual void draw_screen_locked(); |
Tao Bao | 93e46ad | 2018-05-02 14:57:21 -0700 | [diff] [blame] | 270 | virtual void draw_menu_and_text_buffer_locked(const std::vector<std::string>& help_message); |
Tao Bao | 7577965 | 2017-09-10 11:28:32 -0700 | [diff] [blame] | 271 | virtual void update_screen_locked(); |
| 272 | virtual void update_progress_locked(); |
| 273 | |
| 274 | GRSurface* GetCurrentFrame() const; |
| 275 | GRSurface* GetCurrentText() const; |
| 276 | |
Tao Bao | 7577965 | 2017-09-10 11:28:32 -0700 | [diff] [blame] | 277 | void ProgressThreadLoop(); |
| 278 | |
| 279 | virtual void ShowFile(FILE*); |
| 280 | virtual void PrintV(const char*, bool, va_list); |
| 281 | void PutChar(char); |
| 282 | void ClearText(); |
| 283 | |
| 284 | void LoadAnimation(); |
| 285 | void LoadBitmap(const char* filename, GRSurface** surface); |
| 286 | void LoadLocalizedBitmap(const char* filename, GRSurface** surface); |
| 287 | |
| 288 | int PixelsFromDp(int dp) const; |
| 289 | virtual int GetAnimationBaseline() const; |
| 290 | virtual int GetProgressBaseline() const; |
| 291 | virtual int GetTextBaseline() const; |
| 292 | |
Luke Song | 92eda4d | 2017-09-19 10:51:35 -0700 | [diff] [blame] | 293 | // Returns pixel width of draw buffer. |
| 294 | virtual int ScreenWidth() const; |
| 295 | // Returns pixel height of draw buffer. |
| 296 | virtual int ScreenHeight() const; |
| 297 | |
Tianjie Xu | 66dbf63 | 2018-10-11 16:54:50 -0700 | [diff] [blame] | 298 | // Implementation of the draw functions in DrawInterface. |
| 299 | void SetColor(UIElement e) const override; |
| 300 | void DrawHighlightBar(int x, int y, int width, int height) const override; |
| 301 | int DrawHorizontalRule(int y) const override; |
| 302 | void DrawSurface(GRSurface* surface, int sx, int sy, int w, int h, int dx, int dy) const override; |
| 303 | void DrawFill(int x, int y, int w, int h) const override; |
| 304 | void DrawTextIcon(int x, int y, GRSurface* surface) const override; |
| 305 | int DrawTextLine(int x, int y, const std::string& line, bool bold) const override; |
| 306 | int DrawTextLines(int x, int y, const std::vector<std::string>& lines) const override; |
| 307 | int DrawWrappedTextLines(int x, int y, const std::vector<std::string>& lines) const override; |
Tao Bao | 171b4c4 | 2017-06-19 23:10:44 -0700 | [diff] [blame] | 308 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 309 | Icon currentIcon; |
Doug Zongker | 211aebc | 2011-10-28 15:13:10 -0700 | [diff] [blame] | 310 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 311 | // The layout to use. |
| 312 | int layout_; |
Elliott Hughes | faf36e0 | 2016-04-20 17:22:16 -0700 | [diff] [blame] | 313 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 314 | GRSurface* error_icon; |
Elliott Hughes | 498cda6 | 2016-04-14 16:49:04 -0700 | [diff] [blame] | 315 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 316 | GRSurface* erasing_text; |
| 317 | GRSurface* error_text; |
| 318 | GRSurface* installing_text; |
| 319 | GRSurface* no_command_text; |
Elliott Hughes | 498cda6 | 2016-04-14 16:49:04 -0700 | [diff] [blame] | 320 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 321 | GRSurface** introFrames; |
| 322 | GRSurface** loopFrames; |
Elliott Hughes | 498cda6 | 2016-04-14 16:49:04 -0700 | [diff] [blame] | 323 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 324 | GRSurface* progressBarEmpty; |
| 325 | GRSurface* progressBarFill; |
| 326 | GRSurface* stageMarkerEmpty; |
| 327 | GRSurface* stageMarkerFill; |
Doug Zongker | 211aebc | 2011-10-28 15:13:10 -0700 | [diff] [blame] | 328 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 329 | ProgressType progressBarType; |
Doug Zongker | 211aebc | 2011-10-28 15:13:10 -0700 | [diff] [blame] | 330 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 331 | float progressScopeStart, progressScopeSize, progress; |
| 332 | double progressScopeTime, progressScopeDuration; |
Doug Zongker | 211aebc | 2011-10-28 15:13:10 -0700 | [diff] [blame] | 333 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 334 | // true when both graphics pages are the same (except for the progress bar). |
| 335 | bool pagesIdentical; |
Doug Zongker | 211aebc | 2011-10-28 15:13:10 -0700 | [diff] [blame] | 336 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 337 | size_t text_cols_, text_rows_; |
Elliott Hughes | c049163 | 2015-05-06 12:40:05 -0700 | [diff] [blame] | 338 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 339 | // Log text overlay, displayed when a magic key is pressed. |
| 340 | char** text_; |
Tao Bao | cb5524c | 2017-09-08 21:25:32 -0700 | [diff] [blame] | 341 | size_t text_col_, text_row_; |
Elliott Hughes | c049163 | 2015-05-06 12:40:05 -0700 | [diff] [blame] | 342 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 343 | bool show_text; |
| 344 | bool show_text_ever; // has show_text ever been true? |
Doug Zongker | 211aebc | 2011-10-28 15:13:10 -0700 | [diff] [blame] | 345 | |
Jerry Zhang | 0e577ee | 2018-05-07 11:21:10 -0700 | [diff] [blame] | 346 | std::vector<std::string> title_lines_; |
| 347 | |
Tianjie Xu | 5fe5eb6 | 2018-03-20 16:07:39 -0700 | [diff] [blame] | 348 | bool scrollable_menu_; |
| 349 | std::unique_ptr<Menu> menu_; |
Doug Zongker | 211aebc | 2011-10-28 15:13:10 -0700 | [diff] [blame] | 350 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 351 | // An alternate text screen, swapped with 'text_' when we're viewing a log file. |
| 352 | char** file_viewer_text_; |
Elliott Hughes | c049163 | 2015-05-06 12:40:05 -0700 | [diff] [blame] | 353 | |
Tao Bao | 26ea959 | 2018-05-09 16:32:02 -0700 | [diff] [blame] | 354 | std::thread progress_thread_; |
| 355 | std::atomic<bool> progress_thread_stopped_{ false }; |
Doug Zongker | 32a0a47 | 2011-11-01 11:00:20 -0700 | [diff] [blame] | 356 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 357 | // Number of intro frames and loop frames in the animation. |
| 358 | size_t intro_frames; |
| 359 | size_t loop_frames; |
Damien Bargiacchi | 5e7cfb9 | 2016-08-24 18:28:43 -0700 | [diff] [blame] | 360 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 361 | size_t current_frame; |
| 362 | bool intro_done; |
Elliott Hughes | 498cda6 | 2016-04-14 16:49:04 -0700 | [diff] [blame] | 363 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 364 | int stage, max_stage; |
Doug Zongker | c87bab1 | 2013-11-25 13:53:25 -0800 | [diff] [blame] | 365 | |
Tao Bao | 5d2e3bd | 2017-06-23 22:23:50 -0700 | [diff] [blame] | 366 | int char_width_; |
| 367 | int char_height_; |
Tao Bao | 171b4c4 | 2017-06-19 23:10:44 -0700 | [diff] [blame] | 368 | |
Tao Bao | efb49ad | 2017-01-31 23:03:10 -0800 | [diff] [blame] | 369 | // The locale that's used to show the rendered texts. |
| 370 | std::string locale_; |
| 371 | bool rtl_locale_; |
| 372 | |
Jerry Zhang | b31f9ce | 2018-05-21 16:04:57 -0700 | [diff] [blame] | 373 | std::mutex updateMutex; |
Tao Bao | efb49ad | 2017-01-31 23:03:10 -0800 | [diff] [blame] | 374 | |
| 375 | private: |
| 376 | void SetLocale(const std::string&); |
Tianjie Xu | 29d5575 | 2017-09-20 17:53:46 -0700 | [diff] [blame] | 377 | |
| 378 | // Display the background texts for "erasing", "error", "no_command" and "installing" for the |
| 379 | // selected locale. |
| 380 | void SelectAndShowBackgroundText(const std::vector<std::string>& locales_entries, size_t sel); |
Doug Zongker | 211aebc | 2011-10-28 15:13:10 -0700 | [diff] [blame] | 381 | }; |
| 382 | |
| 383 | #endif // RECOVERY_UI_H |