|
@@ -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);
|