gui : Add an option to specify a custom x-axis value for status bar items

 - The var TW_CUSTOM_CLOCK_POS, TW_CUSTOM_CPU_POS and
   TW_CUSTOM_BATTERY_POS can be used to specify a custom position
   for the clock, cpu temperature and battery percentage on the x-axis.
 - The value can either be a whole number refering to the starting
   position of that specific item on the x-axis or it can be 'left',
   'right' or 'center' which will try to automatically calculate such
   a value that items appear to be left , right or center aligned
   respectively.
 - Incase of TW_NO_CPU_TEMP being set to true, the CPU_POS var can be
   used for the TWRP version text that takes the place of the cpu temp.

 One of the use-cases of this var is when the status bar items overlap
 with the camera cutout. In that case, instead of specifiying an offset
 for the whole gui on y-axis, the status bar items can be offset along
 the x-axis only.

Signed-off-by: Yillié <yilliee@protonmail.com>
Change-Id: Ic01d301731822a598b0ca8adb2280c4d01a3622f
Signed-off-by: Mohd Faraz <androiabledroid@gmail.com>
diff --git a/gui/libguitwrp_defaults.go b/gui/libguitwrp_defaults.go
index 222564c..4ba6491 100644
--- a/gui/libguitwrp_defaults.go
+++ b/gui/libguitwrp_defaults.go
@@ -76,14 +76,87 @@
 			version = strings.Split(line, " ")[2]
 		}
 	}
