mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:47:46 +00:00
LibGfx: Rename Rect,Point,Size => IntRect,IntPoint,IntSize
This fits nicer with FloatRect,FloatPoint,FloatSize and gives a much better visual clue about what type of metric is being used.
This commit is contained in:
parent
656b01eb0f
commit
116cf92156
212 changed files with 1144 additions and 1144 deletions
|
@ -43,7 +43,7 @@ BucketTool::~BucketTool()
|
|||
{
|
||||
}
|
||||
|
||||
static void flood_fill(Gfx::Bitmap& bitmap, const Gfx::Point& start_position, Color target_color, Color fill_color)
|
||||
static void flood_fill(Gfx::Bitmap& bitmap, const Gfx::IntPoint& start_position, Color target_color, Color fill_color)
|
||||
{
|
||||
ASSERT(bitmap.bpp() == 32);
|
||||
|
||||
|
@ -53,7 +53,7 @@ static void flood_fill(Gfx::Bitmap& bitmap, const Gfx::Point& start_position, Co
|
|||
if (!bitmap.rect().contains(start_position))
|
||||
return;
|
||||
|
||||
Queue<Gfx::Point> queue;
|
||||
Queue<Gfx::IntPoint> queue;
|
||||
queue.enqueue(start_position);
|
||||
while (!queue.is_empty()) {
|
||||
auto position = queue.dequeue();
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
namespace PixelPaint {
|
||||
|
||||
CreateNewLayerDialog::CreateNewLayerDialog(const Gfx::Size& suggested_size, GUI::Window* parent_window)
|
||||
CreateNewLayerDialog::CreateNewLayerDialog(const Gfx::IntSize& suggested_size, GUI::Window* parent_window)
|
||||
: Dialog(parent_window)
|
||||
{
|
||||
set_title("Create new layer");
|
||||
|
|
|
@ -33,13 +33,13 @@ namespace PixelPaint {
|
|||
class CreateNewLayerDialog final : public GUI::Dialog {
|
||||
C_OBJECT(CreateNewLayerDialog);
|
||||
public:
|
||||
const Gfx::Size& layer_size() const { return m_layer_size; }
|
||||
const Gfx::IntSize& layer_size() const { return m_layer_size; }
|
||||
const String& layer_name() const { return m_layer_name; }
|
||||
|
||||
private:
|
||||
CreateNewLayerDialog(const Gfx::Size& suggested_size, GUI::Window* parent_window);
|
||||
CreateNewLayerDialog(const Gfx::IntSize& suggested_size, GUI::Window* parent_window);
|
||||
|
||||
Gfx::Size m_layer_size;
|
||||
Gfx::IntSize m_layer_size;
|
||||
String m_layer_name;
|
||||
|
||||
RefPtr<GUI::TextBox> m_name_textbox;
|
||||
|
|
|
@ -43,7 +43,7 @@ EllipseTool::~EllipseTool()
|
|||
{
|
||||
}
|
||||
|
||||
void EllipseTool::draw_using(GUI::Painter& painter, const Gfx::Rect& ellipse_intersecting_rect)
|
||||
void EllipseTool::draw_using(GUI::Painter& painter, const Gfx::IntRect& ellipse_intersecting_rect)
|
||||
{
|
||||
switch (m_mode) {
|
||||
case Mode::Outline:
|
||||
|
@ -72,7 +72,7 @@ void EllipseTool::on_mouseup(Layer& layer, GUI::MouseEvent& event, GUI::MouseEve
|
|||
{
|
||||
if (event.button() == m_drawing_button) {
|
||||
GUI::Painter painter(layer.bitmap());
|
||||
draw_using(painter, Gfx::Rect::from_two_points(m_ellipse_start_position, m_ellipse_end_position));
|
||||
draw_using(painter, Gfx::IntRect::from_two_points(m_ellipse_start_position, m_ellipse_end_position));
|
||||
m_drawing_button = GUI::MouseButton::None;
|
||||
m_editor->update();
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ void EllipseTool::on_second_paint(const Layer& layer, GUI::PaintEvent& event)
|
|||
painter.add_clip_rect(event.rect());
|
||||
auto preview_start = m_editor->layer_position_to_editor_position(layer, m_ellipse_start_position).to_int_point();
|
||||
auto preview_end = m_editor->layer_position_to_editor_position(layer, m_ellipse_end_position).to_int_point();
|
||||
draw_using(painter, Gfx::Rect::from_two_points(preview_start, preview_end));
|
||||
draw_using(painter, Gfx::IntRect::from_two_points(preview_start, preview_end));
|
||||
}
|
||||
|
||||
void EllipseTool::on_keydown(GUI::KeyEvent& event)
|
||||
|
|
|
@ -51,11 +51,11 @@ private:
|
|||
};
|
||||
|
||||
virtual const char* class_name() const override { return "EllipseTool"; }
|
||||
void draw_using(GUI::Painter&, const Gfx::Rect&);
|
||||
void draw_using(GUI::Painter&, const Gfx::IntRect&);
|
||||
|
||||
GUI::MouseButton m_drawing_button { GUI::MouseButton::None };
|
||||
Gfx::Point m_ellipse_start_position;
|
||||
Gfx::Point m_ellipse_end_position;
|
||||
Gfx::IntPoint m_ellipse_start_position;
|
||||
Gfx::IntPoint m_ellipse_end_position;
|
||||
RefPtr<GUI::Menu> m_context_menu;
|
||||
int m_thickness { 1 };
|
||||
GUI::ActionGroup m_thickness_actions;
|
||||
|
|
|
@ -42,21 +42,21 @@ EraseTool::~EraseTool()
|
|||
{
|
||||
}
|
||||
|
||||
Gfx::Rect EraseTool::build_rect(const Gfx::Point& pos, const Gfx::Rect& widget_rect)
|
||||
Gfx::IntRect EraseTool::build_rect(const Gfx::IntPoint& pos, const Gfx::IntRect& widget_rect)
|
||||
{
|
||||
const int base_eraser_size = 10;
|
||||
const int eraser_size = (base_eraser_size * m_thickness);
|
||||
const int eraser_radius = eraser_size / 2;
|
||||
const auto ex = pos.x();
|
||||
const auto ey = pos.y();
|
||||
return Gfx::Rect(ex - eraser_radius, ey - eraser_radius, eraser_size, eraser_size).intersected(widget_rect);
|
||||
return Gfx::IntRect(ex - eraser_radius, ey - eraser_radius, eraser_size, eraser_size).intersected(widget_rect);
|
||||
}
|
||||
|
||||
void EraseTool::on_mousedown(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent&)
|
||||
{
|
||||
if (event.button() != GUI::MouseButton::Left && event.button() != GUI::MouseButton::Right)
|
||||
return;
|
||||
Gfx::Rect r = build_rect(event.position(), layer.rect());
|
||||
Gfx::IntRect r = build_rect(event.position(), layer.rect());
|
||||
GUI::Painter painter(layer.bitmap());
|
||||
painter.clear_rect(r, get_color());
|
||||
layer.did_modify_bitmap(*m_editor->image());
|
||||
|
@ -65,7 +65,7 @@ void EraseTool::on_mousedown(Layer& layer, GUI::MouseEvent& event, GUI::MouseEve
|
|||
void EraseTool::on_mousemove(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent&)
|
||||
{
|
||||
if (event.buttons() & GUI::MouseButton::Left || event.buttons() & GUI::MouseButton::Right) {
|
||||
Gfx::Rect r = build_rect(event.position(), layer.rect());
|
||||
Gfx::IntRect r = build_rect(event.position(), layer.rect());
|
||||
GUI::Painter painter(layer.bitmap());
|
||||
painter.clear_rect(r, get_color());
|
||||
layer.did_modify_bitmap(*m_editor->image());
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
private:
|
||||
Gfx::Color get_color() const;
|
||||
virtual const char* class_name() const override { return "EraseTool"; }
|
||||
Gfx::Rect build_rect(const Gfx::Point& pos, const Gfx::Rect& widget_rect);
|
||||
Gfx::IntRect build_rect(const Gfx::IntPoint& pos, const Gfx::IntRect& widget_rect);
|
||||
RefPtr<GUI::Menu> m_context_menu;
|
||||
|
||||
bool m_use_secondary_color { false };
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
namespace PixelPaint {
|
||||
|
||||
RefPtr<Image> Image::create_with_size(const Gfx::Size& size)
|
||||
RefPtr<Image> Image::create_with_size(const Gfx::IntSize& size)
|
||||
{
|
||||
if (size.is_empty())
|
||||
return nullptr;
|
||||
|
@ -43,12 +43,12 @@ RefPtr<Image> Image::create_with_size(const Gfx::Size& size)
|
|||
return adopt(*new Image(size));
|
||||
}
|
||||
|
||||
Image::Image(const Gfx::Size& size)
|
||||
Image::Image(const Gfx::IntSize& size)
|
||||
: m_size(size)
|
||||
{
|
||||
}
|
||||
|
||||
void Image::paint_into(GUI::Painter& painter, const Gfx::Rect& dest_rect)
|
||||
void Image::paint_into(GUI::Painter& painter, const Gfx::IntRect& dest_rect)
|
||||
{
|
||||
float scale = (float)dest_rect.width() / (float)rect().width();
|
||||
Gfx::PainterStateSaver saver(painter);
|
||||
|
|
|
@ -51,18 +51,18 @@ public:
|
|||
|
||||
class Image : public RefCounted<Image> {
|
||||
public:
|
||||
static RefPtr<Image> create_with_size(const Gfx::Size&);
|
||||
static RefPtr<Image> create_with_size(const Gfx::IntSize&);
|
||||
|
||||
size_t layer_count() const { return m_layers.size(); }
|
||||
const Layer& layer(size_t index) const { return m_layers.at(index); }
|
||||
Layer& layer(size_t index) { return m_layers.at(index); }
|
||||
|
||||
const Gfx::Size& size() const { return m_size; }
|
||||
Gfx::Rect rect() const { return { {}, m_size }; }
|
||||
const Gfx::IntSize& size() const { return m_size; }
|
||||
Gfx::IntRect rect() const { return { {}, m_size }; }
|
||||
|
||||
void add_layer(NonnullRefPtr<Layer>);
|
||||
|
||||
void paint_into(GUI::Painter&, const Gfx::Rect& dest_rect);
|
||||
void paint_into(GUI::Painter&, const Gfx::IntRect& dest_rect);
|
||||
|
||||
void move_layer_to_front(Layer&);
|
||||
void move_layer_to_back(Layer&);
|
||||
|
@ -79,12 +79,12 @@ public:
|
|||
size_t index_of(const Layer&) const;
|
||||
|
||||
private:
|
||||
explicit Image(const Gfx::Size&);
|
||||
explicit Image(const Gfx::IntSize&);
|
||||
|
||||
void did_change();
|
||||
void did_modify_layer_stack();
|
||||
|
||||
Gfx::Size m_size;
|
||||
Gfx::IntSize m_size;
|
||||
NonnullRefPtrVector<Layer> m_layers;
|
||||
|
||||
HashTable<ImageClient*> m_clients;
|
||||
|
|
|
@ -76,12 +76,12 @@ void ImageEditor::paint_event(GUI::PaintEvent& event)
|
|||
}
|
||||
}
|
||||
|
||||
Gfx::FloatRect ImageEditor::layer_rect_to_editor_rect(const Layer& layer, const Gfx::Rect& layer_rect) const
|
||||
Gfx::FloatRect ImageEditor::layer_rect_to_editor_rect(const Layer& layer, const Gfx::IntRect& layer_rect) const
|
||||
{
|
||||
return image_rect_to_editor_rect(layer_rect.translated(layer.location()));
|
||||
}
|
||||
|
||||
Gfx::FloatRect ImageEditor::image_rect_to_editor_rect(const Gfx::Rect& image_rect) const
|
||||
Gfx::FloatRect ImageEditor::image_rect_to_editor_rect(const Gfx::IntRect& image_rect) const
|
||||
{
|
||||
Gfx::FloatRect editor_rect;
|
||||
editor_rect.set_location(image_position_to_editor_position(image_rect.location()));
|
||||
|
@ -90,7 +90,7 @@ Gfx::FloatRect ImageEditor::image_rect_to_editor_rect(const Gfx::Rect& image_rec
|
|||
return editor_rect;
|
||||
}
|
||||
|
||||
Gfx::FloatRect ImageEditor::editor_rect_to_image_rect(const Gfx::Rect& editor_rect) const
|
||||
Gfx::FloatRect ImageEditor::editor_rect_to_image_rect(const Gfx::IntRect& editor_rect) const
|
||||
{
|
||||
Gfx::FloatRect image_rect;
|
||||
image_rect.set_location(editor_position_to_image_position(editor_rect.location()));
|
||||
|
@ -99,12 +99,12 @@ Gfx::FloatRect ImageEditor::editor_rect_to_image_rect(const Gfx::Rect& editor_re
|
|||
return image_rect;
|
||||
}
|
||||
|
||||
Gfx::FloatPoint ImageEditor::layer_position_to_editor_position(const Layer& layer, const Gfx::Point& layer_position) const
|
||||
Gfx::FloatPoint ImageEditor::layer_position_to_editor_position(const Layer& layer, const Gfx::IntPoint& layer_position) const
|
||||
{
|
||||
return image_position_to_editor_position(layer_position.translated(layer.location()));
|
||||
}
|
||||
|
||||
Gfx::FloatPoint ImageEditor::image_position_to_editor_position(const Gfx::Point& image_position) const
|
||||
Gfx::FloatPoint ImageEditor::image_position_to_editor_position(const Gfx::IntPoint& image_position) const
|
||||
{
|
||||
Gfx::FloatPoint editor_position;
|
||||
editor_position.set_x(m_editor_image_rect.x() + ((float)image_position.x() * m_scale));
|
||||
|
@ -112,7 +112,7 @@ Gfx::FloatPoint ImageEditor::image_position_to_editor_position(const Gfx::Point&
|
|||
return editor_position;
|
||||
}
|
||||
|
||||
Gfx::FloatPoint ImageEditor::editor_position_to_image_position(const Gfx::Point& editor_position) const
|
||||
Gfx::FloatPoint ImageEditor::editor_position_to_image_position(const Gfx::IntPoint& editor_position) const
|
||||
{
|
||||
Gfx::FloatPoint image_position;
|
||||
image_position.set_x(((float)editor_position.x() - m_editor_image_rect.x()) / m_scale);
|
||||
|
@ -131,7 +131,7 @@ GUI::MouseEvent ImageEditor::event_with_pan_and_scale_applied(const GUI::MouseEv
|
|||
auto image_position = editor_position_to_image_position(event.position());
|
||||
return {
|
||||
static_cast<GUI::Event::Type>(event.type()),
|
||||
Gfx::Point(image_position.x(), image_position.y()),
|
||||
Gfx::IntPoint(image_position.x(), image_position.y()),
|
||||
event.buttons(),
|
||||
event.button(),
|
||||
event.modifiers(),
|
||||
|
@ -145,7 +145,7 @@ GUI::MouseEvent ImageEditor::event_adjusted_for_layer(const GUI::MouseEvent& eve
|
|||
image_position.move_by(-layer.location().x(), -layer.location().y());
|
||||
return {
|
||||
static_cast<GUI::Event::Type>(event.type()),
|
||||
Gfx::Point(image_position.x(), image_position.y()),
|
||||
Gfx::IntPoint(image_position.x(), image_position.y()),
|
||||
event.buttons(),
|
||||
event.button(),
|
||||
event.modifiers(),
|
||||
|
@ -331,14 +331,14 @@ void ImageEditor::set_secondary_color(Color color)
|
|||
on_secondary_color_change(color);
|
||||
}
|
||||
|
||||
Layer* ImageEditor::layer_at_editor_position(const Gfx::Point& editor_position)
|
||||
Layer* ImageEditor::layer_at_editor_position(const Gfx::IntPoint& editor_position)
|
||||
{
|
||||
if (!m_image)
|
||||
return nullptr;
|
||||
auto image_position = editor_position_to_image_position(editor_position);
|
||||
for (ssize_t i = m_image->layer_count() - 1; i >= 0; --i) {
|
||||
auto& layer = m_image->layer(i);
|
||||
if (layer.relative_rect().contains(Gfx::Point(image_position.x(), image_position.y())))
|
||||
if (layer.relative_rect().contains(Gfx::IntPoint(image_position.x(), image_position.y())))
|
||||
return const_cast<Layer*>(&layer);
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -350,12 +350,12 @@ void ImageEditor::relayout()
|
|||
return;
|
||||
auto& image = *this->image();
|
||||
|
||||
Gfx::Size new_size;
|
||||
Gfx::IntSize new_size;
|
||||
new_size.set_width(image.size().width() * m_scale);
|
||||
new_size.set_height(image.size().height() * m_scale);
|
||||
m_editor_image_rect.set_size(new_size);
|
||||
|
||||
Gfx::Point new_location;
|
||||
Gfx::IntPoint new_location;
|
||||
new_location.set_x((width() / 2) - (new_size.width() / 2) - (m_pan_origin.x() * m_scale));
|
||||
new_location.set_y((height() / 2) - (new_size.height() / 2) - (m_pan_origin.y() * m_scale));
|
||||
m_editor_image_rect.set_location(new_location);
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
|
||||
void layers_did_change();
|
||||
|
||||
Layer* layer_at_editor_position(const Gfx::Point&);
|
||||
Layer* layer_at_editor_position(const Gfx::IntPoint&);
|
||||
|
||||
Color primary_color() const { return m_primary_color; }
|
||||
void set_primary_color(Color);
|
||||
|
@ -72,12 +72,12 @@ public:
|
|||
|
||||
Function<void(Layer*)> on_active_layer_change;
|
||||
|
||||
Gfx::FloatRect layer_rect_to_editor_rect(const Layer&, const Gfx::Rect&) const;
|
||||
Gfx::FloatRect image_rect_to_editor_rect(const Gfx::Rect&) const;
|
||||
Gfx::FloatRect editor_rect_to_image_rect(const Gfx::Rect&) const;
|
||||
Gfx::FloatPoint layer_position_to_editor_position(const Layer&, const Gfx::Point&) const;
|
||||
Gfx::FloatPoint image_position_to_editor_position(const Gfx::Point&) const;
|
||||
Gfx::FloatPoint editor_position_to_image_position(const Gfx::Point&) const;
|
||||
Gfx::FloatRect layer_rect_to_editor_rect(const Layer&, const Gfx::IntRect&) const;
|
||||
Gfx::FloatRect image_rect_to_editor_rect(const Gfx::IntRect&) const;
|
||||
Gfx::FloatRect editor_rect_to_image_rect(const Gfx::IntRect&) const;
|
||||
Gfx::FloatPoint layer_position_to_editor_position(const Layer&, const Gfx::IntPoint&) const;
|
||||
Gfx::FloatPoint image_position_to_editor_position(const Gfx::IntPoint&) const;
|
||||
Gfx::FloatPoint editor_position_to_image_position(const Gfx::IntPoint&) const;
|
||||
|
||||
private:
|
||||
ImageEditor();
|
||||
|
@ -110,11 +110,11 @@ private:
|
|||
Color m_primary_color { Color::Black };
|
||||
Color m_secondary_color { Color::White };
|
||||
|
||||
Gfx::Rect m_editor_image_rect;
|
||||
Gfx::IntRect m_editor_image_rect;
|
||||
float m_scale { 1 };
|
||||
Gfx::FloatPoint m_pan_origin;
|
||||
Gfx::FloatPoint m_saved_pan_origin;
|
||||
Gfx::Point m_click_position;
|
||||
Gfx::IntPoint m_click_position;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
namespace PixelPaint {
|
||||
|
||||
RefPtr<Layer> Layer::create_with_size(const Gfx::Size& size, const String& name)
|
||||
RefPtr<Layer> Layer::create_with_size(const Gfx::IntSize& size, const String& name)
|
||||
{
|
||||
if (size.is_empty())
|
||||
return nullptr;
|
||||
|
@ -41,7 +41,7 @@ RefPtr<Layer> Layer::create_with_size(const Gfx::Size& size, const String& name)
|
|||
return adopt(*new Layer(size, name));
|
||||
}
|
||||
|
||||
Layer::Layer(const Gfx::Size& size, const String& name)
|
||||
Layer::Layer(const Gfx::IntSize& size, const String& name)
|
||||
: m_name(name)
|
||||
{
|
||||
m_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::RGBA32, size);
|
||||
|
|
|
@ -40,19 +40,19 @@ class Layer : public RefCounted<Layer> {
|
|||
AK_MAKE_NONMOVABLE(Layer);
|
||||
|
||||
public:
|
||||
static RefPtr<Layer> create_with_size(const Gfx::Size&, const String& name);
|
||||
static RefPtr<Layer> create_with_size(const Gfx::IntSize&, const String& name);
|
||||
|
||||
~Layer() {}
|
||||
|
||||
const Gfx::Point& location() const { return m_location; }
|
||||
void set_location(const Gfx::Point& location) { m_location = location; }
|
||||
const Gfx::IntPoint& location() const { return m_location; }
|
||||
void set_location(const Gfx::IntPoint& location) { m_location = location; }
|
||||
|
||||
const Gfx::Bitmap& bitmap() const { return *m_bitmap; }
|
||||
Gfx::Bitmap& bitmap() { return *m_bitmap; }
|
||||
Gfx::Size size() const { return bitmap().size(); }
|
||||
Gfx::IntSize size() const { return bitmap().size(); }
|
||||
|
||||
Gfx::Rect relative_rect() const { return { location(), size() }; }
|
||||
Gfx::Rect rect() const { return { {}, size() }; }
|
||||
Gfx::IntRect relative_rect() const { return { location(), size() }; }
|
||||
Gfx::IntRect rect() const { return { {}, size() }; }
|
||||
|
||||
const String& name() const { return m_name; }
|
||||
void set_name(const String& name) { m_name = name; }
|
||||
|
@ -63,10 +63,10 @@ public:
|
|||
bool is_selected() const { return m_selected; }
|
||||
|
||||
private:
|
||||
explicit Layer(const Gfx::Size&, const String& name);
|
||||
explicit Layer(const Gfx::IntSize&, const String& name);
|
||||
|
||||
String m_name;
|
||||
Gfx::Point m_location;
|
||||
Gfx::IntPoint m_location;
|
||||
RefPtr<Gfx::Bitmap> m_bitmap;
|
||||
|
||||
bool m_selected { false };
|
||||
|
|
|
@ -102,11 +102,11 @@ void LayerListWidget::paint_event(GUI::PaintEvent& event)
|
|||
|
||||
painter.draw_rect(adjusted_rect, Color::Black);
|
||||
|
||||
Gfx::Rect thumbnail_rect { adjusted_rect.x(), adjusted_rect.y(), adjusted_rect.height(), adjusted_rect.height() };
|
||||
Gfx::IntRect thumbnail_rect { adjusted_rect.x(), adjusted_rect.y(), adjusted_rect.height(), adjusted_rect.height() };
|
||||
thumbnail_rect.shrink(8, 8);
|
||||
painter.draw_scaled_bitmap(thumbnail_rect, layer.bitmap(), layer.bitmap().rect());
|
||||
|
||||
Gfx::Rect text_rect { thumbnail_rect.right() + 10, adjusted_rect.y(), adjusted_rect.width(), adjusted_rect.height() };
|
||||
Gfx::IntRect text_rect { thumbnail_rect.right() + 10, adjusted_rect.y(), adjusted_rect.width(), adjusted_rect.height() };
|
||||
text_rect.intersect(adjusted_rect);
|
||||
|
||||
painter.draw_text(text_rect, layer.name(), Gfx::TextAlignment::CenterLeft, layer.is_selected() ? palette().selection_text() : palette().button_text());
|
||||
|
@ -121,7 +121,7 @@ void LayerListWidget::paint_event(GUI::PaintEvent& event)
|
|||
paint_gadget(m_gadgets[m_moving_gadget_index.value()]);
|
||||
}
|
||||
|
||||
Optional<size_t> LayerListWidget::gadget_at(const Gfx::Point& position)
|
||||
Optional<size_t> LayerListWidget::gadget_at(const Gfx::IntPoint& position)
|
||||
{
|
||||
for (size_t i = 0; i < m_gadgets.size(); ++i) {
|
||||
if (m_gadgets[i].rect.contains(position))
|
||||
|
|
|
@ -69,21 +69,21 @@ private:
|
|||
|
||||
struct Gadget {
|
||||
size_t layer_index { 0 };
|
||||
Gfx::Rect rect;
|
||||
Gfx::Rect temporary_rect_during_move;
|
||||
Gfx::IntRect rect;
|
||||
Gfx::IntRect temporary_rect_during_move;
|
||||
bool is_moving { false };
|
||||
Gfx::Point movement_delta;
|
||||
Gfx::IntPoint movement_delta;
|
||||
};
|
||||
|
||||
bool is_moving_gadget() const { return m_moving_gadget_index.has_value(); }
|
||||
|
||||
Optional<size_t> gadget_at(const Gfx::Point&);
|
||||
Optional<size_t> gadget_at(const Gfx::IntPoint&);
|
||||
|
||||
Vector<Gadget> m_gadgets;
|
||||
RefPtr<Image> m_image;
|
||||
|
||||
Optional<size_t> m_moving_gadget_index;
|
||||
Gfx::Point m_moving_event_origin;
|
||||
Gfx::IntPoint m_moving_event_origin;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
namespace PixelPaint {
|
||||
|
||||
static Gfx::Point constrain_line_angle(const Gfx::Point& start_pos, const Gfx::Point& end_pos, float angle_increment)
|
||||
static Gfx::IntPoint constrain_line_angle(const Gfx::IntPoint& start_pos, const Gfx::IntPoint& end_pos, float angle_increment)
|
||||
{
|
||||
float current_angle = atan2(end_pos.y() - start_pos.y(), end_pos.x() - start_pos.x()) + M_PI * 2.;
|
||||
|
||||
|
|
|
@ -49,8 +49,8 @@ private:
|
|||
virtual const char* class_name() const override { return "LineTool"; }
|
||||
|
||||
GUI::MouseButton m_drawing_button { GUI::MouseButton::None };
|
||||
Gfx::Point m_line_start_position;
|
||||
Gfx::Point m_line_end_position;
|
||||
Gfx::IntPoint m_line_start_position;
|
||||
Gfx::IntPoint m_line_end_position;
|
||||
|
||||
RefPtr<GUI::Menu> m_context_menu;
|
||||
GUI::ActionGroup m_thickness_actions;
|
||||
|
|
|
@ -46,8 +46,8 @@ private:
|
|||
virtual bool is_move_tool() const override { return true; }
|
||||
|
||||
RefPtr<Layer> m_layer_being_moved;
|
||||
Gfx::Point m_event_origin;
|
||||
Gfx::Point m_layer_origin;
|
||||
Gfx::IntPoint m_event_origin;
|
||||
Gfx::IntPoint m_layer_origin;
|
||||
RefPtr<GUI::Menu> m_context_menu;
|
||||
RefPtr<Layer> m_context_menu_layer;
|
||||
};
|
||||
|
|
|
@ -88,7 +88,7 @@ PaletteWidget::PaletteWidget(ImageEditor& editor)
|
|||
set_secondary_color(m_editor.secondary_color());
|
||||
|
||||
m_primary_color_widget = add<GUI::Frame>();
|
||||
Gfx::Rect rect { 0, 0, 38, 15 };
|
||||
Gfx::IntRect rect { 0, 0, 38, 15 };
|
||||
rect.center_within(m_secondary_color_widget->relative_rect());
|
||||
m_primary_color_widget->set_relative_rect(rect);
|
||||
m_primary_color_widget->set_fill_with_background_color(true);
|
||||
|
|
|
@ -64,7 +64,7 @@ void PenTool::on_mousemove(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent
|
|||
return;
|
||||
GUI::Painter painter(layer.bitmap());
|
||||
|
||||
if (m_last_drawing_event_position != Gfx::Point(-1, -1))
|
||||
if (m_last_drawing_event_position != Gfx::IntPoint(-1, -1))
|
||||
painter.draw_line(m_last_drawing_event_position, event.position(), m_editor->color_for(event), m_thickness);
|
||||
else
|
||||
painter.draw_line(event.position(), event.position(), m_editor->color_for(event), m_thickness);
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
private:
|
||||
virtual const char* class_name() const override { return "PenTool"; }
|
||||
|
||||
Gfx::Point m_last_drawing_event_position { -1, -1 };
|
||||
Gfx::IntPoint m_last_drawing_event_position { -1, -1 };
|
||||
RefPtr<GUI::Menu> m_context_menu;
|
||||
int m_thickness { 1 };
|
||||
GUI::ActionGroup m_thickness_actions;
|
||||
|
|
|
@ -43,7 +43,7 @@ RectangleTool::~RectangleTool()
|
|||
{
|
||||
}
|
||||
|
||||
void RectangleTool::draw_using(GUI::Painter& painter, const Gfx::Rect& rect)
|
||||
void RectangleTool::draw_using(GUI::Painter& painter, const Gfx::IntRect& rect)
|
||||
{
|
||||
switch (m_mode) {
|
||||
case Mode::Fill:
|
||||
|
@ -78,7 +78,7 @@ void RectangleTool::on_mouseup(Layer& layer, GUI::MouseEvent& event, GUI::MouseE
|
|||
{
|
||||
if (event.button() == m_drawing_button) {
|
||||
GUI::Painter painter(layer.bitmap());
|
||||
auto rect = Gfx::Rect::from_two_points(m_rectangle_start_position, m_rectangle_end_position);
|
||||
auto rect = Gfx::IntRect::from_two_points(m_rectangle_start_position, m_rectangle_end_position);
|
||||
draw_using(painter, rect);
|
||||
m_drawing_button = GUI::MouseButton::None;
|
||||
layer.did_modify_bitmap(*m_editor->image());
|
||||
|
@ -101,7 +101,7 @@ void RectangleTool::on_second_paint(const Layer& layer, GUI::PaintEvent& event)
|
|||
|
||||
GUI::Painter painter(*m_editor);
|
||||
painter.add_clip_rect(event.rect());
|
||||
auto rect = Gfx::Rect::from_two_points(m_editor->layer_position_to_editor_position(layer, m_rectangle_start_position).to_int_point(), m_editor->layer_position_to_editor_position(layer, m_rectangle_end_position).to_int_point());
|
||||
auto rect = Gfx::IntRect::from_two_points(m_editor->layer_position_to_editor_position(layer, m_rectangle_start_position).to_int_point(), m_editor->layer_position_to_editor_position(layer, m_rectangle_end_position).to_int_point());
|
||||
draw_using(painter, rect);
|
||||
}
|
||||
|
||||
|
|
|
@ -52,11 +52,11 @@ private:
|
|||
};
|
||||
|
||||
virtual const char* class_name() const override { return "RectangleTool"; }
|
||||
void draw_using(GUI::Painter&, const Gfx::Rect&);
|
||||
void draw_using(GUI::Painter&, const Gfx::IntRect&);
|
||||
|
||||
GUI::MouseButton m_drawing_button { GUI::MouseButton::None };
|
||||
Gfx::Point m_rectangle_start_position;
|
||||
Gfx::Point m_rectangle_end_position;
|
||||
Gfx::IntPoint m_rectangle_start_position;
|
||||
Gfx::IntPoint m_rectangle_end_position;
|
||||
RefPtr<GUI::Menu> m_context_menu;
|
||||
Mode m_mode { Mode::Outline };
|
||||
};
|
||||
|
|
|
@ -47,7 +47,7 @@ private:
|
|||
virtual const char* class_name() const override { return "SprayTool"; }
|
||||
void paint_it();
|
||||
RefPtr<Core::Timer> m_timer;
|
||||
Gfx::Point m_last_pos;
|
||||
Gfx::IntPoint m_last_pos;
|
||||
Color m_color;
|
||||
RefPtr<GUI::Menu> m_context_menu;
|
||||
GUI::ActionGroup m_thickness_actions;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue