mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 17:52:45 +00:00 
			
		
		
		
	LibGUI: Paint some knurling in the middle of GUI::Splitter
This makes splitters stand out visually so you can actually spot them. Before this, you had to guess/know where they were, which was weird. The look of the knurling is the same as GUI::ResizeCorner, to build on the established visual language.
This commit is contained in:
		
							parent
							
								
									89272e810a
								
							
						
					
					
						commit
						7a24a60e72
					
				
					 1 changed files with 25 additions and 0 deletions
				
			
		|  | @ -37,8 +37,33 @@ void Splitter::paint_event(PaintEvent& event) | |||
|     painter.add_clip_rect(event.rect()); | ||||
| 
 | ||||
|     auto palette = this->palette(); | ||||
| 
 | ||||
|     auto paint_knurl = [&](int x, int y) { | ||||
|         painter.set_pixel(x, y, palette.threed_shadow1()); | ||||
|         painter.set_pixel(x + 1, y, palette.threed_shadow1()); | ||||
|         painter.set_pixel(x, y + 1, palette.threed_shadow1()); | ||||
|         painter.set_pixel(x + 1, y + 1, palette.threed_highlight()); | ||||
|     }; | ||||
| 
 | ||||
|     constexpr size_t knurl_width = 2; | ||||
|     constexpr size_t knurl_spacing = 1; | ||||
|     constexpr size_t knurl_count = 10; | ||||
|     constexpr size_t total_knurling_width = knurl_count * (knurl_width + knurl_spacing); | ||||
| 
 | ||||
|     if (m_hovered_index.has_value()) | ||||
|         painter.fill_rect(m_grabbables[m_hovered_index.value()].paint_rect, palette.hover_highlight()); | ||||
| 
 | ||||
|     for (auto& grabbable : m_grabbables) { | ||||
|         for (size_t i = 0; i < knurl_count; ++i) { | ||||
|             auto& rect = grabbable.paint_rect; | ||||
|             int primary = rect.center().primary_offset_for_orientation(m_orientation) - 1; | ||||
|             int secondary = rect.center().secondary_offset_for_orientation(m_orientation) - (total_knurling_width / 2) + (i * (knurl_width + knurl_spacing)); | ||||
|             if (m_orientation == Gfx::Orientation::Vertical) | ||||
|                 paint_knurl(secondary, primary); | ||||
|             else | ||||
|                 paint_knurl(primary, secondary); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void Splitter::resize_event(ResizeEvent& event) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling