diff options
author | Andreas Kling <kling@serenityos.org> | 2020-04-29 19:26:21 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-29 19:28:19 +0200 |
commit | 51ab0e967e03d3f138fa93e7b3dd45de910c7a44 (patch) | |
tree | 1fb01f042c48cc6ee25729b7d59722fc2f8dce07 /Libraries/LibGUI | |
parent | d7d57884694ad5fda53e865f1b92ef48fddc9ca8 (diff) | |
download | serenity-51ab0e967e03d3f138fa93e7b3dd45de910c7a44.zip |
LibGUI: Use a sunken GUI::Frame for the ColorPicker color spectrum
This looks a lot nicer than just a plain widget. :^)
Diffstat (limited to 'Libraries/LibGUI')
-rw-r--r-- | Libraries/LibGUI/ColorPicker.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/Libraries/LibGUI/ColorPicker.cpp b/Libraries/LibGUI/ColorPicker.cpp index b090fabcf7..4c7e47d81e 100644 --- a/Libraries/LibGUI/ColorPicker.cpp +++ b/Libraries/LibGUI/ColorPicker.cpp @@ -61,7 +61,7 @@ private: bool m_selected { false }; }; -class CustomColorWidget final : public GUI::Widget { +class CustomColorWidget final : public GUI::Frame { C_OBJECT(CustomColorWidget); public: @@ -414,8 +414,8 @@ void CustomColorWidget::pick_color_at_position(GUI::MouseEvent& event) if (!m_being_pressed) return; - auto position = event.position(); - if (!rect().contains(position)) + auto position = event.position().translated(-frame_thickness(), -frame_thickness()); + if (!frame_inner_rect().contains(position)) return; auto color = m_custom_colors->get_pixel(position); @@ -451,15 +451,17 @@ void CustomColorWidget::mousemove_event(GUI::MouseEvent& event) void CustomColorWidget::paint_event(GUI::PaintEvent& event) { - GUI::Painter painter(*this); - Gfx::Rect rect = event.rect(); + Frame::paint_event(event); - painter.add_clip_rect(rect); + Painter painter(*this); + painter.add_clip_rect(event.rect()); + painter.add_clip_rect(frame_inner_rect()); - painter.draw_scaled_bitmap(rect, *m_custom_colors, m_custom_colors->rect()); + painter.draw_scaled_bitmap(frame_inner_rect(), *m_custom_colors, m_custom_colors->rect()); - painter.draw_line({ m_last_position.x(), 0 }, { m_last_position.x(), rect.height() }, Color::Black); - painter.draw_line({ 0, m_last_position.y() }, { rect.width(), m_last_position.y() }, Color::Black); + painter.translate(frame_thickness(), frame_thickness()); + painter.draw_line({ m_last_position.x(), 0 }, { m_last_position.x(), height() }, Color::Black); + painter.draw_line({ 0, m_last_position.y() }, { width(), m_last_position.y() }, Color::Black); } void CustomColorWidget::resize_event(ResizeEvent&) |