summaryrefslogtreecommitdiff
path: root/Userland/Applications/PixelPaint/HistogramWidget.h
blob: c50ff90d4fb2af7719db8efa7a2ead12d25f9559 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
 * Copyright (c) 2022, Torsten Engelmann
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include "Image.h"
#include <LibGUI/AbstractScrollableWidget.h>

namespace PixelPaint {

class HistogramWidget final
    : public GUI::Frame
    , ImageClient {
    C_OBJECT(HistogramWidget);

public:
    virtual ~HistogramWidget() override;

    void set_image(Image*);
    void image_changed();
    void set_color_at_mouseposition(Color);

private:
    HistogramWidget() = default;

    virtual void paint_event(GUI::PaintEvent&) override;

    ErrorOr<void> rebuild_histogram_data();
    int m_widget_height = 0;
    Color m_color_at_mouseposition = Color::Transparent;
    RefPtr<Image> m_image;

    struct HistogramData {
        Vector<int> red;
        Vector<int> green;
        Vector<int> blue;
        Vector<int> brightness;
    };
    HistogramData m_data;
};

}