summaryrefslogtreecommitdiffstats
path: root/vr_ui.cpp
blob: b2c65e3afe3523c8cf32fba8bf6afff1cbdaa12e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "vr_ui.h"

#include <minui/minui.h>

VrRecoveryUI::VrRecoveryUI() :
  x_offset(400),
  y_offset(400),
  stereo_offset(100) {
}

bool VrRecoveryUI::InitTextParams() {
  if (gr_init() < 0) {
    return false;
  }

  gr_font_size(gr_sys_font(), &char_width_, &char_height_);
  int mid_divide = gr_fb_width() / 2;
  text_rows_ = (gr_fb_height() - 2 * y_offset) / char_height_;
  text_cols_ = (mid_divide - x_offset - stereo_offset) / char_width_;
  log_bottom_offset_ = gr_fb_height() - 2 * y_offset;
  return true;
}

void VrRecoveryUI::DrawHorizontalRule(int* y) {
  SetColor(MENU);
  *y += 4;
  gr_fill(0, *y + y_offset, gr_fb_width(), *y + y_offset + 2);
  *y += 4;
}

void VrRecoveryUI::DrawHighlightBar(int x, int y, int width, int height) const {
  gr_fill(x, y + y_offset, x + width, y + y_offset + height);
}

void VrRecoveryUI::DrawTextLine(int x, int* y, const char* line, bool bold) const {
  int mid_divide = gr_fb_width() / 2;
  gr_text(gr_sys_font(), x + x_offset + stereo_offset, *y + y_offset, line, bold);
  gr_text(gr_sys_font(), x + x_offset - stereo_offset + mid_divide, *y + y_offset, line, bold);
  *y += char_height_ + 4;
}