mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 17:22:43 +00:00 
			
		
		
		
	 b61e4e7cd9
			
		
	
	
		b61e4e7cd9
		
	
	
	
	
		
			
			This patch enables the histogram to redraw itself when it gets resized without calculating the data again through the image.
		
			
				
	
	
		
			41 lines
		
	
	
	
		
			843 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
	
		
			843 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2022, Torsten Engelmann
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include "Image.h"
 | |
| #include "ScopeWidget.h"
 | |
| 
 | |
| namespace PixelPaint {
 | |
| 
 | |
| class HistogramWidget final
 | |
|     : public ScopeWidget {
 | |
|     C_OBJECT(HistogramWidget);
 | |
| 
 | |
| public:
 | |
|     virtual ~HistogramWidget() = default;
 | |
|     virtual void image_changed() override;
 | |
| 
 | |
| private:
 | |
|     HistogramWidget() = default;
 | |
| 
 | |
|     virtual AK::StringView widget_config_name() const override { return "ShowHistogram"sv; }
 | |
|     virtual void paint_event(GUI::PaintEvent&) override;
 | |
| 
 | |
|     ErrorOr<void> rebuild_histogram_data();
 | |
| 
 | |
|     struct HistogramData {
 | |
|         Vector<int> red;
 | |
|         Vector<int> green;
 | |
|         Vector<int> blue;
 | |
|         Vector<int> brightness;
 | |
|         int max_brightness_frequency;
 | |
|         int max_color_frequency;
 | |
|     };
 | |
|     HistogramData m_data;
 | |
| };
 | |
| 
 | |
| }
 |