summaryrefslogtreecommitdiffstats
path: root/gui/image.cpp
diff options
context:
space:
mode:
authorDees_Troy <dees_troy@teamw.in>2012-09-05 21:24:24 +0200
committerDees_Troy <dees_troy@teamw.in>2012-09-05 21:24:31 +0200
commit51a0e82eb29a6dfc79f93479883383fbdbf8bcc2 (patch)
tree52fc18206eb0feba9f50dc3b0ede9fdc5e40f35e /gui/image.cpp
parentInitial stub of partitions.hpp (diff)
downloadandroid_bootable_recovery-51a0e82eb29a6dfc79f93479883383fbdbf8bcc2.tar
android_bootable_recovery-51a0e82eb29a6dfc79f93479883383fbdbf8bcc2.tar.gz
android_bootable_recovery-51a0e82eb29a6dfc79f93479883383fbdbf8bcc2.tar.bz2
android_bootable_recovery-51a0e82eb29a6dfc79f93479883383fbdbf8bcc2.tar.lz
android_bootable_recovery-51a0e82eb29a6dfc79f93479883383fbdbf8bcc2.tar.xz
android_bootable_recovery-51a0e82eb29a6dfc79f93479883383fbdbf8bcc2.tar.zst
android_bootable_recovery-51a0e82eb29a6dfc79f93479883383fbdbf8bcc2.zip
Diffstat (limited to '')
-rw-r--r--gui/image.cpp90
1 files changed, 90 insertions, 0 deletions
diff --git a/gui/image.cpp b/gui/image.cpp
new file mode 100644
index 000000000..44400e626
--- /dev/null
+++ b/gui/image.cpp
@@ -0,0 +1,90 @@
+// image.cpp - GUIImage object
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/reboot.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <time.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+#include <string>
+
+extern "C" {
+#include "../common.h"
+#include "../minuitwrp/minui.h"
+#include "../recovery_ui.h"
+}
+
+#include "rapidxml.hpp"
+#include "objects.hpp"
+
+GUIImage::GUIImage(xml_node<>* node)
+{
+ xml_attribute<>* attr;
+ xml_node<>* child;
+
+ mImage = NULL;
+
+ if (!node)
+ return;
+
+ child = node->first_node("image");
+ if (child)
+ {
+ attr = child->first_attribute("resource");
+ if (attr)
+ mImage = PageManager::FindResource(attr->value());
+ }
+
+ // Load the placement
+ LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY, NULL, NULL, &mPlacement);
+
+ if (mImage && mImage->GetResource())
+ {
+ mRenderW = gr_get_width(mImage->GetResource());
+ mRenderH = gr_get_height(mImage->GetResource());
+
+ // Adjust for placement
+ if (mPlacement != TOP_LEFT && mPlacement != BOTTOM_LEFT)
+ {
+ if (mPlacement == CENTER)
+ mRenderX -= (mRenderW / 2);
+ else
+ mRenderX -= mRenderW;
+ }
+ if (mPlacement != TOP_LEFT && mPlacement != TOP_RIGHT)
+ {
+ if (mPlacement == CENTER)
+ mRenderY -= (mRenderH / 2);
+ else
+ mRenderY -= mRenderH;
+ }
+ SetPlacement(TOP_LEFT);
+ }
+
+ return;
+}
+
+int GUIImage::Render(void)
+{
+ if (!mImage || !mImage->GetResource()) return -1;
+ gr_blit(mImage->GetResource(), 0, 0, mRenderW, mRenderH, mRenderX, mRenderY);
+ return 0;
+}
+
+int GUIImage::SetRenderPos(int x, int y, int w, int h)
+{
+ if (w || h) return -1;
+ mRenderX = x;
+ mRenderY = y;
+ return 0;
+}
+