diff options
-rw-r--r-- | Applications/PaintBrush/BucketTool.cpp | 3 | ||||
-rw-r--r-- | Applications/PaintBrush/EllipseTool.cpp | 3 | ||||
-rw-r--r-- | Applications/PaintBrush/EraseTool.cpp | 3 | ||||
-rw-r--r-- | Applications/PaintBrush/ImageEditor.cpp | 37 | ||||
-rw-r--r-- | Applications/PaintBrush/ImageEditor.h | 15 | ||||
-rw-r--r-- | Applications/PaintBrush/LineTool.cpp | 3 | ||||
-rw-r--r-- | Applications/PaintBrush/Makefile | 1 | ||||
-rw-r--r-- | Applications/PaintBrush/MoveTool.cpp | 1 | ||||
-rw-r--r-- | Applications/PaintBrush/PaintableWidget.cpp | 97 | ||||
-rw-r--r-- | Applications/PaintBrush/PaintableWidget.h | 62 | ||||
-rw-r--r-- | Applications/PaintBrush/PaletteWidget.cpp | 25 | ||||
-rw-r--r-- | Applications/PaintBrush/PaletteWidget.h | 14 | ||||
-rw-r--r-- | Applications/PaintBrush/PenTool.cpp | 7 | ||||
-rw-r--r-- | Applications/PaintBrush/PickerTool.cpp | 6 | ||||
-rw-r--r-- | Applications/PaintBrush/RectangleTool.cpp | 7 | ||||
-rw-r--r-- | Applications/PaintBrush/SprayTool.cpp | 3 | ||||
-rw-r--r-- | Applications/PaintBrush/ToolboxWidget.cpp | 1 | ||||
-rw-r--r-- | Applications/PaintBrush/main.cpp | 7 |
18 files changed, 92 insertions, 203 deletions
diff --git a/Applications/PaintBrush/BucketTool.cpp b/Applications/PaintBrush/BucketTool.cpp index d7aed49e4d..a45448c563 100644 --- a/Applications/PaintBrush/BucketTool.cpp +++ b/Applications/PaintBrush/BucketTool.cpp @@ -27,7 +27,6 @@ #include "BucketTool.h" #include "ImageEditor.h" #include "Layer.h" -#include "PaintableWidget.h" #include <AK/Queue.h> #include <AK/SinglyLinkedList.h> #include <LibGUI/Painter.h> @@ -86,7 +85,7 @@ void BucketTool::on_mousedown(Layer& layer, GUI::MouseEvent& event, GUI::MouseEv GUI::Painter painter(layer.bitmap()); auto target_color = layer.bitmap().get_pixel(event.x(), event.y()); - flood_fill(layer.bitmap(), event.position(), target_color, PaintableWidget::the().color_for(event)); + flood_fill(layer.bitmap(), event.position(), target_color, m_editor->color_for(event)); m_editor->update(); } diff --git a/Applications/PaintBrush/EllipseTool.cpp b/Applications/PaintBrush/EllipseTool.cpp index 9dc39225be..462ffb20af 100644 --- a/Applications/PaintBrush/EllipseTool.cpp +++ b/Applications/PaintBrush/EllipseTool.cpp @@ -27,7 +27,6 @@ #include "EllipseTool.h" #include "ImageEditor.h" #include "Layer.h" -#include "PaintableWidget.h" #include <LibGUI/Action.h> #include <LibGUI/Menu.h> #include <LibGUI/Painter.h> @@ -49,7 +48,7 @@ void EllipseTool::draw_using(GUI::Painter& painter) auto ellipse_intersecting_rect = Gfx::Rect::from_two_points(m_ellipse_start_position, m_ellipse_end_position); switch (m_mode) { case Mode::Outline: - painter.draw_ellipse_intersecting(ellipse_intersecting_rect, PaintableWidget::the().color_for(m_drawing_button), m_thickness); + painter.draw_ellipse_intersecting(ellipse_intersecting_rect, m_editor->color_for(m_drawing_button), m_thickness); break; default: ASSERT_NOT_REACHED(); diff --git a/Applications/PaintBrush/EraseTool.cpp b/Applications/PaintBrush/EraseTool.cpp index 90403df340..e4db9db861 100644 --- a/Applications/PaintBrush/EraseTool.cpp +++ b/Applications/PaintBrush/EraseTool.cpp @@ -27,7 +27,6 @@ #include "EraseTool.h" #include "ImageEditor.h" #include "Layer.h" -#include "PaintableWidget.h" #include <LibGUI/Action.h> #include <LibGUI/Menu.h> #include <LibGUI/Painter.h> @@ -110,7 +109,7 @@ void EraseTool::on_contextmenu(GUI::ContextMenuEvent& event) Color EraseTool::get_color() const { if (m_use_secondary_color) - return PaintableWidget::the().secondary_color(); + return m_editor->secondary_color(); return Color(255, 255, 255, 0); } diff --git a/Applications/PaintBrush/ImageEditor.cpp b/Applications/PaintBrush/ImageEditor.cpp index 51c735c57a..60718044f1 100644 --- a/Applications/PaintBrush/ImageEditor.cpp +++ b/Applications/PaintBrush/ImageEditor.cpp @@ -126,4 +126,41 @@ void ImageEditor::layers_did_change() update(); } +Color ImageEditor::color_for(GUI::MouseButton button) const +{ + if (button == GUI::MouseButton::Left) + return m_primary_color; + if (button == GUI::MouseButton::Right) + return m_secondary_color; + ASSERT_NOT_REACHED(); +} + +Color ImageEditor::color_for(const GUI::MouseEvent& event) const +{ + if (event.buttons() & GUI::MouseButton::Left) + return m_primary_color; + if (event.buttons() & GUI::MouseButton::Right) + return m_secondary_color; + ASSERT_NOT_REACHED(); +} + +void ImageEditor::set_primary_color(Color color) +{ + if (m_primary_color == color) + return; + m_primary_color = color; + if (on_primary_color_change) + on_primary_color_change(color); +} + +void ImageEditor::set_secondary_color(Color color) +{ + if (m_secondary_color == color) + return; + m_secondary_color = color; + if (on_secondary_color_change) + on_secondary_color_change(color); +} + + } diff --git a/Applications/PaintBrush/ImageEditor.h b/Applications/PaintBrush/ImageEditor.h index e1b273ae8c..4807f91676 100644 --- a/Applications/PaintBrush/ImageEditor.h +++ b/Applications/PaintBrush/ImageEditor.h @@ -51,6 +51,18 @@ public: void layers_did_change(); + Color primary_color() const { return m_primary_color; } + void set_primary_color(Color); + + Color secondary_color() const { return m_secondary_color; } + void set_secondary_color(Color); + + Color color_for(const GUI::MouseEvent&) const; + Color color_for(GUI::MouseButton) const; + + Function<void(Color)> on_primary_color_change; + Function<void(Color)> on_secondary_color_change; + private: ImageEditor(); @@ -63,6 +75,9 @@ private: RefPtr<Layer> m_active_layer; Tool* m_active_tool { nullptr }; + + Color m_primary_color { Color::Black }; + Color m_secondary_color { Color::White }; }; } diff --git a/Applications/PaintBrush/LineTool.cpp b/Applications/PaintBrush/LineTool.cpp index a714130cf1..3e7636b459 100644 --- a/Applications/PaintBrush/LineTool.cpp +++ b/Applications/PaintBrush/LineTool.cpp @@ -27,7 +27,6 @@ #include "LineTool.h" #include "ImageEditor.h" #include "Layer.h" -#include "PaintableWidget.h" #include <LibGUI/Action.h> #include <LibGUI/Menu.h> #include <LibGUI/Painter.h> @@ -74,7 +73,7 @@ void LineTool::on_mouseup(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent& { if (event.button() == m_drawing_button) { GUI::Painter painter(layer.bitmap()); - painter.draw_line(m_line_start_position, m_line_end_position, PaintableWidget::the().color_for(m_drawing_button), m_thickness); + painter.draw_line(m_line_start_position, m_line_end_position, m_editor->color_for(m_drawing_button), m_thickness); m_drawing_button = GUI::MouseButton::None; m_editor->update(); } diff --git a/Applications/PaintBrush/Makefile b/Applications/PaintBrush/Makefile index c6514a09b4..9a93358905 100644 --- a/Applications/PaintBrush/Makefile +++ b/Applications/PaintBrush/Makefile @@ -8,7 +8,6 @@ OBJS = \ LayerModel.o \ LineTool.o \ MoveTool.o \ - PaintableWidget.o \ PaletteWidget.o \ PenTool.o \ PickerTool.o \ diff --git a/Applications/PaintBrush/MoveTool.cpp b/Applications/PaintBrush/MoveTool.cpp index e497ee926a..372061a366 100644 --- a/Applications/PaintBrush/MoveTool.cpp +++ b/Applications/PaintBrush/MoveTool.cpp @@ -27,7 +27,6 @@ #include "MoveTool.h" #include "ImageEditor.h" #include "Layer.h" -#include "PaintableWidget.h" #include <LibGUI/Window.h> #include <LibGfx/Bitmap.h> diff --git a/Applications/PaintBrush/PaintableWidget.cpp b/Applications/PaintBrush/PaintableWidget.cpp deleted file mode 100644 index 87b2fe701c..0000000000 --- a/Applications/PaintBrush/PaintableWidget.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "PaintableWidget.h" -#include "Tool.h" -#include <LibGUI/Painter.h> -#include <LibGfx/Bitmap.h> -#include <LibGfx/Palette.h> - -static PaintableWidget* s_the; - -PaintableWidget& PaintableWidget::the() -{ - return *s_the; -} - -PaintableWidget::PaintableWidget() -{ - ASSERT(!s_the); - s_the = this; - set_fill_with_background_color(true); - auto pal = palette(); - pal.set_color(ColorRole::Window, Color::MidGray); - set_palette(pal); - set_background_color(Color::MidGray); - m_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::RGBA32, { 600, 400 }); - m_bitmap->fill(Color(255, 255, 255, 0)); -} - -PaintableWidget::~PaintableWidget() -{ -} - -Color PaintableWidget::color_for(GUI::MouseButton button) const -{ - if (button == GUI::MouseButton::Left) - return m_primary_color; - if (button == GUI::MouseButton::Right) - return m_secondary_color; - ASSERT_NOT_REACHED(); -} - -Color PaintableWidget::color_for(const GUI::MouseEvent& event) const -{ - if (event.buttons() & GUI::MouseButton::Left) - return m_primary_color; - if (event.buttons() & GUI::MouseButton::Right) - return m_secondary_color; - ASSERT_NOT_REACHED(); -} - -void PaintableWidget::set_primary_color(Color color) -{ - if (m_primary_color == color) - return; - m_primary_color = color; - if (on_primary_color_change) - on_primary_color_change(color); -} - -void PaintableWidget::set_secondary_color(Color color) -{ - if (m_secondary_color == color) - return; - m_secondary_color = color; - if (on_secondary_color_change) - on_secondary_color_change(color); -} - -void PaintableWidget::set_bitmap(const Gfx::Bitmap& bitmap) -{ - m_bitmap = bitmap; - update(); -} diff --git a/Applications/PaintBrush/PaintableWidget.h b/Applications/PaintBrush/PaintableWidget.h deleted file mode 100644 index c3947c8542..0000000000 --- a/Applications/PaintBrush/PaintableWidget.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#pragma once - -#include <LibGUI/Widget.h> - -class PaintableWidget final : public GUI::Widget { - C_OBJECT(PaintableWidget) -public: - static PaintableWidget& the(); - - virtual ~PaintableWidget() override; - - Color primary_color() const { return m_primary_color; } - Color secondary_color() const { return m_secondary_color; } - - void set_primary_color(Color); - void set_secondary_color(Color); - - Color color_for(const GUI::MouseEvent&) const; - Color color_for(GUI::MouseButton) const; - - void set_bitmap(const Gfx::Bitmap&); - - Gfx::Bitmap& bitmap() { return *m_bitmap; } - const Gfx::Bitmap& bitmap() const { return *m_bitmap; } - - Function<void(Color)> on_primary_color_change; - Function<void(Color)> on_secondary_color_change; - -private: - PaintableWidget(); - - RefPtr<Gfx::Bitmap> m_bitmap; - - Color m_primary_color { Color::Black }; - Color m_secondary_color { Color::White }; -}; diff --git a/Applications/PaintBrush/PaletteWidget.cpp b/Applications/PaintBrush/PaletteWidget.cpp index 8c518bec66..b6a2830369 100644 --- a/Applications/PaintBrush/PaletteWidget.cpp +++ b/Applications/PaintBrush/PaletteWidget.cpp @@ -25,13 +25,16 @@ */ #include "PaletteWidget.h" -#include "PaintableWidget.h" +#include "ImageEditor.h" #include <LibGUI/BoxLayout.h> #include <LibGUI/ColorPicker.h> #include <LibGfx/Palette.h> +namespace PaintBrush { + class ColorWidget : public GUI::Frame { - C_OBJECT(ColorWidget) + C_OBJECT(ColorWidget); + public: explicit ColorWidget(Color color, PaletteWidget& palette_widget) : m_palette_widget(palette_widget) @@ -68,8 +71,8 @@ private: Color m_color; }; -PaletteWidget::PaletteWidget(PaintableWidget& paintable_widget) - : m_paintable_widget(paintable_widget) +PaletteWidget::PaletteWidget(ImageEditor& editor) + : m_editor(editor) { set_frame_shape(Gfx::FrameShape::Panel); set_frame_shadow(Gfx::FrameShadow::Raised); @@ -82,20 +85,20 @@ PaletteWidget::PaletteWidget(PaintableWidget& paintable_widget) m_secondary_color_widget = add<GUI::Frame>(); m_secondary_color_widget->set_relative_rect({ 2, 2, 60, 31 }); m_secondary_color_widget->set_fill_with_background_color(true); - set_secondary_color(paintable_widget.secondary_color()); + set_secondary_color(m_editor.secondary_color()); m_primary_color_widget = add<GUI::Frame>(); Gfx::Rect 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); - set_primary_color(paintable_widget.primary_color()); + set_primary_color(m_editor.primary_color()); - paintable_widget.on_primary_color_change = [this](Color color) { + m_editor.on_primary_color_change = [this](Color color) { set_primary_color(color); }; - paintable_widget.on_secondary_color_change = [this](Color color) { + m_editor.on_secondary_color_change = [this](Color color) { set_secondary_color(color); }; @@ -157,7 +160,7 @@ PaletteWidget::~PaletteWidget() void PaletteWidget::set_primary_color(Color color) { - m_paintable_widget.set_primary_color(color); + m_editor.set_primary_color(color); auto pal = m_primary_color_widget->palette(); pal.set_color(ColorRole::Background, color); m_primary_color_widget->set_palette(pal); @@ -166,9 +169,11 @@ void PaletteWidget::set_primary_color(Color color) void PaletteWidget::set_secondary_color(Color color) { - m_paintable_widget.set_secondary_color(color); + m_editor.set_secondary_color(color); auto pal = m_secondary_color_widget->palette(); pal.set_color(ColorRole::Background, color); m_secondary_color_widget->set_palette(pal); m_secondary_color_widget->update(); } + +} diff --git a/Applications/PaintBrush/PaletteWidget.h b/Applications/PaintBrush/PaletteWidget.h index 0fbabcd78c..1ae3986fa2 100644 --- a/Applications/PaintBrush/PaletteWidget.h +++ b/Applications/PaintBrush/PaletteWidget.h @@ -28,19 +28,25 @@ #include <LibGUI/Frame.h> -class PaintableWidget; +namespace PaintBrush { + +class ImageEditor; class PaletteWidget final : public GUI::Frame { - C_OBJECT(PaletteWidget) + C_OBJECT(PaletteWidget); + public: - explicit PaletteWidget(PaintableWidget&); virtual ~PaletteWidget() override; void set_primary_color(Color); void set_secondary_color(Color); private: - PaintableWidget& m_paintable_widget; + explicit PaletteWidget(ImageEditor&); + + ImageEditor& m_editor; RefPtr<GUI::Frame> m_primary_color_widget; RefPtr<GUI::Frame> m_secondary_color_widget; }; + +} diff --git a/Applications/PaintBrush/PenTool.cpp b/Applications/PaintBrush/PenTool.cpp index 326db74100..f672fc2180 100644 --- a/Applications/PaintBrush/PenTool.cpp +++ b/Applications/PaintBrush/PenTool.cpp @@ -27,7 +27,6 @@ #include "PenTool.h" #include "ImageEditor.h" #include "Layer.h" -#include "PaintableWidget.h" #include <LibGUI/Action.h> #include <LibGUI/Menu.h> #include <LibGUI/Painter.h> @@ -48,7 +47,7 @@ void PenTool::on_mousedown(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent return; GUI::Painter painter(layer.bitmap()); - painter.draw_line(event.position(), event.position(), PaintableWidget::the().color_for(event), m_thickness); + painter.draw_line(event.position(), event.position(), m_editor->color_for(event), m_thickness); m_editor->update(); m_last_drawing_event_position = event.position(); } @@ -68,9 +67,9 @@ void PenTool::on_mousemove(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent GUI::Painter painter(layer.bitmap()); if (m_last_drawing_event_position != Gfx::Point(-1, -1)) - painter.draw_line(m_last_drawing_event_position, event.position(), PaintableWidget::the().color_for(event), m_thickness); + 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(), PaintableWidget::the().color_for(event), m_thickness); + painter.draw_line(event.position(), event.position(), m_editor->color_for(event), m_thickness); m_editor->update(); m_last_drawing_event_position = event.position(); diff --git a/Applications/PaintBrush/PickerTool.cpp b/Applications/PaintBrush/PickerTool.cpp index 5af72c7935..e8d396f65d 100644 --- a/Applications/PaintBrush/PickerTool.cpp +++ b/Applications/PaintBrush/PickerTool.cpp @@ -25,8 +25,8 @@ */ #include "PickerTool.h" +#include "ImageEditor.h" #include "Layer.h" -#include "PaintableWidget.h" #include <LibGfx/Bitmap.h> namespace PaintBrush { @@ -45,9 +45,9 @@ void PickerTool::on_mousedown(Layer& layer, GUI::MouseEvent& event, GUI::MouseEv return; auto color = layer.bitmap().get_pixel(event.position()); if (event.button() == GUI::MouseButton::Left) - PaintableWidget::the().set_primary_color(color); + m_editor->set_primary_color(color); else if (event.button() == GUI::MouseButton::Right) - PaintableWidget::the().set_secondary_color(color); + m_editor->set_secondary_color(color); } } diff --git a/Applications/PaintBrush/RectangleTool.cpp b/Applications/PaintBrush/RectangleTool.cpp index d99a3e2de5..da6282f51a 100644 --- a/Applications/PaintBrush/RectangleTool.cpp +++ b/Applications/PaintBrush/RectangleTool.cpp @@ -27,7 +27,6 @@ #include "RectangleTool.h" #include "ImageEditor.h" #include "Layer.h" -#include "PaintableWidget.h" #include <LibGUI/Action.h> #include <LibGUI/Menu.h> #include <LibGUI/Painter.h> @@ -49,13 +48,13 @@ void RectangleTool::draw_using(GUI::Painter& painter) auto rect_to_draw = Gfx::Rect::from_two_points(m_rectangle_start_position, m_rectangle_end_position); switch (m_mode) { case Mode::Fill: - painter.fill_rect(rect_to_draw, PaintableWidget::the().color_for(m_drawing_button)); + painter.fill_rect(rect_to_draw, m_editor->color_for(m_drawing_button)); break; case Mode::Outline: - painter.draw_rect(rect_to_draw, PaintableWidget::the().color_for(m_drawing_button)); + painter.draw_rect(rect_to_draw, m_editor->color_for(m_drawing_button)); break; case Mode::Gradient: - painter.fill_rect_with_gradient(rect_to_draw, PaintableWidget::the().primary_color(), PaintableWidget::the().secondary_color()); + painter.fill_rect_with_gradient(rect_to_draw, m_editor->primary_color(), m_editor->secondary_color()); break; default: ASSERT_NOT_REACHED(); diff --git a/Applications/PaintBrush/SprayTool.cpp b/Applications/PaintBrush/SprayTool.cpp index 5349ec3db5..d9dbd89974 100644 --- a/Applications/PaintBrush/SprayTool.cpp +++ b/Applications/PaintBrush/SprayTool.cpp @@ -27,7 +27,6 @@ #include "SprayTool.h" #include "ImageEditor.h" #include "Layer.h" -#include "PaintableWidget.h" #include <AK/Queue.h> #include <AK/SinglyLinkedList.h> #include <LibGUI/Action.h> @@ -87,7 +86,7 @@ void SprayTool::on_mousedown(Layer&, GUI::MouseEvent& event, GUI::MouseEvent&) if (!m_editor->rect().contains(event.position())) return; - m_color = PaintableWidget::the().color_for(event); + m_color = m_editor->color_for(event); m_last_pos = event.position(); m_timer->start(); paint_it(); diff --git a/Applications/PaintBrush/ToolboxWidget.cpp b/Applications/PaintBrush/ToolboxWidget.cpp index b21b0d1190..cff7b21cda 100644 --- a/Applications/PaintBrush/ToolboxWidget.cpp +++ b/Applications/PaintBrush/ToolboxWidget.cpp @@ -30,7 +30,6 @@ #include "EraseTool.h" #include "LineTool.h" #include "MoveTool.h" -#include "PaintableWidget.h" #include "PenTool.h" #include "PickerTool.h" #include "RectangleTool.h" diff --git a/Applications/PaintBrush/main.cpp b/Applications/PaintBrush/main.cpp index 7532d54c4e..c9bc6513fa 100644 --- a/Applications/PaintBrush/main.cpp +++ b/Applications/PaintBrush/main.cpp @@ -27,7 +27,6 @@ #include "Image.h" #include "ImageEditor.h" #include "Layer.h" -#include "PaintableWidget.h" #include "PaletteWidget.h" #include "ToolboxWidget.h" #include <LibGUI/AboutDialog.h> @@ -80,10 +79,7 @@ int main(int argc, char** argv) image_editor.set_active_tool(tool); }; - auto& paintable_widget = vertical_container.add<PaintableWidget>(); - paintable_widget.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); - paintable_widget.set_preferred_size(0, 0); - vertical_container.add<PaletteWidget>(paintable_widget); + vertical_container.add<PaintBrush::PaletteWidget>(image_editor); auto& right_panel = horizontal_container.add<GUI::Widget>(); right_panel.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); @@ -109,7 +105,6 @@ int main(int argc, char** argv) GUI::MessageBox::show(String::format("Failed to load '%s'", open_path.value().characters()), "Open failed", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window); return; } - paintable_widget.set_bitmap(*bitmap); })); app_menu.add_separator(); app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) { |