+
+	_props := [3]string{"TW_CUSTOM_BATTERY_POS", "TW_CUSTOM_CPU_POS", "TW_CUSTOM_CLOCK_POS" }
+	props := [3]string{"0", "0", "0"}
+	for i, item := range _props {
+		if getMakeVars(ctx, item) != "" {
+			props[i] = strings.Trim(getMakeVars(ctx, item), "\"")
+		}
+	}
+
 	_files := [2]string{"splash.xml", "ui.xml"}
 	for _, i := range _files {
+		var fontsize int = 0
+		var width int = 0
+
 		data, err = ioutil.ReadFile(twRes + i)
 		if err != nil {
 			fmt.Println(err)
 			return
 		}
+
 		newFile := strings.Replace(string(data), "{themeversion}", version, -1)
+
+		// Custom position for status bar items - start
+		if i == "ui.xml" {
+
+			for _, line := range strings.Split(string(data), "\n") {
+		                if strings.Contains(line, "name=\"font_m\"") {
+		                      fontsize, err = strconv.Atoi(strings.Split(line, "\"")[5])
+		                       if err != nil {
+		                               fmt.Println(err)
+		                               return
+		                       }
+				}
+				if strings.Contains(line, "resolution") {
+					width, err = strconv.Atoi(strings.Split(line, "\"")[1])
+					if err != nil {
+						fmt.Println(err)
+						return
+					}
+				}
+		        }
+
+			var cpusize int = (fontsize * 5) + (width/100)
+			var clocksize int = (fontsize * 4) + (width/100)
+			var batterysize int = (fontsize * 6) - (width/100)
+			var pos_clock_24 string = props[2]
+			for j := 0; j < len(props); j++ {
+				if props[j] == "left" {
+					props[j] = strconv.Itoa(width/50)
+					if _props[j] == "TW_CUSTOM_CLOCK_POS" {
+						pos_clock_24 = props[j]
+					}
+				} else if props[j] == "center" {
+					if _props[j] == "TW_CUSTOM_BATTERY_POS" {
+						props[j] = strconv.Itoa( (width/2) - (batterysize*43/100) )
+					} else if _props[j] == "TW_CUSTOM_CLOCK_POS" {
+						pos := (width/2) - (clocksize*45/100)
+						props[j] = strconv.Itoa(pos)
+						pos_clock_24 = strconv.Itoa( pos * 31/30 )
+					} else if _props[j] == "TW_CUSTOM_CPU_POS" {
+						props[j] = strconv.Itoa( (width/2) - (cpusize*41/100) )
+					}
+				} else if props[j] == "right" {
+					if _props[j] == "TW_CUSTOM_BATTERY_POS" {
+						props[j] = strconv.Itoa( width - batterysize )
+					} else if _props[j] == "TW_CUSTOM_CLOCK_POS" {
+						props[j] = strconv.Itoa(width - clocksize)
+						pos_clock_24 = props[j]
+					} else if _props[j] == "TW_CUSTOM_CPU_POS" {
+						props[j] = strconv.Itoa( width - cpusize )
+					}
+				}
+			}
+
+			newFile = strings.Replace(newFile, "{battery_pos}", props[0], -1)
+			newFile = strings.Replace(newFile, "{cpu_pos}", props[1], -1)
+			newFile = strings.Replace(newFile, "{clock_12_pos}", props[2], -1)
+			newFile = strings.Replace(newFile, "{clock_24_pos}", pos_clock_24, -1)
+		}
+		// Custom position for status bar items - end
+
 		err = ioutil.WriteFile(twRes + i, []byte(newFile), 0)
 		if err != nil {
 			fmt.Println(err)
diff --git a/gui/theme/landscape_hdpi/ui.xml b/gui/theme/landscape_hdpi/ui.xml
index bd055bd..5f29e09 100755
--- a/gui/theme/landscape_hdpi/ui.xml
+++ b/gui/theme/landscape_hdpi/ui.xml
@@ -226,6 +226,10 @@
 		<variable name="pattern_dot_dia" value="32"/>
 		<variable name="pattern_line_w" value="12"/>
 		<variable name="pattern_size" value="648"/>
+		<variable name="tw_clock_12_pos_x" value="{clock_12_pos}"/>
+		<variable name="tw_clock_24_pos_x" value="{clock_24_pos}"/>
+		<variable name="tw_cpu_pos_x" value="{cpu_pos}"/>
+		<variable name="tw_battery_pos_x" value="{battery_pos}"/>
 	</variables>
 
 	<mousecursor>
@@ -267,6 +271,7 @@
 
 			<text color="%text_color%">
 				<condition var1="tw_no_cpu_temp" var2="1"/>
+				<condition var1="tw_cpu_pos_x" var2="0"/>
 				<font resource="font_m"/>
 				<placement x="%indent%" y="%row1_header_y%"/>
 				<text>%tw_version%</text>
@@ -274,12 +279,15 @@
 
 			<text color="%text_color%">
 				<condition var1="tw_no_cpu_temp" var2="0"/>
+				<condition var1="tw_cpu_pos_x" var2="0"/>
 				<font resource="font_m"/>
 				<placement x="%indent%" y="%row1_header_y%"/>
 				<text>{@cpu_temp=CPU: %tw_cpu_temp% °C}</text>
 			</text>
 
 			<text color="%text_color%">
+				<condition var1="tw_clock_12_pos_x" var2="0"/>
+				<condition var1="tw_clock_24_pos_x" var2="0"/>
 				<font resource="font_m"/>
 				<placement x="%center_x%" y="%row1_header_y%" placement="5"/>
 				<text>%tw_time%</text>
@@ -290,12 +298,61 @@
 					<condition var1="tw_no_battery_percent" var2="0"/>
 					<condition var1="tw_battery" op="&gt;" var2="0"/>
 					<condition var1="tw_battery" op="&lt;" var2="101"/>
+					<condition var1="tw_battery_pos_x" var2="0"/>
 				</conditions>
 				<font resource="font_m"/>
 				<placement x="%indent_right%" y="%row1_header_y%" placement="1"/>
 				<text>{@battery_pct=Battery: %tw_battery%}</text>
 			</text>
 
+			<!-- Custom position for status bar items if defined START -->
+
+			<text color="%text_color%">
+				<condition var1="tw_no_cpu_temp" var2="1"/>
+				<condition var1="tw_cpu_pos_x" op="!=" var2="0"/>
+				<font resource="font_m"/>
+				<placement x="%tw_cpu_pos_x%" y="%row1_header_y%"/>
+				<text>%tw_version%</text>
+			</text>
+
+			<text color="%text_color%">
+				<condition var1="tw_no_cpu_temp" var2="0"/>
+				<condition var1="tw_cpu_pos_x" op="!=" var2="0"/>
+				<font resource="font_m"/>
+				<placement x="%tw_cpu_pos_x%" y="%row1_header_y%"/>
+				<text>{@cpu_temp=CPU: %tw_cpu_temp% °C}</text>
+			</text>
+
+			<text color="%text_color%">
+				<condition var1="tw_clock_12_pos_x" op="!=" var2="0"/>
+				<condition var1="tw_military_time" var2="0"/>
+				<font resource="font_m"/>
+				<placement x="%tw_clock_12_pos_x%" y="%row1_header_y%"/>
+				<text>%tw_time%</text>
+			</text>
+
+			<text color="%text_color%">
+				<condition var1="tw_clock_24_pos_x" op="!=" var2="0"/>
+				<condition var1="tw_military_time" var2="1"/>
+				<font resource="font_m"/>
+				<placement x="%tw_clock_24_pos_x%" y="%row1_header_y%"/>
+				<text>%tw_time%</text>
+			</text>
+
+			<text color="%text_color%">
+				<conditions>
+					<condition var1="tw_no_battery_percent" var2="0"/>
+					<condition var1="tw_battery" op="&gt;" var2="0"/>
+					<condition var1="tw_battery" op="&lt;" var2="101"/>
+					<condition var1="tw_battery_pos_x" op="!=" var2="0"/>
+				</conditions>
+				<font resource="font_m"/>
+				<placement x="%tw_battery_pos_x%" y="%row1_header_y%"/>
+				<text>{@battery_pct=Battery: %tw_battery%}</text>
+			</text>
+
+			<!-- Custom position for status bar items if defined END -->
+
 			<fill color="#000000">
 				<condition var1="tw_busy" var2="0"/>
 				<placement x="0" y="%navbar_y%" w="%screen_width%" h="%navbar_height%"/>
diff --git a/gui/theme/landscape_mdpi/ui.xml b/gui/theme/landscape_mdpi/ui.xml
index 9ab8863..e6c58b2 100755
--- a/gui/theme/landscape_mdpi/ui.xml
+++ b/gui/theme/landscape_mdpi/ui.xml
@@ -226,6 +226,10 @@
 		<variable name="pattern_dot_dia" value="12"/>
 		<variable name="pattern_line_w" value="4"/>
 		<variable name="pattern_size" value="252"/>
+		<variable name="tw_clock_12_pos_x" value="{clock_12_pos}"/>
+		<variable name="tw_clock_24_pos_x" value="{clock_24_pos}"/>
+		<variable name="tw_cpu_pos_x" value="{cpu_pos}"/>
+		<variable name="tw_battery_pos_x" value="{battery_pos}"/>
 	</variables>
 
 	<mousecursor>
@@ -267,6 +271,7 @@
 
 			<text color="%text_color%">
 				<condition var1="tw_no_cpu_temp" var2="1"/>
+				<condition var1="tw_cpu_pos_x" var2="0"/>
 				<font resource="font_m"/>
 				<placement x="%indent%" y="%row1_header_y%"/>
 				<text>%tw_version%</text>
@@ -274,12 +279,15 @@
 
 			<text color="%text_color%">
 				<condition var1="tw_no_cpu_temp" var2="0"/>
+				<condition var1="tw_cpu_pos_x" var2="0"/>
 				<font resource="font_m"/>
 				<placement x="%indent%" y="%row1_header_y%"/>
 				<text>{@cpu_temp=CPU: %tw_cpu_temp% °C}</text>
 			</text>
 
 			<text color="%text_color%">
+				<condition var1="tw_clock_12_pos_x" var2="0"/>
+				<condition var1="tw_clock_24_pos_x" var2="0"/>
 				<font resource="font_m"/>
 				<placement x="%center_x%" y="%row1_header_y%" placement="5"/>
 				<text>%tw_time%</text>
@@ -290,12 +298,61 @@
 					<condition var1="tw_no_battery_percent" var2="0"/>
 					<condition var1="tw_battery" op="&gt;" var2="0"/>
 					<condition var1="tw_battery" op="&lt;" var2="101"/>
+					<condition var1="tw_battery_pos_x" var2="0"/>
 				</conditions>
 				<font resource="font_m"/>
 				<placement x="%indent_right%" y="%row1_header_y%" placement="1"/>
 				<text>{@battery_pct=Battery: %tw_battery%}</text>
 			</text>
 
+			<!-- Custom position for status bar items if defined START -->
+
+			<text color="%text_color%">
+				<condition var1="tw_no_cpu_temp" var2="1"/>
+				<condition var1="tw_cpu_pos_x" op="!=" var2="0"/>
+				<font resource="font_m"/>
+				<placement x="%tw_cpu_pos_x%" y="%row1_header_y%"/>
+				<text>%tw_version%</text>
+			</text>
+
+			<text color="%text_color%">
+				<condition var1="tw_no_cpu_temp" var2="0"/>
+				<condition var1="tw_cpu_pos_x" op="!=" var2="0"/>
+				<font resource="font_m"/>
+				<placement x="%tw_cpu_pos_x%" y="%row1_header_y%"/>
+				<text>{@cpu_temp=CPU: %tw_cpu_temp% °C}</text>
+			</text>
+
+			<text color="%text_color%">
+				<condition var1="tw_clock_12_pos_x" op="!=" var2="0"/>
+				<condition var1="tw_military_time" var2="0"/>
+				<font resource="font_m"/>
+				<placement x="%tw_clock_12_pos_x%" y="%row1_header_y%"/>
+				<text>%tw_time%</text>
+			</text>
+
+			<text color="%text_color%">
+				<condition var1="tw_clock_24_pos_x" op="!=" var2="0"/>
+				<condition var1="tw_military_time" var2="1"/>
+				<font resource="font_m"/>
+				<placement x="%tw_clock_24_pos_x%" y="%row1_header_y%"/>
+				<text>%tw_time%</text>
+			</text>
+
+			<text color="%text_color%">
+				<conditions>
+					<condition var1="tw_no_battery_percent" var2="0"/>
+					<condition var1="tw_battery" op="&gt;" var2="0"/>
+					<condition var1="tw_battery" op="&lt;" var2="101"/>
+					<condition var1="tw_battery_pos_x" op="!=" var2="0"/>
+				</conditions>
+				<font resource="font_m"/>
+				<placement x="%tw_battery_pos_x%" y="%row1_header_y%"/>
+				<text>{@battery_pct=Battery: %tw_battery%}</text>
+			</text>
+
+			<!-- Custom position for status bar items if defined END -->
+
 			<fill color="#000000">
 				<condition var1="tw_busy" var2="0"/>
 				<placement x="0" y="%navbar_y%" w="%screen_width%" h="%navbar_height%"/>
diff --git a/gui/theme/portrait_hdpi/ui.xml b/gui/theme/portrait_hdpi/ui.xml
index f7d21da..7c4d2aa 100755
--- a/gui/theme/portrait_hdpi/ui.xml
+++ b/gui/theme/portrait_hdpi/ui.xml
@@ -223,6 +223,10 @@
 		<variable name="pattern_dot_dia" value="32"/>
 		<variable name="pattern_line_w" value="12"/>
 		<variable name="pattern_size" value="828"/>
+		<variable name="tw_clock_12_pos_x" value="{clock_12_pos}"/>
+		<variable name="tw_clock_24_pos_x" value="{clock_24_pos}"/>
+		<variable name="tw_cpu_pos_x" value="{cpu_pos}"/>
+		<variable name="tw_battery_pos_x" value="{battery_pos}"/>
 	</variables>
 
 	<mousecursor>
@@ -264,6 +268,7 @@
 
 			<text color="%text_color%">
 				<condition var1="tw_no_cpu_temp" var2="1"/>
+				<condition var1="tw_cpu_pos_x" var2="0"/>
 				<font resource="font_m"/>
 				<placement x="%indent%" y="%row1_header_y%"/>
 				<text>%tw_version%</text>
@@ -271,12 +276,15 @@
 
 			<text color="%text_color%">
 				<condition var1="tw_no_cpu_temp" var2="0"/>
+				<condition var1="tw_cpu_pos_x" var2="0"/>
 				<font resource="font_m"/>
 				<placement x="%indent%" y="%row1_header_y%"/>
 				<text>{@cpu_temp=CPU: %tw_cpu_temp% °C}</text>
 			</text>
 
 			<text color="%text_color%">
+				<condition var1="tw_clock_12_pos_x" var2="0"/>
+				<condition var1="tw_clock_24_pos_x" var2="0"/>
 				<font resource="font_m"/>
 				<placement x="%center_x%" y="%row1_header_y%" placement="5"/>
 				<text>%tw_time%</text>
@@ -287,12 +295,61 @@
 					<condition var1="tw_no_battery_percent" var2="0"/>
 					<condition var1="tw_battery" op="&gt;" var2="0"/>
 					<condition var1="tw_battery" op="&lt;" var2="101"/>
+					<condition var1="tw_battery_pos_x" var2="0"/>
 				</conditions>
 				<font resource="font_m"/>
 				<placement x="%indent_right%" y="%row1_header_y%" placement="1"/>
 				<text>{@battery_pct=Battery: %tw_battery%}</text>
 			</text>
 
+			<!-- Custom position for status bar items if defined START -->
+
+			<text color="%text_color%">
+				<condition var1="tw_no_cpu_temp" var2="1"/>
+				<condition var1="tw_cpu_pos_x" op="!=" var2="0"/>
+				<font resource="font_m"/>
+				<placement x="%tw_cpu_pos_x%" y="%row1_header_y%"/>
+				<text>%tw_version%</text>
+			</text>
+
+			<text color="%text_color%">
+				<condition var1="tw_no_cpu_temp" var2="0"/>
+				<condition var1="tw_cpu_pos_x" op="!=" var2="0"/>
+				<font resource="font_m"/>
+				<placement x="%tw_cpu_pos_x%" y="%row1_header_y%"/>
+				<text>{@cpu_temp=CPU: %tw_cpu_temp% °C}</text>
+			</text>
+
+			<text color="%text_color%">
+				<condition var1="tw_clock_12_pos_x" op="!=" var2="0"/>
+				<condition var1="tw_military_time" var2="0"/>
+				<font resource="font_m"/>
+				<placement x="%tw_clock_12_pos_x%" y="%row1_header_y%"/>
+				<text>%tw_time%</text>
+			</text>
+
+			<text color="%text_color%">
+				<condition var1="tw_clock_24_pos_x" op="!=" var2="0"/>
+				<condition var1="tw_military_time" var2="1"/>
+				<font resource="font_m"/>
+				<placement x="%tw_clock_24_pos_x%" y="%row1_header_y%"/>
+				<text>%tw_time%</text>
+			</text>
+
+			<text color="%text_color%">
+				<conditions>
+					<condition var1="tw_no_battery_percent" var2="0"/>
+					<condition var1="tw_battery" op="&gt;" var2="0"/>
+					<condition var1="tw_battery" op="&lt;" var2="101"/>
+					<condition var1="tw_battery_pos_x" op="!=" var2="0"/>
+				</conditions>
+				<font resource="font_m"/>
+				<placement x="%tw_battery_pos_x%" y="%row1_header_y%"/>
+				<text>{@battery_pct=Battery: %tw_battery%}</text>
+			</text>
+
+			<!-- Custom position for status bar items if defined END -->
+
 			<fill color="#000000">
 				<condition var1="tw_busy" var2="0"/>
 				<placement x="0" y="%navbar_y%" w="%screen_width%" h="%navbar_height%"/>
diff --git a/gui/theme/portrait_mdpi/ui.xml b/gui/theme/portrait_mdpi/ui.xml
index 9189df0..4566dc7 100755
--- a/gui/theme/portrait_mdpi/ui.xml
+++ b/gui/theme/portrait_mdpi/ui.xml
@@ -223,6 +223,10 @@
 		<variable name="pattern_dot_dia" value="12"/>
 		<variable name="pattern_line_w" value="4"/>
 		<variable name="pattern_size" value="360"/>
+		<variable name="tw_clock_12_pos_x" value="{clock_12_pos}"/>
+		<variable name="tw_clock_24_pos_x" value="{clock_24_pos}"/>
+		<variable name="tw_cpu_pos_x" value="{cpu_pos}"/>
+		<variable name="tw_battery_pos_x" value="{battery_pos}"/>
 	</variables>
 
 	<mousecursor>
@@ -264,6 +268,7 @@
 
 			<text color="%text_color%">
 				<condition var1="tw_no_cpu_temp" var2="1"/>
+				<condition var1="tw_cpu_pos_x" var2="0"/>
 				<font resource="font_m"/>
 				<placement x="%indent%" y="%row1_header_y%"/>
 				<text>%tw_version%</text>
@@ -271,12 +276,15 @@
 
 			<text color="%text_color%">
 				<condition var1="tw_no_cpu_temp" var2="0"/>
+				<condition var1="tw_cpu_pos_x" var2="0"/>
 				<font resource="font_m"/>
 				<placement x="%indent%" y="%row1_header_y%"/>
 				<text>{@cpu_temp=CPU: %tw_cpu_temp% °C}</text>
 			</text>
 
 			<text color="%text_color%">
+				<condition var1="tw_clock_12_pos_x" var2="0"/>
+				<condition var1="tw_clock_24_pos_x" var2="0"/>
 				<font resource="font_m"/>
 				<placement x="%center_x%" y="%row1_header_y%" placement="5"/>
 				<text>%tw_time%</text>
@@ -287,12 +295,61 @@
 					<condition var1="tw_no_battery_percent" var2="0"/>
 					<condition var1="tw_battery" op="&gt;" var2="0"/>
 					<condition var1="tw_battery" op="&lt;" var2="101"/>
+					<condition var1="tw_battery_pos_x" var2="0"/>
 				</conditions>
 				<font resource="font_m"/>
 				<placement x="%indent_right%" y="%row1_header_y%" placement="1"/>
 				<text>{@battery_pct=Battery: %tw_battery%}</text>
 			</text>
 
+			<!-- Custom position for status bar items if defined START -->
+
+			<text color="%text_color%">
+				<condition var1="tw_no_cpu_temp" var2="1"/>
+				<condition var1="tw_cpu_pos_x" op="!=" var2="0"/>
+				<font resource="font_m"/>
+				<placement x="%tw_cpu_pos_x%" y="%row1_header_y%"/>
+				<text>%tw_version%</text>
+			</text>
+
+			<text color="%text_color%">
+				<condition var1="tw_no_cpu_temp" var2="0"/>
+				<condition var1="tw_cpu_pos_x" op="!=" var2="0"/>
+				<font resource="font_m"/>
+				<placement x="%tw_cpu_pos_x%" y="%row1_header_y%"/>
+				<text>{@cpu_temp=CPU: %tw_cpu_temp% °C}</text>
+			</text>
+
+			<text color="%text_color%">
+				<condition var1="tw_clock_12_pos_x" op="!=" var2="0"/>
+				<condition var1="tw_military_time" var2="0"/>
+				<font resource="font_m"/>
+				<placement x="%tw_clock_12_pos_x%" y="%row1_header_y%"/>
+				<text>%tw_time%</text>
+			</text>
+
+			<text color="%text_color%">
+				<condition var1="tw_clock_24_pos_x" op="!=" var2="0"/>
+				<condition var1="tw_military_time" var2="1"/>
+				<font resource="font_m"/>
+				<placement x="%tw_clock_24_pos_x%" y="%row1_header_y%"/>
+				<text>%tw_time%</text>
+			</text>
+
+			<text color="%text_color%">
+				<conditions>
+					<condition var1="tw_no_battery_percent" var2="0"/>
+					<condition var1="tw_battery" op="&gt;" var2="0"/>
+					<condition var1="tw_battery" op="&lt;" var2="101"/>
+					<condition var1="tw_battery_pos_x" op="!=" var2="0"/>
+				</conditions>
+				<font resource="font_m"/>
+				<placement x="%tw_battery_pos_x%" y="%row1_header_y%"/>
+				<text>{@battery_pct=Battery: %tw_battery%}</text>
+			</text>
+
+			<!-- Custom position for status bar items if defined END -->
+
 			<fill color="#000000">
 				<condition var1="tw_busy" var2="0"/>
 				<placement x="0" y="%navbar_y%" w="%screen_width%" h="%navbar_height%"/>
diff --git a/gui/theme/watch_mdpi/ui.xml b/gui/theme/watch_mdpi/ui.xml
index ed7ac82..24a4d46 100644
--- a/gui/theme/watch_mdpi/ui.xml
+++ b/gui/theme/watch_mdpi/ui.xml
@@ -182,6 +182,10 @@
 		<variable name="pattern_dot_dia" value="12"/>
 		<variable name="pattern_line_w" value="4"/>
 		<variable name="pattern_size" value="200"/>
+		<variable name="tw_clock_12_pos_x" value="{clock_12_pos}"/>
+		<variable name="tw_clock_24_pos_x" value="{clock_24_pos}"/>
+		<variable name="tw_cpu_pos_x" value="{cpu_pos}"/>
+		<variable name="tw_battery_pos_x" value="{battery_pos}"/>
 	</variables>
 
 	<templates>
@@ -203,6 +207,7 @@
 
 			<text color="%text_color%">
 				<condition var1="tw_no_cpu_temp" var2="1"/>
+				<condition var1="tw_cpu_pos_x" var2="0"/>
 				<font resource="font_m"/>
 				<placement x="%indent%" y="%row1_header_y%"/>
 				<text>{@twrp_watch_header=TWRP %tw_version%}</text>
@@ -210,12 +215,15 @@
 
 			<text color="%text_color%">
 				<condition var1="tw_no_cpu_temp" var2="0"/>
+				<condition var1="tw_cpu_pos_x" var2="0"/>
 				<font resource="font_m"/>
 				<placement x="%indent%" y="%row1_header_y%"/>
 				<text>{@cpu_temp=CPU: %tw_cpu_temp% °C}</text>
 			</text>
 
 			<text color="%text_color%">
+				<condition var1="tw_clock_12_pos_x" var2="0"/>
+				<condition var1="tw_clock_24_pos_x" var2="0"/>
 				<font resource="font_m"/>
 				<placement x="%center_x%" y="%row1_header_y%" placement="5"/>
 				<text>%tw_time%</text>
@@ -226,12 +234,61 @@
 					<condition var1="tw_no_battery_percent" var2="0"/>
 					<condition var1="tw_battery" op="&gt;" var2="0"/>
 					<condition var1="tw_battery" op="&lt;" var2="101"/>
+					<condition var1="tw_battery_pos_x" var2="0"/>
 				</conditions>
 				<font resource="font_m"/>
 				<placement x="%indent_right%" y="%row1_header_y%" placement="1"/>
 				<text>{@battery_pct=Battery: %tw_battery%}</text>
 			</text>
 
+			<!-- Custom position for status bar items if defined START -->
+
+			<text color="%text_color%">
+				<condition var1="tw_no_cpu_temp" var2="1"/>
+				<condition var1="tw_cpu_pos_x" op="!=" var2="0"/>
+				<font resource="font_m"/>
+				<placement x="%tw_cpu_pos_x%" y="%row1_header_y%"/>
+				<text>{@twrp_watch_header=TWRP %tw_version%}</text>
+			</text>
+
+			<text color="%text_color%">
+				<condition var1="tw_no_cpu_temp" var2="0"/>
+				<condition var1="tw_cpu_pos_x" op="!=" var2="0"/>
+				<font resource="font_m"/>
+				<placement x="%tw_cpu_pos_x%" y="%row1_header_y%"/>
+				<text>{@cpu_temp=CPU: %tw_cpu_temp% °C}</text>
+			</text>
+
+			<text color="%text_color%">
+				<condition var1="tw_clock_12_pos_x" op="!=" var2="0"/>
+				<condition var1="tw_military_time" var2="0"/>
+				<font resource="font_m"/>
+				<placement x="%tw_clock_12_pos_x%" y="%row1_header_y%"/>
+				<text>%tw_time%</text>
+			</text>
+
+			<text color="%text_color%">
+				<condition var1="tw_clock_24_pos_x" op="!=" var2="0"/>
+				<condition var1="tw_military_time" var2="1"/>
+				<font resource="font_m"/>
+				<placement x="%tw_clock_24_pos_x%" y="%row1_header_y%"/>
+				<text>%tw_time%</text>
+			</text>
+
+			<text color="%text_color%">
+				<conditions>
+					<condition var1="tw_no_battery_percent" var2="0"/>
+					<condition var1="tw_battery" op="&gt;" var2="0"/>
+					<condition var1="tw_battery" op="&lt;" var2="101"/>
+					<condition var1="tw_battery_pos_x" op="!=" var2="0"/>
+				</conditions>
+				<font resource="font_m"/>
+				<placement x="%tw_battery_pos_x%" y="%row1_header_y%"/>
+				<text>{@battery_pct=Battery: %tw_battery%}</text>
+			</text>
+
+			<!-- Custom position for status bar items if defined END -->
+
 			<fill color="#000000">
 				<placement x="0" y="%navbar_y%" w="%screen_width%" h="%navbar_height%"/>
 			</fill>