implemented shrink option
This commit is contained in:
		
							parent
							
								
									a25954f8a6
								
							
						
					
					
						commit
						dd047ccd20
					
				
							
								
								
									
										39
									
								
								x.c
									
									
									
									
									
								
							
							
						
						
									
										39
									
								
								x.c
									
									
									
									
									
								
							| @ -203,7 +203,7 @@ static dimension_t calculate_dimensions(GSList *layouts) | ||||
|         dim.h += (g_slist_length(layouts) - 1) * settings.separator_height; | ||||
|         dim.h += g_slist_length(layouts) * settings.padding * 2; | ||||
| 
 | ||||
|         int text_width = 0; | ||||
|         int text_width = 0, total_width = 0; | ||||
|         for (GSList *iter = layouts; iter; iter = iter->next) { | ||||
|                 colored_layout *cl = iter->data; | ||||
|                 int w,h; | ||||
| @ -211,26 +211,31 @@ static dimension_t calculate_dimensions(GSList *layouts) | ||||
|                 dim.h += h; | ||||
|                 text_width = MAX(w, text_width); | ||||
| 
 | ||||
|                 if (dim.w <= 0) { | ||||
|                 if (dim.w <= 0 || settings.shrink) { | ||||
|                         /* dynamic width */ | ||||
|                         if ((text_width + 2 * settings.h_padding) > scr.dim.w) { | ||||
|                                 /* it's bigger than the screen */ | ||||
|                                 /* subtract height from the unwrapped text */ | ||||
|                                 dim.h -= h; | ||||
|                         total_width = MAX(text_width + 2 * settings.h_padding, total_width); | ||||
| 
 | ||||
|                         /* subtract height from the unwrapped text */ | ||||
|                         dim.h -= h; | ||||
| 
 | ||||
|                         if (total_width > scr.dim.w) { | ||||
|                                 /* set width to screen width */ | ||||
|                                 dim.w = scr.dim.w - xctx.geometry.y * 2; | ||||
| 
 | ||||
|                                 /* re-setup the layout */ | ||||
|                                 int width = dim.w; | ||||
|                                 width -= 2 * settings.h_padding; | ||||
|                                 width -= 2 * settings.frame_width; | ||||
|                                 r_setup_pango_layout(cl->l, width); | ||||
| 
 | ||||
|                                 /* re-read information */ | ||||
|                                 pango_layout_get_pixel_size(cl->l, &w, &h); | ||||
|                                 dim.h += h; | ||||
|                                 text_width = MAX(w, text_width); | ||||
|                         } else if (total_width < xctx.geometry.w && settings.shrink) { | ||||
|                                 /* set width to text width */ | ||||
|                                 dim.w = total_width + 2 * settings.frame_width; | ||||
|                         } | ||||
| 
 | ||||
|                         /* re-setup the layout */ | ||||
|                         int width = dim.w; | ||||
|                         width -= 2 * settings.h_padding; | ||||
|                         width -= 2 * settings.frame_width; | ||||
|                         r_setup_pango_layout(cl->l, width); | ||||
| 
 | ||||
|                         /* re-read information */ | ||||
|                         pango_layout_get_pixel_size(cl->l, &w, &h); | ||||
|                         dim.h += h; | ||||
|                         text_width = MAX(w, text_width); | ||||
|                 } | ||||
|         } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Giuliano Schneider
						Giuliano Schneider