1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 00:27:43 +00:00

Magnifier: Add colorblind preview options

Add the same preview options as the theme editor so you can test the
accessibility of anything on your desktop. Both tools share the same
shortcuts.
This commit is contained in:
TheGrizzlyDev 2021-12-28 20:42:01 +00:00 committed by Linus Groh
parent 7f61d430e6
commit 2905642550
4 changed files with 91 additions and 1 deletions

View file

@ -27,6 +27,12 @@ void MagnifierWidget::set_scale_factor(int scale_factor)
update();
}
void MagnifierWidget::set_color_filter(OwnPtr<Gfx::ColorBlindnessFilter> color_filter)
{
m_color_filter = move(color_filter);
sync();
}
void MagnifierWidget::display_previous_frame()
{
--m_frame_offset_from_head;
@ -64,3 +70,21 @@ void MagnifierWidget::paint_event(GUI::PaintEvent& event)
if (m_grabbed_bitmap)
painter.draw_scaled_bitmap(frame_inner_rect(), *m_grabbed_bitmap, m_grabbed_bitmap->rect());
}
void MagnifierWidget::second_paint_event(GUI::PaintEvent&)
{
if (!m_color_filter)
return;
GUI::Painter painter(*this);
auto target = painter.target();
auto bitmap_clone_or_error = target->clone();
if (bitmap_clone_or_error.is_error())
return;
auto clone = bitmap_clone_or_error.release_value();
auto rect = target->rect();
m_color_filter->apply(*target, rect, *clone, rect);
}