mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:47:35 +00:00
PixelPaint: Enable antialiased option for outline ellipsis
This commit is contained in:
parent
8c2a5bbc15
commit
f98dad94fb
2 changed files with 15 additions and 21 deletions
|
@ -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);
|
ellipse_intersecting_rect = Gfx::IntRect::from_two_points(start_position, end_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Gfx::AntiAliasingPainter aa_painter { painter };
|
||||||
|
|
||||||
switch (m_fill_mode) {
|
switch (m_fill_mode) {
|
||||||
case FillMode::Outline:
|
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;
|
break;
|
||||||
case FillMode::Fill:
|
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;
|
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:
|
default:
|
||||||
VERIFY_NOT_REACHED();
|
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");
|
auto& aa_enable_checkbox = mode_radio_container.add<GUI::CheckBox>("Anti-alias");
|
||||||
|
|
||||||
aa_enable_checkbox.on_checked = [&](bool checked) {
|
aa_enable_checkbox.on_checked = [&](bool checked) {
|
||||||
if (fill_mode_radio.is_checked())
|
m_antialias_enabled = checked;
|
||||||
m_fill_mode = checked ? FillMode::FillAntiAliased : FillMode::Fill;
|
|
||||||
};
|
};
|
||||||
outline_mode_radio.on_checked = [&](bool checked) {
|
outline_mode_radio.on_checked = [&](bool checked) {
|
||||||
if (checked) {
|
if (checked)
|
||||||
m_fill_mode = FillMode::Outline;
|
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) {
|
fill_mode_radio.on_checked = [&](bool checked) {
|
||||||
if (checked) {
|
if (checked)
|
||||||
m_fill_mode = FillMode::Fill;
|
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);
|
aa_enable_checkbox.set_checked(false);
|
||||||
|
|
|
@ -31,8 +31,7 @@ public:
|
||||||
private:
|
private:
|
||||||
enum class FillMode {
|
enum class FillMode {
|
||||||
Outline,
|
Outline,
|
||||||
Fill,
|
Fill
|
||||||
FillAntiAliased
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class DrawMode {
|
enum class DrawMode {
|
||||||
|
@ -51,9 +50,9 @@ private:
|
||||||
Gfx::IntPoint m_ellipse_end_position;
|
Gfx::IntPoint m_ellipse_end_position;
|
||||||
int m_thickness { 1 };
|
int m_thickness { 1 };
|
||||||
FillMode m_fill_mode { FillMode::Outline };
|
FillMode m_fill_mode { FillMode::Outline };
|
||||||
bool m_last_aa_checkbox_state { false };
|
|
||||||
DrawMode m_draw_mode { DrawMode::FromCorner };
|
DrawMode m_draw_mode { DrawMode::FromCorner };
|
||||||
Optional<float> m_aspect_ratio;
|
Optional<float> m_aspect_ratio;
|
||||||
|
bool m_antialias_enabled { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue