ColorPicker.h 1.2 KB

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