blob: 07cc9da597a5b2e96b5895b8c528477af9461b17 [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
Luke Song9d4839c2017-06-23 14:33:46 -070021VrRecoveryUI::VrRecoveryUI() : kStereoOffset(RECOVERY_UI_VR_STEREO_OFFSET) {}
Luke Songe2bd8762017-06-12 16:08:33 -070022
Luke Song92eda4d2017-09-19 10:51:35 -070023int VrRecoveryUI::ScreenWidth() const {
24 return gr_fb_width() / 2;
25}
26
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);
Luke Songe2bd8762017-06-12 16:08:33 -070040}
41
Tao Baoea78d862017-06-28 14:52:17 -070042int VrRecoveryUI::DrawTextLine(int x, int y, const char* line, bool bold) const {
Tao Baoea78d862017-06-28 14:52:17 -070043 gr_text(gr_sys_font(), x + kStereoOffset, y, line, bold);
Luke Song92eda4d2017-09-19 10:51:35 -070044 gr_text(gr_sys_font(), x - kStereoOffset + ScreenWidth(), y, line, bold);
Tao Baoea78d862017-06-28 14:52:17 -070045 return char_height_ + 4;
Luke Songe2bd8762017-06-12 16:08:33 -070046}
Luke Song92eda4d2017-09-19 10:51:35 -070047
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}