@ -56,7 +56,7 @@ pub fn updateStatus(report: comm.Message.PoweroffProgress) !void {
all_stopped = all_stopped and sv . stopped ;
all_stopped = all_stopped and sv . stopped ;
}
}
if ( all_stopped ) {
if ( all_stopped ) {
win . status . set Label Text( " powering off ... " ) ;
win . status . set Text( " powering off ... " ) ;
}
}
} else {
} else {
return error . NoProgressWindow ;
return error . NoProgressWindow ;
@ -67,8 +67,8 @@ pub fn updateStatus(report: comm.Message.PoweroffProgress) !void {
/ / / the device turns off .
/ / / the device turns off .
const ProgressWin = struct {
const ProgressWin = struct {
win : lvgl . Window ,
win : lvgl . Window ,
status : * lvgl . LvObj , / / text status label
status : lvgl . Label , / / text status
svcont : * lvgl . LvObj , / / services container
svcont : lvgl . FlexLayout , / / services container
/ / / symbol width next to the service name . this aligns all service names vertically .
/ / / symbol width next to the service name . this aligns all service names vertically .
/ / / has to be wide enough to accomodate the spinner , but not too wide
/ / / has to be wide enough to accomodate the spinner , but not too wide
@ -76,21 +76,18 @@ const ProgressWin = struct {
const sym_width = 20 ;
const sym_width = 20 ;
fn create ( ) ! ProgressWin {
fn create ( ) ! ProgressWin {
const win = try lvgl . createWindow ( null , 60 , " " + + symbol . Power + + " SHUTDOWN " ) ;
const win = try lvgl . Window . newTop ( 60 , " " + + symbol . Power + + " SHUTDOWN " ) ;
errdefer win . winobj . destroy ( ) ; / / also deletes all children created below
errdefer win . destroy ( ) ; / / also deletes all children created below
const wincont = win . content ( ) ;
const wincont = win . content ( ) . flex ( . column , . { } ) ;
wincont . flexFlow ( . column ) ;
/ / initial status message
/ / initial status message
const status = try lvgl . create Label( wincont , " shutting down services. it may take up to a few minutes. " , . { } ) ;
const status = try lvgl . Label. new ( wincont , " shutting down services. it may take up to a few minutes. " , . { } ) ;
status . setWidth ( lvgl . sizePercent ( 100 ) ) ;
status . setWidth ( lvgl . sizePercent ( 100 ) ) ;
/ / prepare a container for services status
/ / prepare a container for services status
const svcont = try lvgl . createObject ( wincont ) ;
const svcont = try lvgl . FlexLayout . new ( wincont , . column , . { } ) ;
svcont . removeBackgroundStyle ( ) ;
svcont . flexFlow ( . column ) ;
svcont . flexGrow ( 1 ) ;
svcont . padColumnDefault ( ) ;
svcont . setWidth ( lvgl . sizePercent ( 100 ) ) ;
svcont . setWidth ( lvgl . sizePercent ( 100 ) ) ;
svcont . flexGrow ( 1 ) ;
return . {
return . {
. win = win ,
. win = win ,
@ -104,32 +101,28 @@ const ProgressWin = struct {
}
}
fn addServiceStatus ( self : ProgressWin , name : [ ] const u8 , stopped : bool , err : ? [ ] const u8 ) ! void {
fn addServiceStatus ( self : ProgressWin , name : [ ] const u8 , stopped : bool , err : ? [ ] const u8 ) ! void {
const row = try lvgl . createObject ( self . svcont ) ;
const row = try lvgl . FlexLayout . new ( self . svcont , . row , . { . all = . center } ) ;
row . removeBackgroundStyle ( ) ;
row . flexFlow ( . row ) ;
row . flexAlign ( . center , . center , . center ) ;
row . padColumnDefault ( ) ;
row . setPad ( 10 , . all , . { } ) ;
row . setPad ( 10 , . all , . { } ) ;
row . setWidth ( lvgl . sizePercent ( 100 ) ) ;
row . setWidth ( lvgl . sizePercent ( 100 ) ) ;
row . setHeightToContent ( ) ;
row . setHeightToContent ( ) ;
var buf : [ 100 ] u8 = undefined ;
var buf : [ 100 ] u8 = undefined ;
if ( err ) | e | {
if ( err ) | e | {
const sym = try lvgl . create LabelFmt( row , & buf , symbol . Warning , . { } , . { . long_mode = . clip } ) ;
const sym = try lvgl . Label. new Fmt( row , & buf , symbol . Warning , . { } , . { . long_mode = . clip } ) ;
sym . setWidth ( sym_width ) ;
sym . setWidth ( sym_width ) ;
sym . set TextColor( lvgl . paletteM ain( . red ) , . { } ) ;
sym . set Color( lvgl . Palette . m ain( . red ) , . { } ) ;
const lb = try lvgl . create LabelFmt( row , & buf , " {s}: {s} " , . { name , e } , . { . long_mode = . dot } ) ;
const lb = try lvgl . Label. new Fmt( row , & buf , " {s}: {s} " , . { name , e } , . { . long_mode = . dot } ) ;
lb . set TextColor( lvgl . paletteM ain( . red ) , . { } ) ;
lb . set Color( lvgl . Palette . m ain( . red ) , . { } ) ;
lb . flexGrow ( 1 ) ;
lb . flexGrow ( 1 ) ;
} else if ( stopped ) {
} else if ( stopped ) {
const sym = try lvgl . create LabelFmt( row , & buf , symbol . Ok , . { } , . { . long_mode = . clip } ) ;
const sym = try lvgl . Label. new Fmt( row , & buf , symbol . Ok , . { } , . { . long_mode = . clip } ) ;
sym . setWidth ( sym_width ) ;
sym . setWidth ( sym_width ) ;
const lb = try lvgl . create LabelFmt( row , & buf , " {s} " , . { name } , . { . long_mode = . dot } ) ;
const lb = try lvgl . Label. new Fmt( row , & buf , " {s} " , . { name } , . { . long_mode = . dot } ) ;
lb . flexGrow ( 1 ) ;
lb . flexGrow ( 1 ) ;
} else {
} else {
const spin = try lvgl . create Spinner( row ) ;
const spin = try lvgl . Spinner. new ( row ) ;
spin . setWidth ( sym_width ) ;
spin . setWidth ( sym_width ) ;
const lb = try lvgl . create LabelFmt( row , & buf , " {s} " , . { name } , . { . long_mode = . dot } ) ;
const lb = try lvgl . Label. new Fmt( row , & buf , " {s} " , . { name } , . { . long_mode = . dot } ) ;
lb . flexGrow ( 1 ) ;
lb . flexGrow ( 1 ) ;
}
}
}
}