mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 06:12:43 +00:00 
			
		
		
		
	LibGUI: Add a way for GWidgets to do custom layout on child hide/show
This solves an issue in GScrollableWidget where hiding one of the two scrollbars needs to trigger a relayout since the other one should grow into the "shared space" in the bottom right corner. A GWidget can now override custom_layout() which will be called at any time we would normally delegate work to the GLayout, e.g on resize or child visibility changes, size policy changes, etc.
This commit is contained in:
		
							parent
							
								
									77a58119e7
								
							
						
					
					
						commit
						b615a5c780
					
				
					 4 changed files with 13 additions and 7 deletions
				
			
		|  | @ -33,11 +33,9 @@ void GScrollableWidget::mousewheel_event(GMouseEvent& event) | |||
|     vertical_scrollbar().set_value(vertical_scrollbar().value() + event.wheel_delta() * 20); | ||||
| } | ||||
| 
 | ||||
| void GScrollableWidget::resize_event(GResizeEvent& event) | ||||
| void GScrollableWidget::custom_layout() | ||||
| { | ||||
|     auto inner_rect = frame_inner_rect_for_size(event.size()); | ||||
|     update_scrollbar_ranges(); | ||||
| 
 | ||||
|     auto inner_rect = frame_inner_rect_for_size(size()); | ||||
|     int height_wanted_by_horizontal_scrollbar = m_horizontal_scrollbar->is_visible() ? m_horizontal_scrollbar->preferred_size().height() : 0; | ||||
|     int width_wanted_by_vertical_scrollbar = m_vertical_scrollbar->is_visible() ? m_vertical_scrollbar->preferred_size().width() : 0; | ||||
| 
 | ||||
|  | @ -51,6 +49,12 @@ void GScrollableWidget::resize_event(GResizeEvent& event) | |||
|     } | ||||
| } | ||||
| 
 | ||||
| void GScrollableWidget::resize_event(GResizeEvent& event) | ||||
| { | ||||
|     GFrame::resize_event(event); | ||||
|     update_scrollbar_ranges(); | ||||
| } | ||||
| 
 | ||||
| Size GScrollableWidget::available_size() const | ||||
| { | ||||
|     int available_width = frame_inner_rect().width() - m_size_occupied_by_fixed_elements.width() - width_occupied_by_vertical_scrollbar(); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling