aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Song2017-06-12 18:08:33 -0500
committerElliott Hughes2017-06-16 17:33:02 -0500
commite2bd876043c3f26ad4712c2aad62b320368ad815 (patch)
tree7290ac89542e3b13e182836b28c694fee1e58a81 /vr_ui.cpp
parentffd8505f4ddc4e94416f36cd0b425040c8e566b8 (diff)
downloadplatform-bootable-recovery-e2bd876043c3f26ad4712c2aad62b320368ad815.tar.gz
platform-bootable-recovery-e2bd876043c3f26ad4712c2aad62b320368ad815.tar.xz
platform-bootable-recovery-e2bd876043c3f26ad4712c2aad62b320368ad815.zip
Introduce VR recovery ui
A version of screen ui with specific adjustments for vr device compatibility. (cherrypick of a44dba7f4e7296077f65fd571232e8a61aed9418 to AOSP) Bug: 37779982 Test: "adb reboot recovery" to view Change-Id: If6b0f26c1b587f8d0176060685b5efb6c67593b1
Diffstat (limited to 'vr_ui.cpp')
-rw-r--r--vr_ui.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/vr_ui.cpp b/vr_ui.cpp
new file mode 100644
index 00000000..b2c65e3a
--- /dev/null
+++ b/vr_ui.cpp
@@ -0,0 +1,56 @@
1/*
2 * Copyright (C) 2017 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#include "vr_ui.h"
18
19#include <minui/minui.h>
20
21VrRecoveryUI::VrRecoveryUI() :
22 x_offset(400),
23 y_offset(400),
24 stereo_offset(100) {
25}
26
27bool VrRecoveryUI::InitTextParams() {
28 if (gr_init() < 0) {
29 return false;
30 }
31
32 gr_font_size(gr_sys_font(), &char_width_, &char_height_);
33 int mid_divide = gr_fb_width() / 2;
34 text_rows_ = (gr_fb_height() - 2 * y_offset) / char_height_;
35 text_cols_ = (mid_divide - x_offset - stereo_offset) / char_width_;
36 log_bottom_offset_ = gr_fb_height() - 2 * y_offset;
37 return true;
38}
39
40void VrRecoveryUI::DrawHorizontalRule(int* y) {
41 SetColor(MENU);
42 *y += 4;
43 gr_fill(0, *y + y_offset, gr_fb_width(), *y + y_offset + 2);
44 *y += 4;
45}
46
47void VrRecoveryUI::DrawHighlightBar(int x, int y, int width, int height) const {
48 gr_fill(x, y + y_offset, x + width, y + y_offset + height);
49}
50
51void VrRecoveryUI::DrawTextLine(int x, int* y, const char* line, bool bold) const {
52 int mid_divide = gr_fb_width() / 2;
53 gr_text(gr_sys_font(), x + x_offset + stereo_offset, *y + y_offset, line, bold);
54 gr_text(gr_sys_font(), x + x_offset - stereo_offset + mid_divide, *y + y_offset, line, bold);
55 *y += char_height_ + 4;
56}