mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-08 12:19:37 +03:00
PixelPaint: Alt shortcuts and book title capitalization in menus
This commit is contained in:
parent
095979dbcd
commit
4e56e9fa2a
Notes:
sideshowbarker
2024-07-18 20:35:42 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/4e56e9fa2af
@ -123,7 +123,7 @@ void MoveTool::on_context_menu(Layer& layer, GUI::ContextMenuEvent& event)
|
||||
m_editor));
|
||||
m_context_menu->add_separator();
|
||||
m_context_menu->add_action(GUI::Action::create(
|
||||
"Delete layer", Gfx::Bitmap::load_from_file("/res/icons/16x16/delete.png"), [this](auto&) {
|
||||
"&Delete Layer", Gfx::Bitmap::load_from_file("/res/icons/16x16/delete.png"), [this](auto&) {
|
||||
m_editor->image()->remove_layer(*m_context_menu_layer);
|
||||
// FIXME: This should not be done imperatively here. Perhaps a Image::Client interface that ImageEditor can implement?
|
||||
if (m_editor->active_layer() == m_context_menu_layer)
|
||||
|
@ -115,7 +115,7 @@ int main(int argc, char** argv)
|
||||
window->show();
|
||||
|
||||
auto menubar = GUI::MenuBar::construct();
|
||||
auto& app_menu = menubar->add_menu("File");
|
||||
auto& file_menu = menubar->add_menu("&File");
|
||||
|
||||
auto open_image_file = [&](auto& path) {
|
||||
auto image = PixelPaint::Image::create_from_file(path);
|
||||
@ -127,9 +127,9 @@ int main(int argc, char** argv)
|
||||
layer_list_widget.set_image(image);
|
||||
};
|
||||
|
||||
app_menu.add_action(
|
||||
file_menu.add_action(
|
||||
GUI::Action::create(
|
||||
"New", [&](auto&) {
|
||||
"&New Image...", [&](auto&) {
|
||||
auto dialog = PixelPaint::CreateNewImageDialog::construct(window);
|
||||
if (dialog->exec() == GUI::Dialog::ExecOK) {
|
||||
auto image = PixelPaint::Image::create_with_size(dialog->image_size());
|
||||
@ -143,43 +143,35 @@ int main(int argc, char** argv)
|
||||
}
|
||||
},
|
||||
window));
|
||||
app_menu.add_action(GUI::CommonActions::make_open_action([&](auto&) {
|
||||
file_menu.add_action(GUI::CommonActions::make_open_action([&](auto&) {
|
||||
Optional<String> open_path = GUI::FilePicker::get_open_filepath(window);
|
||||
|
||||
if (!open_path.has_value())
|
||||
return;
|
||||
|
||||
open_image_file(open_path.value());
|
||||
}));
|
||||
app_menu.add_action(GUI::CommonActions::make_save_as_action([&](auto&) {
|
||||
file_menu.add_action(GUI::CommonActions::make_save_as_action([&](auto&) {
|
||||
if (!image_editor.image())
|
||||
return;
|
||||
|
||||
Optional<String> save_path = GUI::FilePicker::get_save_filepath(window, "untitled", "pp");
|
||||
|
||||
if (!save_path.has_value())
|
||||
return;
|
||||
|
||||
image_editor.image()->save(save_path.value());
|
||||
}));
|
||||
auto& export_submenu = app_menu.add_submenu("Export");
|
||||
auto& export_submenu = file_menu.add_submenu("&Export");
|
||||
export_submenu.add_action(
|
||||
GUI::Action::create(
|
||||
"As BMP", [&](auto&) {
|
||||
"As &BMP", [&](auto&) {
|
||||
if (!image_editor.image())
|
||||
return;
|
||||
|
||||
Optional<String> save_path = GUI::FilePicker::get_save_filepath(window, "untitled", "bmp");
|
||||
|
||||
if (!save_path.has_value())
|
||||
return;
|
||||
|
||||
image_editor.image()->export_bmp(save_path.value());
|
||||
},
|
||||
window));
|
||||
export_submenu.add_action(
|
||||
GUI::Action::create(
|
||||
"As PNG", [&](auto&) {
|
||||
"As &PNG", [&](auto&) {
|
||||
if (!image_editor.image())
|
||||
return;
|
||||
|
||||
@ -192,13 +184,12 @@ int main(int argc, char** argv)
|
||||
},
|
||||
window));
|
||||
|
||||
app_menu.add_separator();
|
||||
app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
file_menu.add_separator();
|
||||
file_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the()->quit();
|
||||
return;
|
||||
}));
|
||||
|
||||
auto& edit_menu = menubar->add_menu("Edit");
|
||||
auto& edit_menu = menubar->add_menu("&Edit");
|
||||
auto paste_action = GUI::CommonActions::make_paste_action([&](auto&) {
|
||||
VERIFY(image_editor.image());
|
||||
auto bitmap = GUI::Clipboard::the().bitmap();
|
||||
@ -227,16 +218,16 @@ int main(int argc, char** argv)
|
||||
});
|
||||
edit_menu.add_action(redo_action);
|
||||
|
||||
auto& tool_menu = menubar->add_menu("Tool");
|
||||
auto& tool_menu = menubar->add_menu("&Tool");
|
||||
toolbox.for_each_tool([&](auto& tool) {
|
||||
if (tool.action())
|
||||
tool_menu.add_action(*tool.action());
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
||||
auto& layer_menu = menubar->add_menu("Layer");
|
||||
auto& layer_menu = menubar->add_menu("&Layer");
|
||||
layer_menu.add_action(GUI::Action::create(
|
||||
"Create new layer...", { Mod_Ctrl | Mod_Shift, Key_N }, [&](auto&) {
|
||||
"&New Layer...", { Mod_Ctrl | Mod_Shift, Key_N }, [&](auto&) {
|
||||
auto dialog = PixelPaint::CreateNewLayerDialog::construct(image_editor.image()->size(), window);
|
||||
if (dialog->exec() == GUI::Dialog::ExecOK) {
|
||||
auto layer = PixelPaint::Layer::create_with_size(*image_editor.image(), dialog->layer_size(), dialog->layer_name());
|
||||
@ -252,28 +243,28 @@ int main(int argc, char** argv)
|
||||
|
||||
layer_menu.add_separator();
|
||||
layer_menu.add_action(GUI::Action::create(
|
||||
"Select previous layer", { 0, Key_PageUp }, [&](auto&) {
|
||||
"Select &Previous Layer", { 0, Key_PageUp }, [&](auto&) {
|
||||
layer_list_widget.move_selection(1);
|
||||
},
|
||||
window));
|
||||
layer_menu.add_action(GUI::Action::create(
|
||||
"Select next layer", { 0, Key_PageDown }, [&](auto&) {
|
||||
"Select &Next Layer", { 0, Key_PageDown }, [&](auto&) {
|
||||
layer_list_widget.move_selection(-1);
|
||||
},
|
||||
window));
|
||||
layer_menu.add_action(GUI::Action::create(
|
||||
"Select top layer", { 0, Key_Home }, [&](auto&) {
|
||||
"Select &Top Layer", { 0, Key_Home }, [&](auto&) {
|
||||
layer_list_widget.select_top_layer();
|
||||
},
|
||||
window));
|
||||
layer_menu.add_action(GUI::Action::create(
|
||||
"Select bottom layer", { 0, Key_End }, [&](auto&) {
|
||||
"Select &Bottom Layer", { 0, Key_End }, [&](auto&) {
|
||||
layer_list_widget.select_bottom_layer();
|
||||
},
|
||||
window));
|
||||
layer_menu.add_separator();
|
||||
layer_menu.add_action(GUI::Action::create(
|
||||
"Move active layer up", { Mod_Ctrl, Key_PageUp }, [&](auto&) {
|
||||
"Move Active Layer &Up", { Mod_Ctrl, Key_PageUp }, [&](auto&) {
|
||||
auto active_layer = image_editor.active_layer();
|
||||
if (!active_layer)
|
||||
return;
|
||||
@ -281,7 +272,7 @@ int main(int argc, char** argv)
|
||||
},
|
||||
window));
|
||||
layer_menu.add_action(GUI::Action::create(
|
||||
"Move active layer down", { Mod_Ctrl, Key_PageDown }, [&](auto&) {
|
||||
"Move Active Layer &Down", { Mod_Ctrl, Key_PageDown }, [&](auto&) {
|
||||
auto active_layer = image_editor.active_layer();
|
||||
if (!active_layer)
|
||||
return;
|
||||
@ -290,7 +281,7 @@ int main(int argc, char** argv)
|
||||
window));
|
||||
layer_menu.add_separator();
|
||||
layer_menu.add_action(GUI::Action::create(
|
||||
"Remove active layer", { Mod_Ctrl, Key_D }, [&](auto&) {
|
||||
"&Remove Active Layer", { Mod_Ctrl, Key_D }, [&](auto&) {
|
||||
auto active_layer = image_editor.active_layer();
|
||||
if (!active_layer)
|
||||
return;
|
||||
@ -299,11 +290,11 @@ int main(int argc, char** argv)
|
||||
},
|
||||
window));
|
||||
|
||||
auto& filter_menu = menubar->add_menu("Filter");
|
||||
auto& spatial_filters_menu = filter_menu.add_submenu("Spatial");
|
||||
auto& filter_menu = menubar->add_menu("&Filter");
|
||||
auto& spatial_filters_menu = filter_menu.add_submenu("&Spatial");
|
||||
|
||||
auto& edge_detect_submenu = spatial_filters_menu.add_submenu("Edge Detect");
|
||||
edge_detect_submenu.add_action(GUI::Action::create("Laplacian (cardinal)", [&](auto&) {
|
||||
auto& edge_detect_submenu = spatial_filters_menu.add_submenu("&Edge Detect");
|
||||
edge_detect_submenu.add_action(GUI::Action::create("Laplacian (&Cardinal)", [&](auto&) {
|
||||
if (auto* layer = image_editor.active_layer()) {
|
||||
Gfx::LaplacianFilter filter;
|
||||
if (auto parameters = PixelPaint::FilterParameters<Gfx::LaplacianFilter>::get(false)) {
|
||||
@ -312,7 +303,7 @@ int main(int argc, char** argv)
|
||||
}
|
||||
}
|
||||
}));
|
||||
edge_detect_submenu.add_action(GUI::Action::create("Laplacian (diagonal)", [&](auto&) {
|
||||
edge_detect_submenu.add_action(GUI::Action::create("Laplacian (&Diagonal)", [&](auto&) {
|
||||
if (auto* layer = image_editor.active_layer()) {
|
||||
Gfx::LaplacianFilter filter;
|
||||
if (auto parameters = PixelPaint::FilterParameters<Gfx::LaplacianFilter>::get(true)) {
|
||||
@ -321,8 +312,8 @@ int main(int argc, char** argv)
|
||||
}
|
||||
}
|
||||
}));
|
||||
auto& blur_submenu = spatial_filters_menu.add_submenu("Blur and Sharpen");
|
||||
blur_submenu.add_action(GUI::Action::create("Gaussian Blur (3x3)", [&](auto&) {
|
||||
auto& blur_submenu = spatial_filters_menu.add_submenu("&Blur and Sharpen");
|
||||
blur_submenu.add_action(GUI::Action::create("&Gaussian Blur (3x3)", [&](auto&) {
|
||||
if (auto* layer = image_editor.active_layer()) {
|
||||
Gfx::SpatialGaussianBlurFilter<3> filter;
|
||||
if (auto parameters = PixelPaint::FilterParameters<Gfx::SpatialGaussianBlurFilter<3>>::get()) {
|
||||
@ -331,7 +322,7 @@ int main(int argc, char** argv)
|
||||
}
|
||||
}
|
||||
}));
|
||||
blur_submenu.add_action(GUI::Action::create("Gaussian Blur (5x5)", [&](auto&) {
|
||||
blur_submenu.add_action(GUI::Action::create("&Gaussian Blur (5x5)", [&](auto&) {
|
||||
if (auto* layer = image_editor.active_layer()) {
|
||||
Gfx::SpatialGaussianBlurFilter<5> filter;
|
||||
if (auto parameters = PixelPaint::FilterParameters<Gfx::SpatialGaussianBlurFilter<5>>::get()) {
|
||||
@ -340,7 +331,7 @@ int main(int argc, char** argv)
|
||||
}
|
||||
}
|
||||
}));
|
||||
blur_submenu.add_action(GUI::Action::create("Box Blur (3x3)", [&](auto&) {
|
||||
blur_submenu.add_action(GUI::Action::create("&Box Blur (3x3)", [&](auto&) {
|
||||
if (auto* layer = image_editor.active_layer()) {
|
||||
Gfx::BoxBlurFilter<3> filter;
|
||||
if (auto parameters = PixelPaint::FilterParameters<Gfx::BoxBlurFilter<3>>::get()) {
|
||||
@ -349,7 +340,7 @@ int main(int argc, char** argv)
|
||||
}
|
||||
}
|
||||
}));
|
||||
blur_submenu.add_action(GUI::Action::create("Box Blur (5x5)", [&](auto&) {
|
||||
blur_submenu.add_action(GUI::Action::create("&Box Blur (5x5)", [&](auto&) {
|
||||
if (auto* layer = image_editor.active_layer()) {
|
||||
Gfx::BoxBlurFilter<5> filter;
|
||||
if (auto parameters = PixelPaint::FilterParameters<Gfx::BoxBlurFilter<5>>::get()) {
|
||||
@ -358,7 +349,7 @@ int main(int argc, char** argv)
|
||||
}
|
||||
}
|
||||
}));
|
||||
blur_submenu.add_action(GUI::Action::create("Sharpen", [&](auto&) {
|
||||
blur_submenu.add_action(GUI::Action::create("&Sharpen", [&](auto&) {
|
||||
if (auto* layer = image_editor.active_layer()) {
|
||||
Gfx::SharpenFilter filter;
|
||||
if (auto parameters = PixelPaint::FilterParameters<Gfx::SharpenFilter>::get()) {
|
||||
@ -369,7 +360,7 @@ int main(int argc, char** argv)
|
||||
}));
|
||||
|
||||
spatial_filters_menu.add_separator();
|
||||
spatial_filters_menu.add_action(GUI::Action::create("Generic 5x5 Convolution", [&](auto&) {
|
||||
spatial_filters_menu.add_action(GUI::Action::create("Generic 5x5 &Convolution", [&](auto&) {
|
||||
if (auto* layer = image_editor.active_layer()) {
|
||||
Gfx::GenericConvolutionFilter<5> filter;
|
||||
if (auto parameters = PixelPaint::FilterParameters<Gfx::GenericConvolutionFilter<5>>::get(window)) {
|
||||
@ -379,7 +370,7 @@ int main(int argc, char** argv)
|
||||
}
|
||||
}));
|
||||
|
||||
auto& help_menu = menubar->add_menu("Help");
|
||||
auto& help_menu = menubar->add_menu("&Help");
|
||||
help_menu.add_action(GUI::CommonActions::make_about_action("PixelPaint", app_icon, window));
|
||||
|
||||
window->set_menubar(move(menubar));
|
||||
|
Loading…
Reference in New Issue
Block a user