No Description

vr_ui.cpp 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. #include "vr_ui.h"
  17. #include <minui/minui.h>
  18. VrRecoveryUI::VrRecoveryUI() : kStereoOffset(RECOVERY_UI_VR_STEREO_OFFSET) {}
  19. int VrRecoveryUI::ScreenWidth() const {
  20. return gr_fb_width() / 2;
  21. }
  22. int VrRecoveryUI::ScreenHeight() const {
  23. return gr_fb_height();
  24. }
  25. void VrRecoveryUI::DrawSurface(GRSurface* surface, int sx, int sy, int w, int h, int dx,
  26. int dy) const {
  27. gr_blit(surface, sx, sy, w, h, dx + kStereoOffset, dy);
  28. gr_blit(surface, sx, sy, w, h, dx - kStereoOffset + ScreenWidth(), dy);
  29. }
  30. void VrRecoveryUI::DrawTextIcon(int x, int y, GRSurface* surface) const {
  31. gr_texticon(x + kStereoOffset, y, surface);
  32. gr_texticon(x - kStereoOffset + ScreenWidth(), y, surface);
  33. }
  34. int VrRecoveryUI::DrawTextLine(int x, int y, const char* line, bool bold) const {
  35. gr_text(gr_sys_font(), x + kStereoOffset, y, line, bold);
  36. gr_text(gr_sys_font(), x - kStereoOffset + ScreenWidth(), y, line, bold);
  37. return char_height_ + 4;
  38. }
  39. int VrRecoveryUI::DrawHorizontalRule(int y) const {
  40. y += 4;
  41. gr_fill(kMarginWidth + kStereoOffset, y, ScreenWidth() - kMarginWidth + kStereoOffset, y + 2);
  42. gr_fill(ScreenWidth() + kMarginWidth - kStereoOffset, y,
  43. gr_fb_width() - kMarginWidth - kStereoOffset, y + 2);
  44. return y + 4;
  45. }
  46. void VrRecoveryUI::DrawHighlightBar(int /* x */, int y, int /* width */, int height) const {
  47. gr_fill(kMarginWidth + kStereoOffset, y, ScreenWidth() - kMarginWidth + kStereoOffset, y + height);
  48. gr_fill(ScreenWidth() + kMarginWidth - kStereoOffset, y,
  49. gr_fb_width() - kMarginWidth - kStereoOffset, y + height);
  50. }
  51. void VrRecoveryUI::DrawFill(int x, int y, int w, int h) const {
  52. gr_fill(x + kStereoOffset, y, w, h);
  53. gr_fill(x - kStereoOffset + ScreenWidth(), y, w, h);
  54. }