@@ -24,33 +24,36 @@ if (!require("clock_info").loadCount) { // don't load if a clock_info was alread
2424 }
2525 } ) ;
2626 let clockInfoInfo ; // when clockInfoMenu.draw is called we set this up
27+ let draw = function ( e ) {
28+ clockInfoMenu . x = e . x ;
29+ var o = clockInfoMenu ;
30+ // Clear the background
31+ g . reset ( ) ;
32+ // indicate focus
33+ if ( clockInfoMenu . focus ) {
34+ g . setColor ( "#f00" ) ;
35+ }
36+ g . clearRect ( o . x , o . y , o . x + o . w - 1 , o . y + o . h - 1 ) ;
37+
38+ if ( clockInfoInfo ) {
39+ var x = o . x ;
40+ if ( clockInfoInfo . img ) {
41+ g . drawImage ( clockInfoInfo . img , x , o . y ) ; // draw the image
42+ x += 24 ;
43+ }
44+ var availableWidth = o . x + clockInfoMenu . w - ( x + 2 ) ;
45+ g . setFont ( "6x8:2" ) . setFontAlign ( - 1 , 0 ) ;
46+ if ( g . stringWidth ( clockInfoInfo . text ) > availableWidth )
47+ g . setFont ( "6x8:1x2" ) ;
48+ g . drawString ( clockInfoInfo . text , x + 2 , o . y + 12 ) ; // draw the text
49+ }
50+ } ;
2751
2852 // The actual widget we're displaying
2953 WIDGETS [ "clkinfo" ] = {
30- area :"tl" ,
54+ area : "tl" ,
3155 width : clockInfoMenu . w ,
32- draw :function ( e ) {
33- clockInfoMenu . x = e . x ;
34- clockInfoMenu . y = e . y ;
35- var o = clockInfoMenu ;
36- // Clear the background
37- g . reset ( ) ;
38- // indicate focus
39- if ( clockInfoMenu . focus ) g . setColor ( "#f00" ) ;
40- g . clearRect ( o . x , o . y , o . x + o . w - 1 , o . y + o . h - 1 ) ;
41- if ( clockInfoInfo ) {
42- var x = o . x ;
43- if ( clockInfoInfo . img ) {
44- g . drawImage ( clockInfoInfo . img , x , o . y ) ; // draw the image
45- x += 24 ;
46- }
47- var availableWidth = o . x + clockInfoMenu . w - ( x + 2 ) ;
48- g . setFont ( "6x8:2" ) . setFontAlign ( - 1 , 0 ) ;
49- if ( g . stringWidth ( clockInfoInfo . text ) > availableWidth )
50- g . setFont ( "6x8:1x2" ) ;
51- g . drawString ( clockInfoInfo . text , x + 2 , o . y + 12 ) ; // draw the text
52- }
53- }
56+ draw : draw
5457 } ;
5558
5659 Bangle . on ( "widgets-start-show" , ( ) => {
0 commit comments