summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Applications/PixelPaint/CMakeLists.txt1
-rw-r--r--Userland/Applications/PixelPaint/IconBag.cpp36
-rw-r--r--Userland/Applications/PixelPaint/IconBag.h35
-rw-r--r--Userland/Applications/PixelPaint/MainWidget.cpp40
-rw-r--r--Userland/Applications/PixelPaint/MainWidget.h3
-rw-r--r--Userland/Applications/PixelPaint/main.cpp2
6 files changed, 97 insertions, 20 deletions
diff --git a/Userland/Applications/PixelPaint/CMakeLists.txt b/Userland/Applications/PixelPaint/CMakeLists.txt
index 8919cc3695..d3ca024630 100644
--- a/Userland/Applications/PixelPaint/CMakeLists.txt
+++ b/Userland/Applications/PixelPaint/CMakeLists.txt
@@ -30,6 +30,7 @@ set(SOURCES
Filters/LaplaceDiagonal.cpp
Filters/Sepia.cpp
Filters/Sharpen.cpp
+ IconBag.cpp
Image.cpp
ImageEditor.cpp
Layer.cpp
diff --git a/Userland/Applications/PixelPaint/IconBag.cpp b/Userland/Applications/PixelPaint/IconBag.cpp
new file mode 100644
index 0000000000..88017b99e0
--- /dev/null
+++ b/Userland/Applications/PixelPaint/IconBag.cpp
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2022, Brandon Jordan <brandonjordan124@gmail.com>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <AK/String.h>
+#include <Applications/PixelPaint/IconBag.h>
+
+namespace PixelPaint {
+ErrorOr<IconBag> IconBag::try_create()
+{
+ IconBag icon_bag;
+
+ icon_bag.filetype_pixelpaint = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-pixelpaint.png"));
+ icon_bag.new_clipboard = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/new-clipboard.png"));
+ icon_bag.file_export = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/file-export.png"));
+ icon_bag.edit_copy = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png"));
+ icon_bag.clear_selection = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/clear-selection.png"));
+ icon_bag.swap_colors = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/swap-colors.png"));
+ icon_bag.default_colors = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/default-colors.png"));
+ icon_bag.edit_flip_vertical = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-flip-vertical.png"));
+ icon_bag.edit_flip_horizontal = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-flip-horizontal.png"));
+ icon_bag.new_layer = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new-layer.png"));
+ icon_bag.previous_layer = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/previous-layer.png"));
+ icon_bag.next_layer = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/next-layer.png"));
+ icon_bag.top_layer = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/top-layer.png"));
+ icon_bag.bottom_layer = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/bottom-layer.png"));
+ icon_bag.active_layer_up = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/active-layer-up.png"));
+ icon_bag.active_layer_down = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/active-layer-down.png"));
+ icon_bag.delete_layer = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png"));
+ icon_bag.filter = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/filter.png"));
+
+ return icon_bag;
+}
+}
diff --git a/Userland/Applications/PixelPaint/IconBag.h b/Userland/Applications/PixelPaint/IconBag.h
new file mode 100644
index 0000000000..eab3879073
--- /dev/null
+++ b/Userland/Applications/PixelPaint/IconBag.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2022, Brandon Jordan <brandonjordan124@gmail.com>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <AK/Error.h>
+#include <LibGfx/Bitmap.h>
+
+namespace PixelPaint {
+struct IconBag final {
+ static ErrorOr<IconBag> try_create();
+
+ RefPtr<Gfx::Bitmap> filetype_pixelpaint { nullptr };
+ RefPtr<Gfx::Bitmap> new_clipboard { nullptr };
+ RefPtr<Gfx::Bitmap> file_export { nullptr };
+ RefPtr<Gfx::Bitmap> edit_copy { nullptr };
+ RefPtr<Gfx::Bitmap> clear_selection { nullptr };
+ RefPtr<Gfx::Bitmap> swap_colors { nullptr };
+ RefPtr<Gfx::Bitmap> default_colors { nullptr };
+ RefPtr<Gfx::Bitmap> edit_flip_vertical { nullptr };
+ RefPtr<Gfx::Bitmap> edit_flip_horizontal { nullptr };
+ RefPtr<Gfx::Bitmap> new_layer { nullptr };
+ RefPtr<Gfx::Bitmap> previous_layer { nullptr };
+ RefPtr<Gfx::Bitmap> next_layer { nullptr };
+ RefPtr<Gfx::Bitmap> top_layer { nullptr };
+ RefPtr<Gfx::Bitmap> bottom_layer { nullptr };
+ RefPtr<Gfx::Bitmap> active_layer_up { nullptr };
+ RefPtr<Gfx::Bitmap> active_layer_down { nullptr };
+ RefPtr<Gfx::Bitmap> delete_layer { nullptr };
+ RefPtr<Gfx::Bitmap> filter { nullptr };
+};
+}
diff --git a/Userland/Applications/PixelPaint/MainWidget.cpp b/Userland/Applications/PixelPaint/MainWidget.cpp
index c144c0f870..d1509c0326 100644
--- a/Userland/Applications/PixelPaint/MainWidget.cpp
+++ b/Userland/Applications/PixelPaint/MainWidget.cpp
@@ -25,11 +25,12 @@
#include <LibGUI/MessageBox.h>
#include <LibGUI/Toolbar.h>
#include <LibGUI/Window.h>
-#include <LibGfx/Bitmap.h>
#include <LibGfx/Rect.h>
namespace PixelPaint {
+IconBag g_icon_bag;
+
MainWidget::MainWidget()
: Widget()
{
@@ -107,7 +108,7 @@ void MainWidget::initialize_menubar(GUI::Window& window)
auto& file_menu = window.add_menu("&File");
m_new_image_action = GUI::Action::create(
- "&New Image...", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-pixelpaint.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
+ "&New Image...", { Mod_Ctrl, Key_N }, g_icon_bag.filetype_pixelpaint, [&](auto&) {
auto dialog = PixelPaint::CreateNewImageDialog::construct(&window);
if (dialog->exec() == GUI::Dialog::ExecOK) {
auto image = PixelPaint::Image::try_create_with_size(dialog->image_size()).release_value_but_fixme_should_propagate_errors();
@@ -126,7 +127,7 @@ void MainWidget::initialize_menubar(GUI::Window& window)
});
m_new_image_from_clipboard_action = GUI::Action::create(
- "&New Image from Clipboard", { Mod_Ctrl | Mod_Shift, Key_V }, Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/new-clipboard.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
+ "&New Image from Clipboard", { Mod_Ctrl | Mod_Shift, Key_V }, g_icon_bag.new_clipboard, [&](auto&) {
create_image_from_clipboard();
});
@@ -186,7 +187,7 @@ void MainWidget::initialize_menubar(GUI::Window& window)
GUI::MessageBox::show_error(&window, String::formatted("Export to PNG failed: {}", result.error()));
}));
- m_export_submenu->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/file-export.png").release_value_but_fixme_should_propagate_errors());
+ m_export_submenu->set_icon(g_icon_bag.file_export);
file_menu.add_separator();
@@ -222,8 +223,7 @@ void MainWidget::initialize_menubar(GUI::Window& window)
});
m_copy_merged_action = GUI::Action::create(
- "Copy &Merged", { Mod_Ctrl | Mod_Shift, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png").release_value_but_fixme_should_propagate_errors(),
- [&](auto&) {
+ "Copy &Merged", { Mod_Ctrl | Mod_Shift, Key_C }, g_icon_bag.edit_copy, [&](auto&) {
auto* editor = current_image_editor();
VERIFY(editor);
@@ -282,7 +282,7 @@ void MainWidget::initialize_menubar(GUI::Window& window)
editor->selection().merge(editor->active_layer()->relative_rect(), PixelPaint::Selection::MergeMode::Set);
}));
m_edit_menu->add_action(GUI::Action::create(
- "Clear &Selection", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/clear-selection.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
+ "Clear &Selection", g_icon_bag.clear_selection, [&](auto&) {
auto* editor = current_image_editor();
VERIFY(editor);
editor->selection().clear();
@@ -290,7 +290,7 @@ void MainWidget::initialize_menubar(GUI::Window& window)
m_edit_menu->add_separator();
m_edit_menu->add_action(GUI::Action::create(
- "S&wap Colors", { Mod_None, Key_X }, Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/swap-colors.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
+ "S&wap Colors", { Mod_None, Key_X }, g_icon_bag.swap_colors, [&](auto&) {
auto* editor = current_image_editor();
VERIFY(editor);
auto old_primary_color = editor->primary_color();
@@ -298,7 +298,7 @@ void MainWidget::initialize_menubar(GUI::Window& window)
editor->set_secondary_color(old_primary_color);
}));
m_edit_menu->add_action(GUI::Action::create(
- "&Default Colors", { Mod_None, Key_D }, Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/default-colors.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
+ "&Default Colors", { Mod_None, Key_D }, g_icon_bag.default_colors, [&](auto&) {
auto* editor = current_image_editor();
VERIFY(editor);
editor->set_primary_color(Color::Black);
@@ -434,13 +434,13 @@ void MainWidget::initialize_menubar(GUI::Window& window)
m_image_menu = window.add_menu("&Image");
m_image_menu->add_action(GUI::Action::create(
- "Flip &Vertically", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-flip-vertical.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
+ "Flip &Vertically", g_icon_bag.edit_flip_vertical, [&](auto&) {
auto* editor = current_image_editor();
VERIFY(editor);
editor->image().flip(Gfx::Orientation::Vertical);
}));
m_image_menu->add_action(GUI::Action::create(
- "Flip &Horizontally", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-flip-horizontal.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
+ "Flip &Horizontally", g_icon_bag.edit_flip_horizontal, [&](auto&) {
auto* editor = current_image_editor();
VERIFY(editor);
editor->image().flip(Gfx::Orientation::Horizontal);
@@ -475,7 +475,7 @@ void MainWidget::initialize_menubar(GUI::Window& window)
m_layer_menu = window.add_menu("&Layer");
m_layer_menu->add_action(GUI::Action::create(
- "New &Layer...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new-layer.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
+ "New &Layer...", { Mod_Ctrl | Mod_Shift, Key_N }, g_icon_bag.new_layer, [&](auto&) {
auto* editor = current_image_editor();
VERIFY(editor);
auto dialog = PixelPaint::CreateNewLayerDialog::construct(editor->image().size(), &window);
@@ -493,19 +493,19 @@ void MainWidget::initialize_menubar(GUI::Window& window)
m_layer_menu->add_separator();
m_layer_menu->add_action(GUI::Action::create(
- "Select &Previous Layer", { 0, Key_PageUp }, Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/previous-layer.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
+ "Select &Previous Layer", { 0, Key_PageUp }, g_icon_bag.previous_layer, [&](auto&) {
m_layer_list_widget->cycle_through_selection(1);
}));
m_layer_menu->add_action(GUI::Action::create(
- "Select &Next Layer", { 0, Key_PageDown }, Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/next-layer.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
+ "Select &Next Layer", { 0, Key_PageDown }, g_icon_bag.next_layer, [&](auto&) {
m_layer_list_widget->cycle_through_selection(-1);
}));
m_layer_menu->add_action(GUI::Action::create(
- "Select &Top Layer", { 0, Key_Home }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/top-layer.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
+ "Select &Top Layer", { 0, Key_Home }, g_icon_bag.top_layer, [&](auto&) {
m_layer_list_widget->select_top_layer();
}));
m_layer_menu->add_action(GUI::Action::create(
- "Select B&ottom Layer", { 0, Key_End }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/bottom-layer.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
+ "Select B&ottom Layer", { 0, Key_End }, g_icon_bag.bottom_layer, [&](auto&) {
m_layer_list_widget->select_bottom_layer();
}));
m_layer_menu->add_separator();
@@ -531,7 +531,7 @@ void MainWidget::initialize_menubar(GUI::Window& window)
}));
m_layer_menu->add_separator();
m_layer_menu->add_action(GUI::Action::create(
- "Move Active Layer &Up", { Mod_Ctrl, Key_PageUp }, Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/active-layer-up.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
+ "Move Active Layer &Up", { Mod_Ctrl, Key_PageUp }, g_icon_bag.active_layer_up, [&](auto&) {
auto* editor = current_image_editor();
VERIFY(editor);
auto active_layer = editor->active_layer();
@@ -540,7 +540,7 @@ void MainWidget::initialize_menubar(GUI::Window& window)
editor->image().move_layer_up(*active_layer);
}));
m_layer_menu->add_action(GUI::Action::create(
- "Move Active Layer &Down", { Mod_Ctrl, Key_PageDown }, Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/active-layer-down.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
+ "Move Active Layer &Down", { Mod_Ctrl, Key_PageDown }, g_icon_bag.active_layer_down, [&](auto&) {
auto* editor = current_image_editor();
VERIFY(editor);
auto active_layer = editor->active_layer();
@@ -550,7 +550,7 @@ void MainWidget::initialize_menubar(GUI::Window& window)
}));
m_layer_menu->add_separator();
m_layer_menu->add_action(GUI::Action::create(
- "&Remove Active Layer", { Mod_Ctrl, Key_D }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
+ "&Remove Active Layer", { Mod_Ctrl, Key_D }, g_icon_bag.delete_layer, [&](auto&) {
auto* editor = current_image_editor();
VERIFY(editor);
auto active_layer = editor->active_layer();
@@ -604,7 +604,7 @@ void MainWidget::initialize_menubar(GUI::Window& window)
m_filter_menu = window.add_menu("&Filter");
- m_filter_menu->add_action(GUI::Action::create("Filter &Gallery", Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/filter.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
+ m_filter_menu->add_action(GUI::Action::create("Filter &Gallery", g_icon_bag.filter, [&](auto&) {
auto* editor = current_image_editor();
VERIFY(editor);
auto dialog = PixelPaint::FilterGallery::construct(&window, editor);
diff --git a/Userland/Applications/PixelPaint/MainWidget.h b/Userland/Applications/PixelPaint/MainWidget.h
index 88e7e8df25..bf718933a8 100644
--- a/Userland/Applications/PixelPaint/MainWidget.h
+++ b/Userland/Applications/PixelPaint/MainWidget.h
@@ -7,6 +7,7 @@
#pragma once
#include "Guide.h"
+#include "IconBag.h"
#include "Image.h"
#include "ImageEditor.h"
#include "Layer.h"
@@ -27,6 +28,8 @@
namespace PixelPaint {
+extern IconBag g_icon_bag;
+
class MainWidget : public GUI::Widget {
C_OBJECT(MainWidget);
diff --git a/Userland/Applications/PixelPaint/main.cpp b/Userland/Applications/PixelPaint/main.cpp
index 6369aa921f..e2cebb31b9 100644
--- a/Userland/Applications/PixelPaint/main.cpp
+++ b/Userland/Applications/PixelPaint/main.cpp
@@ -40,6 +40,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto app_icon = GUI::Icon::default_icon("app-pixel-paint");
+ PixelPaint::g_icon_bag = TRY(PixelPaint::IconBag::try_create());
+
auto window = GUI::Window::construct();
window->set_title("Pixel Paint");
window->resize(800, 510);