mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 15:42:44 +00:00 
			
		
		
		
	LibGUI+LibGfx: Paint scollbar tracks with a dithered pattern
Instead of a solid color, we now paint the track/gutter of scrollbars using a 2-color dither pattern for a pleasant millennium feel. :^)
This commit is contained in:
		
							parent
							
								
									ac701cb589
								
							
						
					
					
						commit
						9e74793ce2
					
				
					 3 changed files with 22 additions and 1 deletions
				
			
		|  | @ -220,7 +220,7 @@ void ScrollBar::paint_event(PaintEvent& event) | ||||||
|     Painter painter(*this); |     Painter painter(*this); | ||||||
|     painter.add_clip_rect(event.rect()); |     painter.add_clip_rect(event.rect()); | ||||||
| 
 | 
 | ||||||
|     painter.fill_rect(rect(), palette().button().lightened(1.1f)); |     painter.fill_rect_with_dither_pattern(rect(), palette().button().lightened(1.3f), palette().button()); | ||||||
| 
 | 
 | ||||||
|     bool decrement_pressed = m_automatic_scrolling_direction == AutomaticScrollingDirection::Decrement; |     bool decrement_pressed = m_automatic_scrolling_direction == AutomaticScrollingDirection::Decrement; | ||||||
|     bool increment_pressed = m_automatic_scrolling_direction == AutomaticScrollingDirection::Increment; |     bool increment_pressed = m_automatic_scrolling_direction == AutomaticScrollingDirection::Increment; | ||||||
|  |  | ||||||
|  | @ -136,6 +136,26 @@ void Painter::fill_rect(const Rect& a_rect, Color color) | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | void Painter::fill_rect_with_dither_pattern(const Rect& a_rect, Color color_a, Color color_b) | ||||||
|  | { | ||||||
|  |     auto rect = a_rect.translated(translation()).intersected(clip_rect()); | ||||||
|  |     if (rect.is_empty()) | ||||||
|  |         return; | ||||||
|  | 
 | ||||||
|  |     RGBA32* dst = m_target->scanline(rect.top()) + rect.left(); | ||||||
|  |     const size_t dst_skip = m_target->pitch() / sizeof(RGBA32); | ||||||
|  | 
 | ||||||
|  |     for (int i = 0; i < rect.height(); ++i) { | ||||||
|  |         for (int j = 0; j < rect.width(); ++j) { | ||||||
|  |             if (i & 1) | ||||||
|  |                 dst[j] = (j & 1) ? color_a.value() : color_b.value(); | ||||||
|  |             else | ||||||
|  |                 dst[j] = (j & 1) ? color_b.value() : color_a.value(); | ||||||
|  |         } | ||||||
|  |         dst += dst_skip; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
| void Painter::fill_rect_with_checkerboard(const Rect& a_rect, const Size& cell_size, Color color_dark, Color color_light) | void Painter::fill_rect_with_checkerboard(const Rect& a_rect, const Size& cell_size, Color color_dark, Color color_light) | ||||||
| { | { | ||||||
|     auto rect = a_rect.translated(translation()).intersected(clip_rect()); |     auto rect = a_rect.translated(translation()).intersected(clip_rect()); | ||||||
|  |  | ||||||
|  | @ -45,6 +45,7 @@ public: | ||||||
|     ~Painter(); |     ~Painter(); | ||||||
|     void clear_rect(const Rect&, Color); |     void clear_rect(const Rect&, Color); | ||||||
|     void fill_rect(const Rect&, Color); |     void fill_rect(const Rect&, Color); | ||||||
|  |     void fill_rect_with_dither_pattern(const Rect&, Color, Color); | ||||||
|     void fill_rect_with_checkerboard(const Rect&, const Size&, Color color_dark, Color color_light); |     void fill_rect_with_checkerboard(const Rect&, const Size&, Color color_dark, Color color_light); | ||||||
|     void fill_rect_with_gradient(Orientation, const Rect&, Color gradient_start, Color gradient_end); |     void fill_rect_with_gradient(Orientation, const Rect&, Color gradient_start, Color gradient_end); | ||||||
|     void fill_rect_with_gradient(const Rect&, Color gradient_start, Color gradient_end); |     void fill_rect_with_gradient(const Rect&, Color gradient_start, Color gradient_end); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling