Luke Song | e2bd876 | 2017-06-12 16:08:33 -0700 | [diff] [blame] | 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 | |
Luke Song | 9d4839c | 2017-06-23 14:33:46 -0700 | [diff] [blame] | 21 | VrRecoveryUI::VrRecoveryUI() : kStereoOffset(RECOVERY_UI_VR_STEREO_OFFSET) {} |
Luke Song | e2bd876 | 2017-06-12 16:08:33 -0700 | [diff] [blame] | 22 | |
Luke Song | 92eda4d | 2017-09-19 10:51:35 -0700 | [diff] [blame] | 23 | int VrRecoveryUI::ScreenWidth() const { |
| 24 | return gr_fb_width() / 2; |
| 25 | } |
| 26 | |
| 27 | int VrRecoveryUI::ScreenHeight() const { |
| 28 | return gr_fb_height(); |
| 29 | } |
| 30 | |
| 31 | void 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 | |
| 37 | void 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 Song | e2bd876 | 2017-06-12 16:08:33 -0700 | [diff] [blame] | 40 | } |
| 41 | |
Tao Bao | ea78d86 | 2017-06-28 14:52:17 -0700 | [diff] [blame] | 42 | int VrRecoveryUI::DrawTextLine(int x, int y, const char* line, bool bold) const { |
Tao Bao | ea78d86 | 2017-06-28 14:52:17 -0700 | [diff] [blame] | 43 | gr_text(gr_sys_font(), x + kStereoOffset, y, line, bold); |
Luke Song | 92eda4d | 2017-09-19 10:51:35 -0700 | [diff] [blame] | 44 | gr_text(gr_sys_font(), x - kStereoOffset + ScreenWidth(), y, line, bold); |
Tao Bao | ea78d86 | 2017-06-28 14:52:17 -0700 | [diff] [blame] | 45 | return char_height_ + 4; |
Luke Song | e2bd876 | 2017-06-12 16:08:33 -0700 | [diff] [blame] | 46 | } |
Luke Song | 92eda4d | 2017-09-19 10:51:35 -0700 | [diff] [blame] | 47 | |
| 48 | int 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 | |
Tao Bao | 99f0d9e | 2016-10-13 12:46:38 -0700 | [diff] [blame] | 56 | void VrRecoveryUI::DrawHighlightBar(int /* x */, int y, int /* width */, int height) const { |
Luke Song | 92eda4d | 2017-09-19 10:51:35 -0700 | [diff] [blame] | 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 | |
| 62 | void 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 | } |