PixelPaint: Enable antialiased option for outline ellipsis

This commit is contained in:
MacDue 2022-06-01 12:19:37 +01:00 committed by Andreas Kling
parent 8c2a5bbc15
commit f98dad94fb
Notes: sideshowbarker 2024-07-17 10:32:24 +09:00
2 changed files with 15 additions and 21 deletions

View file

@ -33,18 +33,21 @@ void EllipseTool::draw_using(GUI::Painter& painter, Gfx::IntPoint const& start_p
ellipse_intersecting_rect = Gfx::IntRect::from_two_points(start_position, end_position);
}
Gfx::AntiAliasingPainter aa_painter { painter };
switch (m_fill_mode) {
case FillMode::Outline:
painter.draw_ellipse_intersecting(ellipse_intersecting_rect, m_editor->color_for(m_drawing_button), thickness);
if (m_antialias_enabled)
aa_painter.draw_ellipse(ellipse_intersecting_rect, m_editor->color_for(m_drawing_button), thickness);
else
painter.draw_ellipse_intersecting(ellipse_intersecting_rect, m_editor->color_for(m_drawing_button), thickness);
break;
case FillMode::Fill:
painter.fill_ellipse(ellipse_intersecting_rect, m_editor->color_for(m_drawing_button));
if (m_antialias_enabled)
aa_painter.fill_ellipse(ellipse_intersecting_rect, m_editor->color_for(m_drawing_button));
else
painter.fill_ellipse(ellipse_intersecting_rect, m_editor->color_for(m_drawing_button));
break;
case FillMode::FillAntiAliased: {
Gfx::AntiAliasingPainter aa_painter { painter };
aa_painter.fill_ellipse(ellipse_intersecting_rect, m_editor->color_for(m_drawing_button));
break;
}
default:
VERIFY_NOT_REACHED();
}
@ -158,23 +161,15 @@ GUI::Widget* EllipseTool::get_properties_widget()
auto& aa_enable_checkbox = mode_radio_container.add<GUI::CheckBox>("Anti-alias");
aa_enable_checkbox.on_checked = [&](bool checked) {
if (fill_mode_radio.is_checked())
m_fill_mode = checked ? FillMode::FillAntiAliased : FillMode::Fill;
m_antialias_enabled = checked;
};
outline_mode_radio.on_checked = [&](bool checked) {
if (checked) {
if (checked)
m_fill_mode = FillMode::Outline;
aa_enable_checkbox.set_enabled(false);
m_last_aa_checkbox_state = aa_enable_checkbox.is_checked();
aa_enable_checkbox.set_checked(false);
}
};
fill_mode_radio.on_checked = [&](bool checked) {
if (checked) {
if (checked)
m_fill_mode = FillMode::Fill;
aa_enable_checkbox.set_checked(m_last_aa_checkbox_state);
aa_enable_checkbox.set_enabled(true);
}
};
aa_enable_checkbox.set_checked(false);

View file

@ -31,8 +31,7 @@ public:
private:
enum class FillMode {
Outline,
Fill,
FillAntiAliased
Fill
};
enum class DrawMode {
@ -51,9 +50,9 @@ private:
Gfx::IntPoint m_ellipse_end_position;
int m_thickness { 1 };
FillMode m_fill_mode { FillMode::Outline };
bool m_last_aa_checkbox_state { false };
DrawMode m_draw_mode { DrawMode::FromCorner };
Optional<float> m_aspect_ratio;
bool m_antialias_enabled { false };
};
}