PixelPaint: Refactor `main.cpp` into `MainWidget`
Previously, all the UI setup was done in `main.cpp`, with a whole
bunch of lambdas,, and actions etc just being stored in the main
function. This is probably an artifact from back when it was first
created.
Most other applications now have a "MainWidget" class of some sort
which handles setting up all the UI/menubars, etc. More importantly,,
it also lets us handle application-wide events which we were
previously not able to do directly, since the main widget was just
a default GUI::Widget.
This patch moves all the core functionality of the PixelPaint
application into PixelPaint::MainWidget, which is then instantiated
by the main function. There is likely some more refactoring that
would help, but this commit is big enough as it is doing mostly
a direct port.
2021-09-06 07:11:46 +03:00
|
|
|
/*
|
2022-01-05 05:35:55 +03:00
|
|
|
* Copyright (c) 2021-2022, Mustafa Quraish <mustafa@serenityos.org>
|
PixelPaint: Refactor `main.cpp` into `MainWidget`
Previously, all the UI setup was done in `main.cpp`, with a whole
bunch of lambdas,, and actions etc just being stored in the main
function. This is probably an artifact from back when it was first
created.
Most other applications now have a "MainWidget" class of some sort
which handles setting up all the UI/menubars, etc. More importantly,,
it also lets us handle application-wide events which we were
previously not able to do directly, since the main widget was just
a default GUI::Widget.
This patch moves all the core functionality of the PixelPaint
application into PixelPaint::MainWidget, which is then instantiated
by the main function. There is likely some more refactoring that
would help, but this commit is big enough as it is doing mostly
a direct port.
2021-09-06 07:11:46 +03:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "Guide.h"
|
2022-04-18 16:24:49 +03:00
|
|
|
#include "HistogramWidget.h"
|
2022-02-09 21:48:56 +03:00
|
|
|
#include "IconBag.h"
|
PixelPaint: Refactor `main.cpp` into `MainWidget`
Previously, all the UI setup was done in `main.cpp`, with a whole
bunch of lambdas,, and actions etc just being stored in the main
function. This is probably an artifact from back when it was first
created.
Most other applications now have a "MainWidget" class of some sort
which handles setting up all the UI/menubars, etc. More importantly,,
it also lets us handle application-wide events which we were
previously not able to do directly, since the main widget was just
a default GUI::Widget.
This patch moves all the core functionality of the PixelPaint
application into PixelPaint::MainWidget, which is then instantiated
by the main function. There is likely some more refactoring that
would help, but this commit is big enough as it is doing mostly
a direct port.
2021-09-06 07:11:46 +03:00
|
|
|
#include "Image.h"
|
|
|
|
#include "ImageEditor.h"
|
|
|
|
#include "Layer.h"
|
|
|
|
#include "LayerListWidget.h"
|
|
|
|
#include "LayerPropertiesWidget.h"
|
|
|
|
#include "PaletteWidget.h"
|
|
|
|
#include "ProjectLoader.h"
|
|
|
|
#include "ToolPropertiesWidget.h"
|
|
|
|
#include "ToolboxWidget.h"
|
2021-09-17 10:54:55 +03:00
|
|
|
#include "Tools/Tool.h"
|
2022-08-17 13:18:16 +03:00
|
|
|
#include "VectorscopeWidget.h"
|
2022-12-17 19:51:26 +03:00
|
|
|
#include <LibFileSystemAccessClient/Client.h>
|
PixelPaint: Refactor `main.cpp` into `MainWidget`
Previously, all the UI setup was done in `main.cpp`, with a whole
bunch of lambdas,, and actions etc just being stored in the main
function. This is probably an artifact from back when it was first
created.
Most other applications now have a "MainWidget" class of some sort
which handles setting up all the UI/menubars, etc. More importantly,,
it also lets us handle application-wide events which we were
previously not able to do directly, since the main widget was just
a default GUI::Widget.
This patch moves all the core functionality of the PixelPaint
application into PixelPaint::MainWidget, which is then instantiated
by the main function. There is likely some more refactoring that
would help, but this commit is big enough as it is doing mostly
a direct port.
2021-09-06 07:11:46 +03:00
|
|
|
#include <LibGUI/Action.h>
|
2021-11-22 02:49:10 +03:00
|
|
|
#include <LibGUI/ComboBox.h>
|
PixelPaint: Refactor `main.cpp` into `MainWidget`
Previously, all the UI setup was done in `main.cpp`, with a whole
bunch of lambdas,, and actions etc just being stored in the main
function. This is probably an artifact from back when it was first
created.
Most other applications now have a "MainWidget" class of some sort
which handles setting up all the UI/menubars, etc. More importantly,,
it also lets us handle application-wide events which we were
previously not able to do directly, since the main widget was just
a default GUI::Widget.
This patch moves all the core functionality of the PixelPaint
application into PixelPaint::MainWidget, which is then instantiated
by the main function. There is likely some more refactoring that
would help, but this commit is big enough as it is doing mostly
a direct port.
2021-09-06 07:11:46 +03:00
|
|
|
#include <LibGUI/Forward.h>
|
2022-01-09 02:58:33 +03:00
|
|
|
#include <LibGUI/Menu.h>
|
PixelPaint: Refactor `main.cpp` into `MainWidget`
Previously, all the UI setup was done in `main.cpp`, with a whole
bunch of lambdas,, and actions etc just being stored in the main
function. This is probably an artifact from back when it was first
created.
Most other applications now have a "MainWidget" class of some sort
which handles setting up all the UI/menubars, etc. More importantly,,
it also lets us handle application-wide events which we were
previously not able to do directly, since the main widget was just
a default GUI::Widget.
This patch moves all the core functionality of the PixelPaint
application into PixelPaint::MainWidget, which is then instantiated
by the main function. There is likely some more refactoring that
would help, but this commit is big enough as it is doing mostly
a direct port.
2021-09-06 07:11:46 +03:00
|
|
|
#include <LibGUI/Statusbar.h>
|
|
|
|
#include <LibGUI/TabWidget.h>
|
|
|
|
#include <LibGUI/Widget.h>
|
|
|
|
|
|
|
|
namespace PixelPaint {
|
|
|
|
|
2022-02-09 21:48:56 +03:00
|
|
|
extern IconBag g_icon_bag;
|
|
|
|
|
PixelPaint: Refactor `main.cpp` into `MainWidget`
Previously, all the UI setup was done in `main.cpp`, with a whole
bunch of lambdas,, and actions etc just being stored in the main
function. This is probably an artifact from back when it was first
created.
Most other applications now have a "MainWidget" class of some sort
which handles setting up all the UI/menubars, etc. More importantly,,
it also lets us handle application-wide events which we were
previously not able to do directly, since the main widget was just
a default GUI::Widget.
This patch moves all the core functionality of the PixelPaint
application into PixelPaint::MainWidget, which is then instantiated
by the main function. There is likely some more refactoring that
would help, but this commit is big enough as it is doing mostly
a direct port.
2021-09-06 07:11:46 +03:00
|
|
|
class MainWidget : public GUI::Widget {
|
|
|
|
C_OBJECT(MainWidget);
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~MainWidget() {};
|
|
|
|
|
2022-12-18 00:22:02 +03:00
|
|
|
ErrorOr<void> initialize_menubar(GUI::Window&);
|
PixelPaint: Refactor `main.cpp` into `MainWidget`
Previously, all the UI setup was done in `main.cpp`, with a whole
bunch of lambdas,, and actions etc just being stored in the main
function. This is probably an artifact from back when it was first
created.
Most other applications now have a "MainWidget" class of some sort
which handles setting up all the UI/menubars, etc. More importantly,,
it also lets us handle application-wide events which we were
previously not able to do directly, since the main widget was just
a default GUI::Widget.
This patch moves all the core functionality of the PixelPaint
application into PixelPaint::MainWidget, which is then instantiated
by the main function. There is likely some more refactoring that
would help, but this commit is big enough as it is doing mostly
a direct port.
2021-09-06 07:11:46 +03:00
|
|
|
|
2022-12-17 19:51:26 +03:00
|
|
|
void open_image(FileSystemAccessClient::File);
|
2022-12-18 00:22:02 +03:00
|
|
|
ErrorOr<void> create_default_image();
|
2022-01-05 05:35:55 +03:00
|
|
|
|
2021-09-17 20:28:22 +03:00
|
|
|
bool request_close();
|
PixelPaint: Refactor `main.cpp` into `MainWidget`
Previously, all the UI setup was done in `main.cpp`, with a whole
bunch of lambdas,, and actions etc just being stored in the main
function. This is probably an artifact from back when it was first
created.
Most other applications now have a "MainWidget" class of some sort
which handles setting up all the UI/menubars, etc. More importantly,,
it also lets us handle application-wide events which we were
previously not able to do directly, since the main widget was just
a default GUI::Widget.
This patch moves all the core functionality of the PixelPaint
application into PixelPaint::MainWidget, which is then instantiated
by the main function. There is likely some more refactoring that
would help, but this commit is big enough as it is doing mostly
a direct port.
2021-09-06 07:11:46 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
MainWidget();
|
|
|
|
|
|
|
|
ImageEditor* current_image_editor();
|
|
|
|
ImageEditor& create_new_editor(NonnullRefPtr<Image>);
|
2022-12-18 00:22:02 +03:00
|
|
|
ErrorOr<void> create_image_from_clipboard();
|
PixelPaint: Refactor `main.cpp` into `MainWidget`
Previously, all the UI setup was done in `main.cpp`, with a whole
bunch of lambdas,, and actions etc just being stored in the main
function. This is probably an artifact from back when it was first
created.
Most other applications now have a "MainWidget" class of some sort
which handles setting up all the UI/menubars, etc. More importantly,,
it also lets us handle application-wide events which we were
previously not able to do directly, since the main widget was just
a default GUI::Widget.
This patch moves all the core functionality of the PixelPaint
application into PixelPaint::MainWidget, which is then instantiated
by the main function. There is likely some more refactoring that
would help, but this commit is big enough as it is doing mostly
a direct port.
2021-09-06 07:11:46 +03:00
|
|
|
|
2022-08-21 21:33:03 +03:00
|
|
|
void image_editor_did_update_undo_stack();
|
|
|
|
|
2022-01-09 02:58:33 +03:00
|
|
|
void set_actions_enabled(bool enabled);
|
2023-02-25 09:45:55 +03:00
|
|
|
void set_mask_actions_for_layer(Layer* active_layer);
|
2022-01-09 02:58:33 +03:00
|
|
|
|
2022-11-05 00:32:17 +03:00
|
|
|
virtual void drag_enter_event(GUI::DragEvent&) override;
|
2021-09-06 07:24:12 +03:00
|
|
|
virtual void drop_event(GUI::DropEvent&) override;
|
|
|
|
|
2022-12-11 12:12:37 +03:00
|
|
|
void update_window_modified();
|
2023-12-16 17:19:34 +03:00
|
|
|
void update_status_bar(ByteString appended_text = ByteString::empty());
|
2022-12-11 12:12:37 +03:00
|
|
|
|
PixelPaint: Refactor `main.cpp` into `MainWidget`
Previously, all the UI setup was done in `main.cpp`, with a whole
bunch of lambdas,, and actions etc just being stored in the main
function. This is probably an artifact from back when it was first
created.
Most other applications now have a "MainWidget" class of some sort
which handles setting up all the UI/menubars, etc. More importantly,,
it also lets us handle application-wide events which we were
previously not able to do directly, since the main widget was just
a default GUI::Widget.
This patch moves all the core functionality of the PixelPaint
application into PixelPaint::MainWidget, which is then instantiated
by the main function. There is likely some more refactoring that
would help, but this commit is big enough as it is doing mostly
a direct port.
2021-09-06 07:11:46 +03:00
|
|
|
ProjectLoader m_loader;
|
|
|
|
|
|
|
|
RefPtr<ToolboxWidget> m_toolbox;
|
|
|
|
RefPtr<PaletteWidget> m_palette_widget;
|
2022-04-18 16:24:49 +03:00
|
|
|
RefPtr<HistogramWidget> m_histogram_widget;
|
2022-08-17 13:18:16 +03:00
|
|
|
RefPtr<VectorscopeWidget> m_vectorscope_widget;
|
PixelPaint: Refactor `main.cpp` into `MainWidget`
Previously, all the UI setup was done in `main.cpp`, with a whole
bunch of lambdas,, and actions etc just being stored in the main
function. This is probably an artifact from back when it was first
created.
Most other applications now have a "MainWidget" class of some sort
which handles setting up all the UI/menubars, etc. More importantly,,
it also lets us handle application-wide events which we were
previously not able to do directly, since the main widget was just
a default GUI::Widget.
This patch moves all the core functionality of the PixelPaint
application into PixelPaint::MainWidget, which is then instantiated
by the main function. There is likely some more refactoring that
would help, but this commit is big enough as it is doing mostly
a direct port.
2021-09-06 07:11:46 +03:00
|
|
|
RefPtr<LayerListWidget> m_layer_list_widget;
|
|
|
|
RefPtr<LayerPropertiesWidget> m_layer_properties_widget;
|
|
|
|
RefPtr<ToolPropertiesWidget> m_tool_properties_widget;
|
|
|
|
RefPtr<GUI::TabWidget> m_tab_widget;
|
|
|
|
RefPtr<GUI::Statusbar> m_statusbar;
|
2021-11-22 02:49:10 +03:00
|
|
|
RefPtr<GUI::ComboBox> m_zoom_combobox;
|
PixelPaint: Refactor `main.cpp` into `MainWidget`
Previously, all the UI setup was done in `main.cpp`, with a whole
bunch of lambdas,, and actions etc just being stored in the main
function. This is probably an artifact from back when it was first
created.
Most other applications now have a "MainWidget" class of some sort
which handles setting up all the UI/menubars, etc. More importantly,,
it also lets us handle application-wide events which we were
previously not able to do directly, since the main widget was just
a default GUI::Widget.
This patch moves all the core functionality of the PixelPaint
application into PixelPaint::MainWidget, which is then instantiated
by the main function. There is likely some more refactoring that
would help, but this commit is big enough as it is doing mostly
a direct port.
2021-09-06 07:11:46 +03:00
|
|
|
|
2022-01-09 02:58:33 +03:00
|
|
|
RefPtr<GUI::Menu> m_export_submenu;
|
|
|
|
RefPtr<GUI::Menu> m_edit_menu;
|
|
|
|
RefPtr<GUI::Menu> m_view_menu;
|
|
|
|
RefPtr<GUI::Menu> m_tool_menu;
|
|
|
|
RefPtr<GUI::Menu> m_image_menu;
|
|
|
|
RefPtr<GUI::Menu> m_layer_menu;
|
|
|
|
RefPtr<GUI::Menu> m_filter_menu;
|
|
|
|
|
PixelPaint: Refactor `main.cpp` into `MainWidget`
Previously, all the UI setup was done in `main.cpp`, with a whole
bunch of lambdas,, and actions etc just being stored in the main
function. This is probably an artifact from back when it was first
created.
Most other applications now have a "MainWidget" class of some sort
which handles setting up all the UI/menubars, etc. More importantly,,
it also lets us handle application-wide events which we were
previously not able to do directly, since the main widget was just
a default GUI::Widget.
This patch moves all the core functionality of the PixelPaint
application into PixelPaint::MainWidget, which is then instantiated
by the main function. There is likely some more refactoring that
would help, but this commit is big enough as it is doing mostly
a direct port.
2021-09-06 07:11:46 +03:00
|
|
|
RefPtr<GUI::Action> m_new_image_action;
|
2021-11-26 23:04:12 +03:00
|
|
|
RefPtr<GUI::Action> m_new_image_from_clipboard_action;
|
PixelPaint: Refactor `main.cpp` into `MainWidget`
Previously, all the UI setup was done in `main.cpp`, with a whole
bunch of lambdas,, and actions etc just being stored in the main
function. This is probably an artifact from back when it was first
created.
Most other applications now have a "MainWidget" class of some sort
which handles setting up all the UI/menubars, etc. More importantly,,
it also lets us handle application-wide events which we were
previously not able to do directly, since the main widget was just
a default GUI::Widget.
This patch moves all the core functionality of the PixelPaint
application into PixelPaint::MainWidget, which is then instantiated
by the main function. There is likely some more refactoring that
would help, but this commit is big enough as it is doing mostly
a direct port.
2021-09-06 07:11:46 +03:00
|
|
|
RefPtr<GUI::Action> m_open_image_action;
|
2022-01-04 19:48:49 +03:00
|
|
|
RefPtr<GUI::Action> m_save_image_action;
|
PixelPaint: Refactor `main.cpp` into `MainWidget`
Previously, all the UI setup was done in `main.cpp`, with a whole
bunch of lambdas,, and actions etc just being stored in the main
function. This is probably an artifact from back when it was first
created.
Most other applications now have a "MainWidget" class of some sort
which handles setting up all the UI/menubars, etc. More importantly,,
it also lets us handle application-wide events which we were
previously not able to do directly, since the main widget was just
a default GUI::Widget.
This patch moves all the core functionality of the PixelPaint
application into PixelPaint::MainWidget, which is then instantiated
by the main function. There is likely some more refactoring that
would help, but this commit is big enough as it is doing mostly
a direct port.
2021-09-06 07:11:46 +03:00
|
|
|
RefPtr<GUI::Action> m_save_image_as_action;
|
2022-01-09 02:58:33 +03:00
|
|
|
RefPtr<GUI::Action> m_close_image_action;
|
2022-04-24 11:46:59 +03:00
|
|
|
RefPtr<GUI::Action> m_levels_dialog_action;
|
PixelPaint: Refactor `main.cpp` into `MainWidget`
Previously, all the UI setup was done in `main.cpp`, with a whole
bunch of lambdas,, and actions etc just being stored in the main
function. This is probably an artifact from back when it was first
created.
Most other applications now have a "MainWidget" class of some sort
which handles setting up all the UI/menubars, etc. More importantly,,
it also lets us handle application-wide events which we were
previously not able to do directly, since the main widget was just
a default GUI::Widget.
This patch moves all the core functionality of the PixelPaint
application into PixelPaint::MainWidget, which is then instantiated
by the main function. There is likely some more refactoring that
would help, but this commit is big enough as it is doing mostly
a direct port.
2021-09-06 07:11:46 +03:00
|
|
|
|
2022-03-19 01:36:17 +03:00
|
|
|
RefPtr<GUI::Action> m_cut_action;
|
PixelPaint: Refactor `main.cpp` into `MainWidget`
Previously, all the UI setup was done in `main.cpp`, with a whole
bunch of lambdas,, and actions etc just being stored in the main
function. This is probably an artifact from back when it was first
created.
Most other applications now have a "MainWidget" class of some sort
which handles setting up all the UI/menubars, etc. More importantly,,
it also lets us handle application-wide events which we were
previously not able to do directly, since the main widget was just
a default GUI::Widget.
This patch moves all the core functionality of the PixelPaint
application into PixelPaint::MainWidget, which is then instantiated
by the main function. There is likely some more refactoring that
would help, but this commit is big enough as it is doing mostly
a direct port.
2021-09-06 07:11:46 +03:00
|
|
|
RefPtr<GUI::Action> m_copy_action;
|
|
|
|
RefPtr<GUI::Action> m_copy_merged_action;
|
|
|
|
RefPtr<GUI::Action> m_paste_action;
|
|
|
|
RefPtr<GUI::Action> m_undo_action;
|
|
|
|
RefPtr<GUI::Action> m_redo_action;
|
|
|
|
|
|
|
|
RefPtr<GUI::Action> m_zoom_in_action;
|
|
|
|
RefPtr<GUI::Action> m_zoom_out_action;
|
|
|
|
RefPtr<GUI::Action> m_reset_zoom_action;
|
|
|
|
RefPtr<GUI::Action> m_add_guide_action;
|
|
|
|
RefPtr<GUI::Action> m_show_guides_action;
|
2021-09-05 13:22:27 +03:00
|
|
|
RefPtr<GUI::Action> m_show_rulers_action;
|
2021-11-19 19:26:49 +03:00
|
|
|
RefPtr<GUI::Action> m_show_active_layer_boundary_action;
|
2022-09-01 01:53:23 +03:00
|
|
|
|
|
|
|
RefPtr<GUI::Action> m_layer_via_copy;
|
|
|
|
RefPtr<GUI::Action> m_layer_via_cut;
|
2022-12-14 08:22:03 +03:00
|
|
|
|
2023-02-25 09:45:55 +03:00
|
|
|
RefPtr<GUI::Action> m_add_mask_action;
|
|
|
|
RefPtr<GUI::Action> m_delete_mask_action;
|
2023-02-25 09:46:18 +03:00
|
|
|
RefPtr<GUI::Action> m_apply_mask_action;
|
2023-05-12 17:07:51 +03:00
|
|
|
RefPtr<GUI::Action> m_add_editing_mask_action;
|
|
|
|
RefPtr<GUI::Action> m_invert_mask_action;
|
|
|
|
RefPtr<GUI::Action> m_clear_mask_action;
|
2023-06-13 15:59:32 +03:00
|
|
|
RefPtr<GUI::Action> m_toggle_mask_visibility_action;
|
2023-06-13 16:49:29 +03:00
|
|
|
RefPtr<GUI::Action> m_open_luminosity_masking_action;
|
2023-06-23 13:43:59 +03:00
|
|
|
RefPtr<GUI::Action> m_open_color_masking_action;
|
2023-02-25 09:45:55 +03:00
|
|
|
|
2022-12-14 08:22:03 +03:00
|
|
|
Gfx::IntPoint m_last_image_editor_mouse_position;
|
PixelPaint: Refactor `main.cpp` into `MainWidget`
Previously, all the UI setup was done in `main.cpp`, with a whole
bunch of lambdas,, and actions etc just being stored in the main
function. This is probably an artifact from back when it was first
created.
Most other applications now have a "MainWidget" class of some sort
which handles setting up all the UI/menubars, etc. More importantly,,
it also lets us handle application-wide events which we were
previously not able to do directly, since the main widget was just
a default GUI::Widget.
This patch moves all the core functionality of the PixelPaint
application into PixelPaint::MainWidget, which is then instantiated
by the main function. There is likely some more refactoring that
would help, but this commit is big enough as it is doing mostly
a direct port.
2021-09-06 07:11:46 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|