summaryrefslogtreecommitdiffstats
path: root/screen_ui.h
diff options
context:
space:
mode:
Diffstat (limited to 'screen_ui.h')
-rw-r--r--screen_ui.h127
1 files changed, 77 insertions, 50 deletions
diff --git a/screen_ui.h b/screen_ui.h
index 8231a2ba0..f05761c42 100644
--- a/screen_ui.h
+++ b/screen_ui.h
@@ -32,6 +32,17 @@ struct GRSurface;
// (shows an icon + a progress bar, text logging, menu, etc.)
class ScreenRecoveryUI : public RecoveryUI {
public:
+ enum UIElement {
+ HEADER,
+ MENU,
+ MENU_SEL_BG,
+ MENU_SEL_BG_ACTIVE,
+ MENU_SEL_FG,
+ LOG,
+ TEXT_FILL,
+ INFO
+ };
+
ScreenRecoveryUI();
bool Init(const std::string& locale) override;
@@ -67,18 +78,12 @@ class ScreenRecoveryUI : public RecoveryUI {
void Redraw();
- enum UIElement {
- HEADER,
- MENU,
- MENU_SEL_BG,
- MENU_SEL_BG_ACTIVE,
- MENU_SEL_FG,
- LOG,
- TEXT_FILL,
- INFO
- };
void SetColor(UIElement e) const;
+ // Check the background text image. Use volume up/down button to cycle through the locales
+ // embedded in the png file, and power button to go back to recovery main menu.
+ void CheckBackgroundTextImages(const std::string& saved_locale);
+
protected:
// The margin that we don't want to use for showing texts (e.g. round screen, or screen with
// rounded corners).
@@ -89,7 +94,58 @@ class ScreenRecoveryUI : public RecoveryUI {
const int kAnimationFps;
// The scale factor from dp to pixels. 1.0 for mdpi, 4.0 for xxxhdpi.
- const float density_;
+ const float kDensity;
+
+ virtual bool InitTextParams();
+
+ virtual void draw_background_locked();
+ virtual void draw_foreground_locked();
+ virtual void draw_screen_locked();
+ virtual void update_screen_locked();
+ virtual void update_progress_locked();
+
+ GRSurface* GetCurrentFrame() const;
+ GRSurface* GetCurrentText() const;
+
+ static void* ProgressThreadStartRoutine(void* data);
+ void ProgressThreadLoop();
+
+ virtual void 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 LoadLocalizedBitmap(const char* filename, GRSurface** surface);
+
+ int PixelsFromDp(int dp) const;
+ virtual int GetAnimationBaseline() const;
+ virtual int GetProgressBaseline() const;
+ virtual int GetTextBaseline() const;
+
+ // Returns pixel width of draw buffer.
+ virtual int ScreenWidth() const;
+ // Returns pixel height of draw buffer.
+ virtual int ScreenHeight() const;
+
+ // Draws a highlight bar at (x, y) - (x + width, y + height).
+ virtual void DrawHighlightBar(int x, int y, int width, int height) const;
+ // Draws a horizontal rule at Y. Returns the offset it should be moving along Y-axis.
+ virtual int DrawHorizontalRule(int y) const;
+ // Draws a line of text. Returns the offset it should be moving along Y-axis.
+ virtual int DrawTextLine(int x, int y, const char* line, bool bold) const;
+ // Draws surface portion (sx, sy, w, h) at screen location (dx, dy).
+ virtual void DrawSurface(GRSurface* surface, int sx, int sy, int w, int h, int dx, int dy) const;
+ // Draws rectangle at (x, y) - (x + w, y + h).
+ virtual void DrawFill(int x, int y, int w, int h) const;
+ // Draws given surface (surface->pixel_bytes = 1) as text at (x, y).
+ virtual void DrawTextIcon(int x, int y, GRSurface* surface) const;
+ // Draws multiple text lines. Returns the offset it should be moving along Y-axis.
+ int DrawTextLines(int x, int y, const char* const* lines) const;
+ // Similar to DrawTextLines() to draw multiple text lines, but additionally wraps long lines.
+ // Returns the offset it should be moving along Y-axis.
+ int DrawWrappedTextLines(int x, int y, const char* const* lines) const;
Icon currentIcon;
@@ -123,7 +179,7 @@ class ScreenRecoveryUI : public RecoveryUI {
// Log text overlay, displayed when a magic key is pressed.
char** text_;
- size_t text_col_, text_row_, text_top_;
+ size_t text_col_, text_row_;
bool show_text;
bool show_text_ever; // has show_text ever been true?
@@ -150,47 +206,18 @@ class ScreenRecoveryUI : public RecoveryUI {
int char_width_;
int char_height_;
- pthread_mutex_t updateMutex;
-
- virtual bool InitTextParams();
+ // The locale that's used to show the rendered texts.
+ std::string locale_;
+ bool rtl_locale_;
- virtual void draw_background_locked();
- virtual void draw_foreground_locked();
- virtual void draw_screen_locked();
- virtual void update_screen_locked();
- virtual void update_progress_locked();
-
- GRSurface* GetCurrentFrame() const;
- GRSurface* GetCurrentText() const;
-
- static void* ProgressThreadStartRoutine(void* data);
- void ProgressThreadLoop();
+ pthread_mutex_t updateMutex;
- virtual void ShowFile(FILE*);
- virtual void PrintV(const char*, bool, va_list);
- void PutChar(char);
- void ClearText();
+ private:
+ void SetLocale(const std::string&);
- void LoadAnimation();
- void LoadBitmap(const char* filename, GRSurface** surface);
- void LoadLocalizedBitmap(const char* filename, GRSurface** surface);
-
- int PixelsFromDp(int dp) const;
- virtual int GetAnimationBaseline() const;
- virtual int GetProgressBaseline() const;
- virtual int GetTextBaseline() const;
-
- // Draws a highlight bar at (x, y) - (x + width, y + height).
- virtual void DrawHighlightBar(int x, int y, int width, int height) const;
- // Draws a horizontal rule at Y. Returns the offset it should be moving along Y-axis.
- virtual int DrawHorizontalRule(int y) const;
- // Draws a line of text. Returns the offset it should be moving along Y-axis.
- virtual int DrawTextLine(int x, int y, const char* line, bool bold) const;
- // Draws multiple text lines. Returns the offset it should be moving along Y-axis.
- int DrawTextLines(int x, int y, const char* const* lines) const;
- // Similar to DrawTextLines() to draw multiple text lines, but additionally wraps long lines.
- // Returns the offset it should be moving along Y-axis.
- int DrawWrappedTextLines(int x, int y, const char* const* lines) const;
+ // Display the background texts for "erasing", "error", "no_command" and "installing" for the
+ // selected locale.
+ void SelectAndShowBackgroundText(const std::vector<std::string>& locales_entries, size_t sel);
};
#endif // RECOVERY_UI_H