aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--screen_ui.cpp64
-rw-r--r--screen_ui.h11
-rw-r--r--vr_ui.cpp44
-rw-r--r--vr_ui.h8
4 files changed, 97 insertions, 30 deletions
diff --git a/screen_ui.cpp b/screen_ui.cpp
index 166d7b4c..c8fb5aa7 100644
--- a/screen_ui.cpp
+++ b/screen_ui.cpp
@@ -149,8 +149,8 @@ int ScreenRecoveryUI::GetProgressBaseline() const {
149 int elements_sum = gr_get_height(loopFrames[0]) + PixelsFromDp(kLayouts[layout_][ICON]) + 149 int elements_sum = gr_get_height(loopFrames[0]) + PixelsFromDp(kLayouts[layout_][ICON]) +
150 gr_get_height(installing_text) + PixelsFromDp(kLayouts[layout_][TEXT]) + 150 gr_get_height(installing_text) + PixelsFromDp(kLayouts[layout_][TEXT]) +
151 gr_get_height(progressBarFill); 151 gr_get_height(progressBarFill);
152 int bottom_gap = (gr_fb_height() - elements_sum) / 2; 152 int bottom_gap = (ScreenHeight() - elements_sum) / 2;
153 return gr_fb_height() - bottom_gap - gr_get_height(progressBarFill); 153 return ScreenHeight() - bottom_gap - gr_get_height(progressBarFill);
154} 154}
155 155
156// Clear the screen and draw the currently selected background icon (if any). 156// Clear the screen and draw the currently selected background icon (if any).
@@ -159,25 +159,24 @@ void ScreenRecoveryUI::draw_background_locked() {
159 pagesIdentical = false; 159 pagesIdentical = false;
160 gr_color(0, 0, 0, 255); 160 gr_color(0, 0, 0, 255);
161 gr_clear(); 161 gr_clear();
162
163 if (currentIcon != NONE) { 162 if (currentIcon != NONE) {
164 if (max_stage != -1) { 163 if (max_stage != -1) {
165 int stage_height = gr_get_height(stageMarkerEmpty); 164 int stage_height = gr_get_height(stageMarkerEmpty);
166 int stage_width = gr_get_width(stageMarkerEmpty); 165 int stage_width = gr_get_width(stageMarkerEmpty);
167 int x = (gr_fb_width() - max_stage * gr_get_width(stageMarkerEmpty)) / 2; 166 int x = (ScreenWidth() - max_stage * gr_get_width(stageMarkerEmpty)) / 2;
168 int y = gr_fb_height() - stage_height - kMarginHeight; 167 int y = ScreenHeight() - stage_height - kMarginHeight;
169 for (int i = 0; i < max_stage; ++i) { 168 for (int i = 0; i < max_stage; ++i) {
170 GRSurface* stage_surface = (i < stage) ? stageMarkerFill : stageMarkerEmpty; 169 GRSurface* stage_surface = (i < stage) ? stageMarkerFill : stageMarkerEmpty;
171 gr_blit(stage_surface, 0, 0, stage_width, stage_height, x, y); 170 DrawSurface(stage_surface, 0, 0, stage_width, stage_height, x, y);
172 x += stage_width; 171 x += stage_width;
173 } 172 }
174 } 173 }
175 174
176 GRSurface* text_surface = GetCurrentText(); 175 GRSurface* text_surface = GetCurrentText();
177 int text_x = (gr_fb_width() - gr_get_width(text_surface)) / 2; 176 int text_x = (ScreenWidth() - gr_get_width(text_surface)) / 2;
178 int text_y = GetTextBaseline(); 177 int text_y = GetTextBaseline();
179 gr_color(255, 255, 255, 255); 178 gr_color(255, 255, 255, 255);
180 gr_texticon(text_x, text_y, text_surface); 179 DrawTextIcon(text_x, text_y, text_surface);
181 } 180 }
182} 181}
183 182
@@ -188,21 +187,21 @@ void ScreenRecoveryUI::draw_foreground_locked() {
188 GRSurface* frame = GetCurrentFrame(); 187 GRSurface* frame = GetCurrentFrame();
189 int frame_width = gr_get_width(frame); 188 int frame_width = gr_get_width(frame);
190 int frame_height = gr_get_height(frame); 189 int frame_height = gr_get_height(frame);
191 int frame_x = (gr_fb_width() - frame_width) / 2; 190 int frame_x = (ScreenWidth() - frame_width) / 2;
192 int frame_y = GetAnimationBaseline(); 191 int frame_y = GetAnimationBaseline();
193 gr_blit(frame, 0, 0, frame_width, frame_height, frame_x, frame_y); 192 DrawSurface(frame, 0, 0, frame_width, frame_height, frame_x, frame_y);
194 } 193 }
195 194
196 if (progressBarType != EMPTY) { 195 if (progressBarType != EMPTY) {
197 int width = gr_get_width(progressBarEmpty); 196 int width = gr_get_width(progressBarEmpty);
198 int height = gr_get_height(progressBarEmpty); 197 int height = gr_get_height(progressBarEmpty);
199 198
200 int progress_x = (gr_fb_width() - width) / 2; 199 int progress_x = (ScreenWidth() - width) / 2;
201 int progress_y = GetProgressBaseline(); 200 int progress_y = GetProgressBaseline();
202 201
203 // Erase behind the progress bar (in case this was a progress-only update) 202 // Erase behind the progress bar (in case this was a progress-only update)
204 gr_color(0, 0, 0, 255); 203 gr_color(0, 0, 0, 255);
205 gr_fill(progress_x, progress_y, width, height); 204 DrawFill(progress_x, progress_y, width, height);
206 205
207 if (progressBarType == DETERMINATE) { 206 if (progressBarType == DETERMINATE) {
208 float p = progressScopeStart + progress * progressScopeSize; 207 float p = progressScopeStart + progress * progressScopeSize;
@@ -211,19 +210,19 @@ void ScreenRecoveryUI::draw_foreground_locked() {
211 if (rtl_locale_) { 210 if (rtl_locale_) {
212 // Fill the progress bar from right to left. 211 // Fill the progress bar from right to left.
213 if (pos > 0) { 212 if (pos > 0) {
214 gr_blit(progressBarFill, width - pos, 0, pos, height, progress_x + width - pos, 213 DrawSurface(progressBarFill, width - pos, 0, pos, height, progress_x + width - pos,
215 progress_y); 214 progress_y);
216 } 215 }
217 if (pos < width - 1) { 216 if (pos < width - 1) {
218 gr_blit(progressBarEmpty, 0, 0, width - pos, height, progress_x, progress_y); 217 DrawSurface(progressBarEmpty, 0, 0, width - pos, height, progress_x, progress_y);
219 } 218 }
220 } else { 219 } else {
221 // Fill the progress bar from left to right. 220 // Fill the progress bar from left to right.
222 if (pos > 0) { 221 if (pos > 0) {
223 gr_blit(progressBarFill, 0, 0, pos, height, progress_x, progress_y); 222 DrawSurface(progressBarFill, 0, 0, pos, height, progress_x, progress_y);
224 } 223 }
225 if (pos < width - 1) { 224 if (pos < width - 1) {
226 gr_blit(progressBarEmpty, pos, 0, width - pos, height, progress_x + pos, progress_y); 225 DrawSurface(progressBarEmpty, pos, 0, width - pos, height, progress_x + pos, progress_y);
227 } 226 }
228 } 227 }
229 } 228 }
@@ -335,8 +334,21 @@ void ScreenRecoveryUI::CheckBackgroundTextImages(const std::string& saved_locale
335 SetLocale(saved_locale); 334 SetLocale(saved_locale);
336} 335}
337 336
337int ScreenRecoveryUI::ScreenWidth() const {
338 return gr_fb_width();
339}
340
341int ScreenRecoveryUI::ScreenHeight() const {
342 return gr_fb_height();
343}
344
345void ScreenRecoveryUI::DrawSurface(GRSurface* surface, int sx, int sy, int w, int h, int dx,
346 int dy) const {
347 gr_blit(surface, sx, sy, w, h, dx, dy);
348}
349
338int ScreenRecoveryUI::DrawHorizontalRule(int y) const { 350int ScreenRecoveryUI::DrawHorizontalRule(int y) const {
339 gr_fill(0, y + 4, gr_fb_width(), y + 6); 351 gr_fill(0, y + 4, ScreenWidth(), y + 6);
340 return 8; 352 return 8;
341} 353}
342 354
@@ -344,6 +356,14 @@ void ScreenRecoveryUI::DrawHighlightBar(int x, int y, int width, int height) con
344 gr_fill(x, y, x + width, y + height); 356 gr_fill(x, y, x + width, y + height);
345} 357}
346 358
359void ScreenRecoveryUI::DrawFill(int x, int y, int w, int h) const {
360 gr_fill(x, y, w, h);
361}
362
363void ScreenRecoveryUI::DrawTextIcon(int x, int y, GRSurface* surface) const {
364 gr_texticon(x, y, surface);
365}
366
347int ScreenRecoveryUI::DrawTextLine(int x, int y, const char* line, bool bold) const { 367int ScreenRecoveryUI::DrawTextLine(int x, int y, const char* line, bool bold) const {
348 gr_text(gr_sys_font(), x, y, line, bold); 368 gr_text(gr_sys_font(), x, y, line, bold);
349 return char_height_ + 4; 369 return char_height_ + 4;
@@ -432,7 +452,7 @@ void ScreenRecoveryUI::draw_screen_locked() {
432 if (i == menu_sel) { 452 if (i == menu_sel) {
433 // Draw the highlight bar. 453 // Draw the highlight bar.
434 SetColor(IsLongPress() ? MENU_SEL_BG_ACTIVE : MENU_SEL_BG); 454 SetColor(IsLongPress() ? MENU_SEL_BG_ACTIVE : MENU_SEL_BG);
435 DrawHighlightBar(0, y - 2, gr_fb_width(), char_height_ + 4); 455 DrawHighlightBar(0, y - 2, ScreenWidth(), char_height_ + 4);
436 // Bold white text for the selected item. 456 // Bold white text for the selected item.
437 SetColor(MENU_SEL_FG); 457 SetColor(MENU_SEL_FG);
438 y += DrawTextLine(x, y, menu_[i].c_str(), true); 458 y += DrawTextLine(x, y, menu_[i].c_str(), true);
@@ -449,7 +469,7 @@ void ScreenRecoveryUI::draw_screen_locked() {
449 SetColor(LOG); 469 SetColor(LOG);
450 int row = text_row_; 470 int row = text_row_;
451 size_t count = 0; 471 size_t count = 0;
452 for (int ty = gr_fb_height() - kMarginHeight - char_height_; ty >= y && count < text_rows_; 472 for (int ty = ScreenHeight() - kMarginHeight - char_height_; ty >= y && count < text_rows_;
453 ty -= char_height_, ++count) { 473 ty -= char_height_, ++count) {
454 DrawTextLine(kMarginWidth, ty, text_[row], false); 474 DrawTextLine(kMarginWidth, ty, text_[row], false);
455 --row; 475 --row;
@@ -569,8 +589,8 @@ bool ScreenRecoveryUI::InitTextParams() {
569 } 589 }
570 590
571 gr_font_size(gr_sys_font(), &char_width_, &char_height_); 591 gr_font_size(gr_sys_font(), &char_width_, &char_height_);
572 text_rows_ = (gr_fb_height() - kMarginHeight * 2) / char_height_; 592 text_rows_ = (ScreenHeight() - kMarginHeight * 2) / char_height_;
573 text_cols_ = (gr_fb_width() - kMarginWidth * 2) / char_width_; 593 text_cols_ = (ScreenWidth() - kMarginWidth * 2) / char_width_;
574 return true; 594 return true;
575} 595}
576 596
diff --git a/screen_ui.h b/screen_ui.h
index 3a28a09d..f05761c4 100644
--- a/screen_ui.h
+++ b/screen_ui.h
@@ -124,12 +124,23 @@ class ScreenRecoveryUI : public RecoveryUI {
124 virtual int GetProgressBaseline() const; 124 virtual int GetProgressBaseline() const;
125 virtual int GetTextBaseline() const; 125 virtual int GetTextBaseline() const;
126 126
127 // Returns pixel width of draw buffer.
128 virtual int ScreenWidth() const;
129 // Returns pixel height of draw buffer.
130 virtual int ScreenHeight() const;
131
127 // Draws a highlight bar at (x, y) - (x + width, y + height). 132 // Draws a highlight bar at (x, y) - (x + width, y + height).
128 virtual void DrawHighlightBar(int x, int y, int width, int height) const; 133 virtual void DrawHighlightBar(int x, int y, int width, int height) const;
129 // Draws a horizontal rule at Y. Returns the offset it should be moving along Y-axis. 134 // Draws a horizontal rule at Y. Returns the offset it should be moving along Y-axis.
130 virtual int DrawHorizontalRule(int y) const; 135 virtual int DrawHorizontalRule(int y) const;
131 // Draws a line of text. Returns the offset it should be moving along Y-axis. 136 // Draws a line of text. Returns the offset it should be moving along Y-axis.
132 virtual int DrawTextLine(int x, int y, const char* line, bool bold) const; 137 virtual int DrawTextLine(int x, int y, const char* line, bool bold) const;
138 // Draws surface portion (sx, sy, w, h) at screen location (dx, dy).
139 virtual void DrawSurface(GRSurface* surface, int sx, int sy, int w, int h, int dx, int dy) const;
140 // Draws rectangle at (x, y) - (x + w, y + h).
141 virtual void DrawFill(int x, int y, int w, int h) const;
142 // Draws given surface (surface->pixel_bytes = 1) as text at (x, y).
143 virtual void DrawTextIcon(int x, int y, GRSurface* surface) const;
133 // Draws multiple text lines. Returns the offset it should be moving along Y-axis. 144 // Draws multiple text lines. Returns the offset it should be moving along Y-axis.
134 int DrawTextLines(int x, int y, const char* const* lines) const; 145 int DrawTextLines(int x, int y, const char* const* lines) const;
135 // Similar to DrawTextLines() to draw multiple text lines, but additionally wraps long lines. 146 // Similar to DrawTextLines() to draw multiple text lines, but additionally wraps long lines.
diff --git a/vr_ui.cpp b/vr_ui.cpp
index 12516726..07cc9da5 100644
--- a/vr_ui.cpp
+++ b/vr_ui.cpp
@@ -20,16 +20,46 @@
20 20
21VrRecoveryUI::VrRecoveryUI() : kStereoOffset(RECOVERY_UI_VR_STEREO_OFFSET) {} 21VrRecoveryUI::VrRecoveryUI() : kStereoOffset(RECOVERY_UI_VR_STEREO_OFFSET) {}
22 22
23bool VrRecoveryUI::InitTextParams() { 23int VrRecoveryUI::ScreenWidth() const {
24 if (!ScreenRecoveryUI::InitTextParams()) return false; 24 return gr_fb_width() / 2;
25 int mid_divide = gr_fb_width() / 2; 25}
26 text_cols_ = (mid_divide - kMarginWidth - kStereoOffset) / char_width_; 26
27 return true; 27int VrRecoveryUI::ScreenHeight() const {
28 return gr_fb_height();
29}
30
31void VrRecoveryUI::DrawSurface(GRSurface* surface, int sx, int sy, int w, int h, int dx,
32 int dy) const {
33 gr_blit(surface, sx, sy, w, h, dx + kStereoOffset, dy);
34 gr_blit(surface, sx, sy, w, h, dx - kStereoOffset + ScreenWidth(), dy);
35}
36
37void VrRecoveryUI::DrawTextIcon(int x, int y, GRSurface* surface) const {
38 gr_texticon(x + kStereoOffset, y, surface);
39 gr_texticon(x - kStereoOffset + ScreenWidth(), y, surface);
28} 40}
29 41
30int VrRecoveryUI::DrawTextLine(int x, int y, const char* line, bool bold) const { 42int VrRecoveryUI::DrawTextLine(int x, int y, const char* line, bool bold) const {
31 int mid_divide = gr_fb_width() / 2;
32 gr_text(gr_sys_font(), x + kStereoOffset, y, line, bold); 43 gr_text(gr_sys_font(), x + kStereoOffset, y, line, bold);
33 gr_text(gr_sys_font(), x - kStereoOffset + mid_divide, y, line, bold); 44 gr_text(gr_sys_font(), x - kStereoOffset + ScreenWidth(), y, line, bold);
34 return char_height_ + 4; 45 return char_height_ + 4;
35} 46}
47
48int VrRecoveryUI::DrawHorizontalRule(int y) const {
49 y += 4;
50 gr_fill(kMarginWidth + kStereoOffset, y, ScreenWidth() - kMarginWidth + kStereoOffset, y + 2);
51 gr_fill(ScreenWidth() + kMarginWidth - kStereoOffset, y,
52 gr_fb_width() - kMarginWidth - kStereoOffset, y + 2);
53 return y + 4;
54}
55
56void VrRecoveryUI::DrawHighlightBar(int x, int y, int width, int height) const {
57 gr_fill(kMarginWidth + kStereoOffset, y, ScreenWidth() - kMarginWidth + kStereoOffset, y + height);
58 gr_fill(ScreenWidth() + kMarginWidth - kStereoOffset, y,
59 gr_fb_width() - kMarginWidth - kStereoOffset, y + height);
60}
61
62void VrRecoveryUI::DrawFill(int x, int y, int w, int h) const {
63 gr_fill(x + kStereoOffset, y, w, h);
64 gr_fill(x - kStereoOffset + ScreenWidth(), y, w, h);
65}
diff --git a/vr_ui.h b/vr_ui.h
index d996c145..eeb45891 100644
--- a/vr_ui.h
+++ b/vr_ui.h
@@ -28,8 +28,14 @@ class VrRecoveryUI : public ScreenRecoveryUI {
28 // Can vary per device depending on screen size and lens distortion. 28 // Can vary per device depending on screen size and lens distortion.
29 const int kStereoOffset; 29 const int kStereoOffset;
30 30
31 bool InitTextParams() override; 31 int ScreenWidth() const override;
32 int ScreenHeight() const override;
32 33
34 void DrawSurface(GRSurface* surface, int sx, int sy, int w, int h, int dx, int dy) const override;
35 int DrawHorizontalRule(int y) const override;
36 void DrawHighlightBar(int x, int y, int width, int height) const override;
37 void DrawFill(int x, int y, int w, int h) const override;
38 void DrawTextIcon(int x, int y, GRSurface* surface) const override;
33 int DrawTextLine(int x, int y, const char* line, bool bold) const override; 39 int DrawTextLine(int x, int y, const char* line, bool bold) const override;
34}; 40};
35 41