@ -3,8 +3,8 @@
# include <math.h>
# include "ui.hpp"
static void ui_draw_sidebar_background ( UIState * s , bool hasSidebar ) {
int sbr_x = hasSidebar ? 0 : - ( sbr_w ) + bdr_s * 2 ;
static void ui_draw_sidebar_background ( UIState * s ) {
int sbr_x = ! s - > scene . uilayout_sidebarcollapsed ? 0 : - ( sbr_w ) + bdr_s * 2 ;
nvgBeginPath ( s - > vg ) ;
nvgRect ( s - > vg , sbr_x , 0 , sbr_w , vwp_h ) ;
@ -12,9 +12,9 @@ static void ui_draw_sidebar_background(UIState *s, bool hasSidebar) {
nvgFill ( s - > vg ) ;
}
static void ui_draw_sidebar_settings_button ( UIState * s , bool hasSidebar ) {
static void ui_draw_sidebar_settings_button ( UIState * s ) {
bool settingsActive = s - > active_app = = cereal_UiLayoutState_App_settings ;
const int settings_btn_xr = hasSidebar ? settings_btn_x : - ( sbr_w ) ;
const int settings_btn_xr = ! s - > scene . uilayout_sidebarcollapsed ? settings_btn_x : - ( sbr_w ) ;
nvgBeginPath ( s - > vg ) ;
NVGpaint imgPaint = nvgImagePattern ( s - > vg , settings_btn_xr , settings_btn_y ,
@ -24,9 +24,9 @@ static void ui_draw_sidebar_settings_button(UIState *s, bool hasSidebar) {
nvgFill ( s - > vg ) ;
}
static void ui_draw_sidebar_home_button ( UIState * s , bool hasSidebar ) {
static void ui_draw_sidebar_home_button ( UIState * s ) {
bool homeActive = s - > active_app = = cereal_UiLayoutState_App_home ;
const int home_btn_xr = hasSidebar ? home_btn_x : - ( sbr_w ) ;
const int home_btn_xr = ! s - > scene . uilayout_sidebarcollapsed ? home_btn_x : - ( sbr_w ) ;
nvgBeginPath ( s - > vg ) ;
NVGpaint imgPaint = nvgImagePattern ( s - > vg , home_btn_xr , home_btn_y ,
@ -36,10 +36,10 @@ static void ui_draw_sidebar_home_button(UIState *s, bool hasSidebar) {
nvgFill ( s - > vg ) ;
}
static void ui_draw_sidebar_network_strength ( UIState * s , bool hasSidebar ) {
static void ui_draw_sidebar_network_strength ( UIState * s ) {
const int network_img_h = 27 ;
const int network_img_w = 176 ;
const int network_img_x = hasSidebar ? 58 : - ( sbr_w ) ;
const int network_img_x = ! s - > scene . uilayout_sidebarcollapsed ? 58 : - ( sbr_w ) ;
const int network_img_y = 196 ;
const int network_img = s - > scene . networkType = = cereal_ThermalData_NetworkType_none ?
s - > img_network [ 0 ] : s - > img_network [ s - > scene . networkStrength + 1 ] ;
@ -52,10 +52,10 @@ static void ui_draw_sidebar_network_strength(UIState *s, bool hasSidebar) {
nvgFill ( s - > vg ) ;
}
static void ui_draw_sidebar_battery_icon ( UIState * s , bool hasSidebar ) {
static void ui_draw_sidebar_battery_icon ( UIState * s ) {
const int battery_img_h = 36 ;
const int battery_img_w = 76 ;
const int battery_img_x = hasSidebar ? 160 : - ( sbr_w ) ;
const int battery_img_x = ! s - > scene . uilayout_sidebarcollapsed ? 160 : - ( sbr_w ) ;
const int battery_img_y = 255 ;
int battery_img = strcmp ( s - > scene . batteryStatus , " Charging " ) = = 0 ?
@ -75,8 +75,8 @@ static void ui_draw_sidebar_battery_icon(UIState *s, bool hasSidebar) {
nvgFill ( s - > vg ) ;
}
static void ui_draw_sidebar_network_type ( UIState * s , bool hasSidebar ) {
const int network_x = hasSidebar ? 50 : - ( sbr_w ) ;
static void ui_draw_sidebar_network_type ( UIState * s ) {
const int network_x = ! s - > scene . uilayout_sidebarcollapsed ? 50 : - ( sbr_w ) ;
const int network_y = 273 ;
const int network_w = 100 ;
const int network_h = 100 ;
@ -94,8 +94,8 @@ static void ui_draw_sidebar_network_type(UIState *s, bool hasSidebar) {
nvgTextBox ( s - > vg , network_x , network_y , network_w , network_type_str , NULL ) ;
}
static void ui_draw_sidebar_metric ( UIState * s , const char * label_str , const char * value_str , const int severity , const int y_offset , const char * message_str , bool hasSidebar ) {
const int metric_x = hasSidebar ? 30 : - ( sbr_w ) ;
static void ui_draw_sidebar_metric ( UIState * s , const char * label_str , const char * value_str , const int severity , const int y_offset , const char * message_str ) {
const int metric_x = ! s - > scene . uilayout_sidebarcollapsed ? 30 : - ( sbr_w ) ;
const int metric_y = 338 + y_offset ;
const int metric_w = 240 ;
const int metric_h = message_str ? strchr ( message_str , ' \n ' ) ? 124 : 100 : 148 ;
@ -142,7 +142,7 @@ static void ui_draw_sidebar_metric(UIState *s, const char* label_str, const char
}
}
static void ui_draw_sidebar_temp_metric ( UIState * s , bool hasSidebar ) {
static void ui_draw_sidebar_temp_metric ( UIState * s ) {
int temp_severity ;
char temp_label_str [ 32 ] ;
char temp_value_str [ 32 ] ;
@ -164,10 +164,10 @@ static void ui_draw_sidebar_temp_metric(UIState *s, bool hasSidebar) {
snprintf ( temp_label_str , sizeof ( temp_label_str ) , " %s " , " TEMP " ) ;
strcat ( temp_value_str , temp_value_unit ) ;
ui_draw_sidebar_metric ( s , temp_label_str , temp_value_str , temp_severity , temp_y_offset , NULL , hasSidebar ) ;
ui_draw_sidebar_metric ( s , temp_label_str , temp_value_str , temp_severity , temp_y_offset , NULL ) ;
}
static void ui_draw_sidebar_panda_metric ( UIState * s , bool hasSidebar ) {
static void ui_draw_sidebar_panda_metric ( UIState * s ) {
int panda_severity ;
char panda_message_str [ 32 ] ;
const int panda_y_offset = 32 + 148 ;
@ -194,17 +194,27 @@ static void ui_draw_sidebar_panda_metric(UIState *s, bool hasSidebar) {
}
}
ui_draw_sidebar_metric ( s , NULL , NULL , panda_severity , panda_y_offset , panda_message_str , hasSidebar ) ;
ui_draw_sidebar_metric ( s , NULL , NULL , panda_severity , panda_y_offset , panda_message_str ) ;
}
static void ui_draw_sidebar_connectivity ( UIState * s ) {
if ( s - > scene . athenaStatus = = NET_DISCONNECTED ) {
ui_draw_sidebar_metric ( s , NULL , NULL , 1 , 180 + 158 , " ATHENA \n OFFLINE " ) ;
} else if ( s - > scene . athenaStatus = = NET_CONNECTED ) {
ui_draw_sidebar_metric ( s , NULL , NULL , 0 , 180 + 158 , " ATHENA \n ONLINE " ) ;
} else {
ui_draw_sidebar_metric ( s , NULL , NULL , 2 , 180 + 158 , " ATHENA \n ERROR " ) ;
}
}
void ui_draw_sidebar ( UIState * s ) {
bool hasSidebar = ! s - > scene . uilayout_sidebarcollapsed ;
ui_draw_sidebar_background ( s , hasSidebar ) ;
ui_draw_sidebar_settings_button ( s , hasSidebar ) ;
ui_draw_sidebar_home_button ( s , hasSidebar ) ;
ui_draw_sidebar_network_strength ( s , hasSidebar ) ;
ui_draw_sidebar_battery_icon ( s , hasSidebar ) ;
ui_draw_sidebar_network_type ( s , hasSidebar ) ;
ui_draw_sidebar_tem p_metric ( s , hasSidebar ) ;
ui_draw_sidebar_panda_metric ( s , hasSidebar ) ;
ui_draw_sidebar_background ( s ) ;
ui_draw_sidebar_settings_button ( s ) ;
ui_draw_sidebar_home _button ( s ) ;
ui_draw_sidebar_network_strength ( s ) ;
ui_draw_sidebar_battery_icon ( s ) ;
ui_draw_sidebar_network_type ( s ) ;
ui_draw_sidebar_temp_metric ( s ) ;
ui_draw_sidebar_panda _metric ( s ) ;
ui_draw_sidebar_connectivity ( s ) ;
}