2020-01-18 09:38:21 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
|
2019-06-16 15:09:36 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
2020-04-03 19:19:44 +03:00
|
|
|
#include <LibGUI/AbstractButton.h>
|
2020-02-06 20:33:02 +01:00
|
|
|
#include <LibGUI/Dialog.h>
|
2019-06-16 15:09:36 +02:00
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
namespace GUI {
|
2019-09-21 19:21:36 +02:00
|
|
|
|
2020-04-04 10:38:24 +02:00
|
|
|
class ColorButton;
|
2020-09-25 17:01:58 +02:00
|
|
|
class ColorPreview;
|
2020-04-04 10:38:24 +02:00
|
|
|
class CustomColorWidget;
|
2021-09-04 00:37:39 -04:00
|
|
|
class ColorSelectOverlay;
|
2020-04-03 19:19:44 +03:00
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
class ColorPicker final : public Dialog {
|
|
|
|
|
C_OBJECT(ColorPicker)
|
2020-04-03 19:19:44 +03:00
|
|
|
|
2019-06-16 15:09:36 +02:00
|
|
|
public:
|
2020-02-02 15:07:41 +01:00
|
|
|
virtual ~ColorPicker() override;
|
2019-06-16 15:09:36 +02:00
|
|
|
|
2020-04-29 16:22:09 +02:00
|
|
|
bool color_has_alpha_channel() const { return m_color_has_alpha_channel; }
|
2020-09-26 19:31:27 +02:00
|
|
|
void set_color_has_alpha_channel(bool);
|
2019-06-16 15:09:36 +02:00
|
|
|
Color color() const { return m_color; }
|
|
|
|
|
|
|
|
|
|
private:
|
2020-04-03 19:19:44 +03:00
|
|
|
explicit ColorPicker(Color, Window* parent_window = nullptr, String title = "Edit Color");
|
2019-09-21 19:21:36 +02:00
|
|
|
|
2020-04-03 19:19:44 +03:00
|
|
|
void build_ui();
|
|
|
|
|
void build_ui_custom(Widget& root_container);
|
|
|
|
|
void build_ui_palette(Widget& root_container);
|
|
|
|
|
void update_color_widgets();
|
|
|
|
|
void create_color_button(Widget& container, unsigned rgb);
|
2019-06-16 15:09:36 +02:00
|
|
|
|
|
|
|
|
Color m_color;
|
2020-04-29 16:22:09 +02:00
|
|
|
bool m_color_has_alpha_channel { true };
|
2020-04-03 19:19:44 +03:00
|
|
|
|
2021-06-08 19:36:27 +04:30
|
|
|
Vector<ColorButton&> m_color_widgets;
|
2020-04-04 10:38:24 +02:00
|
|
|
RefPtr<CustomColorWidget> m_custom_color;
|
2020-09-25 17:01:58 +02:00
|
|
|
RefPtr<ColorPreview> m_preview_widget;
|
2021-09-04 00:37:39 -04:00
|
|
|
RefPtr<Button> m_selector_button;
|
2020-04-03 19:19:44 +03:00
|
|
|
RefPtr<TextBox> m_html_text;
|
|
|
|
|
RefPtr<SpinBox> m_red_spinbox;
|
|
|
|
|
RefPtr<SpinBox> m_green_spinbox;
|
|
|
|
|
RefPtr<SpinBox> m_blue_spinbox;
|
2020-08-25 22:56:57 +02:00
|
|
|
RefPtr<SpinBox> m_alpha_spinbox;
|
2019-06-16 15:09:36 +02:00
|
|
|
};
|
2020-02-02 15:07:41 +01:00
|
|
|
|
|
|
|
|
}
|