@@ -58,7 +58,7 @@ let clockInfoItems = require("clock_info").load();
5858
5959let clockInfoMenuLeft = require ( "clock_info" ) . addInteractive ( clockInfoItems , {
6060 // Add the dimensions we're rendering to here - these are used to detect taps on the clock info area
61- x : 13 , y : 103 , w : 66 , h :65 ,
61+ x : 10 , y : 100 , w : 72 , h :70 ,
6262 // You can add other information here you want to be passed into 'options' in 'draw'
6363 // This function draws the info
6464 draw : ( itm , info , options ) => {
@@ -71,10 +71,10 @@ let clockInfoMenuLeft = require("clock_info").addInteractive(clockInfoItems, {
7171 if ( options . focus ) {
7272 // show if focused
7373 g . setColor ( 0 , 15 , 255 ) ;
74- bRoundedRectangle ( 10 , 100 , 82 , 170 , 8 ) ;
74+ bRoundedRectangle ( options . x , options . y , options . x + options . w , options . y + options . h , 8 ) ;
7575 } else {
7676 g . setColor ( g . theme . fg ) ;
77- bRoundedRectangle ( 10 , 100 , 82 , 170 , 8 ) ;
77+ bRoundedRectangle ( options . x , options . y , options . x + options . w , options . y + options . h , 8 ) ;
7878 }
7979 // we're drawing center-aligned here
8080 var midx = options . x + options . w / 2 ;
@@ -91,7 +91,7 @@ let clockInfoMenuLeft = require("clock_info").addInteractive(clockInfoItems, {
9191//CLOCK INFO RIGHT DIMENSIONS: 97,113, w:66, h: 55
9292let clockInfoMenuRight = require ( "clock_info" ) . addInteractive ( clockInfoItems , {
9393 // Add the dimensions we're rendering to here - these are used to detect taps on the clock info area
94- x : 97 , y : 103 , w : 66 , h :65 ,
94+ x : 94 , y : 100 , w : 72 , h :70 ,
9595 // You can add other information here you want to be passed into 'options' in 'draw'
9696 // This function draws the info
9797 draw : ( itm , info , options ) => {
@@ -104,10 +104,10 @@ let clockInfoMenuRight = require("clock_info").addInteractive(clockInfoItems, {
104104 if ( options . focus ) {
105105 // show if focused
106106 g . setColor ( 0 , 15 , 255 ) ;
107- bRoundedRectangle ( 94 , 100 , 166 , 170 , 8 ) ;
107+ bRoundedRectangle ( options . x , options . y , options . x + options . w , options . y + options . h , 8 ) ;
108108 } else {
109109 g . setColor ( g . theme . fg ) ;
110- bRoundedRectangle ( 94 , 100 , 166 , 170 , 8 ) ;
110+ bRoundedRectangle ( options . x , options . y , options . x + options . w , options . y + options . h , 8 ) ;
111111 }
112112 // we're drawing center-aligned here
113113 var midx = options . x + options . w / 2 ;
@@ -138,22 +138,42 @@ let draw = function() {
138138 // align bottom right
139139
140140 g . setFontBold ( ) ;
141- g . setFontAlign ( 0 , 1 ) ;
142- g . drawString ( " " + clock + " " , X - 10 , Y + 1 , true /*clear background*/ ) ;
143- // draw the meridian(am/pm) and seconds (2x size 7 segment)
144141
145- g . setFont ( "Vector" , 20 ) ;
146-
147- g . setFontAlign ( - 1 , 1 ) ; // align bottom left
148- g . drawString ( meridian , X + 50 , Y - 10 , true /*clear background*/ ) ;
142+ if ( meridian != "" ) {
143+ //calculate alignment
144+ g . setFontBold ( ) ;
145+ //padding in px
146+ var padding = 7 ;
147+ var clkStrWidth = g . stringWidth ( clock ) ;
148+ g . setFont ( "Vector" , 18 ) ;
149+ var meridianStrWidth = g . stringWidth ( meridian ) ;
150+ var totalStrWidth = meridianStrWidth + padding + clkStrWidth ;
151+ var startX = ( ( g . getWidth ( ) - totalStrWidth ) / 2 ) + 6 ;
152+ g . clearRect ( 0 , 0 , g . getWidth ( ) , 90 ) ;
153+ g . setFontBold ( ) ;
154+ g . setFontAlign ( - 1 , 1 ) ;
155+ g . drawString ( clock , startX , Y + 2 , true ) ;
156+ g . setFont ( "Vector" , 20 ) ;
157+ g . setFontAlign ( - 1 , 1 ) ;
158+ g . drawString ( meridian , startX + clkStrWidth + padding , Y - 5 , true ) ;
159+
160+ } else {
161+
162+ g . setFontBold ( ) ;
163+ g . setFontAlign ( 0 , 1 ) ;
164+ g . drawString ( " " + clock + " " , X , Y - 2 , true ) ;
165+
166+ }
167+
168+
149169 // draw the date, in a normal font
150170 g . setFont ( "Vector" , 18 ) ;
151171 g . setFontAlign ( 0 , 0 ) ; // align center bottom
152172 // pad the date - this clears the background if the date were to change length
153173 var dateStr = require ( "locale" ) . dow ( new Date ( ) , 1 ) + ", " + require ( "locale" ) . month ( new Date ( ) , true ) + " " + new Date ( ) . getDate ( ) ;
154174 g . drawString ( " " + dateStr + " " , g . getWidth ( ) / 2 , Y + 9 , true /*clear background*/ ) ;
155175
156-
176+ Bangle . drawWidgets ( ) ;
157177
158178 // queue next draw
159179 if ( drawTimeout ) clearTimeout ( drawTimeout ) ;
@@ -183,5 +203,4 @@ g.clear();
183203// Load widgets
184204Bangle . loadWidgets ( ) ;
185205draw ( ) ;
186- setTimeout ( Bangle . drawWidgets , 0 ) ;
187206}
0 commit comments