Allow for X and Y offsets in GUI

These can be used to center a lower resolution theme onto a
higher resolution screen. May be useful for Nexus 9 unless or
until we decide to do a 1536x2048 theme or on devices like the
Moto 360 and LG G Watch R.

The build flags will only affect the stock theme. If a custom
theme wishes to apply an offset, it can be done by setting
tw_x_offset and / or tw_y_offset in the variables section of the
XML.

Change-Id: I2390769ed861b96a4a3bb8a0f06d9021ec91b6b9
diff --git a/gui/pages.cpp b/gui/pages.cpp
index bea39e9..a1a6346 100644
--- a/gui/pages.cpp
+++ b/gui/pages.cpp
@@ -60,6 +60,9 @@
 MouseCursor *PageManager::mMouseCursor = NULL;
 HardwareKeyboard *PageManager::mHardwareKeyboard = NULL;
 
+int tw_x_offset = 0;
+int tw_y_offset = 0;
+
 // Helper routine to convert a string to a color declaration
 int ConvertStrToColor(std::string str, COLOR* color)
 {
@@ -115,6 +118,7 @@
 		value = node->first_attribute("x")->value();
 		DataManager::GetValue(value, value);
 		*x = atol(value.c_str());
+		*x += tw_x_offset;
 	}
 
 	if (node->first_attribute("y"))
@@ -122,6 +126,7 @@
 		value = node->first_attribute("y")->value();
 		DataManager::GetValue(value, value);
 		*y = atol(value.c_str());
+		*y += tw_y_offset;
 	}
 
 	if (w && node->first_attribute("w"))
@@ -785,6 +790,16 @@
 		persist = child->first_attribute("persist");
 		if(name && value)
 		{
+			if (strcmp(name->value(), "tw_x_offset") == 0) {
+				tw_x_offset = atoi(value->value());
+				child = child->next_sibling("variable");
+				continue;
+			}
+			if (strcmp(name->value(), "tw_y_offset") == 0) {
+				tw_y_offset = atoi(value->value());
+				child = child->next_sibling("variable");
+				continue;
+			}
 			p = persist ? atoi(persist->value()) : 0;
 			string temp = value->value();
 			string valstr = gui_parse_text(temp);
@@ -928,6 +943,8 @@
 	if (package.size() > 4 && package.substr(package.size() - 4) != ".zip")
 	{
 		LOGINFO("Load XML directly\n");
+		tw_x_offset = TW_X_OFFSET;
+		tw_y_offset = TW_Y_OFFSET;
 		// We can try to load the XML directly...
 		struct stat st;
 		if(stat(package.c_str(),&st) != 0)
@@ -948,6 +965,8 @@
 	else
 	{
 		LOGINFO("Loading zip theme\n");
+		tw_x_offset = 0;
+		tw_y_offset = 0;
 		if (!TWFunc::Path_Exists(package))
 			return -1;
 		if (sysMapFile(package.c_str(), &map) != 0) {