diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index ff923af9d..b3a3e014f 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -53,7 +53,7 @@ add_custom_command( DEPENDS gen) list(APPEND generated_files ${output_fn}) -# Generate strings.h from data/strings/en.ini +# Generate strings.ini.h from data/strings/en.ini set(strings_en_ini ${CMAKE_SOURCE_DIR}/data/strings/en.ini) set(output_fn ${CMAKE_CURRENT_BINARY_DIR}/strings.ini.h) add_custom_command( @@ -65,6 +65,17 @@ add_custom_command( DEPENDS gen) list(APPEND generated_files ${output_fn}) +# Generate command_ids.ini.h from data/strings/en.ini +set(output_fn ${CMAKE_CURRENT_BINARY_DIR}/command_ids.ini.h) +add_custom_command( + OUTPUT ${output_fn} + COMMAND ${CMAKE_BINARY_DIR}/bin/gen --input ${strings_en_ini} --command-ids > ${output_fn}.tmp + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${output_fn}.tmp ${output_fn} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + MAIN_DEPENDENCY ${strings_en_ini} + DEPENDS gen) +list(APPEND generated_files ${output_fn}) + # Check translations file(GLOB string_files ${CMAKE_SOURCE_DIR}/data/strings/*.ini) set(output_fn ${CMAKE_CURRENT_BINARY_DIR}/check-translations.txt) diff --git a/src/app/app_menus.cpp b/src/app/app_menus.cpp index a6553797e..8112a5045 100644 --- a/src/app/app_menus.cpp +++ b/src/app/app_menus.cpp @@ -382,7 +382,7 @@ bool AppMenus::rebuildRecentList() return false; Command* cmd_open_file = - Commands::instance()->byId(CommandId::OpenFile); + Commands::instance()->byId(CommandId::OpenFile()); Menu* submenu = list_menuitem->getSubmenu(); if (submenu) { @@ -627,21 +627,21 @@ void AppMenus::createNativeMenus() #ifdef __APPLE__ // Create default macOS app menus (App ... Window) { she::MenuItemInfo about("About " PACKAGE); - auto native = get_native_shortcut_for_command(CommandId::About); + auto native = get_native_shortcut_for_command(CommandId::About()); about.shortcut = native.shortcut; about.execute = [native]{ if (can_call_global_shortcut(&native)) { - Command* cmd = Commands::instance()->byId(CommandId::About); + Command* cmd = Commands::instance()->byId(CommandId::About()); UIContext::instance()->executeCommand(cmd); } }; she::MenuItemInfo preferences("Preferences..."); - native = get_native_shortcut_for_command(CommandId::Options); + native = get_native_shortcut_for_command(CommandId::Options()); preferences.shortcut = native.shortcut; preferences.execute = [native]{ if (can_call_global_shortcut(&native)) { - Command* cmd = Commands::instance()->byId(CommandId::Options); + Command* cmd = Commands::instance()->byId(CommandId::Options()); UIContext::instance()->executeCommand(cmd); } }; diff --git a/src/app/cli/cli_processor.cpp b/src/app/cli/cli_processor.cpp index c7238734e..62bdd1c3d 100644 --- a/src/app/cli/cli_processor.cpp +++ b/src/app/cli/cli_processor.cpp @@ -335,7 +335,7 @@ void CliProcessor::process() } // --scale else if (opt == &m_options.scale()) { - Command* command = Commands::instance()->byId(CommandId::SpriteSize); + Command* command = Commands::instance()->byId(CommandId::SpriteSize()); double scale = strtod(value.value().c_str(), NULL); static_cast(command)->setScale(scale, scale); @@ -364,7 +364,7 @@ void CliProcessor::process() } // --color-mode else if (opt == &m_options.colorMode()) { - Command* command = Commands::instance()->byId(CommandId::ChangePixelFormat); + Command* command = Commands::instance()->byId(CommandId::ChangePixelFormat()); Params params; if (value.value() == "rgb") { params.set("format", "rgb"); @@ -422,7 +422,7 @@ void CliProcessor::process() scaleHeight = (doc->height() > maxHeight ? maxHeight / doc->height() : 1.0); if (scaleWidth < 1.0 || scaleHeight < 1.0) { scale = MIN(scaleWidth, scaleHeight); - Command* command = Commands::instance()->byId(CommandId::SpriteSize); + Command* command = Commands::instance()->byId(CommandId::SpriteSize()); static_cast(command)->setScale(scale, scale); ctx->executeCommand(command); } @@ -494,7 +494,7 @@ bool CliProcessor::openFile(CliOpenFile& cof) Context* ctx = UIContext::instance(); app::Document* oldDoc = ctx->activeDocument(); - Command* openCommand = Commands::instance()->byId(CommandId::OpenFile); + Command* openCommand = Commands::instance()->byId(CommandId::OpenFile()); Params params; params.set("filename", cof.filename.c_str()); if (cof.oneFrame) @@ -581,8 +581,8 @@ void CliProcessor::saveFile(const CliOpenFile& cof) UIContext* ctx = UIContext::instance(); ctx->setActiveDocument(cof.document); - Command* trimCommand = Commands::instance()->byId(CommandId::AutocropSprite); - Command* undoCommand = Commands::instance()->byId(CommandId::Undo); + Command* trimCommand = Commands::instance()->byId(CommandId::AutocropSprite()); + Command* undoCommand = Commands::instance()->byId(CommandId::Undo()); app::Document* doc = cof.document; bool clearUndo = false; @@ -593,7 +593,7 @@ void CliProcessor::saveFile(const CliOpenFile& cof) cropParams.set("width", base::convert_to(cof.crop.w).c_str()); cropParams.set("height", base::convert_to(cof.crop.h).c_str()); ctx->executeCommand( - Commands::instance()->byId(CommandId::CropSprite), + Commands::instance()->byId(CommandId::CropSprite()), cropParams); } diff --git a/src/app/cli/default_cli_delegate.cpp b/src/app/cli/default_cli_delegate.cpp index 75582f142..8f973ded3 100644 --- a/src/app/cli/default_cli_delegate.cpp +++ b/src/app/cli/default_cli_delegate.cpp @@ -76,7 +76,7 @@ void DefaultCliDelegate::afterOpenFile(const CliOpenFile& cof) void DefaultCliDelegate::saveFile(const CliOpenFile& cof) { Context* ctx = UIContext::instance(); - Command* saveAsCommand = Commands::instance()->byId(CommandId::SaveFileCopyAs); + Command* saveAsCommand = Commands::instance()->byId(CommandId::SaveFileCopyAs()); Params params; params.set("filename", cof.filename.c_str()); params.set("filename-format", cof.filenameFormat.c_str()); @@ -101,7 +101,7 @@ void DefaultCliDelegate::loadPalette(const CliOpenFile& cof, base::UniquePtr palette(load_palette(filename.c_str())); if (palette) { Context* ctx = UIContext::instance(); - Command* loadPalCommand = Commands::instance()->byId(CommandId::LoadPalette); + Command* loadPalCommand = Commands::instance()->byId(CommandId::LoadPalette()); Params params; params.set("filename", filename.c_str()); diff --git a/src/app/commands/cmd_about.cpp b/src/app/commands/cmd_about.cpp index 7d21009ae..b388cb062 100644 --- a/src/app/commands/cmd_about.cpp +++ b/src/app/commands/cmd_about.cpp @@ -29,7 +29,7 @@ protected: }; AboutCommand::AboutCommand() - : Command("About", CmdUIOnlyFlag) + : Command(CommandId::About(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_add_color.cpp b/src/app/commands/cmd_add_color.cpp index 6c340fb7d..49469368f 100644 --- a/src/app/commands/cmd_add_color.cpp +++ b/src/app/commands/cmd_add_color.cpp @@ -45,7 +45,7 @@ protected: }; AddColorCommand::AddColorCommand() - : Command("AddColor", CmdUIOnlyFlag) + : Command(CommandId::AddColor(), CmdUIOnlyFlag) , m_source(Source::Fg) { } diff --git a/src/app/commands/cmd_advanced_mode.cpp b/src/app/commands/cmd_advanced_mode.cpp index 907d9b2cf..4dbbe45c5 100644 --- a/src/app/commands/cmd_advanced_mode.cpp +++ b/src/app/commands/cmd_advanced_mode.cpp @@ -33,7 +33,7 @@ protected: }; AdvancedModeCommand::AdvancedModeCommand() - : Command("AdvancedMode", CmdUIOnlyFlag) + : Command(CommandId::AdvancedMode(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_background_from_layer.cpp b/src/app/commands/cmd_background_from_layer.cpp index aa1eb374d..5af76ba5b 100644 --- a/src/app/commands/cmd_background_from_layer.cpp +++ b/src/app/commands/cmd_background_from_layer.cpp @@ -30,7 +30,7 @@ protected: }; BackgroundFromLayerCommand::BackgroundFromLayerCommand() - : Command("BackgroundFromLayer", CmdRecordableFlag) + : Command(CommandId::BackgroundFromLayer(), CmdRecordableFlag) { } diff --git a/src/app/commands/cmd_cancel.cpp b/src/app/commands/cmd_cancel.cpp index 2949b7ab0..347655b0b 100644 --- a/src/app/commands/cmd_cancel.cpp +++ b/src/app/commands/cmd_cancel.cpp @@ -38,7 +38,7 @@ private: }; CancelCommand::CancelCommand() - : Command("Cancel", CmdUIOnlyFlag) + : Command(CommandId::Cancel(), CmdUIOnlyFlag) , m_type(NoOp) { } @@ -62,7 +62,8 @@ void CancelCommand::onExecute(Context* context) // TODO should the ContextBar be a InputChainElement to intercept onCancel()? // Discard brush { - Command* discardBrush = Commands::instance()->byId(CommandId::DiscardBrush); + Command* discardBrush = Commands::instance()->byId( + CommandId::DiscardBrush()); context->executeCommand(discardBrush); } diff --git a/src/app/commands/cmd_canvas_size.cpp b/src/app/commands/cmd_canvas_size.cpp index f2a65fbd9..8924b9037 100644 --- a/src/app/commands/cmd_canvas_size.cpp +++ b/src/app/commands/cmd_canvas_size.cpp @@ -13,12 +13,12 @@ #include "app/document_api.h" #include "app/modules/editors.h" #include "app/modules/gui.h" +#include "app/transaction.h" #include "app/ui/button_set.h" #include "app/ui/color_bar.h" #include "app/ui/editor/editor.h" #include "app/ui/editor/select_box_state.h" #include "app/ui/skin/skin_theme.h" -#include "app/transaction.h" #include "base/bind.h" #include "base/unique_ptr.h" #include "doc/image.h" @@ -281,7 +281,7 @@ protected: }; CanvasSizeCommand::CanvasSizeCommand() - : Command("CanvasSize", CmdRecordableFlag) + : Command(CommandId::CanvasSize(), CmdRecordableFlag) { m_left = m_right = m_top = m_bottom = 0; } diff --git a/src/app/commands/cmd_cel_properties.cpp b/src/app/commands/cmd_cel_properties.cpp index e439c45c5..d02e49886 100644 --- a/src/app/commands/cmd_cel_properties.cpp +++ b/src/app/commands/cmd_cel_properties.cpp @@ -282,7 +282,7 @@ protected: }; CelPropertiesCommand::CelPropertiesCommand() - : Command("CelProperties", CmdUIOnlyFlag) + : Command(CommandId::CelProperties(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_change_brush.cpp b/src/app/commands/cmd_change_brush.cpp index b5d038cf6..622897a45 100644 --- a/src/app/commands/cmd_change_brush.cpp +++ b/src/app/commands/cmd_change_brush.cpp @@ -50,7 +50,7 @@ private: }; ChangeBrushCommand::ChangeBrushCommand() - : Command("ChangeBrush", CmdUIOnlyFlag) + : Command(CommandId::ChangeBrush(), CmdUIOnlyFlag) { m_change = None; m_slot = 0; diff --git a/src/app/commands/cmd_change_color.cpp b/src/app/commands/cmd_change_color.cpp index 872a18081..3f431c93a 100644 --- a/src/app/commands/cmd_change_color.cpp +++ b/src/app/commands/cmd_change_color.cpp @@ -47,7 +47,7 @@ protected: }; ChangeColorCommand::ChangeColorCommand() - : Command("ChangeColor", CmdUIOnlyFlag) + : Command(CommandId::ChangeColor(), CmdUIOnlyFlag) { m_background = false; m_change = None; diff --git a/src/app/commands/cmd_change_pixel_format.cpp b/src/app/commands/cmd_change_pixel_format.cpp index eaa66ed63..e9ee498fb 100644 --- a/src/app/commands/cmd_change_pixel_format.cpp +++ b/src/app/commands/cmd_change_pixel_format.cpp @@ -351,7 +351,7 @@ private: }; ChangePixelFormatCommand::ChangePixelFormatCommand() - : Command("ChangePixelFormat", CmdUIOnlyFlag) + : Command(CommandId::ChangePixelFormat(), CmdUIOnlyFlag) { m_useUI = true; m_format = IMAGE_RGB; diff --git a/src/app/commands/cmd_clear.cpp b/src/app/commands/cmd_clear.cpp index 150f82445..e8c167f7c 100644 --- a/src/app/commands/cmd_clear.cpp +++ b/src/app/commands/cmd_clear.cpp @@ -25,7 +25,7 @@ protected: }; ClearCommand::ClearCommand() - : Command("Clear", CmdUIOnlyFlag) + : Command(CommandId::Clear(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_clear_cel.cpp b/src/app/commands/cmd_clear_cel.cpp index 18bb337fa..8101ab2e2 100644 --- a/src/app/commands/cmd_clear_cel.cpp +++ b/src/app/commands/cmd_clear_cel.cpp @@ -32,7 +32,7 @@ protected: }; ClearCelCommand::ClearCelCommand() - : Command("ClearCel", CmdRecordableFlag) + : Command(CommandId::ClearCel(), CmdRecordableFlag) { } diff --git a/src/app/commands/cmd_close_file.cpp b/src/app/commands/cmd_close_file.cpp index 8210e6222..c94bbca1b 100644 --- a/src/app/commands/cmd_close_file.cpp +++ b/src/app/commands/cmd_close_file.cpp @@ -30,7 +30,7 @@ using namespace ui; class CloseFileCommand : public Command { public: CloseFileCommand() - : Command("CloseFile", CmdUIOnlyFlag) { + : Command(CommandId::CloseFile(), CmdUIOnlyFlag) { } Command* clone() const override { return new CloseFileCommand(*this); } @@ -54,7 +54,7 @@ protected: class CloseAllFilesCommand : public Command { public: CloseAllFilesCommand() - : Command("CloseAllFiles", CmdRecordableFlag) { + : Command(CommandId::CloseAllFiles(), CmdRecordableFlag) { m_quitting = false; } diff --git a/src/app/commands/cmd_color_quantization.cpp b/src/app/commands/cmd_color_quantization.cpp index 87cb592c6..e9bb09541 100644 --- a/src/app/commands/cmd_color_quantization.cpp +++ b/src/app/commands/cmd_color_quantization.cpp @@ -43,7 +43,7 @@ protected: }; ColorQuantizationCommand::ColorQuantizationCommand() - : Command("ColorQuantization", CmdRecordableFlag) + : Command(CommandId::ColorQuantization(), CmdRecordableFlag) { } diff --git a/src/app/commands/cmd_contiguous_fill.cpp b/src/app/commands/cmd_contiguous_fill.cpp index d9e594846..50820e8ba 100644 --- a/src/app/commands/cmd_contiguous_fill.cpp +++ b/src/app/commands/cmd_contiguous_fill.cpp @@ -26,7 +26,7 @@ protected: }; ContiguousFillCommand::ContiguousFillCommand() - : Command("ContiguousFill", CmdUIOnlyFlag) + : Command(CommandId::ContiguousFill(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_copy.cpp b/src/app/commands/cmd_copy.cpp index d7e552573..e37eb6ab0 100644 --- a/src/app/commands/cmd_copy.cpp +++ b/src/app/commands/cmd_copy.cpp @@ -25,7 +25,7 @@ protected: }; CopyCommand::CopyCommand() - : Command("Copy", CmdUIOnlyFlag) + : Command(CommandId::Copy(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_copy_cel.cpp b/src/app/commands/cmd_copy_cel.cpp index a6ab0bd65..5c601ab7f 100644 --- a/src/app/commands/cmd_copy_cel.cpp +++ b/src/app/commands/cmd_copy_cel.cpp @@ -27,7 +27,7 @@ protected: }; CopyCelCommand::CopyCelCommand() - : Command("CopyCel", CmdUIOnlyFlag) + : Command(CommandId::CopyCel(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_copy_merged.cpp b/src/app/commands/cmd_copy_merged.cpp index ac5bc80ac..3e5f07025 100644 --- a/src/app/commands/cmd_copy_merged.cpp +++ b/src/app/commands/cmd_copy_merged.cpp @@ -25,7 +25,7 @@ protected: }; CopyMergedCommand::CopyMergedCommand() - : Command("CopyMerged", CmdUIOnlyFlag) + : Command(CommandId::CopyMerged(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_crop.cpp b/src/app/commands/cmd_crop.cpp index 2becc5378..7580e42eb 100644 --- a/src/app/commands/cmd_crop.cpp +++ b/src/app/commands/cmd_crop.cpp @@ -12,8 +12,8 @@ #include "app/context_access.h" #include "app/document_api.h" #include "app/modules/gui.h" -#include "app/ui/color_bar.h" #include "app/transaction.h" +#include "app/ui/color_bar.h" #include "app/util/autocrop.h" #include "doc/image.h" #include "doc/layer.h" @@ -37,7 +37,7 @@ private: }; CropSpriteCommand::CropSpriteCommand() - : Command("CropSprite", CmdRecordableFlag) + : Command(CommandId::CropSprite(), CmdRecordableFlag) { } @@ -90,7 +90,7 @@ protected: }; AutocropSpriteCommand::AutocropSpriteCommand() - : Command("AutocropSprite", CmdRecordableFlag) + : Command(CommandId::AutocropSprite(), CmdRecordableFlag) { } diff --git a/src/app/commands/cmd_cut.cpp b/src/app/commands/cmd_cut.cpp index d9b9b3ac1..576b671bf 100644 --- a/src/app/commands/cmd_cut.cpp +++ b/src/app/commands/cmd_cut.cpp @@ -25,7 +25,7 @@ protected: }; CutCommand::CutCommand() - : Command("Cut", CmdUIOnlyFlag) + : Command(CommandId::Cut(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_deselect_mask.cpp b/src/app/commands/cmd_deselect_mask.cpp index 08834ed9b..bd0daed48 100644 --- a/src/app/commands/cmd_deselect_mask.cpp +++ b/src/app/commands/cmd_deselect_mask.cpp @@ -29,7 +29,7 @@ protected: }; DeselectMaskCommand::DeselectMaskCommand() - : Command("DeselectMask", CmdRecordableFlag) + : Command(CommandId::DeselectMask(), CmdRecordableFlag) { } diff --git a/src/app/commands/cmd_developer_console.cpp b/src/app/commands/cmd_developer_console.cpp index 8e24f8056..4922523f2 100644 --- a/src/app/commands/cmd_developer_console.cpp +++ b/src/app/commands/cmd_developer_console.cpp @@ -30,7 +30,7 @@ protected: }; DeveloperConsoleCommand::DeveloperConsoleCommand() - : Command("DeveloperConsole", CmdUIOnlyFlag) + : Command(CommandId::DeveloperConsole(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_discard_brush.cpp b/src/app/commands/cmd_discard_brush.cpp index ac526114f..3aeb144a6 100644 --- a/src/app/commands/cmd_discard_brush.cpp +++ b/src/app/commands/cmd_discard_brush.cpp @@ -30,7 +30,7 @@ protected: }; DiscardBrushCommand::DiscardBrushCommand() - : Command("DiscardBrush", CmdUIOnlyFlag) + : Command(CommandId::DiscardBrush(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_duplicate_layer.cpp b/src/app/commands/cmd_duplicate_layer.cpp index d12ba9839..74ebc1264 100644 --- a/src/app/commands/cmd_duplicate_layer.cpp +++ b/src/app/commands/cmd_duplicate_layer.cpp @@ -16,8 +16,8 @@ #include "app/document_undo.h" #include "app/modules/editors.h" #include "app/modules/gui.h" -#include "app/ui/editor/editor.h" #include "app/transaction.h" +#include "app/ui/editor/editor.h" #include "doc/layer.h" #include "doc/sprite.h" #include "ui/ui.h" @@ -35,7 +35,7 @@ protected: }; DuplicateLayerCommand::DuplicateLayerCommand() - : Command("DuplicateLayer", CmdRecordableFlag) + : Command(CommandId::DuplicateLayer(), CmdRecordableFlag) { } diff --git a/src/app/commands/cmd_duplicate_sprite.cpp b/src/app/commands/cmd_duplicate_sprite.cpp index 629bc1493..aab5d8eca 100644 --- a/src/app/commands/cmd_duplicate_sprite.cpp +++ b/src/app/commands/cmd_duplicate_sprite.cpp @@ -37,7 +37,7 @@ protected: }; DuplicateSpriteCommand::DuplicateSpriteCommand() - : Command("DuplicateSprite", CmdUIOnlyFlag) + : Command(CommandId::DuplicateSprite(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_duplicate_view.cpp b/src/app/commands/cmd_duplicate_view.cpp index d002dc2b8..a8a6873d1 100644 --- a/src/app/commands/cmd_duplicate_view.cpp +++ b/src/app/commands/cmd_duplicate_view.cpp @@ -8,9 +8,8 @@ #include "config.h" #endif -#include "app/commands/command.h" - #include "app/app.h" +#include "app/commands/command.h" #include "app/ui/workspace.h" #include @@ -30,7 +29,7 @@ protected: }; DuplicateViewCommand::DuplicateViewCommand() - : Command("DuplicateView", CmdUIOnlyFlag) + : Command(CommandId::DuplicateView(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_exit.cpp b/src/app/commands/cmd_exit.cpp index e216b7423..cc5e8f98a 100644 --- a/src/app/commands/cmd_exit.cpp +++ b/src/app/commands/cmd_exit.cpp @@ -29,7 +29,7 @@ protected: }; ExitCommand::ExitCommand() - : Command("Exit", CmdUIOnlyFlag) + : Command(CommandId::Exit(), CmdUIOnlyFlag) { } @@ -41,7 +41,7 @@ void ExitCommand::onExecute(Context* ctx) return; if (ctx->hasModifiedDocuments()) { - Command* closeAll = Commands::instance()->byId(CommandId::CloseAllFiles); + Command* closeAll = Commands::instance()->byId(CommandId::CloseAllFiles()); Params params; params.set("quitting", "1"); ctx->executeCommand(closeAll, params); diff --git a/src/app/commands/cmd_export_sprite_sheet.cpp b/src/app/commands/cmd_export_sprite_sheet.cpp index 1e5f3c450..ef76ae6d2 100644 --- a/src/app/commands/cmd_export_sprite_sheet.cpp +++ b/src/app/commands/cmd_export_sprite_sheet.cpp @@ -593,7 +593,7 @@ private: }; ExportSpriteSheetCommand::ExportSpriteSheetCommand() - : Command("ExportSpriteSheet", CmdRecordableFlag) + : Command(CommandId::ExportSpriteSheet(), CmdRecordableFlag) , m_useUI(true) , m_askOverwrite(true) { diff --git a/src/app/commands/cmd_eyedropper.cpp b/src/app/commands/cmd_eyedropper.cpp index 561d55325..88c7eeb42 100644 --- a/src/app/commands/cmd_eyedropper.cpp +++ b/src/app/commands/cmd_eyedropper.cpp @@ -32,7 +32,7 @@ namespace app { using namespace ui; EyedropperCommand::EyedropperCommand() - : Command("Eyedropper", CmdUIOnlyFlag) + : Command(CommandId::Eyedropper(), CmdUIOnlyFlag) { m_background = false; } @@ -194,7 +194,7 @@ void EyedropperCommand::onExecute(Context* context) // Discard current image brush if (Preferences::instance().eyedropper.discardBrush()) { - Command* discardBrush = Commands::instance()->byId(CommandId::DiscardBrush); + Command* discardBrush = Commands::instance()->byId(CommandId::DiscardBrush()); context->executeCommand(discardBrush); } diff --git a/src/app/commands/cmd_fit_screen.cpp b/src/app/commands/cmd_fit_screen.cpp index 4c9835194..91dbc4d05 100644 --- a/src/app/commands/cmd_fit_screen.cpp +++ b/src/app/commands/cmd_fit_screen.cpp @@ -27,7 +27,7 @@ protected: }; FitScreenCommand::FitScreenCommand() - : Command("FitScreen", CmdUIOnlyFlag) + : Command(CommandId::FitScreen(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_flatten_layers.cpp b/src/app/commands/cmd_flatten_layers.cpp index e7a4b6b87..cfe8fef31 100644 --- a/src/app/commands/cmd_flatten_layers.cpp +++ b/src/app/commands/cmd_flatten_layers.cpp @@ -29,7 +29,7 @@ protected: }; FlattenLayersCommand::FlattenLayersCommand() - : Command("FlattenLayers", CmdUIOnlyFlag) + : Command(CommandId::FlattenLayers(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_flip.cpp b/src/app/commands/cmd_flip.cpp index 18b75f981..e586f10bf 100644 --- a/src/app/commands/cmd_flip.cpp +++ b/src/app/commands/cmd_flip.cpp @@ -39,7 +39,7 @@ namespace app { FlipCommand::FlipCommand() - : Command("Flip", CmdRecordableFlag) + : Command(CommandId::Flip(), CmdRecordableFlag) { m_flipMask = false; m_flipType = doc::algorithm::FlipHorizontal; diff --git a/src/app/commands/cmd_frame_properties.cpp b/src/app/commands/cmd_frame_properties.cpp index d8dfc0c03..90681b3a8 100644 --- a/src/app/commands/cmd_frame_properties.cpp +++ b/src/app/commands/cmd_frame_properties.cpp @@ -51,7 +51,7 @@ private: }; FramePropertiesCommand::FramePropertiesCommand() - : Command("FrameProperties", CmdUIOnlyFlag) + : Command(CommandId::FrameProperties(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_frame_tag_properties.cpp b/src/app/commands/cmd_frame_tag_properties.cpp index c60b5613e..5f431d01a 100644 --- a/src/app/commands/cmd_frame_tag_properties.cpp +++ b/src/app/commands/cmd_frame_tag_properties.cpp @@ -44,7 +44,7 @@ private: }; FrameTagPropertiesCommand::FrameTagPropertiesCommand() - : Command("FrameTagProperties", CmdUIOnlyFlag) + : Command(CommandId::FrameTagProperties(), CmdUIOnlyFlag) , m_tagId(NullId) { } diff --git a/src/app/commands/cmd_fullscreen_preview.cpp b/src/app/commands/cmd_fullscreen_preview.cpp index 76a92e8b2..84bbf78e4 100644 --- a/src/app/commands/cmd_fullscreen_preview.cpp +++ b/src/app/commands/cmd_fullscreen_preview.cpp @@ -122,10 +122,10 @@ protected: // Change frame if (command != NULL && - (command->id() == CommandId::GotoFirstFrame || - command->id() == CommandId::GotoPreviousFrame || - command->id() == CommandId::GotoNextFrame || - command->id() == CommandId::GotoLastFrame)) { + (command->id() == CommandId::GotoFirstFrame() || + command->id() == CommandId::GotoPreviousFrame() || + command->id() == CommandId::GotoNextFrame() || + command->id() == CommandId::GotoLastFrame())) { m_context->executeCommand(command, params); invalidate(); m_render.reset(NULL); // Re-render @@ -133,7 +133,7 @@ protected: #if 0 // Play the animation else if (command != NULL && - std::strcmp(command->short_name(), CommandId::PlayAnimation) == 0) { + std::strcmp(command->short_name(), CommandId::PlayAnimation()) == 0) { // TODO } #endif @@ -264,7 +264,7 @@ protected: }; FullscreenPreviewCommand::FullscreenPreviewCommand() - : Command("FullscreenPreview", CmdUIOnlyFlag) + : Command(CommandId::FullscreenPreview(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_goto_frame.cpp b/src/app/commands/cmd_goto_frame.cpp index 590ccf1dd..96c72b4a0 100644 --- a/src/app/commands/cmd_goto_frame.cpp +++ b/src/app/commands/cmd_goto_frame.cpp @@ -49,7 +49,7 @@ protected: class GotoFirstFrameCommand : public GotoCommand { public: GotoFirstFrameCommand() - : GotoCommand("GotoFirstFrame") { } + : GotoCommand(CommandId::GotoFirstFrame()) { } Command* clone() const override { return new GotoFirstFrameCommand(*this); } protected: @@ -61,7 +61,7 @@ protected: class GotoPreviousFrameCommand : public GotoCommand { public: GotoPreviousFrameCommand() - : GotoCommand("GotoPreviousFrame") { } + : GotoCommand(CommandId::GotoPreviousFrame()) { } Command* clone() const override { return new GotoPreviousFrameCommand(*this); } protected: @@ -75,7 +75,7 @@ protected: class GotoNextFrameCommand : public GotoCommand { public: - GotoNextFrameCommand() : GotoCommand("GotoNextFrame") { } + GotoNextFrameCommand() : GotoCommand(CommandId::GotoNextFrame()) { } Command* clone() const override { return new GotoNextFrameCommand(*this); } protected: @@ -89,7 +89,7 @@ protected: class GotoNextFrameWithSameTagCommand : public GotoCommand { public: - GotoNextFrameWithSameTagCommand() : GotoCommand("GotoNextFrameWithSameTag") { } + GotoNextFrameWithSameTagCommand() : GotoCommand(CommandId::GotoNextFrameWithSameTag()) { } Command* clone() const override { return new GotoNextFrameWithSameTagCommand(*this); } protected: @@ -108,7 +108,7 @@ protected: class GotoPreviousFrameWithSameTagCommand : public GotoCommand { public: - GotoPreviousFrameWithSameTagCommand() : GotoCommand("GotoPreviousFrameWithSameTag") { } + GotoPreviousFrameWithSameTagCommand() : GotoCommand(CommandId::GotoPreviousFrameWithSameTag()) { } Command* clone() const override { return new GotoPreviousFrameWithSameTagCommand(*this); } protected: @@ -127,7 +127,7 @@ protected: class GotoLastFrameCommand : public GotoCommand { public: - GotoLastFrameCommand() : GotoCommand("GotoLastFrame") { } + GotoLastFrameCommand() : GotoCommand(CommandId::GotoLastFrame()) { } Command* clone() const override { return new GotoLastFrameCommand(*this); } protected: @@ -138,7 +138,7 @@ protected: class GotoFrameCommand : public GotoCommand { public: - GotoFrameCommand() : GotoCommand("GotoFrame") + GotoFrameCommand() : GotoCommand(CommandId::GotoFrame()) , m_showUI(true) { } Command* clone() const override { return new GotoFrameCommand(*this); } diff --git a/src/app/commands/cmd_goto_tab.cpp b/src/app/commands/cmd_goto_tab.cpp index d7d701f2f..ff9a9c0a2 100644 --- a/src/app/commands/cmd_goto_tab.cpp +++ b/src/app/commands/cmd_goto_tab.cpp @@ -8,9 +8,8 @@ #include "config.h" #endif -#include "app/commands/command.h" - #include "app/app.h" +#include "app/commands/command.h" #include "app/ui/workspace.h" namespace app { @@ -26,7 +25,7 @@ protected: }; GotoNextTabCommand::GotoNextTabCommand() - : Command("GotoNextTab", CmdUIOnlyFlag) + : Command(CommandId::GotoNextTab(), CmdUIOnlyFlag) { } @@ -51,7 +50,7 @@ protected: }; GotoPreviousTabCommand::GotoPreviousTabCommand() - : Command("GotoPreviousTab", CmdRecordableFlag) + : Command(CommandId::GotoPreviousTab(), CmdRecordableFlag) { } diff --git a/src/app/commands/cmd_grid.cpp b/src/app/commands/cmd_grid.cpp index a71deae25..dcd16f0a0 100644 --- a/src/app/commands/cmd_grid.cpp +++ b/src/app/commands/cmd_grid.cpp @@ -31,7 +31,7 @@ using namespace gfx; class SnapToGridCommand : public Command { public: SnapToGridCommand() - : Command("SnapToGrid", CmdUIOnlyFlag) { + : Command(CommandId::SnapToGrid(), CmdUIOnlyFlag) { } Command* clone() const override { return new SnapToGridCommand(*this); } @@ -54,7 +54,7 @@ protected: class SelectionAsGridCommand : public Command { public: SelectionAsGridCommand() - : Command("SelectionAsGrid", CmdUIOnlyFlag) { + : Command(CommandId::SelectionAsGrid(), CmdUIOnlyFlag) { } Command* clone() const override { return new SelectionAsGridCommand(*this); } @@ -91,7 +91,7 @@ protected: }; GridSettingsCommand::GridSettingsCommand() - : Command("GridSettings", CmdUIOnlyFlag) + : Command(CommandId::GridSettings(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_home.cpp b/src/app/commands/cmd_home.cpp index d9b9753bd..f39b3771a 100644 --- a/src/app/commands/cmd_home.cpp +++ b/src/app/commands/cmd_home.cpp @@ -27,7 +27,7 @@ protected: }; HomeCommand::HomeCommand() - : Command("Home", CmdUIOnlyFlag) + : Command(CommandId::Home(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_import_sprite_sheet.cpp b/src/app/commands/cmd_import_sprite_sheet.cpp index 19c665434..8bc12ad7e 100644 --- a/src/app/commands/cmd_import_sprite_sheet.cpp +++ b/src/app/commands/cmd_import_sprite_sheet.cpp @@ -120,7 +120,7 @@ protected: void onSelectFile() { Document* oldActiveDocument = m_context->activeDocument(); - Command* openFile = Commands::instance()->byId(CommandId::OpenFile); + Command* openFile = Commands::instance()->byId(CommandId::OpenFile()); Params params; params.set("filename", ""); openFile->loadParams(params); @@ -297,7 +297,7 @@ protected: }; ImportSpriteSheetCommand::ImportSpriteSheetCommand() - : Command("ImportSpriteSheet", CmdRecordableFlag) + : Command(CommandId::ImportSpriteSheet(), CmdRecordableFlag) { } diff --git a/src/app/commands/cmd_invert_mask.cpp b/src/app/commands/cmd_invert_mask.cpp index 8b2d7f228..28f2323e5 100644 --- a/src/app/commands/cmd_invert_mask.cpp +++ b/src/app/commands/cmd_invert_mask.cpp @@ -33,7 +33,7 @@ protected: }; InvertMaskCommand::InvertMaskCommand() - : Command("InvertMask", CmdRecordableFlag) + : Command(CommandId::InvertMask(), CmdRecordableFlag) { } @@ -56,7 +56,7 @@ void InvertMaskCommand::onExecute(Context* context) if (!hasMask) { // so we select all Command* mask_all_cmd = - Commands::instance()->byId(CommandId::MaskAll); + Commands::instance()->byId(CommandId::MaskAll()); context->executeCommand(mask_all_cmd); } // invert the current mask diff --git a/src/app/commands/cmd_keyboard_shortcuts.cpp b/src/app/commands/cmd_keyboard_shortcuts.cpp index 8954974e4..b9f811d02 100644 --- a/src/app/commands/cmd_keyboard_shortcuts.cpp +++ b/src/app/commands/cmd_keyboard_shortcuts.cpp @@ -749,7 +749,7 @@ private: }; KeyboardShortcutsCommand::KeyboardShortcutsCommand() - : Command("KeyboardShortcuts", CmdUIOnlyFlag) + : Command(CommandId::KeyboardShortcuts(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_launch.cpp b/src/app/commands/cmd_launch.cpp index 5c1b4c37a..4d87aa436 100644 --- a/src/app/commands/cmd_launch.cpp +++ b/src/app/commands/cmd_launch.cpp @@ -32,7 +32,7 @@ private: }; LaunchCommand::LaunchCommand() - : Command("Launch", CmdUIOnlyFlag) + : Command(CommandId::Launch(), CmdUIOnlyFlag) , m_type(Url) , m_path("") { diff --git a/src/app/commands/cmd_layer_from_background.cpp b/src/app/commands/cmd_layer_from_background.cpp index 6b7379027..2f81cd440 100644 --- a/src/app/commands/cmd_layer_from_background.cpp +++ b/src/app/commands/cmd_layer_from_background.cpp @@ -30,7 +30,7 @@ protected: }; LayerFromBackgroundCommand::LayerFromBackgroundCommand() - : Command("LayerFromBackground", CmdRecordableFlag) + : Command(CommandId::LayerFromBackground(), CmdRecordableFlag) { } diff --git a/src/app/commands/cmd_layer_lock.cpp b/src/app/commands/cmd_layer_lock.cpp index bed0153a1..441f81dcc 100644 --- a/src/app/commands/cmd_layer_lock.cpp +++ b/src/app/commands/cmd_layer_lock.cpp @@ -32,7 +32,7 @@ protected: }; LayerLockCommand::LayerLockCommand() - : Command("LayerLock", CmdRecordableFlag) + : Command(CommandId::LayerLock(), CmdRecordableFlag) { } diff --git a/src/app/commands/cmd_layer_opacity.cpp b/src/app/commands/cmd_layer_opacity.cpp index 07ab9ac0b..92927d169 100644 --- a/src/app/commands/cmd_layer_opacity.cpp +++ b/src/app/commands/cmd_layer_opacity.cpp @@ -41,7 +41,7 @@ private: }; LayerOpacityCommand::LayerOpacityCommand() - : Command("LayerOpacity", CmdUIOnlyFlag) + : Command(CommandId::LayerOpacity(), CmdUIOnlyFlag) { m_opacity = 255; } diff --git a/src/app/commands/cmd_layer_properties.cpp b/src/app/commands/cmd_layer_properties.cpp index 3d0463206..9a448545e 100644 --- a/src/app/commands/cmd_layer_properties.cpp +++ b/src/app/commands/cmd_layer_properties.cpp @@ -353,7 +353,7 @@ private: }; LayerPropertiesCommand::LayerPropertiesCommand() - : Command("LayerProperties", CmdRecordableFlag) + : Command(CommandId::LayerProperties(), CmdRecordableFlag) { } diff --git a/src/app/commands/cmd_layer_visibility.cpp b/src/app/commands/cmd_layer_visibility.cpp index 7a6a6eada..c9b2c79eb 100644 --- a/src/app/commands/cmd_layer_visibility.cpp +++ b/src/app/commands/cmd_layer_visibility.cpp @@ -32,7 +32,7 @@ protected: }; LayerVisibilityCommand::LayerVisibilityCommand() - : Command("LayerVisibility", CmdRecordableFlag) + : Command(CommandId::LayerVisibility(), CmdRecordableFlag) { } diff --git a/src/app/commands/cmd_link_cels.cpp b/src/app/commands/cmd_link_cels.cpp index 81607e145..53dd96a91 100644 --- a/src/app/commands/cmd_link_cels.cpp +++ b/src/app/commands/cmd_link_cels.cpp @@ -32,7 +32,7 @@ protected: }; LinkCelsCommand::LinkCelsCommand() - : Command("LinkCels", CmdRecordableFlag) + : Command(CommandId::LinkCels(), CmdRecordableFlag) { } diff --git a/src/app/commands/cmd_load_mask.cpp b/src/app/commands/cmd_load_mask.cpp index d7131f0e7..092bd7172 100644 --- a/src/app/commands/cmd_load_mask.cpp +++ b/src/app/commands/cmd_load_mask.cpp @@ -38,7 +38,7 @@ protected: }; LoadMaskCommand::LoadMaskCommand() - : Command("LoadMask", CmdRecordableFlag) + : Command(CommandId::LoadMask(), CmdRecordableFlag) { m_filename = ""; } diff --git a/src/app/commands/cmd_load_palette.cpp b/src/app/commands/cmd_load_palette.cpp index 4c0ac244c..4c08e78a2 100644 --- a/src/app/commands/cmd_load_palette.cpp +++ b/src/app/commands/cmd_load_palette.cpp @@ -41,7 +41,7 @@ private: }; LoadPaletteCommand::LoadPaletteCommand() - : Command("LoadPalette", CmdRecordableFlag) + : Command(CommandId::LoadPalette(), CmdRecordableFlag) { } @@ -85,7 +85,7 @@ void LoadPaletteCommand::onExecute(Context* context) } SetPaletteCommand* cmd = static_cast( - Commands::instance()->byId(CommandId::SetPalette)); + Commands::instance()->byId(CommandId::SetPalette())); cmd->setPalette(palette); context->executeCommand(cmd); } diff --git a/src/app/commands/cmd_mask_all.cpp b/src/app/commands/cmd_mask_all.cpp index d3372f036..daab1b8f4 100644 --- a/src/app/commands/cmd_mask_all.cpp +++ b/src/app/commands/cmd_mask_all.cpp @@ -29,7 +29,7 @@ protected: }; MaskAllCommand::MaskAllCommand() - : Command("MaskAll", CmdRecordableFlag) + : Command(CommandId::MaskAll(), CmdRecordableFlag) { } diff --git a/src/app/commands/cmd_mask_by_color.cpp b/src/app/commands/cmd_mask_by_color.cpp index b06248b75..d7abfd3b8 100644 --- a/src/app/commands/cmd_mask_by_color.cpp +++ b/src/app/commands/cmd_mask_by_color.cpp @@ -63,7 +63,7 @@ private: }; MaskByColorCommand::MaskByColorCommand() - : Command("MaskByColor", CmdUIOnlyFlag) + : Command(CommandId::MaskByColor(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_mask_content.cpp b/src/app/commands/cmd_mask_content.cpp index b8a94eac4..986af7c26 100644 --- a/src/app/commands/cmd_mask_content.cpp +++ b/src/app/commands/cmd_mask_content.cpp @@ -40,7 +40,7 @@ protected: }; MaskContentCommand::MaskContentCommand() - : Command("MaskContent", CmdRecordableFlag) + : Command(CommandId::MaskContent(), CmdRecordableFlag) { } diff --git a/src/app/commands/cmd_merge_down_layer.cpp b/src/app/commands/cmd_merge_down_layer.cpp index 27061d308..e4226a106 100644 --- a/src/app/commands/cmd_merge_down_layer.cpp +++ b/src/app/commands/cmd_merge_down_layer.cpp @@ -42,7 +42,7 @@ protected: }; MergeDownLayerCommand::MergeDownLayerCommand() - : Command("MergeDownLayer", CmdRecordableFlag) + : Command(CommandId::MergeDownLayer(), CmdRecordableFlag) { } diff --git a/src/app/commands/cmd_modify_selection.cpp b/src/app/commands/cmd_modify_selection.cpp index e125556b0..80bfece02 100644 --- a/src/app/commands/cmd_modify_selection.cpp +++ b/src/app/commands/cmd_modify_selection.cpp @@ -59,7 +59,7 @@ private: }; ModifySelectionCommand::ModifySelectionCommand() - : Command("ModifySelection", CmdRecordableFlag) + : Command(CommandId::ModifySelection(), CmdRecordableFlag) , m_modifier(Expand) , m_quantity(0) , m_brushType(doc::kCircleBrushType) diff --git a/src/app/commands/cmd_move_cel.cpp b/src/app/commands/cmd_move_cel.cpp index fe78f9fac..dd550d550 100644 --- a/src/app/commands/cmd_move_cel.cpp +++ b/src/app/commands/cmd_move_cel.cpp @@ -27,7 +27,7 @@ protected: }; MoveCelCommand::MoveCelCommand() - : Command("MoveCel", CmdUIOnlyFlag) + : Command(CommandId::MoveCel(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_move_mask.cpp b/src/app/commands/cmd_move_mask.cpp index a1a107cc0..c336d6cc0 100644 --- a/src/app/commands/cmd_move_mask.cpp +++ b/src/app/commands/cmd_move_mask.cpp @@ -32,7 +32,7 @@ namespace app { MoveMaskCommand::MoveMaskCommand() - : Command("MoveMask", CmdRecordableFlag) + : Command(CommandId::MoveMask(), CmdRecordableFlag) { } diff --git a/src/app/commands/cmd_new_brush.cpp b/src/app/commands/cmd_new_brush.cpp index cfc4a9673..2e166b963 100644 --- a/src/app/commands/cmd_new_brush.cpp +++ b/src/app/commands/cmd_new_brush.cpp @@ -55,7 +55,7 @@ private: }; NewBrushCommand::NewBrushCommand() - : Command("NewBrush", CmdUIOnlyFlag) + : Command(CommandId::NewBrush(), CmdUIOnlyFlag) { } @@ -96,7 +96,7 @@ void NewBrushCommand::onExecute(Context* context) // Deselect mask Command* cmd = - Commands::instance()->byId(CommandId::DeselectMask); + Commands::instance()->byId(CommandId::DeselectMask()); UIContext::instance()->executeCommand(cmd); } } @@ -166,7 +166,7 @@ void NewBrushCommand::createBrush(const Site& site, const Mask* mask) params.set("change", "custom"); params.set("slot", base::convert_to(slot).c_str()); Key* key = KeyboardShortcuts::instance()->command( - CommandId::ChangeBrush, params); + CommandId::ChangeBrush(), params); if (key && !key->accels().empty()) { std::string tooltip; tooltip += "Shortcut: "; diff --git a/src/app/commands/cmd_new_file.cpp b/src/app/commands/cmd_new_file.cpp index 2f8425bd7..6c7bd53f3 100644 --- a/src/app/commands/cmd_new_file.cpp +++ b/src/app/commands/cmd_new_file.cpp @@ -51,7 +51,7 @@ protected: static int _sprite_counter = 0; NewFileCommand::NewFileCommand() - : Command("NewFile", CmdRecordableFlag) + : Command(CommandId::NewFile(), CmdRecordableFlag) { } diff --git a/src/app/commands/cmd_new_frame.cpp b/src/app/commands/cmd_new_frame.cpp index 0eab2a778..7c1341b15 100644 --- a/src/app/commands/cmd_new_frame.cpp +++ b/src/app/commands/cmd_new_frame.cpp @@ -58,7 +58,7 @@ private: }; NewFrameCommand::NewFrameCommand() - : Command("NewFrame", CmdRecordableFlag) + : Command(CommandId::NewFrame(), CmdRecordableFlag) { } diff --git a/src/app/commands/cmd_new_frame_tag.cpp b/src/app/commands/cmd_new_frame_tag.cpp index a0fb60e4f..78acce60e 100644 --- a/src/app/commands/cmd_new_frame_tag.cpp +++ b/src/app/commands/cmd_new_frame_tag.cpp @@ -35,7 +35,7 @@ protected: }; NewFrameTagCommand::NewFrameTagCommand() - : Command("NewFrameTag", CmdRecordableFlag) + : Command(CommandId::NewFrameTag(), CmdRecordableFlag) { } diff --git a/src/app/commands/cmd_new_layer.cpp b/src/app/commands/cmd_new_layer.cpp index 9d950d231..92a4a335e 100644 --- a/src/app/commands/cmd_new_layer.cpp +++ b/src/app/commands/cmd_new_layer.cpp @@ -65,7 +65,7 @@ private: }; NewLayerCommand::NewLayerCommand() - : Command("NewLayer", CmdRecordableFlag) + : Command(CommandId::NewLayer(), CmdRecordableFlag) { m_name = ""; m_type = Type::Layer; @@ -130,7 +130,7 @@ void NewLayerCommand::onExecute(Context* context) // Select a file to copy its content if (m_fromFile) { Document* oldActiveDocument = context->activeDocument(); - Command* openFile = Commands::instance()->byId(CommandId::OpenFile); + Command* openFile = Commands::instance()->byId(CommandId::OpenFile()); Params params; params.set("filename", ""); context->executeCommand(openFile, params); diff --git a/src/app/commands/cmd_new_sprite_from_selection.cpp b/src/app/commands/cmd_new_sprite_from_selection.cpp index 30efa1e02..3b7ca157a 100644 --- a/src/app/commands/cmd_new_sprite_from_selection.cpp +++ b/src/app/commands/cmd_new_sprite_from_selection.cpp @@ -14,12 +14,12 @@ #include "app/util/new_image_from_mask.h" #include "base/fs.h" #include "doc/cel.h" +#include "doc/document.h" +#include "doc/layer.h" #include "doc/mask.h" #include "doc/palette.h" -#include "doc/layer.h" #include "doc/site.h" #include "doc/sprite.h" -#include "doc/document.h" #include @@ -38,7 +38,7 @@ protected: }; NewSpriteFromSelectionCommand::NewSpriteFromSelectionCommand() - : Command("NewSpriteFromSelection", CmdUIOnlyFlag) + : Command(CommandId::NewSpriteFromSelection(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_onionskin.cpp b/src/app/commands/cmd_onionskin.cpp index 1b7504c20..63299408f 100644 --- a/src/app/commands/cmd_onionskin.cpp +++ b/src/app/commands/cmd_onionskin.cpp @@ -21,7 +21,7 @@ using namespace gfx; class ShowOnionSkinCommand : public Command { public: ShowOnionSkinCommand() - : Command("ShowOnionSkin", CmdUIOnlyFlag) + : Command(CommandId::ShowOnionSkin(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_open_browser.cpp b/src/app/commands/cmd_open_browser.cpp index 7157339c2..541dc68d3 100644 --- a/src/app/commands/cmd_open_browser.cpp +++ b/src/app/commands/cmd_open_browser.cpp @@ -30,7 +30,7 @@ private: }; OpenBrowserCommand::OpenBrowserCommand() - : Command("OpenBrowser", CmdUIOnlyFlag) + : Command(CommandId::OpenBrowser(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_open_file.cpp b/src/app/commands/cmd_open_file.cpp index aec33f0fb..35a824d45 100644 --- a/src/app/commands/cmd_open_file.cpp +++ b/src/app/commands/cmd_open_file.cpp @@ -75,7 +75,7 @@ private: }; OpenFileCommand::OpenFileCommand() - : Command("OpenFile", CmdRecordableFlag) + : Command(CommandId::OpenFile(), CmdRecordableFlag) , m_repeatCheckbox(false) , m_oneFrame(false) , m_seqDecision(SequenceDecision::Ask) diff --git a/src/app/commands/cmd_open_group.cpp b/src/app/commands/cmd_open_group.cpp index 5bfb901a2..a73f90484 100644 --- a/src/app/commands/cmd_open_group.cpp +++ b/src/app/commands/cmd_open_group.cpp @@ -33,7 +33,7 @@ protected: }; OpenGroupCommand::OpenGroupCommand() - : Command("OpenGroup", CmdRecordableFlag) + : Command(CommandId::OpenGroup(), CmdRecordableFlag) { } diff --git a/src/app/commands/cmd_open_in_folder.cpp b/src/app/commands/cmd_open_in_folder.cpp index 93d8f3b3e..e3b970496 100644 --- a/src/app/commands/cmd_open_in_folder.cpp +++ b/src/app/commands/cmd_open_in_folder.cpp @@ -27,7 +27,7 @@ protected: }; OpenInFolderCommand::OpenInFolderCommand() - : Command("OpenInFolder", CmdUIOnlyFlag) + : Command(CommandId::OpenInFolder(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_open_with_app.cpp b/src/app/commands/cmd_open_with_app.cpp index 81c9b4bc9..39ea52dd9 100644 --- a/src/app/commands/cmd_open_with_app.cpp +++ b/src/app/commands/cmd_open_with_app.cpp @@ -27,7 +27,7 @@ protected: }; OpenWithAppCommand::OpenWithAppCommand() - : Command("OpenWithApp", CmdUIOnlyFlag) + : Command(CommandId::OpenWithApp(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_options.cpp b/src/app/commands/cmd_options.cpp index ec1a384ae..2b71d75fc 100644 --- a/src/app/commands/cmd_options.cpp +++ b/src/app/commands/cmd_options.cpp @@ -1037,7 +1037,7 @@ protected: }; OptionsCommand::OptionsCommand() - : Command("Options", CmdUIOnlyFlag) + : Command(CommandId::Options(), CmdUIOnlyFlag) { Preferences& preferences = Preferences::instance(); diff --git a/src/app/commands/cmd_palette_editor.cpp b/src/app/commands/cmd_palette_editor.cpp index 04c7250dc..6009b723c 100644 --- a/src/app/commands/cmd_palette_editor.cpp +++ b/src/app/commands/cmd_palette_editor.cpp @@ -34,7 +34,7 @@ private: }; PaletteEditorCommand::PaletteEditorCommand() - : Command("PaletteEditor", CmdRecordableFlag) + : Command(CommandId::PaletteEditor(), CmdRecordableFlag) { m_edit = true; m_popup = false; diff --git a/src/app/commands/cmd_palette_size.cpp b/src/app/commands/cmd_palette_size.cpp index 47289b7f7..1dc3cf180 100644 --- a/src/app/commands/cmd_palette_size.cpp +++ b/src/app/commands/cmd_palette_size.cpp @@ -37,7 +37,7 @@ private: }; PaletteSizeCommand::PaletteSizeCommand() - : Command("PaletteSize", CmdRecordableFlag) + : Command(CommandId::PaletteSize(), CmdRecordableFlag) { m_size = 0; } diff --git a/src/app/commands/cmd_paste.cpp b/src/app/commands/cmd_paste.cpp index da63e7a0b..b8ede9b2d 100644 --- a/src/app/commands/cmd_paste.cpp +++ b/src/app/commands/cmd_paste.cpp @@ -25,7 +25,7 @@ protected: }; PasteCommand::PasteCommand() - : Command("Paste", CmdUIOnlyFlag) + : Command(CommandId::Paste(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_paste_text.cpp b/src/app/commands/cmd_paste_text.cpp index 85d45692b..cfacb7a35 100644 --- a/src/app/commands/cmd_paste_text.cpp +++ b/src/app/commands/cmd_paste_text.cpp @@ -45,7 +45,7 @@ protected: }; PasteTextCommand::PasteTextCommand() - : Command("PasteText", CmdUIOnlyFlag) + : Command(CommandId::PasteText(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_pixel_perfect_mode.cpp b/src/app/commands/cmd_pixel_perfect_mode.cpp index c3db050ed..e614dbcf3 100644 --- a/src/app/commands/cmd_pixel_perfect_mode.cpp +++ b/src/app/commands/cmd_pixel_perfect_mode.cpp @@ -30,7 +30,7 @@ protected: }; PixelPerfectModeCommand::PixelPerfectModeCommand() - : Command("PixelPerfectMode", CmdUIOnlyFlag) + : Command(CommandId::PixelPerfectMode(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_play_animation.cpp b/src/app/commands/cmd_play_animation.cpp index d653d3cb5..a1e03e73e 100644 --- a/src/app/commands/cmd_play_animation.cpp +++ b/src/app/commands/cmd_play_animation.cpp @@ -30,7 +30,7 @@ protected: }; PlayAnimationCommand::PlayAnimationCommand() - : Command("PlayAnimation", CmdUIOnlyFlag) + : Command(CommandId::PlayAnimation(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_refresh.cpp b/src/app/commands/cmd_refresh.cpp index e0c10f354..15660e45e 100644 --- a/src/app/commands/cmd_refresh.cpp +++ b/src/app/commands/cmd_refresh.cpp @@ -33,7 +33,7 @@ protected: }; RefreshCommand::RefreshCommand() - : Command("Refresh", CmdUIOnlyFlag) + : Command(CommandId::Refresh(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_remove_frame.cpp b/src/app/commands/cmd_remove_frame.cpp index c46314379..9cbaaf580 100644 --- a/src/app/commands/cmd_remove_frame.cpp +++ b/src/app/commands/cmd_remove_frame.cpp @@ -30,7 +30,7 @@ protected: }; RemoveFrameCommand::RemoveFrameCommand() - : Command("RemoveFrame", CmdRecordableFlag) + : Command(CommandId::RemoveFrame(), CmdRecordableFlag) { } diff --git a/src/app/commands/cmd_remove_frame_tag.cpp b/src/app/commands/cmd_remove_frame_tag.cpp index 14ef07f27..9d2b1d1fe 100644 --- a/src/app/commands/cmd_remove_frame_tag.cpp +++ b/src/app/commands/cmd_remove_frame_tag.cpp @@ -38,7 +38,7 @@ private: }; RemoveFrameTagCommand::RemoveFrameTagCommand() - : Command("RemoveFrameTag", CmdRecordableFlag) + : Command(CommandId::RemoveFrameTag(), CmdRecordableFlag) , m_tagId(NullId) { } diff --git a/src/app/commands/cmd_remove_layer.cpp b/src/app/commands/cmd_remove_layer.cpp index d93391690..4276cf452 100644 --- a/src/app/commands/cmd_remove_layer.cpp +++ b/src/app/commands/cmd_remove_layer.cpp @@ -34,7 +34,7 @@ protected: }; RemoveLayerCommand::RemoveLayerCommand() - : Command("RemoveLayer", CmdRecordableFlag) + : Command(CommandId::RemoveLayer(), CmdRecordableFlag) { } diff --git a/src/app/commands/cmd_remove_slice.cpp b/src/app/commands/cmd_remove_slice.cpp index 0e72f610a..18f5fbb16 100644 --- a/src/app/commands/cmd_remove_slice.cpp +++ b/src/app/commands/cmd_remove_slice.cpp @@ -41,7 +41,7 @@ private: }; RemoveSliceCommand::RemoveSliceCommand() - : Command("RemoveSlice", CmdRecordableFlag) + : Command(CommandId::RemoveSlice(), CmdRecordableFlag) { } diff --git a/src/app/commands/cmd_repeat_last_export.cpp b/src/app/commands/cmd_repeat_last_export.cpp index abfe6dbab..cc8b474da 100644 --- a/src/app/commands/cmd_repeat_last_export.cpp +++ b/src/app/commands/cmd_repeat_last_export.cpp @@ -29,7 +29,7 @@ protected: }; RepeatLastExportCommand::RepeatLastExportCommand() - : Command("RepeatLastExport", CmdRecordableFlag) + : Command(CommandId::RepeatLastExport(), CmdRecordableFlag) { } @@ -40,7 +40,7 @@ bool RepeatLastExportCommand::onEnabled(Context* context) void RepeatLastExportCommand::onExecute(Context* context) { - Command* cmd = Commands::instance()->byId(CommandId::ExportSpriteSheet); + Command* cmd = Commands::instance()->byId(CommandId::ExportSpriteSheet()); Params params; { diff --git a/src/app/commands/cmd_reselect_mask.cpp b/src/app/commands/cmd_reselect_mask.cpp index 7408eecbd..89d92b43a 100644 --- a/src/app/commands/cmd_reselect_mask.cpp +++ b/src/app/commands/cmd_reselect_mask.cpp @@ -29,7 +29,7 @@ protected: }; ReselectMaskCommand::ReselectMaskCommand() - : Command("ReselectMask", CmdRecordableFlag) + : Command(CommandId::ReselectMask(), CmdRecordableFlag) { } diff --git a/src/app/commands/cmd_reverse_frames.cpp b/src/app/commands/cmd_reverse_frames.cpp index a665cd0f4..3577f0e32 100644 --- a/src/app/commands/cmd_reverse_frames.cpp +++ b/src/app/commands/cmd_reverse_frames.cpp @@ -28,7 +28,7 @@ protected: }; ReverseFramesCommand::ReverseFramesCommand() - : Command("ReverseFrames", CmdUIOnlyFlag) + : Command(CommandId::ReverseFrames(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_rotate.cpp b/src/app/commands/cmd_rotate.cpp index 58056f50e..6163d1b00 100644 --- a/src/app/commands/cmd_rotate.cpp +++ b/src/app/commands/cmd_rotate.cpp @@ -167,7 +167,7 @@ protected: }; RotateCommand::RotateCommand() - : Command("Rotate", CmdRecordableFlag) + : Command(CommandId::Rotate(), CmdRecordableFlag) { m_flipMask = false; m_angle = 0; diff --git a/src/app/commands/cmd_run_script.cpp b/src/app/commands/cmd_run_script.cpp index 8e5ee9edb..7bd8fe591 100644 --- a/src/app/commands/cmd_run_script.cpp +++ b/src/app/commands/cmd_run_script.cpp @@ -49,7 +49,7 @@ private: }; RunScriptCommand::RunScriptCommand() - : Command("RunScript", CmdRecordableFlag) + : Command(CommandId::RunScript(), CmdRecordableFlag) { } diff --git a/src/app/commands/cmd_save_file.cpp b/src/app/commands/cmd_save_file.cpp index 4a76ba284..c60d935a9 100644 --- a/src/app/commands/cmd_save_file.cpp +++ b/src/app/commands/cmd_save_file.cpp @@ -240,7 +240,7 @@ bool SaveFileBaseCommand::saveAsDialog( // Apply scale bool undoResize = false; if (xscale != 1.0 || yscale != 1.0) { - Command* resizeCmd = Commands::instance()->byId(CommandId::SpriteSize); + Command* resizeCmd = Commands::instance()->byId(CommandId::SpriteSize()); ASSERT(resizeCmd); if (resizeCmd) { int width = document->sprite()->width(); @@ -287,7 +287,7 @@ bool SaveFileBaseCommand::saveAsDialog( // Undo resize if (undoResize) { - Command* undoCmd = Commands::instance()->byId(CommandId::Undo); + Command* undoCmd = Commands::instance()->byId(CommandId::Undo()); if (undoCmd) context->executeCommand(undoCmd); } @@ -357,7 +357,7 @@ protected: }; SaveFileCommand::SaveFileCommand() - : SaveFileBaseCommand("SaveFile", CmdRecordableFlag) + : SaveFileBaseCommand(CommandId::SaveFile(), CmdRecordableFlag) { } @@ -393,7 +393,7 @@ protected: }; SaveFileAsCommand::SaveFileAsCommand() - : SaveFileBaseCommand("SaveFileAs", CmdRecordableFlag) + : SaveFileBaseCommand(CommandId::SaveFileAs(), CmdRecordableFlag) { } @@ -412,7 +412,7 @@ protected: }; SaveFileCopyAsCommand::SaveFileCopyAsCommand() - : SaveFileBaseCommand("SaveFileCopyAs", CmdRecordableFlag) + : SaveFileBaseCommand(CommandId::SaveFileCopyAs(), CmdRecordableFlag) { } diff --git a/src/app/commands/cmd_save_mask.cpp b/src/app/commands/cmd_save_mask.cpp index d758520c4..8dcb1a1f3 100644 --- a/src/app/commands/cmd_save_mask.cpp +++ b/src/app/commands/cmd_save_mask.cpp @@ -32,7 +32,7 @@ protected: }; SaveMaskCommand::SaveMaskCommand() - : Command("SaveMask", CmdUIOnlyFlag) + : Command(CommandId::SaveMask(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_save_palette.cpp b/src/app/commands/cmd_save_palette.cpp index 8e6d65915..3ce25dc6d 100644 --- a/src/app/commands/cmd_save_palette.cpp +++ b/src/app/commands/cmd_save_palette.cpp @@ -39,7 +39,7 @@ private: }; SavePaletteCommand::SavePaletteCommand() - : Command("SavePalette", CmdRecordableFlag) + : Command(CommandId::SavePalette(), CmdRecordableFlag) { } diff --git a/src/app/commands/cmd_scroll.cpp b/src/app/commands/cmd_scroll.cpp index 278c7c6c2..687bbe621 100644 --- a/src/app/commands/cmd_scroll.cpp +++ b/src/app/commands/cmd_scroll.cpp @@ -39,7 +39,7 @@ private: }; ScrollCommand::ScrollCommand() - : Command("Scroll", CmdUIOnlyFlag) + : Command(CommandId::Scroll(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_scroll_center.cpp b/src/app/commands/cmd_scroll_center.cpp index 9adbafa22..b42ad35db 100644 --- a/src/app/commands/cmd_scroll_center.cpp +++ b/src/app/commands/cmd_scroll_center.cpp @@ -27,7 +27,7 @@ protected: }; ScrollCenterCommand::ScrollCenterCommand() - : Command("ScrollCenter", CmdUIOnlyFlag) + : Command(CommandId::ScrollCenter(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_select_tile.cpp b/src/app/commands/cmd_select_tile.cpp index cc1f9e310..5735563c6 100644 --- a/src/app/commands/cmd_select_tile.cpp +++ b/src/app/commands/cmd_select_tile.cpp @@ -43,7 +43,7 @@ private: }; SelectTileCommand::SelectTileCommand() - : Command("SelectTile", CmdRecordableFlag) + : Command(CommandId::SelectTile(), CmdRecordableFlag) , m_mode(gen::SelectionMode::DEFAULT) { } diff --git a/src/app/commands/cmd_set_color_selector.cpp b/src/app/commands/cmd_set_color_selector.cpp index 78db2284f..39f49ad24 100644 --- a/src/app/commands/cmd_set_color_selector.cpp +++ b/src/app/commands/cmd_set_color_selector.cpp @@ -34,7 +34,7 @@ private: }; SetColorSelectorCommand::SetColorSelectorCommand() - : Command("SetColorSelector", CmdUIOnlyFlag) + : Command(CommandId::SetColorSelector(), CmdUIOnlyFlag) , m_type(ColorBar::ColorSelector::SPECTRUM) { } diff --git a/src/app/commands/cmd_set_ink_type.cpp b/src/app/commands/cmd_set_ink_type.cpp index 5b30d8363..866a84567 100644 --- a/src/app/commands/cmd_set_ink_type.cpp +++ b/src/app/commands/cmd_set_ink_type.cpp @@ -36,7 +36,7 @@ private: }; SetInkTypeCommand::SetInkTypeCommand() - : Command("SetInkType", CmdUIOnlyFlag) + : Command(CommandId::SetInkType(), CmdUIOnlyFlag) , m_type(tools::InkType::DEFAULT) { } diff --git a/src/app/commands/cmd_set_loop_section.cpp b/src/app/commands/cmd_set_loop_section.cpp index 122d0e1a1..985f97df2 100644 --- a/src/app/commands/cmd_set_loop_section.cpp +++ b/src/app/commands/cmd_set_loop_section.cpp @@ -40,7 +40,7 @@ protected: }; SetLoopSectionCommand::SetLoopSectionCommand() - : Command("SetLoopSection", CmdRecordableFlag) + : Command(CommandId::SetLoopSection(), CmdRecordableFlag) , m_action(Action::Auto) , m_begin(0) , m_end(0) @@ -120,7 +120,7 @@ void SetLoopSectionCommand::onExecute(Context* ctx) transaction.commit(); } else { - Command* cmd = Commands::instance()->byId(CommandId::FrameTagProperties); + Command* cmd = Commands::instance()->byId(CommandId::FrameTagProperties()); ctx->executeCommand(cmd); } } diff --git a/src/app/commands/cmd_set_palette.cpp b/src/app/commands/cmd_set_palette.cpp index c14025f13..1679dab05 100644 --- a/src/app/commands/cmd_set_palette.cpp +++ b/src/app/commands/cmd_set_palette.cpp @@ -25,7 +25,7 @@ namespace app { using namespace ui; SetPaletteCommand::SetPaletteCommand() - : Command("SetPalette", CmdRecordableFlag) + : Command(CommandId::SetPalette(), CmdRecordableFlag) , m_palette(NULL) { } diff --git a/src/app/commands/cmd_set_palette_entry_size.cpp b/src/app/commands/cmd_set_palette_entry_size.cpp index 0b0a8892e..540840cd4 100644 --- a/src/app/commands/cmd_set_palette_entry_size.cpp +++ b/src/app/commands/cmd_set_palette_entry_size.cpp @@ -30,7 +30,7 @@ private: }; SetPaletteEntrySizeCommand::SetPaletteEntrySizeCommand() - : Command("SetPaletteEntrySize", CmdUIOnlyFlag) + : Command(CommandId::SetPaletteEntrySize(), CmdUIOnlyFlag) , m_size(7) { } diff --git a/src/app/commands/cmd_set_same_ink.cpp b/src/app/commands/cmd_set_same_ink.cpp index c3eb3b0b4..0dc0d4dd1 100644 --- a/src/app/commands/cmd_set_same_ink.cpp +++ b/src/app/commands/cmd_set_same_ink.cpp @@ -29,7 +29,7 @@ protected: }; SetSameInkCommand::SetSameInkCommand() - : Command("SetSameInk", CmdUIOnlyFlag) + : Command(CommandId::SetSameInk(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_show.cpp b/src/app/commands/cmd_show.cpp index 5b2b6f9da..6e2343648 100644 --- a/src/app/commands/cmd_show.cpp +++ b/src/app/commands/cmd_show.cpp @@ -18,7 +18,7 @@ namespace app { class ShowExtrasCommand : public Command { public: ShowExtrasCommand() - : Command("ShowExtras", CmdUIOnlyFlag) { + : Command(CommandId::ShowExtras(), CmdUIOnlyFlag) { } Command* clone() const override { return new ShowExtrasCommand(*this); } @@ -57,7 +57,7 @@ protected: class ShowLayerEdgesCommand : public Command { public: ShowLayerEdgesCommand() - : Command("ShowLayerEdges", CmdUIOnlyFlag) { + : Command(CommandId::ShowLayerEdges(), CmdUIOnlyFlag) { } Command* clone() const override { return new ShowLayerEdgesCommand(*this); } @@ -77,7 +77,7 @@ protected: class ShowGridCommand : public Command { public: ShowGridCommand() - : Command("ShowGrid", CmdUIOnlyFlag) { + : Command(CommandId::ShowGrid(), CmdUIOnlyFlag) { } Command* clone() const override { return new ShowGridCommand(*this); } @@ -97,7 +97,7 @@ protected: class ShowPixelGridCommand : public Command { public: ShowPixelGridCommand() - : Command("ShowPixelGrid", CmdUIOnlyFlag) { + : Command(CommandId::ShowPixelGrid(), CmdUIOnlyFlag) { } Command* clone() const override { return new ShowPixelGridCommand(*this); } @@ -117,7 +117,7 @@ protected: class ShowSelectionEdgesCommand : public Command { public: ShowSelectionEdgesCommand() - : Command("ShowSelectionEdges", CmdUIOnlyFlag) { + : Command(CommandId::ShowSelectionEdges(), CmdUIOnlyFlag) { } Command* clone() const override { return new ShowSelectionEdgesCommand(*this); } @@ -137,7 +137,7 @@ protected: class ShowBrushPreviewCommand : public Command { public: ShowBrushPreviewCommand() - : Command("ShowBrushPreview", CmdUIOnlyFlag) { + : Command(CommandId::ShowBrushPreview(), CmdUIOnlyFlag) { } Command* clone() const override { return new ShowBrushPreviewCommand(*this); } @@ -162,7 +162,7 @@ protected: class ShowAutoGuidesCommand : public Command { public: ShowAutoGuidesCommand() - : Command("ShowAutoGuides", CmdUIOnlyFlag) { + : Command(CommandId::ShowAutoGuides(), CmdUIOnlyFlag) { } Command* clone() const override { return new ShowAutoGuidesCommand(*this); } @@ -182,7 +182,7 @@ protected: class ShowSlicesCommand : public Command { public: ShowSlicesCommand() - : Command("ShowSlices", CmdUIOnlyFlag) { + : Command(CommandId::ShowSlices(), CmdUIOnlyFlag) { } Command* clone() const override { return new ShowSlicesCommand(*this); } diff --git a/src/app/commands/cmd_slice_properties.cpp b/src/app/commands/cmd_slice_properties.cpp index ccb01128e..59f101c2c 100644 --- a/src/app/commands/cmd_slice_properties.cpp +++ b/src/app/commands/cmd_slice_properties.cpp @@ -39,7 +39,7 @@ private: }; SlicePropertiesCommand::SlicePropertiesCommand() - : Command("SliceProperties", CmdUIOnlyFlag) + : Command(CommandId::SliceProperties(), CmdUIOnlyFlag) , m_sliceId(NullId) { } diff --git a/src/app/commands/cmd_sprite_properties.cpp b/src/app/commands/cmd_sprite_properties.cpp index 76bb72439..95571cfe9 100644 --- a/src/app/commands/cmd_sprite_properties.cpp +++ b/src/app/commands/cmd_sprite_properties.cpp @@ -43,7 +43,7 @@ protected: }; SpritePropertiesCommand::SpritePropertiesCommand() - : Command("SpriteProperties", CmdUIOnlyFlag) + : Command(CommandId::SpriteProperties(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_sprite_size.cpp b/src/app/commands/cmd_sprite_size.cpp index 048018011..bdf85c4e2 100644 --- a/src/app/commands/cmd_sprite_size.cpp +++ b/src/app/commands/cmd_sprite_size.cpp @@ -271,7 +271,7 @@ private: }; SpriteSizeCommand::SpriteSizeCommand() - : Command("SpriteSize", CmdRecordableFlag) + : Command(CommandId::SpriteSize(), CmdRecordableFlag) { m_useUI = true; m_width = 0; diff --git a/src/app/commands/cmd_switch_colors.cpp b/src/app/commands/cmd_switch_colors.cpp index 571a517fc..03f1bdba9 100644 --- a/src/app/commands/cmd_switch_colors.cpp +++ b/src/app/commands/cmd_switch_colors.cpp @@ -28,7 +28,7 @@ protected: }; SwitchColorsCommand::SwitchColorsCommand() - : Command("SwitchColors", CmdUIOnlyFlag) + : Command(CommandId::SwitchColors(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_symmetry_mode.cpp b/src/app/commands/cmd_symmetry_mode.cpp index eaa28250a..b5da17966 100644 --- a/src/app/commands/cmd_symmetry_mode.cpp +++ b/src/app/commands/cmd_symmetry_mode.cpp @@ -28,7 +28,7 @@ protected: }; SymmetryModeCommand::SymmetryModeCommand() - : Command("SymmetryMode", CmdUIOnlyFlag) + : Command(CommandId::SymmetryMode(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_tiled_mode.cpp b/src/app/commands/cmd_tiled_mode.cpp index f96b0cd87..240b861ba 100644 --- a/src/app/commands/cmd_tiled_mode.cpp +++ b/src/app/commands/cmd_tiled_mode.cpp @@ -32,7 +32,7 @@ protected: }; TiledModeCommand::TiledModeCommand() - : Command("TiledMode", CmdUIOnlyFlag) + : Command(CommandId::TiledMode(), CmdUIOnlyFlag) , m_mode(filters::TiledMode::NONE) { } diff --git a/src/app/commands/cmd_timeline.cpp b/src/app/commands/cmd_timeline.cpp index e0c59e27d..10fddf520 100644 --- a/src/app/commands/cmd_timeline.cpp +++ b/src/app/commands/cmd_timeline.cpp @@ -36,7 +36,7 @@ protected: }; TimelineCommand::TimelineCommand() - : Command("Timeline", CmdUIOnlyFlag) + : Command(CommandId::Timeline(), CmdUIOnlyFlag) { m_open = true; m_close = false; diff --git a/src/app/commands/cmd_toggle_preview.cpp b/src/app/commands/cmd_toggle_preview.cpp index 794284965..41340bcc1 100644 --- a/src/app/commands/cmd_toggle_preview.cpp +++ b/src/app/commands/cmd_toggle_preview.cpp @@ -28,7 +28,7 @@ protected: }; TogglePreviewCommand::TogglePreviewCommand() - : Command("TogglePreview", CmdUIOnlyFlag) + : Command(CommandId::TogglePreview(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_toggle_timeline_thumbnails.cpp b/src/app/commands/cmd_toggle_timeline_thumbnails.cpp index d52fff274..2406709c9 100644 --- a/src/app/commands/cmd_toggle_timeline_thumbnails.cpp +++ b/src/app/commands/cmd_toggle_timeline_thumbnails.cpp @@ -22,7 +22,7 @@ using namespace gfx; class ToggleTimelineThumbnailsCommand : public Command { public: ToggleTimelineThumbnailsCommand() - : Command("ToggleTimelineThumbnails", CmdUIOnlyFlag) { + : Command(CommandId::ToggleTimelineThumbnails(), CmdUIOnlyFlag) { } Command* clone() const override { return new ToggleTimelineThumbnailsCommand(*this); } diff --git a/src/app/commands/cmd_undo.cpp b/src/app/commands/cmd_undo.cpp index 9eb91522e..a6d292cb6 100644 --- a/src/app/commands/cmd_undo.cpp +++ b/src/app/commands/cmd_undo.cpp @@ -42,7 +42,8 @@ private: }; UndoCommand::UndoCommand(Type type) - : Command((type == Undo ? "Undo": "Redo"), CmdUIOnlyFlag) + : Command((type == Undo ? CommandId::Undo(): + CommandId::Redo()), CmdUIOnlyFlag) , m_type(type) { } diff --git a/src/app/commands/cmd_undo_history.cpp b/src/app/commands/cmd_undo_history.cpp index 20c37ec05..10430d244 100644 --- a/src/app/commands/cmd_undo_history.cpp +++ b/src/app/commands/cmd_undo_history.cpp @@ -266,7 +266,7 @@ protected: static UndoHistoryWindow* g_window = NULL; UndoHistoryCommand::UndoHistoryCommand() - : Command("UndoHistory", CmdUIOnlyFlag) + : Command(CommandId::UndoHistory(), CmdUIOnlyFlag) { } diff --git a/src/app/commands/cmd_unlink_cel.cpp b/src/app/commands/cmd_unlink_cel.cpp index a468f2b65..cf64a7ec8 100644 --- a/src/app/commands/cmd_unlink_cel.cpp +++ b/src/app/commands/cmd_unlink_cel.cpp @@ -32,7 +32,7 @@ protected: }; UnlinkCelCommand::UnlinkCelCommand() - : Command("UnlinkCel", CmdRecordableFlag) + : Command(CommandId::UnlinkCel(), CmdRecordableFlag) { } diff --git a/src/app/commands/cmd_zoom.cpp b/src/app/commands/cmd_zoom.cpp index 646de856a..9c86bf654 100644 --- a/src/app/commands/cmd_zoom.cpp +++ b/src/app/commands/cmd_zoom.cpp @@ -45,7 +45,7 @@ private: }; ZoomCommand::ZoomCommand() - : Command("Zoom", CmdUIOnlyFlag) + : Command(CommandId::Zoom(), CmdUIOnlyFlag) , m_action(Action::In) , m_zoom(1, 1) , m_focus(Focus::Default) diff --git a/src/app/commands/command.h b/src/app/commands/command.h index b34271aa1..6a4ae9291 100644 --- a/src/app/commands/command.h +++ b/src/app/commands/command.h @@ -9,6 +9,8 @@ #pragma once #include "app/commands/command_factory.h" +#include "app/commands/command_ids.h" + #include namespace app { diff --git a/src/app/commands/command_ids.h b/src/app/commands/command_ids.h new file mode 100644 index 000000000..1091deeb2 --- /dev/null +++ b/src/app/commands/command_ids.h @@ -0,0 +1,19 @@ +// Aseprite +// Copyright (C) 2017 David Capello +// +// This program is distributed under the terms of +// the End-User License Agreement for Aseprite. + +#ifndef APP_COMMANDS_COMMAND_IDS_H_INCLUDED +#define APP_COMMANDS_COMMAND_IDS_H_INCLUDED +#pragma once + +#include "command_ids.ini.h" + +namespace app { + + typedef gen::CommandId CommandId; + +} // namespace app + +#endif diff --git a/src/app/commands/commands.cpp b/src/app/commands/commands.cpp index 97ad9299d..ef457e3ba 100644 --- a/src/app/commands/commands.cpp +++ b/src/app/commands/commands.cpp @@ -20,12 +20,6 @@ namespace app { -#undef FOR_EACH_COMMAND - #define FOR_EACH_COMMAND(Name) \ - const char* CommandId::Name = #Name; - #include "app/commands/commands_list.h" -#undef FOR_EACH_COMMAND - Commands* Commands::m_instance = NULL; Commands::Commands() diff --git a/src/app/commands/commands.h b/src/app/commands/commands.h index ceeff0d44..5e72f889d 100644 --- a/src/app/commands/commands.h +++ b/src/app/commands/commands.h @@ -8,6 +8,7 @@ #define APP_COMMANDS_COMMANDS_H_INCLUDED #pragma once +#include "app/commands/command_ids.h" #include "ui/base.h" #include @@ -15,15 +16,6 @@ #include namespace app { - - struct CommandId { -#undef FOR_EACH_COMMAND -#define FOR_EACH_COMMAND(Name) \ - static const char* Name; -#include "app/commands/commands_list.h" -#undef FOR_EACH_COMMAND - }; - class Command; class Commands { diff --git a/src/app/commands/filters/cmd_brightness_contrast.cpp b/src/app/commands/filters/cmd_brightness_contrast.cpp index 7f8e2de93..9b59577aa 100644 --- a/src/app/commands/filters/cmd_brightness_contrast.cpp +++ b/src/app/commands/filters/cmd_brightness_contrast.cpp @@ -75,7 +75,7 @@ protected: }; BrightnessContrastCommand::BrightnessContrastCommand() - : Command("BrightnessContrast", CmdRecordableFlag) + : Command(CommandId::BrightnessContrast(), CmdRecordableFlag) { } diff --git a/src/app/commands/filters/cmd_color_curve.cpp b/src/app/commands/filters/cmd_color_curve.cpp index 0267a636c..1a57fc35d 100644 --- a/src/app/commands/filters/cmd_color_curve.cpp +++ b/src/app/commands/filters/cmd_color_curve.cpp @@ -79,7 +79,7 @@ protected: }; ColorCurveCommand::ColorCurveCommand() - : Command("ColorCurve", CmdRecordableFlag) + : Command(CommandId::ColorCurve(), CmdRecordableFlag) { } diff --git a/src/app/commands/filters/cmd_convolution_matrix.cpp b/src/app/commands/filters/cmd_convolution_matrix.cpp index 52afd56b5..40b9e48dc 100644 --- a/src/app/commands/filters/cmd_convolution_matrix.cpp +++ b/src/app/commands/filters/cmd_convolution_matrix.cpp @@ -151,7 +151,7 @@ protected: }; ConvolutionMatrixCommand::ConvolutionMatrixCommand() - : Command("ConvolutionMatrix", CmdRecordableFlag) + : Command(CommandId::ConvolutionMatrix(), CmdRecordableFlag) { } diff --git a/src/app/commands/filters/cmd_despeckle.cpp b/src/app/commands/filters/cmd_despeckle.cpp index 47156d63c..3d8e668e4 100644 --- a/src/app/commands/filters/cmd_despeckle.cpp +++ b/src/app/commands/filters/cmd_despeckle.cpp @@ -97,7 +97,7 @@ protected: }; DespeckleCommand::DespeckleCommand() - : Command("Despeckle", CmdRecordableFlag) + : Command(CommandId::Despeckle(), CmdRecordableFlag) { } diff --git a/src/app/commands/filters/cmd_hue_saturation.cpp b/src/app/commands/filters/cmd_hue_saturation.cpp index 20a795863..734846058 100644 --- a/src/app/commands/filters/cmd_hue_saturation.cpp +++ b/src/app/commands/filters/cmd_hue_saturation.cpp @@ -80,7 +80,7 @@ protected: }; HueSaturationCommand::HueSaturationCommand() - : Command("HueSaturation", CmdRecordableFlag) + : Command(CommandId::HueSaturation(), CmdRecordableFlag) { } diff --git a/src/app/commands/filters/cmd_invert_color.cpp b/src/app/commands/filters/cmd_invert_color.cpp index c23e011c0..16d3bae1d 100644 --- a/src/app/commands/filters/cmd_invert_color.cpp +++ b/src/app/commands/filters/cmd_invert_color.cpp @@ -52,7 +52,7 @@ protected: }; InvertColorCommand::InvertColorCommand() - : Command("InvertColor", CmdRecordableFlag) + : Command(CommandId::InvertColor(), CmdRecordableFlag) { } diff --git a/src/app/commands/filters/cmd_replace_color.cpp b/src/app/commands/filters/cmd_replace_color.cpp index ecb7c5965..760d39238 100644 --- a/src/app/commands/filters/cmd_replace_color.cpp +++ b/src/app/commands/filters/cmd_replace_color.cpp @@ -106,7 +106,7 @@ private: switch (msg->type()) { case ui::kKeyDownMessage: { const Key* key = - KeyboardShortcuts::instance()->command(CommandId::SwitchColors); + KeyboardShortcuts::instance()->command(CommandId::SwitchColors()); if (key && key->isPressed(msg)) { // Switch colors app::Color from = m_fromButton->getColor(); @@ -138,7 +138,7 @@ protected: }; ReplaceColorCommand::ReplaceColorCommand() - : Command("ReplaceColor", CmdRecordableFlag) + : Command(CommandId::ReplaceColor(), CmdRecordableFlag) { } diff --git a/src/app/modules/gui.cpp b/src/app/modules/gui.cpp index 8dc98ac68..01440ac74 100644 --- a/src/app/modules/gui.cpp +++ b/src/app/modules/gui.cpp @@ -322,7 +322,7 @@ bool CustomizedGuiManager::onProcessMessage(Message* msg) case kCloseDisplayMessage: { // Execute the "Exit" command. - Command* command = Commands::instance()->byId(CommandId::Exit); + Command* command = Commands::instance()->byId(CommandId::Exit()); UIContext::instance()->executeCommand(command); } break; diff --git a/src/app/script/app_object.cpp b/src/app/script/app_object.cpp index db0b9b636..29ac066e9 100644 --- a/src/app/script/app_object.cpp +++ b/src/app/script/app_object.cpp @@ -30,7 +30,7 @@ void App_open(script::ContextHandle handle) app::Document* oldDoc = UIContext::instance()->activeDocument(); Command* openCommand = - Commands::instance()->byId(CommandId::OpenFile); + Commands::instance()->byId(CommandId::OpenFile()); Params params; params.set("filename", filename); UIContext::instance()->executeCommand(openCommand, params); @@ -48,7 +48,7 @@ void App_exit(script::ContextHandle handle) UIContext* appCtx = UIContext::instance(); if (appCtx && appCtx->isUIAvailable()) { Command* exitCommand = - Commands::instance()->byId(CommandId::Exit); + Commands::instance()->byId(CommandId::Exit()); appCtx->executeCommand(exitCommand); } ctx.pushUndefined(); diff --git a/src/app/script/sprite_class.cpp b/src/app/script/sprite_class.cpp index 33d05dafe..74c1e6256 100644 --- a/src/app/script/sprite_class.cpp +++ b/src/app/script/sprite_class.cpp @@ -108,7 +108,7 @@ void Sprite_save(script::ContextHandle handle) auto uiCtx = UIContext::instance(); uiCtx->setActiveDocument(doc); Command* saveCommand = - Commands::instance()->byId(CommandId::SaveFile); + Commands::instance()->byId(CommandId::SaveFile()); uiCtx->executeCommand(saveCommand); } @@ -129,7 +129,7 @@ void Sprite_saveAs(script::ContextHandle handle) uiCtx->setActiveDocument(doc); Command* saveCommand = - Commands::instance()->byId(CommandId::SaveFile); + Commands::instance()->byId(CommandId::SaveFile()); Params params; doc->setFilename(fn); @@ -153,7 +153,7 @@ void Sprite_saveCopyAs(script::ContextHandle handle) uiCtx->setActiveDocument(doc); Command* saveCommand = - Commands::instance()->byId(CommandId::SaveFileCopyAs); + Commands::instance()->byId(CommandId::SaveFileCopyAs()); Params params; params.set("filename", fn); diff --git a/src/app/ui/brush_popup.cpp b/src/app/ui/brush_popup.cpp index 1337a536e..1c4a1c488 100644 --- a/src/app/ui/brush_popup.cpp +++ b/src/app/ui/brush_popup.cpp @@ -126,13 +126,13 @@ private: Params params; params.set("change", "custom"); params.set("slot", base::convert_to(m_slot).c_str()); - Command* cmd = Commands::instance()->byId(CommandId::ChangeBrush); + Command* cmd = Commands::instance()->byId(CommandId::ChangeBrush()); cmd->loadParams(params); std::string search = cmd->friendlyName(); if (!search.empty()) { params.clear(); params.set("search", search.c_str()); - cmd = Commands::instance()->byId(CommandId::KeyboardShortcuts); + cmd = Commands::instance()->byId(CommandId::KeyboardShortcuts()); ASSERT(cmd); if (cmd) UIContext::instance()->executeCommand(cmd, params); @@ -409,7 +409,7 @@ void BrushPopup::regenerate(const gfx::Rect& box) params.set("change", "custom"); params.set("slot", base::convert_to(slot).c_str()); Key* key = KeyboardShortcuts::instance()->command( - CommandId::ChangeBrush, params); + CommandId::ChangeBrush(), params); if (key && !key->accels().empty()) shortcut = key->accels().front().toString(); } diff --git a/src/app/ui/color_bar.cpp b/src/app/ui/color_bar.cpp index b34c5f192..3bc832db9 100644 --- a/src/app/ui/color_bar.cpp +++ b/src/app/ui/color_bar.cpp @@ -452,16 +452,16 @@ void ColorBar::onFocusPaletteView() void ColorBar::onBeforeExecuteCommand(CommandExecutionEvent& ev) { - if (ev.command()->id() == CommandId::SetPalette || - ev.command()->id() == CommandId::LoadPalette || - ev.command()->id() == CommandId::ColorQuantization) + if (ev.command()->id() == CommandId::SetPalette() || + ev.command()->id() == CommandId::LoadPalette() || + ev.command()->id() == CommandId::ColorQuantization()) showRemap(); } void ColorBar::onAfterExecuteCommand(CommandExecutionEvent& ev) { - if (ev.command()->id() == CommandId::Undo || - ev.command()->id() == CommandId::Redo) + if (ev.command()->id() == CommandId::Undo() || + ev.command()->id() == CommandId::Redo()) invalidate(); // If the sprite isn't Indexed anymore (e.g. because we've just @@ -1024,7 +1024,7 @@ void ColorBar::onFixWarningClick(ColorButton* colorButton, ui::Button* warningIc Palette* palette = get_current_palette(); const int oldEntries = palette->size(); - Command* command = Commands::instance()->byId(CommandId::AddColor); + Command* command = Commands::instance()->byId(CommandId::AddColor()); Params params; params.set("source", "color"); params.set("color", colorButton->getColor().toString().c_str()); @@ -1191,7 +1191,7 @@ void ColorBar::setupTooltips(TooltipManager* tooltipManager) { tooltipManager->addTooltipFor( m_buttons.getItem((int)PalButton::EDIT), - key_tooltip("Edit Color", CommandId::PaletteEditor), BOTTOM); + key_tooltip("Edit Color", CommandId::PaletteEditor()), BOTTOM); tooltipManager->addTooltipFor(m_buttons.getItem((int)PalButton::SORT), "Sort & Gradients", BOTTOM); tooltipManager->addTooltipFor(m_buttons.getItem((int)PalButton::PRESETS), "Presets", BOTTOM); @@ -1219,15 +1219,15 @@ void ColorBar::registerCommands() Commands::instance() ->add( new QuickCommand( - "ShowPaletteSortOptions", + CommandId::ShowPaletteSortOptions(), [this]{ this->showPaletteSortOptions(); })) ->add( new QuickCommand( - "ShowPalettePresets", + CommandId::ShowPalettePresets(), [this]{ this->showPalettePresets(); })) ->add( new QuickCommand( - "ShowPaletteOptions", + CommandId::ShowPaletteOptions(), [this]{ this->showPaletteOptions(); })); } diff --git a/src/app/ui/context_bar.cpp b/src/app/ui/context_bar.cpp index 376706121..ad81d97bf 100644 --- a/src/app/ui/context_bar.cpp +++ b/src/app/ui/context_bar.cpp @@ -92,7 +92,7 @@ private: switch (selectedItem()) { case 0: { - cmd = Commands::instance()->byId(CommandId::Zoom); + cmd = Commands::instance()->byId(CommandId::Zoom()); params.set("action", "set"); params.set("percentage", "100"); params.set("focus", "center"); @@ -101,12 +101,12 @@ private: } case 1: { - cmd = Commands::instance()->byId(CommandId::ScrollCenter); + cmd = Commands::instance()->byId(CommandId::ScrollCenter()); break; } case 2: { - cmd = Commands::instance()->byId(CommandId::FitScreen); + cmd = Commands::instance()->byId(CommandId::FitScreen()); break; } } @@ -131,7 +131,7 @@ protected: ButtonSet::onItemChange(item); Command* discardBrush = Commands::instance() - ->byId(CommandId::DiscardBrush); + ->byId(CommandId::DiscardBrush()); UIContext::instance()->executeCommand(discardBrush); } }; @@ -2059,10 +2059,10 @@ void ContextBar::setupTooltips(TooltipManager* tooltipManager) tooltipManager->addTooltipFor(m_rotAlgo, "Rotation Algorithm", BOTTOM); tooltipManager->addTooltipFor(m_freehandAlgo, key_tooltip("Freehand trace algorithm", - CommandId::PixelPerfectMode), BOTTOM); + CommandId::PixelPerfectMode()), BOTTOM); tooltipManager->addTooltipFor(m_contiguous, key_tooltip("Fill contiguous areas color", - CommandId::ContiguousFill), BOTTOM); + CommandId::ContiguousFill()), BOTTOM); tooltipManager->addTooltipFor(m_paintBucketSettings, "Extra paint bucket options", BOTTOM); @@ -2078,7 +2078,7 @@ void ContextBar::registerCommands() Commands::instance() ->add( new QuickCommand( - "ShowBrushes", + CommandId::ShowBrushes(), [this]{ this->showBrushes(); })); } diff --git a/src/app/ui/document_view.cpp b/src/app/ui/document_view.cpp index 964053861..f85fdb615 100644 --- a/src/app/ui/document_view.cpp +++ b/src/app/ui/document_view.cpp @@ -309,7 +309,7 @@ bool DocumentView::onCloseView(Workspace* workspace, bool quitting) ctx->updateFlags(); Command* save_command = - Commands::instance()->byId(CommandId::SaveFile); + Commands::instance()->byId(CommandId::SaveFile()); ctx->executeCommand(save_command); try_again = true; @@ -579,7 +579,7 @@ void DocumentView::onCancel(Context* ctx) // Deselect mask if (ctx->checkFlags(ContextFlags::ActiveDocumentIsWritable | ContextFlags::HasVisibleMask)) { - Command* deselectMask = Commands::instance()->byId(CommandId::DeselectMask); + Command* deselectMask = Commands::instance()->byId(CommandId::DeselectMask()); ctx->executeCommand(deselectMask); } } diff --git a/src/app/ui/editor/drawing_state.cpp b/src/app/ui/editor/drawing_state.cpp index 142b23b56..c423e172e 100644 --- a/src/app/ui/editor/drawing_state.cpp +++ b/src/app/ui/editor/drawing_state.cpp @@ -220,7 +220,7 @@ bool DrawingState::onKeyDown(Editor* editor, KeyMessage* msg) if (KeyboardShortcuts::instance() ->getCommandFromKeyMessage(msg, &command, ¶ms)) { // We accept zoom commands. - if (command->id() == CommandId::Zoom) { + if (command->id() == CommandId::Zoom()) { UIContext::instance()->executeCommand(command, params); return true; } diff --git a/src/app/ui/editor/moving_pixels_state.cpp b/src/app/ui/editor/moving_pixels_state.cpp index 0d57e52e8..55b043960 100644 --- a/src/app/ui/editor/moving_pixels_state.cpp +++ b/src/app/ui/editor/moving_pixels_state.cpp @@ -423,7 +423,7 @@ bool MovingPixelsState::onKeyDown(Editor* editor, KeyMessage* msg) // The escape key drop pixels and deselect the mask. if (msg->scancode() == kKeyEsc) { // TODO make this key customizable - Command* cmd = Commands::instance()->byId(CommandId::DeselectMask); + Command* cmd = Commands::instance()->byId(CommandId::DeselectMask()); UIContext::instance()->executeCommand(cmd); } @@ -498,21 +498,21 @@ void MovingPixelsState::onBeforeCommandExecution(CommandExecutionEvent& ev) } // Don't drop pixels if the user zooms/scrolls/picks a color // using commands. - else if ((command->id() == CommandId::Zoom) || - (command->id() == CommandId::Scroll) || - (command->id() == CommandId::Eyedropper) || + else if ((command->id() == CommandId::Zoom()) || + (command->id() == CommandId::Scroll()) || + (command->id() == CommandId::Eyedropper()) || // DiscardBrush is used by Eyedropper command - (command->id() == CommandId::DiscardBrush)) { + (command->id() == CommandId::DiscardBrush())) { // Do not drop pixels return; } // Intercept the "Cut" or "Copy" command to handle them locally // with the current m_pixelsMovement data. - else if (command->id() == CommandId::Cut || - command->id() == CommandId::Copy || - command->id() == CommandId::Clear) { + else if (command->id() == CommandId::Cut() || + command->id() == CommandId::Copy() || + command->id() == CommandId::Clear()) { // Copy the floating image to the clipboard on Cut/Copy. - if (command->id() != CommandId::Clear) { + if (command->id() != CommandId::Clear()) { Document* document = m_editor->document(); base::UniquePtr floatingImage; base::UniquePtr floatingMask; @@ -524,12 +524,12 @@ void MovingPixelsState::onBeforeCommandExecution(CommandExecutionEvent& ev) } // Clear floating pixels on Cut/Clear. - if (command->id() != CommandId::Copy) { + if (command->id() != CommandId::Copy()) { m_pixelsMovement->trim(); // Should we keep the mask after an Edit > Clear command? auto keepMask = PixelsMovement::DontKeepMask; - if (command->id() == CommandId::Clear && + if (command->id() == CommandId::Clear() && Preferences::instance().selection.keepSelectionAfterClear()) { keepMask = PixelsMovement::KeepMask; } @@ -548,7 +548,7 @@ void MovingPixelsState::onBeforeCommandExecution(CommandExecutionEvent& ev) } // Flip Horizontally/Vertically commands are handled manually to // avoid dropping the floating region of pixels. - else if (command->id() == CommandId::Flip) { + else if (command->id() == CommandId::Flip()) { if (FlipCommand* flipCommand = dynamic_cast(command)) { m_pixelsMovement->flipImage(flipCommand->getFlipType()); @@ -557,7 +557,7 @@ void MovingPixelsState::onBeforeCommandExecution(CommandExecutionEvent& ev) } } // Rotate is quite simple, we can add the angle to the current transformation. - else if (command->id() == CommandId::Rotate) { + else if (command->id() == CommandId::Rotate()) { if (RotateCommand* rotate = dynamic_cast(command)) { if (rotate->flipMask()) { m_pixelsMovement->rotate(rotate->angle()); diff --git a/src/app/ui/editor/play_state.cpp b/src/app/ui/editor/play_state.cpp index 7281a9cc6..ff297c60b 100644 --- a/src/app/ui/editor/play_state.cpp +++ b/src/app/ui/editor/play_state.cpp @@ -238,9 +238,9 @@ void PlayState::onBeforeCommandExecution(CommandExecutionEvent& ev) // // There are other commands that just doesn't stop the animation // (zoom, scroll, etc.) - if (ev.command()->id() == CommandId::PlayAnimation || - ev.command()->id() == CommandId::Zoom || - ev.command()->id() == CommandId::Scroll) { + if (ev.command()->id() == CommandId::PlayAnimation() || + ev.command()->id() == CommandId::Zoom() || + ev.command()->id() == CommandId::Scroll()) { return; } diff --git a/src/app/ui/editor/standby_state.cpp b/src/app/ui/editor/standby_state.cpp index f6aad8fae..0a4eab409 100644 --- a/src/app/ui/editor/standby_state.cpp +++ b/src/app/ui/editor/standby_state.cpp @@ -378,7 +378,7 @@ bool StandbyState::onDoubleClick(Editor* editor, MouseMessage* msg) // Select a tile with double-click if (ink->isSelection()) { Command* selectTileCmd = - Commands::instance()->byId(CommandId::SelectTile); + Commands::instance()->byId(CommandId::SelectTile()); Params params; if (int(editor->getToolLoopModifiers()) & int(tools::ToolLoopModifiers::kAddSelection)) @@ -740,7 +740,7 @@ void StandbyState::callEyedropper(Editor* editor) return; Command* eyedropper_cmd = - Commands::instance()->byId(CommandId::Eyedropper); + Commands::instance()->byId(CommandId::Eyedropper()); bool fg = (static_cast(clickedInk)->target() == tools::PickInk::Fg); Params params; diff --git a/src/app/ui/editor/state_with_wheel_behavior.cpp b/src/app/ui/editor/state_with_wheel_behavior.cpp index 20df6617e..640f2c6a6 100644 --- a/src/app/ui/editor/state_with_wheel_behavior.cpp +++ b/src/app/ui/editor/state_with_wheel_behavior.cpp @@ -117,9 +117,9 @@ bool StateWithWheelBehavior::onMouseWheel(Editor* editor, MouseMessage* msg) Command* command = nullptr; if (dz < 0.0) - command = Commands::instance()->byId(CommandId::GotoNextFrame); + command = Commands::instance()->byId(CommandId::GotoNextFrame()); else if (dz > 0.0) - command = Commands::instance()->byId(CommandId::GotoPreviousFrame); + command = Commands::instance()->byId(CommandId::GotoPreviousFrame()); if (command) UIContext::instance()->executeCommand(command); diff --git a/src/app/ui/home_view.cpp b/src/app/ui/home_view.cpp index e6fd03c9a..fcb552f2f 100644 --- a/src/app/ui/home_view.cpp +++ b/src/app/ui/home_view.cpp @@ -113,13 +113,13 @@ void HomeView::onWorkspaceViewSelected() void HomeView::onNewFile() { - Command* command = Commands::instance()->byId(CommandId::NewFile); + Command* command = Commands::instance()->byId(CommandId::NewFile()); UIContext::instance()->executeCommand(command); } void HomeView::onOpenFile() { - Command* command = Commands::instance()->byId(CommandId::OpenFile); + Command* command = Commands::instance()->byId(CommandId::OpenFile()); UIContext::instance()->executeCommand(command); } diff --git a/src/app/ui/main_window.cpp b/src/app/ui/main_window.cpp index 0150a2516..b91033880 100644 --- a/src/app/ui/main_window.cpp +++ b/src/app/ui/main_window.cpp @@ -436,7 +436,7 @@ void MainWindow::onTabsContainerDoubleClicked(Tabs* tabs) WorkspaceView* oldActiveView = mainPanel->activeView(); app::Document* oldDoc = static_cast(UIContext::instance()->activeDocument()); - Command* command = Commands::instance()->byId(CommandId::NewFile); + Command* command = Commands::instance()->byId(CommandId::NewFile()); UIContext::instance()->executeCommand(command); app::Document* newDoc = static_cast(UIContext::instance()->activeDocument()); diff --git a/src/app/ui/palette_popup.cpp b/src/app/ui/palette_popup.cpp index c5c9db533..801e90ace 100644 --- a/src/app/ui/palette_popup.cpp +++ b/src/app/ui/palette_popup.cpp @@ -108,7 +108,7 @@ void PalettePopup::onLoadPal() return; SetPaletteCommand* cmd = static_cast( - Commands::instance()->byId(CommandId::SetPalette)); + Commands::instance()->byId(CommandId::SetPalette())); cmd->setPalette(palette); UIContext::instance()->executeCommand(cmd); diff --git a/src/app/ui/recent_listbox.cpp b/src/app/ui/recent_listbox.cpp index a99e612c7..9fa3a3003 100644 --- a/src/app/ui/recent_listbox.cpp +++ b/src/app/ui/recent_listbox.cpp @@ -146,7 +146,7 @@ void RecentFilesListBox::onRebuildList() void RecentFilesListBox::onClick(const std::string& path) { - Command* command = Commands::instance()->byId(CommandId::OpenFile); + Command* command = Commands::instance()->byId(CommandId::OpenFile()); Params params; params.set("filename", path.c_str()); UIContext::instance()->executeCommand(command, params); @@ -171,7 +171,7 @@ void RecentFoldersListBox::onRebuildList() void RecentFoldersListBox::onClick(const std::string& path) { - Command* command = Commands::instance()->byId(CommandId::OpenFile); + Command* command = Commands::instance()->byId(CommandId::OpenFile()); Params params; params.set("folder", path.c_str()); UIContext::instance()->executeCommand(command, params); diff --git a/src/app/ui/status_bar.cpp b/src/app/ui/status_bar.cpp index 445031158..e3d88846e 100644 --- a/src/app/ui/status_bar.cpp +++ b/src/app/ui/status_bar.cpp @@ -510,7 +510,7 @@ public: if (hasFocus() && (scancode == kKeyEnter || // TODO customizable keys scancode == kKeyEnterPad)) { - Command* cmd = Commands::instance()->byId(CommandId::GotoFrame); + Command* cmd = Commands::instance()->byId(CommandId::GotoFrame()); Params params; params.set("frame", text().c_str()); UIContext::instance()->executeCommand(cmd, params); @@ -806,7 +806,7 @@ void StatusBar::onPixelFormatChanged(DocumentEvent& ev) void StatusBar::newFrame() { - Command* cmd = Commands::instance()->byId(CommandId::NewFrame); + Command* cmd = Commands::instance()->byId(CommandId::NewFrame()); UIContext::instance()->executeCommand(cmd); } diff --git a/src/app/ui/timeline/ani_controls.cpp b/src/app/ui/timeline/ani_controls.cpp index 53f061c76..cfd4fb82f 100644 --- a/src/app/ui/timeline/ani_controls.cpp +++ b/src/app/ui/timeline/ani_controls.cpp @@ -102,11 +102,11 @@ void AniControls::onRightClick(Item* item) const char* AniControls::getCommandId(int index) const { switch (index) { - case ACTION_FIRST: return CommandId::GotoFirstFrame; - case ACTION_PREV: return CommandId::GotoPreviousFrame; - case ACTION_PLAY: return CommandId::PlayAnimation; - case ACTION_NEXT: return CommandId::GotoNextFrame; - case ACTION_LAST: return CommandId::GotoLastFrame; + case ACTION_FIRST: return CommandId::GotoFirstFrame(); + case ACTION_PREV: return CommandId::GotoPreviousFrame(); + case ACTION_PLAY: return CommandId::PlayAnimation(); + case ACTION_NEXT: return CommandId::GotoNextFrame(); + case ACTION_LAST: return CommandId::GotoLastFrame(); } ASSERT(false); return nullptr; diff --git a/src/app/ui/timeline/timeline.cpp b/src/app/ui/timeline/timeline.cpp index d225d53f8..ee9f735d8 100644 --- a/src/app/ui/timeline/timeline.cpp +++ b/src/app/ui/timeline/timeline.cpp @@ -1050,7 +1050,7 @@ bool Timeline::onProcessMessage(Message* msg) } else if (mouseMsg->left()) { Command* command = Commands::instance() - ->byId(CommandId::FrameTagProperties); + ->byId(CommandId::FrameTagProperties()); UIContext::instance()->executeCommand(command, params); } } @@ -1104,7 +1104,7 @@ bool Timeline::onProcessMessage(Message* msg) case PART_ROW_TEXT: { Command* command = Commands::instance() - ->byId(CommandId::LayerProperties); + ->byId(CommandId::LayerProperties()); UIContext::instance()->executeCommand(command); return true; @@ -1112,7 +1112,7 @@ bool Timeline::onProcessMessage(Message* msg) case PART_HEADER_FRAME: { Command* command = Commands::instance() - ->byId(CommandId::FrameProperties); + ->byId(CommandId::FrameProperties()); Params params; params.set("frame", "current"); @@ -1122,7 +1122,7 @@ bool Timeline::onProcessMessage(Message* msg) case PART_CEL: { Command* command = Commands::instance() - ->byId(CommandId::CelProperties); + ->byId(CommandId::CelProperties()); UIContext::instance()->executeCommand(command); return true; @@ -3609,13 +3609,13 @@ bool Timeline::onClear(Context* ctx) switch (m_range.type()) { case DocumentRange::kCels: - cmd = Commands::instance()->byId(CommandId::ClearCel); + cmd = Commands::instance()->byId(CommandId::ClearCel()); break; case DocumentRange::kFrames: - cmd = Commands::instance()->byId(CommandId::RemoveFrame); + cmd = Commands::instance()->byId(CommandId::RemoveFrame()); break; case DocumentRange::kLayers: - cmd = Commands::instance()->byId(CommandId::RemoveLayer); + cmd = Commands::instance()->byId(CommandId::RemoveLayer()); break; } diff --git a/src/gen/gen.cpp b/src/gen/gen.cpp index c7d47a3ba..74464ed91 100644 --- a/src/gen/gen.cpp +++ b/src/gen/gen.cpp @@ -29,6 +29,7 @@ static void run(int argc, const char* argv[]) PO::Option& prefCpp = po.add("pref-cpp"); PO::Option& theme = po.add("theme"); PO::Option& strings = po.add("strings"); + PO::Option& commandIds = po.add("command-ids"); PO::Option& widgetsDir = po.add("widgets-dir").requiresValue(""); PO::Option& stringsDir = po.add("strings-dir").requiresValue(""); PO::Option& guiFile = po.add("gui-file").requiresValue(""); @@ -72,6 +73,10 @@ static void run(int argc, const char* argv[]) else if (po.enabled(strings)) { gen_strings_class(inputFilename); } + // Generate command_ids.ini.h file + else if (po.enabled(commandIds)) { + gen_command_ids(inputFilename); + } // Check all translation files (en.ini, es.ini, etc.) else if (po.enabled(widgetsDir) && po.enabled(stringsDir)) { diff --git a/src/gen/strings_class.cpp b/src/gen/strings_class.cpp index d97244c23..43401c6db 100644 --- a/src/gen/strings_class.cpp +++ b/src/gen/strings_class.cpp @@ -28,11 +28,9 @@ void gen_strings_class(const std::string& inputFn) << "// Don't modify, generated file from " << inputFn << "\n" << "\n"; - std::string fnUpper = base::string_to_upper(base::get_file_title(inputFn)); - std::cout - << "#ifndef GENERATED_" << fnUpper << "_H_INCLUDED\n" - << "#define GENERATED_" << fnUpper << "_H_INCLUDED\n" + << "#ifndef GENERATED_STRINGS_INI_H_INCLUDED\n" + << "#define GENERATED_STRINGS_INI_H_INCLUDED\n" << "#pragma once\n" << "\n" << "namespace app {\n" @@ -68,3 +66,43 @@ void gen_strings_class(const std::string& inputFn) << "\n" << "#endif\n"; } + +void gen_command_ids(const std::string& inputFn) +{ + cfg::CfgFile cfg; + cfg.load(inputFn); + + std::cout + << "// Don't modify, generated file from " << inputFn << "\n" + << "\n"; + + std::cout + << "#ifndef GENERATED_COMMAND_IDS_H_INCLUDED\n" + << "#define GENERATED_COMMAND_IDS_H_INCLUDED\n" + << "#pragma once\n" + << "\n" + << "namespace app {\n" + << "namespace gen {\n" + << "\n" + << " class CommandId {\n" + << " public:\n"; + + std::vector keys; + cfg.getAllKeys("commands", keys); + for (auto key : keys) { + if (key.find('_') != std::string::npos) + continue; + + std::cout << " static const char* " + << key << "() { return \"" + << key << "\"; }\n"; + } + + std::cout + << " };\n" + << "\n" + << "} // namespace gen\n" + << "} // namespace app\n" + << "\n" + << "#endif\n"; +} diff --git a/src/gen/strings_class.h b/src/gen/strings_class.h index 88ba497e4..1e7a72128 100644 --- a/src/gen/strings_class.h +++ b/src/gen/strings_class.h @@ -1,5 +1,5 @@ // Aseprite Code Generator -// Copyright (c) 2016 David Capello +// Copyright (c) 2016-2017 David Capello // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. @@ -11,5 +11,6 @@ #include void gen_strings_class(const std::string& iniFile); +void gen_command_ids(const std::string& iniFile); #endif