blob: b2c65e3afe3523c8cf32fba8bf6afff1cbdaa12e [file] [log] [blame]
Luke Songe2bd8762017-06-12 16:08:33 -07001/*
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}