summaryrefslogtreecommitdiffstats
path: root/gui/gui.cpp
diff options
context:
space:
mode:
authorEthan Yonker <dees_troy@teamw.in>2015-02-06 22:44:39 +0100
committerEthan Yonker <dees_troy@teamw.in>2015-02-10 21:11:50 +0100
commit63e414fc8a7ec04a0710a05ac9ce610fbb15f1e5 (patch)
tree37e36e03019d131e7fe8a42f7becef1414eb8c8b /gui/gui.cpp
parentRemove deletes for images from scroll list GUI Elements (diff)
downloadandroid_bootable_recovery-63e414fc8a7ec04a0710a05ac9ce610fbb15f1e5.tar
android_bootable_recovery-63e414fc8a7ec04a0710a05ac9ce610fbb15f1e5.tar.gz
android_bootable_recovery-63e414fc8a7ec04a0710a05ac9ce610fbb15f1e5.tar.bz2
android_bootable_recovery-63e414fc8a7ec04a0710a05ac9ce610fbb15f1e5.tar.lz
android_bootable_recovery-63e414fc8a7ec04a0710a05ac9ce610fbb15f1e5.tar.xz
android_bootable_recovery-63e414fc8a7ec04a0710a05ac9ce610fbb15f1e5.tar.zst
android_bootable_recovery-63e414fc8a7ec04a0710a05ac9ce610fbb15f1e5.zip
Diffstat (limited to 'gui/gui.cpp')
-rw-r--r--gui/gui.cpp64
1 files changed, 61 insertions, 3 deletions
diff --git a/gui/gui.cpp b/gui/gui.cpp
index 8bdd4251c..35b33b10c 100644
--- a/gui/gui.cpp
+++ b/gui/gui.cpp
@@ -75,6 +75,8 @@ static TWAtomicInt gForceRender;
const int gNoAnimation = 1;
blanktimer blankTimer;
int ors_read_fd = -1;
+static float scale_theme_w = 1;
+static float scale_theme_h = 1;
// Needed by pages.cpp too
int gGuiRunning = 0;
@@ -767,13 +769,26 @@ extern "C" int gui_init(void)
{
gr_init();
std::string curtain_path = TWRES "images/curtain.jpg";
+ gr_surface source_Surface = NULL;
- if (res_create_surface(curtain_path.c_str(), &gCurtain))
+ if (res_create_surface(curtain_path.c_str(), &source_Surface))
{
- printf
- ("Unable to locate '%s'\nDid you set a DEVICE_RESOLUTION in your config files?\n", curtain_path.c_str());
+ printf("Unable to locate '%s'\nDid you set a DEVICE_RESOLUTION in your config files?\n", curtain_path.c_str());
return -1;
}
+ if (gr_get_width(source_Surface) != gr_fb_width() || gr_get_height(source_Surface) != gr_fb_height()) {
+ // We need to scale the curtain to fit the screen
+ float scale_w = (float)gr_fb_width() / (float)gr_get_width(source_Surface);
+ float scale_h = (float)gr_fb_height() / (float)gr_get_height(source_Surface);
+ if (res_scale_surface(source_Surface, &gCurtain, scale_w, scale_h)) {
+ LOGINFO("Failed to scale curtain\n");
+ gCurtain = source_Surface;
+ } else {
+ LOGINFO("Scaling the curtain width %fx and height %fx\n", scale_w, scale_h);
+ }
+ } else {
+ gCurtain = source_Surface;
+ }
curtainSet();
@@ -965,3 +980,46 @@ extern "C" int gui_console_only(void)
return 0;
}
+
+extern "C" void set_scale_values(float w, float h)
+{
+ scale_theme_w = w;
+ scale_theme_h = h;
+}
+
+extern "C" int scale_theme_x(int initial_x)
+{
+ if (scale_theme_w != 1) {
+ return (int) ((float)initial_x * scale_theme_w);
+ }
+ return initial_x;
+}
+
+extern "C" int scale_theme_y(int initial_y)
+{
+ if (scale_theme_h != 1) {
+ return (int) ((float)initial_y * scale_theme_h);
+ }
+ return initial_y;
+}
+
+extern "C" int scale_theme_min(int initial_value)
+{
+ if (scale_theme_w != 1 || scale_theme_h != 1) {
+ if (scale_theme_w < scale_theme_h)
+ return scale_theme_x(initial_value);
+ else
+ return scale_theme_y(initial_value);
+ }
+ return initial_value;
+}
+
+extern "C" float get_scale_w()
+{
+ return scale_theme_w;
+}
+
+extern "C" float get_scale_h()
+{
+ return scale_theme_h;
+}