ColorPicker.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. * Copyright (c) 2022, the SerenityOS developers.
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include <LibGUI/AbstractButton.h>
  9. #include <LibGUI/Dialog.h>
  10. namespace GUI {
  11. class ColorButton;
  12. class ColorPreview;
  13. class CustomColorWidget;
  14. class ColorSelectOverlay;
  15. class ColorPicker final : public Dialog {
  16. C_OBJECT(ColorPicker)
  17. public:
  18. virtual ~ColorPicker() override = default;
  19. bool color_has_alpha_channel() const { return m_color_has_alpha_channel; }
  20. void set_color_has_alpha_channel(bool);
  21. Color color() const { return m_color; }
  22. private:
  23. explicit ColorPicker(Color, Window* parent_window = nullptr, String title = "Edit Color");
  24. void build_ui();
  25. void build_ui_custom(Widget& root_container);
  26. void build_ui_palette(Widget& root_container);
  27. void update_color_widgets();
  28. void create_color_button(Widget& container, unsigned rgb);
  29. Color m_color;
  30. bool m_color_has_alpha_channel { true };
  31. Vector<ColorButton&> m_color_widgets;
  32. RefPtr<CustomColorWidget> m_custom_color;
  33. RefPtr<ColorPreview> m_preview_widget;
  34. RefPtr<Button> m_selector_button;
  35. RefPtr<TextBox> m_html_text;
  36. RefPtr<SpinBox> m_red_spinbox;
  37. RefPtr<SpinBox> m_green_spinbox;
  38. RefPtr<SpinBox> m_blue_spinbox;
  39. RefPtr<SpinBox> m_alpha_spinbox;
  40. };
  41. }