mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 11:18:13 +00:00
PixelPaint: Add antialiased ellipse option
Currently this option is only supported for filled ellipses as that is all the AntiAliasingPainter supports.
This commit is contained in:
parent
60aba4c9f3
commit
89445b967d
2 changed files with 28 additions and 8 deletions
|
@ -11,14 +11,15 @@
|
|||
#include "../Layer.h"
|
||||
#include <LibGUI/Action.h>
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
#include <LibGUI/CheckBox.h>
|
||||
#include <LibGUI/Label.h>
|
||||
#include <LibGUI/Menu.h>
|
||||
#include <LibGUI/Painter.h>
|
||||
#include <LibGUI/RadioButton.h>
|
||||
#include <LibGUI/TextBox.h>
|
||||
#include <LibGUI/ValueSlider.h>
|
||||
#include <LibGfx/Rect.h>
|
||||
#include <LibGfx/AntiAliasingPainter.h>
|
||||
#include <LibGfx/Rect.h>
|
||||
|
||||
namespace PixelPaint {
|
||||
|
||||
|
@ -36,7 +37,10 @@ void EllipseTool::draw_using(GUI::Painter& painter, Gfx::IntPoint const& start_p
|
|||
case FillMode::Outline:
|
||||
painter.draw_ellipse_intersecting(ellipse_intersecting_rect, m_editor->color_for(m_drawing_button), thickness);
|
||||
break;
|
||||
case FillMode::Fill: {
|
||||
case FillMode::Fill:
|
||||
painter.fill_ellipse(ellipse_intersecting_rect, m_editor->color_for(m_drawing_button));
|
||||
break;
|
||||
case FillMode::FillAntiAliased: {
|
||||
Gfx::AntiAliasingPainter aa_painter { painter };
|
||||
aa_painter.draw_ellipse(ellipse_intersecting_rect, m_editor->color_for(m_drawing_button));
|
||||
break;
|
||||
|
@ -142,24 +146,38 @@ GUI::Widget* EllipseTool::get_properties_widget()
|
|||
set_primary_slider(&thickness_slider);
|
||||
|
||||
auto& mode_container = m_properties_widget->add<GUI::Widget>();
|
||||
mode_container.set_fixed_height(46);
|
||||
mode_container.set_fixed_height(70);
|
||||
mode_container.set_layout<GUI::HorizontalBoxLayout>();
|
||||
auto& mode_label = mode_container.add<GUI::Label>("Mode:");
|
||||
mode_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||
mode_label.set_fixed_size(80, 20);
|
||||
|
||||
auto& mode_radio_container = mode_container.add<GUI::Widget>();
|
||||
mode_radio_container.set_layout<GUI::VerticalBoxLayout>();
|
||||
auto& outline_mode_radio = mode_radio_container.add<GUI::RadioButton>("Outline");
|
||||
auto& fill_mode_radio = mode_radio_container.add<GUI::RadioButton>("Fill");
|
||||
auto& aa_enable_checkbox = mode_radio_container.add<GUI::CheckBox>("Anti-alias");
|
||||
|
||||
outline_mode_radio.on_checked = [&](bool) {
|
||||
m_fill_mode = FillMode::Outline;
|
||||
aa_enable_checkbox.on_checked = [&](bool checked) {
|
||||
if (fill_mode_radio.is_checked())
|
||||
m_fill_mode = checked ? FillMode::FillAntiAliased : FillMode::Fill;
|
||||
};
|
||||
fill_mode_radio.on_checked = [&](bool) {
|
||||
m_fill_mode = FillMode::Fill;
|
||||
outline_mode_radio.on_checked = [&](bool 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) {
|
||||
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);
|
||||
outline_mode_radio.set_checked(true);
|
||||
|
||||
auto& aspect_container = m_properties_widget->add<GUI::Widget>();
|
||||
|
|
|
@ -32,6 +32,7 @@ private:
|
|||
enum class FillMode {
|
||||
Outline,
|
||||
Fill,
|
||||
FillAntiAliased
|
||||
};
|
||||
|
||||
enum class DrawMode {
|
||||
|
@ -50,6 +51,7 @@ 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;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue