diff options
-rw-r--r-- | screen_ui.cpp | 42 | ||||
-rw-r--r-- | screen_ui.h | 4 |
2 files changed, 31 insertions, 15 deletions
diff --git a/screen_ui.cpp b/screen_ui.cpp index 85f789f3..2a0769e4 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp | |||
@@ -105,29 +105,41 @@ int ScreenRecoveryUI::PixelsFromDp(int dp) { | |||
105 | 105 | ||
106 | // Here's the intended layout: | 106 | // Here's the intended layout: |
107 | 107 | ||
108 | // | regular large | 108 | // | portrait large landscape large |
109 | // ---------+-------------------- | 109 | // ---------+------------------------------------------------- |
110 | // | 220dp 366dp | 110 | // gap | 220dp 366dp 142dp 284dp |
111 | // icon | (200dp) (200dp) | 111 | // icon | (200dp) |
112 | // | 68dp 68dp | 112 | // gap | 68dp 68dp 56dp 112dp |
113 | // text | (14sp) (14sp) | 113 | // text | (14sp) |
114 | // | 32dp 32dp | 114 | // gap | 32dp 32dp 26dp 52dp |
115 | // progress | (2dp) (2dp) | 115 | // progress | (2dp) |
116 | // | 194dp 340dp | 116 | // gap | 194dp 340dp 131dp 262dp |
117 | 117 | ||
118 | // Note that "baseline" is actually the *top* of each icon (because that's how our drawing | 118 | // Note that "baseline" is actually the *top* of each icon (because that's how our drawing |
119 | // routines work), so that's the more useful measurement for calling code. | 119 | // routines work), so that's the more useful measurement for calling code. |
120 | 120 | ||
121 | enum Layout { PORTRAIT = 0, PORTRAIT_LARGE = 1, LANDSCAPE = 2, LANDSCAPE_LARGE = 3, LAYOUT_MAX }; | ||
122 | enum Dimension { PROGRESS = 0, TEXT = 1, ICON = 2, DIMENSION_MAX }; | ||
123 | static constexpr int kLayouts[LAYOUT_MAX][DIMENSION_MAX] = { | ||
124 | { 194, 32, 68, }, // PORTRAIT | ||
125 | { 340, 32, 68, }, // PORTRAIT_LARGE | ||
126 | { 131, 26, 56, }, // LANDSCAPE | ||
127 | { 262, 52, 112, }, // LANDSCAPE_LARGE | ||
128 | }; | ||
129 | |||
121 | int ScreenRecoveryUI::GetAnimationBaseline() { | 130 | int ScreenRecoveryUI::GetAnimationBaseline() { |
122 | return GetTextBaseline() - PixelsFromDp(68) - gr_get_height(loopFrames[0]); | 131 | return GetTextBaseline() - PixelsFromDp(kLayouts[layout_][ICON]) - |
132 | gr_get_height(loopFrames[0]); | ||
123 | } | 133 | } |
124 | 134 | ||
125 | int ScreenRecoveryUI::GetTextBaseline() { | 135 | int ScreenRecoveryUI::GetTextBaseline() { |
126 | return GetProgressBaseline() - PixelsFromDp(32) - gr_get_height(installing_text); | 136 | return GetProgressBaseline() - PixelsFromDp(kLayouts[layout_][TEXT]) - |
137 | gr_get_height(installing_text); | ||
127 | } | 138 | } |
128 | 139 | ||
129 | int ScreenRecoveryUI::GetProgressBaseline() { | 140 | int ScreenRecoveryUI::GetProgressBaseline() { |
130 | return gr_fb_height() - PixelsFromDp(is_large_ ? 340 : 194) - gr_get_height(progressBarFill); | 141 | return gr_fb_height() - PixelsFromDp(kLayouts[layout_][PROGRESS]) - |
142 | gr_get_height(progressBarFill); | ||
131 | } | 143 | } |
132 | 144 | ||
133 | // Clear the screen and draw the currently selected background icon (if any). | 145 | // Clear the screen and draw the currently selected background icon (if any). |
@@ -439,7 +451,11 @@ void ScreenRecoveryUI::Init() { | |||
439 | gr_init(); | 451 | gr_init(); |
440 | 452 | ||
441 | density_ = static_cast<float>(property_get_int32("ro.sf.lcd_density", 160)) / 160.f; | 453 | density_ = static_cast<float>(property_get_int32("ro.sf.lcd_density", 160)) / 160.f; |
442 | is_large_ = gr_fb_height() > PixelsFromDp(800); | 454 | |
455 | // Are we portrait or landscape? | ||
456 | layout_ = (gr_fb_width() > gr_fb_height()) ? LANDSCAPE : PORTRAIT; | ||
457 | // Are we the large variant of our base layout? | ||
458 | if (gr_fb_height() > PixelsFromDp(800)) ++layout_; | ||
443 | 459 | ||
444 | gr_font_size(&char_width_, &char_height_); | 460 | gr_font_size(&char_width_, &char_height_); |
445 | text_rows_ = gr_fb_height() / char_height_; | 461 | text_rows_ = gr_fb_height() / char_height_; |
diff --git a/screen_ui.h b/screen_ui.h index 4319b76c..89877577 100644 --- a/screen_ui.h +++ b/screen_ui.h | |||
@@ -77,8 +77,8 @@ class ScreenRecoveryUI : public RecoveryUI { | |||
77 | 77 | ||
78 | // The scale factor from dp to pixels. 1.0 for mdpi, 4.0 for xxxhdpi. | 78 | // The scale factor from dp to pixels. 1.0 for mdpi, 4.0 for xxxhdpi. |
79 | float density_; | 79 | float density_; |
80 | // True if we should use the large layout. | 80 | // The layout to use. |
81 | bool is_large_; | 81 | int layout_; |
82 | 82 | ||
83 | GRSurface* error_icon; | 83 | GRSurface* error_icon; |
84 | 84 | ||