@ -119,8 +119,8 @@ static void draw_lead(UIState *s, int idx){ 
			
		
	
		
			
				
					  }   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					  float  sz  =  std : : clamp ( ( 25  *  30 )  /  ( d_rel  /  3  +  30 ) ,  15.0f ,  30.0f )  *  zoom ;   
			
		
	
		
			
				
					  x  =  std : : clamp ( x ,  0.f ,  s - > scene . viz_rect . right ( )  -  sz  /  2 ) ;   
			
		
	
		
			
				
					  y  =  std : : fmin ( s - > scene . viz_rect . bottom ( )  -  sz  *  .6 ,   y ) ;   
			
		
	
		
			
				
					  x  =  std : : clamp ( x ,  0.f ,  s - > viz_rect . right ( )  -  sz  /  2 ) ;   
			
		
	
		
			
				
					  y  =  std : : fmin ( s - > viz_rect . bottom ( )  -  sz  *  .6 ,   y ) ;   
			
		
	
		
			
				
					  draw_chevron ( s ,  x ,  y ,  sz ,  nvgRGBA ( 201 ,  34 ,  49 ,  fillAlpha ) ,  COLOR_YELLOW ) ;   
			
		
	
		
			
				
					}  
			
		
	
		
			
				
					
 
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -196,7 +196,7 @@ static void ui_draw_vision_lane_lines(UIState *s) { 
			
		
	
		
			
				
					static  void  ui_draw_world ( UIState  * s )  {  
			
		
	
		
			
				
					  const  UIScene  * scene  =  & s - > scene ;   
			
		
	
		
			
				
					  // Don't draw on top of sidebar
   
			
		
	
		
			
				
					  nvgScissor ( s - > vg ,  scene  - > viz_rect . x ,  scene  - > viz_rect . y ,  scene  - > viz_rect . w ,  scene  - > viz_rect . h ) ;   
			
		
	
		
			
				
					  nvgScissor ( s - > vg ,  s - > viz_rect . x ,  s - > viz_rect . y ,  s - > viz_rect . w ,  s - > viz_rect . h ) ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					  // Draw lane edges and vision/mpc tracks
   
			
		
	
		
			
				
					  ui_draw_vision_lane_lines ( s ) ;   
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -218,7 +218,7 @@ static void ui_draw_vision_maxspeed(UIState *s) { 
			
		
	
		
			
				
					  const  bool  is_cruise_set  =  maxspeed  ! =  0  & &  maxspeed  ! =  SET_SPEED_NA ;   
			
		
	
		
			
				
					  if  ( is_cruise_set  & &  ! s - > is_metric )  {  maxspeed  * =  0.6225 ;  }   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					  const  Rect  rect  =  { s - > scene . viz_rect . x  +  ( bdr_s  *  2 ) ,  int ( s - > scene . viz_rect . y  +  ( bdr_s  *  1.5 ) ) ,  184 ,  202 } ;   
			
		
	
		
			
				
					  const  Rect  rect  =  { s - > viz_rect . x  +  ( bdr_s  *  2 ) ,  int ( s - > viz_rect . y  +  ( bdr_s  *  1.5 ) ) ,  184 ,  202 } ;   
			
		
	
		
			
				
					  ui_fill_rect ( s - > vg ,  rect ,  COLOR_BLACK_ALPHA ( 100 ) ,  30. ) ;   
			
		
	
		
			
				
					  ui_draw_rect ( s - > vg ,  rect ,  COLOR_WHITE_ALPHA ( 100 ) ,  10 ,  20. ) ;   
			
		
	
		
			
				
					
 
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -236,14 +236,14 @@ static void ui_draw_vision_speed(UIState *s) { 
			
		
	
		
			
				
					  const  float  speed  =  std : : max ( 0.0 ,  s - > scene . controls_state . getVEgo ( )  *  ( s - > is_metric  ?  3.6  :  2.2369363 ) ) ;   
			
		
	
		
			
				
					  const  std : : string  speed_str  =  std : : to_string ( ( int ) std : : nearbyint ( speed ) ) ;   
			
		
	
		
			
				
					  nvgTextAlign ( s - > vg ,  NVG_ALIGN_CENTER  |  NVG_ALIGN_BASELINE ) ;   
			
		
	
		
			
				
					  ui_draw_text ( s ,  s - > scene . viz_rect . centerX ( ) ,  240 ,  speed_str . c_str ( ) ,  96  *  2.5 ,  COLOR_WHITE ,  " sans-bold " ) ;   
			
		
	
		
			
				
					  ui_draw_text ( s ,  s - > scene . viz_rect . centerX ( ) ,  320 ,  s - > is_metric  ?  " km/h "  :  " mph " ,  36  *  2.5 ,  COLOR_WHITE_ALPHA ( 200 ) ,  " sans-regular " ) ;   
			
		
	
		
			
				
					  ui_draw_text ( s ,  s - > viz_rect . centerX ( ) ,  240 ,  speed_str . c_str ( ) ,  96  *  2.5 ,  COLOR_WHITE ,  " sans-bold " ) ;   
			
		
	
		
			
				
					  ui_draw_text ( s ,  s - > viz_rect . centerX ( ) ,  320 ,  s - > is_metric  ?  " km/h "  :  " mph " ,  36  *  2.5 ,  COLOR_WHITE_ALPHA ( 200 ) ,  " sans-regular " ) ;   
			
		
	
		
			
				
					}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					static  void  ui_draw_vision_event ( UIState  * s )  {  
			
		
	
		
			
				
					  const  int  viz_event_w  =  220 ;   
			
		
	
		
			
				
					  const  int  viz_event_x  =  s - > scene . viz_rect . right ( )  -  ( viz_event_w  +  bdr_s * 2 ) ;   
			
		
	
		
			
				
					  const  int  viz_event_y  =  s - > scene . viz_rect . y  +  ( bdr_s * 1.5 ) ;   
			
		
	
		
			
				
					  const  int  viz_event_x  =  s - > viz_rect . right ( )  -  ( viz_event_w  +  bdr_s * 2 ) ;   
			
		
	
		
			
				
					  const  int  viz_event_y  =  s - > viz_rect . y  +  ( bdr_s * 1.5 ) ;   
			
		
	
		
			
				
					  if  ( s - > scene . controls_state . getDecelForModel ( )  & &  s - > scene . controls_state . getEnabled ( ) )  {   
			
		
	
		
			
				
					    // draw winding road sign
   
			
		
	
		
			
				
					    const  int  img_turn_size  =  160 * 1.5 ;   
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -262,17 +262,16 @@ static void ui_draw_vision_event(UIState *s) { 
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					static  void  ui_draw_vision_face ( UIState  * s )  {  
			
		
	
		
			
				
					  const  int  face_size  =  96 ;   
			
		
	
		
			
				
					  const  int  face_x  =  ( s - > scene . viz_rect . x  +  face_size  +  ( bdr_s  *  2 ) ) ;   
			
		
	
		
			
				
					  const  int  face_y  =  ( s - > scene . viz_rect . bottom ( )  -  footer_h  +  ( ( footer_h  -  face_size )  /  2 ) ) ;   
			
		
	
		
			
				
					  const  int  face_x  =  ( s - > viz_rect . x  +  face_size  +  ( bdr_s  *  2 ) ) ;   
			
		
	
		
			
				
					  const  int  face_y  =  ( s - > viz_rect . bottom ( )  -  footer_h  +  ( ( footer_h  -  face_size )  /  2 ) ) ;   
			
		
	
		
			
				
					  ui_draw_circle_image ( s ,  face_x ,  face_y ,  face_size ,  " driver_face " ,  s - > scene . dmonitoring_state . getIsActiveMode ( ) ) ;   
			
		
	
		
			
				
					}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					static  void  ui_draw_driver_view ( UIState  * s )  {  
			
		
	
		
			
				
					  s - > scene . s idebar_collapsed  =  true ;   
			
		
	
		
			
				
					  s - > sidebar_collapsed  =  true ;   
			
		
	
		
			
				
					  const  bool  is_rhd  =  s - > scene . is_rhd ;   
			
		
	
		
			
				
					  const  Rect  & viz_rect  =  s - > scene . viz_rect ;  
  
			
		
	
		
			
				
					  const  int  width  =  3  *  viz_rect . w  /  4 ;   
			
		
	
		
			
				
					  const  Rect  rect  =  { viz_rect . centerX ( )  -  width  /  2 ,  viz_rect . y ,  width ,  viz_rect . h } ;   // x, y, w, h
   
			
		
	
		
			
				
					  const  int  width  =  3  *  s - > viz_rect . w  /  4 ;   
			
		
	
		
			
				
					  const  Rect  rect  =  { s - > viz_rect . centerX ( )  -  width  /  2 ,  s - > viz_rect . y ,  width ,  s - > viz_rect . h } ;   // x, y, w, h
   
			
		
	
		
			
				
					  const  Rect  valid_rect  =  { is_rhd  ?  rect . right ( )  -  rect . h  /  2  :  rect . x ,  rect . y ,  rect . h  /  2 ,  rect . h } ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					  // blackout
   
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -309,13 +308,12 @@ static void ui_draw_driver_view(UIState *s) { 
			
		
	
		
			
				
					}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					static  void  ui_draw_vision_header ( UIState  * s )  {  
			
		
	
		
			
				
					  const  Rect  & viz_rect  =  s - > scene . viz_rect ;   
			
		
	
		
			
				
					  NVGpaint  gradient  =  nvgLinearGradient ( s - > vg ,  viz_rect . x ,   
			
		
	
		
			
				
					                        viz_rect . y + ( header_h - ( header_h / 2.5 ) ) ,   
			
		
	
		
			
				
					                        viz_rect . x ,  viz_rect . y + header_h ,   
			
		
	
		
			
				
					  NVGpaint  gradient  =  nvgLinearGradient ( s - > vg ,  s - > viz_rect . x ,   
			
		
	
		
			
				
					                        s - > viz_rect . y + ( header_h - ( header_h / 2.5 ) ) ,   
			
		
	
		
			
				
					                        s - > viz_rect . x ,  s - > viz_rect . y + header_h ,   
			
		
	
		
			
				
					                        nvgRGBAf ( 0 , 0 , 0 , 0.45 ) ,  nvgRGBAf ( 0 , 0 , 0 , 0 ) ) ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					  ui_fill_rect ( s - > vg ,  { viz_rect . x ,  viz_rect . y ,  viz_rect . w ,  header_h } ,  gradient ) ;   
			
		
	
		
			
				
					  ui_fill_rect ( s - > vg ,  { s - > viz_rect . x ,  s - > viz_rect . y ,  s - > viz_rect . w ,  header_h } ,  gradient ) ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					  ui_draw_vision_maxspeed ( s ) ;   
			
		
	
		
			
				
					  ui_draw_vision_speed ( s ) ;   
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -341,9 +339,9 @@ static void ui_draw_vision_alert(UIState *s) { 
			
		
	
		
			
				
					  NVGcolor  color  =  bg_colors [ s - > status ] ;   
			
		
	
		
			
				
					  color . a  * =  get_alert_alpha ( scene - > alert_blinking_rate ) ;   
			
		
	
		
			
				
					  const  int  alr_h  =  alert_size_map [ scene - > alert_size ]  +  bdr_s ;   
			
		
	
		
			
				
					  const  Rect  rect  =  { . x  =  scene  - > viz_rect . x  -  bdr_s ,   
			
		
	
		
			
				
					  const  Rect  rect  =  { . x  =  s - > viz_rect . x  -  bdr_s ,   
			
		
	
		
			
				
					                  . y  =  s - > fb_h  -  alr_h ,   
			
		
	
		
			
				
					                  . w  =  scene  - > viz_rect . w  +  ( bdr_s  *  2 ) ,   
			
		
	
		
			
				
					                  . w  =  s - > viz_rect . w  +  ( bdr_s  *  2 ) ,   
			
		
	
		
			
				
					                  . h  =  alr_h } ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					  ui_fill_rect ( s - > vg ,  rect ,  color ) ;   
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -371,13 +369,10 @@ static void ui_draw_vision_alert(UIState *s) { 
			
		
	
		
			
				
					}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					static  void  ui_draw_vision_frame ( UIState  * s )  {  
			
		
	
		
			
				
					  const  UIScene  * scene  =  & s - > scene ;   
			
		
	
		
			
				
					  const  Rect  & viz_rect  =  scene - > viz_rect ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					  // Draw video frames
   
			
		
	
		
			
				
					  glEnable ( GL_SCISSOR_TEST ) ;   
			
		
	
		
			
				
					  glViewport ( s - > video_rect . x ,  s - > video_rect . y ,  s - > video_rect . w ,  s - > video_rect . h ) ;   
			
		
	
		
			
				
					  glScissor ( viz_rect . x ,  viz_rect . y ,  viz_rect . w ,  viz_rect . h ) ;   
			
		
	
		
			
				
					  glScissor ( s - > viz_rect . x ,  s - > viz_rect . y ,  s - > viz_rect . w ,  s - > viz_rect . h ) ;   
			
		
	
		
			
				
					  draw_frame ( s ) ;   
			
		
	
		
			
				
					  glDisable ( GL_SCISSOR_TEST ) ;   
			
		
	
		
			
				
					
 
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -408,10 +403,10 @@ static void ui_draw_background(UIState *s) { 
			
		
	
		
			
				
					}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					void  ui_draw ( UIState  * s )  {  
			
		
	
		
			
				
					  s - > scene . viz_rect  =  Rect { bdr_s ,  bdr_s ,  s - > fb_w  -  2  *  bdr_s ,  s - > fb_h  -  2  *  bdr_s } ;   
			
		
	
		
			
				
					  if  ( ! s - > scene . s idebar_collapsed )  {   
			
		
	
		
			
				
					    s - > scene . viz_rect . x  + =  sbr_w ;   
			
		
	
		
			
				
					    s - > scene . viz_rect . w  - =  sbr_w ;   
			
		
	
		
			
				
					  s - > viz_rect  =  Rect { bdr_s ,  bdr_s ,  s - > fb_w  -  2  *  bdr_s ,  s - > fb_h  -  2  *  bdr_s } ;   
			
		
	
		
			
				
					  if  ( ! s - > sidebar_collapsed )  {   
			
		
	
		
			
				
					    s - > viz_rect . x  + =  sbr_w ;   
			
		
	
		
			
				
					    s - > viz_rect . w  - =  sbr_w ;   
			
		
	
		
			
				
					  }   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					  const  bool  draw_alerts  =  s - > started  & &  s - > active_app  = =  cereal : : UiLayoutState : : App : : NONE ;