mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 17:07:35 +00:00
LibGUI: Use a sunken GUI::Frame for the ColorPicker color spectrum
This looks a lot nicer than just a plain widget. :^)
This commit is contained in:
parent
d7d5788469
commit
51ab0e967e
1 changed files with 11 additions and 9 deletions
|
@ -61,7 +61,7 @@ private:
|
||||||
bool m_selected { false };
|
bool m_selected { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
class CustomColorWidget final : public GUI::Widget {
|
class CustomColorWidget final : public GUI::Frame {
|
||||||
C_OBJECT(CustomColorWidget);
|
C_OBJECT(CustomColorWidget);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -414,8 +414,8 @@ void CustomColorWidget::pick_color_at_position(GUI::MouseEvent& event)
|
||||||
if (!m_being_pressed)
|
if (!m_being_pressed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto position = event.position();
|
auto position = event.position().translated(-frame_thickness(), -frame_thickness());
|
||||||
if (!rect().contains(position))
|
if (!frame_inner_rect().contains(position))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto color = m_custom_colors->get_pixel(position);
|
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)
|
void CustomColorWidget::paint_event(GUI::PaintEvent& event)
|
||||||
{
|
{
|
||||||
GUI::Painter painter(*this);
|
Frame::paint_event(event);
|
||||||
Gfx::Rect rect = event.rect();
|
|
||||||
|
|
||||||
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.translate(frame_thickness(), frame_thickness());
|
||||||
painter.draw_line({ 0, m_last_position.y() }, { rect.width(), m_last_position.y() }, Color::Black);
|
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&)
|
void CustomColorWidget::resize_event(ResizeEvent&)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue