From 5108762f65a22808dd26b33199a98d1f94a62f58 Mon Sep 17 00:00:00 2001 From: Christian Kaiser Date: Wed, 23 Jul 2025 20:00:12 -0300 Subject: [PATCH] [WIP] Command refresh --- src/app/commands/cmd_about.cpp | 2 +- src/app/commands/cmd_add_color.cpp | 3 +- src/app/commands/cmd_advanced_mode.cpp | 2 +- .../commands/cmd_background_from_layer.cpp | 3 +- src/app/commands/cmd_cancel.cpp | 2 +- src/app/commands/cmd_canvas_size.cpp | 3 +- src/app/commands/cmd_cel_opacity.cpp | 4 +- src/app/commands/cmd_cel_properties.cpp | 3 +- src/app/commands/cmd_change_brush.cpp | 2 +- src/app/commands/cmd_change_color.cpp | 2 +- src/app/commands/cmd_change_pixel_format.cpp | 2 +- src/app/commands/cmd_clear.cpp | 2 +- src/app/commands/cmd_clear_cel.cpp | 4 +- src/app/commands/cmd_clear_recent_files.cpp | 3 +- src/app/commands/cmd_close_file.cpp | 13 ++-- src/app/commands/cmd_color_quantization.cpp | 2 +- src/app/commands/cmd_contiguous_fill.cpp | 2 +- src/app/commands/cmd_copy.cpp | 2 +- src/app/commands/cmd_copy_cel.cpp | 4 +- src/app/commands/cmd_copy_merged.cpp | 2 +- src/app/commands/cmd_crop.cpp | 5 +- src/app/commands/cmd_cut.cpp | 2 +- src/app/commands/cmd_deselect_mask.cpp | 2 +- src/app/commands/cmd_developer_console.cpp | 3 +- src/app/commands/cmd_discard_brush.cpp | 5 +- src/app/commands/cmd_duplicate_layer.cpp | 3 +- src/app/commands/cmd_duplicate_sprite.cpp | 2 +- src/app/commands/cmd_duplicate_view.cpp | 2 +- src/app/commands/cmd_enter_license.cpp | 2 +- src/app/commands/cmd_exit.cpp | 2 +- src/app/commands/cmd_export_sprite_sheet.cpp | 3 +- src/app/commands/cmd_eyedropper.cpp | 2 +- src/app/commands/cmd_fill_and_stroke.cpp | 2 +- src/app/commands/cmd_fit_screen.cpp | 2 +- src/app/commands/cmd_flatten_layers.cpp | 2 +- src/app/commands/cmd_flip.cpp | 2 +- src/app/commands/cmd_frame_properties.cpp | 21 +++--- src/app/commands/cmd_frame_tag_properties.cpp | 4 +- src/app/commands/cmd_fullscreen_mode.cpp | 2 +- src/app/commands/cmd_fullscreen_preview.cpp | 3 +- src/app/commands/cmd_goto_frame.cpp | 2 +- src/app/commands/cmd_goto_layer.cpp | 10 +-- src/app/commands/cmd_goto_tab.cpp | 5 +- src/app/commands/cmd_grid.cpp | 11 +-- src/app/commands/cmd_home.cpp | 5 +- src/app/commands/cmd_import_sprite_sheet.cpp | 2 +- src/app/commands/cmd_invert_mask.cpp | 2 +- src/app/commands/cmd_keyboard_shortcuts.cpp | 9 ++- src/app/commands/cmd_launch.cpp | 7 +- .../commands/cmd_layer_from_background.cpp | 3 +- src/app/commands/cmd_layer_lock.cpp | 2 +- src/app/commands/cmd_layer_opacity.cpp | 2 +- src/app/commands/cmd_layer_properties.cpp | 6 +- src/app/commands/cmd_layer_visibility.cpp | 3 +- src/app/commands/cmd_link_cels.cpp | 4 +- src/app/commands/cmd_load_mask.cpp | 13 ++-- src/app/commands/cmd_load_palette.cpp | 19 +++-- src/app/commands/cmd_mask_all.cpp | 2 +- src/app/commands/cmd_mask_by_color.cpp | 3 +- src/app/commands/cmd_mask_content.cpp | 10 +-- src/app/commands/cmd_merge_down_layer.cpp | 3 +- src/app/commands/cmd_modify_selection.cpp | 11 ++- src/app/commands/cmd_move_cel.cpp | 4 +- src/app/commands/cmd_move_mask.cpp | 2 +- src/app/commands/cmd_new_brush.cpp | 4 +- src/app/commands/cmd_new_file.cpp | 2 +- src/app/commands/cmd_new_frame.cpp | 2 +- src/app/commands/cmd_new_frame_tag.cpp | 6 +- src/app/commands/cmd_new_layer.cpp | 2 +- .../cmd_new_sprite_from_selection.cpp | 2 +- src/app/commands/cmd_onionskin.cpp | 2 +- src/app/commands/cmd_open_browser.cpp | 8 ++- src/app/commands/cmd_open_file.cpp | 2 +- src/app/commands/cmd_open_group.cpp | 2 +- src/app/commands/cmd_open_in_folder.cpp | 2 +- src/app/commands/cmd_open_script_folder.cpp | 3 +- src/app/commands/cmd_open_with_app.cpp | 2 +- src/app/commands/cmd_options.cpp | 2 +- src/app/commands/cmd_palette_editor.cpp | 10 ++- src/app/commands/cmd_palette_size.cpp | 12 ++-- src/app/commands/cmd_paste.cpp | 2 +- src/app/commands/cmd_paste_text.cpp | 6 +- src/app/commands/cmd_pixel_perfect_mode.cpp | 3 +- src/app/commands/cmd_play_animation.cpp | 10 +-- src/app/commands/cmd_refresh.cpp | 2 +- src/app/commands/cmd_remove_frame.cpp | 2 +- src/app/commands/cmd_remove_frame_tag.cpp | 2 +- src/app/commands/cmd_remove_layer.cpp | 2 +- src/app/commands/cmd_remove_slice.cpp | 18 ++--- src/app/commands/cmd_reopen_closed_file.cpp | 3 +- src/app/commands/cmd_repeat_last_export.cpp | 3 +- src/app/commands/cmd_reselect_mask.cpp | 2 +- src/app/commands/cmd_reverse_frames.cpp | 2 +- src/app/commands/cmd_rotate.cpp | 6 +- src/app/commands/cmd_run_script.cpp | 2 +- src/app/commands/cmd_save_file.cpp | 11 ++- src/app/commands/cmd_save_file.h | 2 +- src/app/commands/cmd_save_mask.cpp | 37 ++++++---- src/app/commands/cmd_save_palette.cpp | 71 +++++++++++-------- src/app/commands/cmd_scroll.cpp | 4 +- src/app/commands/cmd_scroll_center.cpp | 2 +- src/app/commands/cmd_select_palette.cpp | 2 +- src/app/commands/cmd_select_tile.cpp | 5 +- src/app/commands/cmd_set_color_selector.cpp | 9 ++- src/app/commands/cmd_set_ink_type.cpp | 9 ++- src/app/commands/cmd_set_loop_section.cpp | 5 +- src/app/commands/cmd_set_palette.cpp | 4 +- .../commands/cmd_set_palette_entry_size.cpp | 9 ++- src/app/commands/cmd_set_same_ink.cpp | 2 +- src/app/commands/cmd_show.cpp | 23 +++--- src/app/commands/cmd_slice_properties.cpp | 4 +- src/app/commands/cmd_sprite_properties.cpp | 7 +- src/app/commands/cmd_sprite_size.cpp | 2 +- .../commands/cmd_swap_checkerboard_colors.cpp | 2 +- src/app/commands/cmd_switch_colors.cpp | 2 +- src/app/commands/cmd_symmetry_mode.cpp | 5 +- src/app/commands/cmd_tiled_mode.cpp | 2 +- src/app/commands/cmd_timeline.cpp | 8 ++- src/app/commands/cmd_toggle_preview.cpp | 6 +- src/app/commands/cmd_toggle_tiles_mode.cpp | 2 +- .../cmd_toggle_timeline_thumbnails.cpp | 4 +- src/app/commands/cmd_undo.cpp | 2 +- src/app/commands/cmd_undo_history.cpp | 8 ++- src/app/commands/cmd_unlink_cel.cpp | 2 +- src/app/commands/cmd_zoom.cpp | 2 +- src/app/commands/command.cpp | 2 +- src/app/commands/command.h | 8 +-- src/app/commands/convert_layer.cpp | 2 +- src/app/commands/copy_path.cpp | 2 +- src/app/commands/debugger.cpp | 2 +- .../filters/cmd_brightness_contrast.cpp | 3 +- src/app/commands/filters/cmd_color_curve.cpp | 2 +- .../filters/cmd_convolution_matrix.cpp | 2 +- src/app/commands/filters/cmd_despeckle.cpp | 3 +- .../commands/filters/cmd_hue_saturation.cpp | 2 +- src/app/commands/filters/cmd_invert_color.cpp | 2 +- src/app/commands/filters/cmd_outline.cpp | 3 +- .../commands/filters/cmd_replace_color.cpp | 2 +- src/app/commands/move_colors_command.cpp | 3 +- src/app/commands/move_tiles_command.cpp | 3 +- src/app/commands/quick_command.cpp | 2 +- src/app/commands/screenshot.cpp | 2 +- src/app/commands/set_playback_speed.cpp | 2 +- src/app/commands/show_menu.cpp | 3 +- src/app/commands/tileset_mode.cpp | 5 +- .../commands/toggle_other_layers_opacity.cpp | 3 +- src/app/commands/toggle_play_option.cpp | 2 +- src/app/inline_command_execution.h | 2 +- src/app/script/plugin_class.cpp | 2 +- 149 files changed, 389 insertions(+), 329 deletions(-) diff --git a/src/app/commands/cmd_about.cpp b/src/app/commands/cmd_about.cpp index d44a9686b..abc0cc4ae 100644 --- a/src/app/commands/cmd_about.cpp +++ b/src/app/commands/cmd_about.cpp @@ -30,7 +30,7 @@ protected: void onExecute(Context* context) override; }; -AboutCommand::AboutCommand() : Command(CommandId::About(), CmdUIOnlyFlag) +AboutCommand::AboutCommand() : Command(CommandId::About()) { } diff --git a/src/app/commands/cmd_add_color.cpp b/src/app/commands/cmd_add_color.cpp index 4ed1bdfa4..2e4f4148c 100644 --- a/src/app/commands/cmd_add_color.cpp +++ b/src/app/commands/cmd_add_color.cpp @@ -63,8 +63,7 @@ protected: std::string onGetFriendlyName() const override; }; -AddColorCommand::AddColorCommand() - : CommandWithNewParams(CommandId::AddColor(), CmdUIOnlyFlag) +AddColorCommand::AddColorCommand() : CommandWithNewParams(CommandId::AddColor()) { } diff --git a/src/app/commands/cmd_advanced_mode.cpp b/src/app/commands/cmd_advanced_mode.cpp index 59b7d8120..d6cacbcee 100644 --- a/src/app/commands/cmd_advanced_mode.cpp +++ b/src/app/commands/cmd_advanced_mode.cpp @@ -32,7 +32,7 @@ protected: void onExecute(Context* context) override; }; -AdvancedModeCommand::AdvancedModeCommand() : Command(CommandId::AdvancedMode(), CmdUIOnlyFlag) +AdvancedModeCommand::AdvancedModeCommand() : Command(CommandId::AdvancedMode()) { } diff --git a/src/app/commands/cmd_background_from_layer.cpp b/src/app/commands/cmd_background_from_layer.cpp index ffce8e933..a23d7b93c 100644 --- a/src/app/commands/cmd_background_from_layer.cpp +++ b/src/app/commands/cmd_background_from_layer.cpp @@ -28,8 +28,7 @@ protected: void onExecute(Context* context) override; }; -BackgroundFromLayerCommand::BackgroundFromLayerCommand() - : Command(CommandId::BackgroundFromLayer(), CmdRecordableFlag) +BackgroundFromLayerCommand::BackgroundFromLayerCommand() : Command(CommandId::BackgroundFromLayer()) { } diff --git a/src/app/commands/cmd_cancel.cpp b/src/app/commands/cmd_cancel.cpp index 18f37a6a3..83f3b15e9 100644 --- a/src/app/commands/cmd_cancel.cpp +++ b/src/app/commands/cmd_cancel.cpp @@ -37,7 +37,7 @@ private: Type m_type; }; -CancelCommand::CancelCommand() : Command(CommandId::Cancel(), CmdUIOnlyFlag), m_type(NoOp) +CancelCommand::CancelCommand() : Command(CommandId::Cancel()), m_type(NoOp) { } diff --git a/src/app/commands/cmd_canvas_size.cpp b/src/app/commands/cmd_canvas_size.cpp index 20cce8826..86204962e 100644 --- a/src/app/commands/cmd_canvas_size.cpp +++ b/src/app/commands/cmd_canvas_size.cpp @@ -282,8 +282,7 @@ protected: void onExecute(Context* context) override; }; -CanvasSizeCommand::CanvasSizeCommand() - : CommandWithNewParams(CommandId::CanvasSize(), CmdRecordableFlag) +CanvasSizeCommand::CanvasSizeCommand() : CommandWithNewParams(CommandId::CanvasSize()) { } diff --git a/src/app/commands/cmd_cel_opacity.cpp b/src/app/commands/cmd_cel_opacity.cpp index 5773ea417..8119f0090 100644 --- a/src/app/commands/cmd_cel_opacity.cpp +++ b/src/app/commands/cmd_cel_opacity.cpp @@ -20,8 +20,6 @@ #include "app/tx.h" #include "app/ui/timeline/timeline.h" #include "doc/cel.h" -#include "doc/cels_range.h" -#include "doc/sprite.h" #include @@ -42,7 +40,7 @@ private: int m_opacity; }; -CelOpacityCommand::CelOpacityCommand() : Command(CommandId::CelOpacity(), CmdUIOnlyFlag) +CelOpacityCommand::CelOpacityCommand() : Command(CommandId::CelOpacity()) { m_opacity = 255; } diff --git a/src/app/commands/cmd_cel_properties.cpp b/src/app/commands/cmd_cel_properties.cpp index 140f6ec02..dcdd3ef73 100644 --- a/src/app/commands/cmd_cel_properties.cpp +++ b/src/app/commands/cmd_cel_properties.cpp @@ -23,7 +23,6 @@ #include "app/ui/timeline/timeline.h" #include "app/ui/user_data_view.h" #include "app/ui_context.h" -#include "base/mem_utils.h" #include "base/scoped_value.h" #include "doc/cel.h" #include "doc/cels_range.h" @@ -385,7 +384,7 @@ protected: void onExecute(Context* context) override; }; -CelPropertiesCommand::CelPropertiesCommand() : Command(CommandId::CelProperties(), CmdUIOnlyFlag) +CelPropertiesCommand::CelPropertiesCommand() : Command(CommandId::CelProperties()) { } diff --git a/src/app/commands/cmd_change_brush.cpp b/src/app/commands/cmd_change_brush.cpp index 71e68d80e..f83a1da79 100644 --- a/src/app/commands/cmd_change_brush.cpp +++ b/src/app/commands/cmd_change_brush.cpp @@ -64,7 +64,7 @@ private: int m_slot; }; -ChangeBrushCommand::ChangeBrushCommand() : Command(CommandId::ChangeBrush(), CmdUIOnlyFlag) +ChangeBrushCommand::ChangeBrushCommand() : Command(CommandId::ChangeBrush()) { 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 f5e4d8c1c..6043e3206 100644 --- a/src/app/commands/cmd_change_color.cpp +++ b/src/app/commands/cmd_change_color.cpp @@ -45,7 +45,7 @@ protected: std::string onGetFriendlyName() const override; }; -ChangeColorCommand::ChangeColorCommand() : Command(CommandId::ChangeColor(), CmdUIOnlyFlag) +ChangeColorCommand::ChangeColorCommand() : Command(CommandId::ChangeColor()) { 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 7f44bf6df..4b899e3b3 100644 --- a/src/app/commands/cmd_change_pixel_format.cpp +++ b/src/app/commands/cmd_change_pixel_format.cpp @@ -507,7 +507,7 @@ private: }; ChangePixelFormatCommand::ChangePixelFormatCommand() - : CommandWithNewParams(CommandId::ChangePixelFormat(), CmdUIOnlyFlag) + : CommandWithNewParams(CommandId::ChangePixelFormat()) { } diff --git a/src/app/commands/cmd_clear.cpp b/src/app/commands/cmd_clear.cpp index fefd8b6b4..0f6da332d 100644 --- a/src/app/commands/cmd_clear.cpp +++ b/src/app/commands/cmd_clear.cpp @@ -23,7 +23,7 @@ protected: void onExecute(Context* ctx) override; }; -ClearCommand::ClearCommand() : Command(CommandId::Clear(), CmdUIOnlyFlag) +ClearCommand::ClearCommand() : Command(CommandId::Clear()) { } diff --git a/src/app/commands/cmd_clear_cel.cpp b/src/app/commands/cmd_clear_cel.cpp index b2061d0f8..15865c9c0 100644 --- a/src/app/commands/cmd_clear_cel.cpp +++ b/src/app/commands/cmd_clear_cel.cpp @@ -32,7 +32,7 @@ protected: void onExecute(Context* context) override; }; -ClearCelCommand::ClearCelCommand() : Command(CommandId::ClearCel(), CmdRecordableFlag) +ClearCelCommand::ClearCelCommand() : Command(CommandId::ClearCel()) { } @@ -76,7 +76,7 @@ void ClearCelCommand::onExecute(Context* context) tx.commit(); } - if (nonEditableLayers) + if (context->isUIAvailable() && nonEditableLayers) StatusBar::instance()->showTip(1000, Strings::statusbar_tips_locked_layers()); update_screen_for_document(document); diff --git a/src/app/commands/cmd_clear_recent_files.cpp b/src/app/commands/cmd_clear_recent_files.cpp index 4c76380c2..06cb44d91 100644 --- a/src/app/commands/cmd_clear_recent_files.cpp +++ b/src/app/commands/cmd_clear_recent_files.cpp @@ -23,8 +23,7 @@ protected: void onExecute(Context* ctx) override; }; -ClearRecentFilesCommand::ClearRecentFilesCommand() - : Command(CommandId::ClearRecentFiles(), CmdUIOnlyFlag) +ClearRecentFilesCommand::ClearRecentFilesCommand() : Command(CommandId::ClearRecentFiles()) { } diff --git a/src/app/commands/cmd_close_file.cpp b/src/app/commands/cmd_close_file.cpp index 57e1ce8e5..8a71ec3ae 100644 --- a/src/app/commands/cmd_close_file.cpp +++ b/src/app/commands/cmd_close_file.cpp @@ -28,7 +28,7 @@ using namespace ui; class CloseFileCommand : public Command { public: - CloseFileCommand() : Command(CommandId::CloseFile(), CmdUIOnlyFlag) {} + CloseFileCommand() : Command(CommandId::CloseFile()) {} protected: bool onEnabled(Context* context) override @@ -51,12 +51,15 @@ protected: class CloseAllFilesCommand : public Command { public: - CloseAllFilesCommand() : Command(CommandId::CloseAllFiles(), CmdRecordableFlag) - { - m_quitting = false; - } + CloseAllFilesCommand() : Command(CommandId::CloseAllFiles()) { m_quitting = false; } protected: + bool onEnabled(Context* context) override + { + // Null if we are in --batch mode + return App::instance()->workspace() != nullptr; + } + void onLoadParams(const Params& params) override { m_quitting = params.get_as("quitting"); } void onExecute(Context* context) override diff --git a/src/app/commands/cmd_color_quantization.cpp b/src/app/commands/cmd_color_quantization.cpp index dbd2d7e7c..de2460447 100644 --- a/src/app/commands/cmd_color_quantization.cpp +++ b/src/app/commands/cmd_color_quantization.cpp @@ -71,7 +71,7 @@ protected: }; ColorQuantizationCommand::ColorQuantizationCommand() - : CommandWithNewParams(CommandId::ColorQuantization(), CmdRecordableFlag) + : CommandWithNewParams(CommandId::ColorQuantization()) { } diff --git a/src/app/commands/cmd_contiguous_fill.cpp b/src/app/commands/cmd_contiguous_fill.cpp index 2a02336bb..7aed7a8f6 100644 --- a/src/app/commands/cmd_contiguous_fill.cpp +++ b/src/app/commands/cmd_contiguous_fill.cpp @@ -24,7 +24,7 @@ protected: void onExecute(Context* context) override; }; -ContiguousFillCommand::ContiguousFillCommand() : Command(CommandId::ContiguousFill(), CmdUIOnlyFlag) +ContiguousFillCommand::ContiguousFillCommand() : Command(CommandId::ContiguousFill()) { } diff --git a/src/app/commands/cmd_copy.cpp b/src/app/commands/cmd_copy.cpp index 3dabf25c5..627104400 100644 --- a/src/app/commands/cmd_copy.cpp +++ b/src/app/commands/cmd_copy.cpp @@ -23,7 +23,7 @@ protected: void onExecute(Context* ctx) override; }; -CopyCommand::CopyCommand() : Command(CommandId::Copy(), CmdUIOnlyFlag) +CopyCommand::CopyCommand() : Command(CommandId::Copy()) { } diff --git a/src/app/commands/cmd_copy_cel.cpp b/src/app/commands/cmd_copy_cel.cpp index 0b80a02cf..17fad104d 100644 --- a/src/app/commands/cmd_copy_cel.cpp +++ b/src/app/commands/cmd_copy_cel.cpp @@ -25,13 +25,13 @@ protected: void onExecute(Context* context) override; }; -CopyCelCommand::CopyCelCommand() : Command(CommandId::CopyCel(), CmdUIOnlyFlag) +CopyCelCommand::CopyCelCommand() : Command(CommandId::CopyCel()) { } bool CopyCelCommand::onEnabled(Context* context) { - return App::instance()->timeline()->isMovingCel(); + return App::instance()->timeline() && App::instance()->timeline()->isMovingCel(); } void CopyCelCommand::onExecute(Context* context) diff --git a/src/app/commands/cmd_copy_merged.cpp b/src/app/commands/cmd_copy_merged.cpp index 6458a4dca..c70f1e398 100644 --- a/src/app/commands/cmd_copy_merged.cpp +++ b/src/app/commands/cmd_copy_merged.cpp @@ -24,7 +24,7 @@ protected: void onExecute(Context* ctx) override; }; -CopyMergedCommand::CopyMergedCommand() : Command(CommandId::CopyMerged(), CmdUIOnlyFlag) +CopyMergedCommand::CopyMergedCommand() : Command(CommandId::CopyMerged()) { } diff --git a/src/app/commands/cmd_crop.cpp b/src/app/commands/cmd_crop.cpp index 970472887..fe8c35067 100644 --- a/src/app/commands/cmd_crop.cpp +++ b/src/app/commands/cmd_crop.cpp @@ -37,7 +37,7 @@ private: gfx::Rect m_bounds; }; -CropSpriteCommand::CropSpriteCommand() : Command(CommandId::CropSprite(), CmdRecordableFlag) +CropSpriteCommand::CropSpriteCommand() : Command(CommandId::CropSprite()) { } @@ -95,8 +95,7 @@ private: bool m_byGrid = false; }; -AutocropSpriteCommand::AutocropSpriteCommand() - : Command(CommandId::AutocropSprite(), CmdRecordableFlag) +AutocropSpriteCommand::AutocropSpriteCommand() : Command(CommandId::AutocropSprite()) { } diff --git a/src/app/commands/cmd_cut.cpp b/src/app/commands/cmd_cut.cpp index ec3d370a8..50973c27d 100644 --- a/src/app/commands/cmd_cut.cpp +++ b/src/app/commands/cmd_cut.cpp @@ -23,7 +23,7 @@ protected: void onExecute(Context* ctx) override; }; -CutCommand::CutCommand() : Command(CommandId::Cut(), CmdUIOnlyFlag) +CutCommand::CutCommand() : Command(CommandId::Cut()) { } diff --git a/src/app/commands/cmd_deselect_mask.cpp b/src/app/commands/cmd_deselect_mask.cpp index 1ce6495e9..47dbca775 100644 --- a/src/app/commands/cmd_deselect_mask.cpp +++ b/src/app/commands/cmd_deselect_mask.cpp @@ -28,7 +28,7 @@ protected: void onExecute(Context* context) override; }; -DeselectMaskCommand::DeselectMaskCommand() : Command(CommandId::DeselectMask(), CmdRecordableFlag) +DeselectMaskCommand::DeselectMaskCommand() : Command(CommandId::DeselectMask()) { } diff --git a/src/app/commands/cmd_developer_console.cpp b/src/app/commands/cmd_developer_console.cpp index 821e1282e..1489653b2 100644 --- a/src/app/commands/cmd_developer_console.cpp +++ b/src/app/commands/cmd_developer_console.cpp @@ -29,8 +29,7 @@ protected: void onExecute(Context* context); }; -DeveloperConsoleCommand::DeveloperConsoleCommand() - : Command(CommandId::DeveloperConsole(), CmdUIOnlyFlag) +DeveloperConsoleCommand::DeveloperConsoleCommand() : Command(CommandId::DeveloperConsole()) { } diff --git a/src/app/commands/cmd_discard_brush.cpp b/src/app/commands/cmd_discard_brush.cpp index 49a1d45e1..7246e3d86 100644 --- a/src/app/commands/cmd_discard_brush.cpp +++ b/src/app/commands/cmd_discard_brush.cpp @@ -28,12 +28,15 @@ protected: void onExecute(Context* context) override; }; -DiscardBrushCommand::DiscardBrushCommand() : Command(CommandId::DiscardBrush(), CmdUIOnlyFlag) +DiscardBrushCommand::DiscardBrushCommand() : Command(CommandId::DiscardBrush()) { } bool DiscardBrushCommand::onEnabled(Context* context) { + if (!context->isUIAvailable()) + return false; + ContextBar* ctxBar = App::instance()->contextBar(); return (ctxBar->activeBrush()->type() == kImageBrushType); } diff --git a/src/app/commands/cmd_duplicate_layer.cpp b/src/app/commands/cmd_duplicate_layer.cpp index 52a96a5a0..1dc7d0332 100644 --- a/src/app/commands/cmd_duplicate_layer.cpp +++ b/src/app/commands/cmd_duplicate_layer.cpp @@ -32,8 +32,7 @@ protected: void onExecute(Context* context) override; }; -DuplicateLayerCommand::DuplicateLayerCommand() - : Command(CommandId::DuplicateLayer(), CmdRecordableFlag) +DuplicateLayerCommand::DuplicateLayerCommand() : Command(CommandId::DuplicateLayer()) { } diff --git a/src/app/commands/cmd_duplicate_sprite.cpp b/src/app/commands/cmd_duplicate_sprite.cpp index 3d4047958..7ae1823c9 100644 --- a/src/app/commands/cmd_duplicate_sprite.cpp +++ b/src/app/commands/cmd_duplicate_sprite.cpp @@ -43,7 +43,7 @@ protected: }; DuplicateSpriteCommand::DuplicateSpriteCommand() - : CommandWithNewParams(CommandId::DuplicateSprite(), CmdRecordableFlag) + : CommandWithNewParams(CommandId::DuplicateSprite()) { } diff --git a/src/app/commands/cmd_duplicate_view.cpp b/src/app/commands/cmd_duplicate_view.cpp index 4f1ecedff..8b26c6ace 100644 --- a/src/app/commands/cmd_duplicate_view.cpp +++ b/src/app/commands/cmd_duplicate_view.cpp @@ -28,7 +28,7 @@ protected: void onExecute(Context* context) override; }; -DuplicateViewCommand::DuplicateViewCommand() : Command(CommandId::DuplicateView(), CmdUIOnlyFlag) +DuplicateViewCommand::DuplicateViewCommand() : Command(CommandId::DuplicateView()) { } diff --git a/src/app/commands/cmd_enter_license.cpp b/src/app/commands/cmd_enter_license.cpp index 342761c94..d4e7ffc64 100644 --- a/src/app/commands/cmd_enter_license.cpp +++ b/src/app/commands/cmd_enter_license.cpp @@ -24,7 +24,7 @@ protected: void onExecute(Context* context) override; }; -EnterLicenseCommand::EnterLicenseCommand() : Command(CommandId::EnterLicense(), CmdUIOnlyFlag) +EnterLicenseCommand::EnterLicenseCommand() : Command(CommandId::EnterLicense()) { } diff --git a/src/app/commands/cmd_exit.cpp b/src/app/commands/cmd_exit.cpp index bafd6981a..1eeb0aeea 100644 --- a/src/app/commands/cmd_exit.cpp +++ b/src/app/commands/cmd_exit.cpp @@ -32,7 +32,7 @@ protected: void onExecute(Context* context) override; }; -ExitCommand::ExitCommand() : Command(CommandId::Exit(), CmdUIOnlyFlag) +ExitCommand::ExitCommand() : Command(CommandId::Exit()) { } diff --git a/src/app/commands/cmd_export_sprite_sheet.cpp b/src/app/commands/cmd_export_sprite_sheet.cpp index b24dc314e..aee25eaa5 100644 --- a/src/app/commands/cmd_export_sprite_sheet.cpp +++ b/src/app/commands/cmd_export_sprite_sheet.cpp @@ -1187,8 +1187,7 @@ private: } // anonymous namespace -ExportSpriteSheetCommand::ExportSpriteSheetCommand(const char* id) - : CommandWithNewParams(id, CmdRecordableFlag) +ExportSpriteSheetCommand::ExportSpriteSheetCommand(const char* id) : CommandWithNewParams(id) { } diff --git a/src/app/commands/cmd_eyedropper.cpp b/src/app/commands/cmd_eyedropper.cpp index 330c6c8a7..418b84647 100644 --- a/src/app/commands/cmd_eyedropper.cpp +++ b/src/app/commands/cmd_eyedropper.cpp @@ -28,7 +28,7 @@ namespace app { using namespace ui; -EyedropperCommand::EyedropperCommand() : Command(CommandId::Eyedropper(), CmdUIOnlyFlag) +EyedropperCommand::EyedropperCommand() : Command(CommandId::Eyedropper()) { m_background = false; } diff --git a/src/app/commands/cmd_fill_and_stroke.cpp b/src/app/commands/cmd_fill_and_stroke.cpp index 95c3cd4b3..c617c1e7a 100644 --- a/src/app/commands/cmd_fill_and_stroke.cpp +++ b/src/app/commands/cmd_fill_and_stroke.cpp @@ -39,7 +39,7 @@ private: }; FillCommand::FillCommand(Type type) - : Command(type == Stroke ? CommandId::Stroke() : CommandId::Fill(), CmdUIOnlyFlag) + : Command(type == Stroke ? CommandId::Stroke() : CommandId::Fill()) , m_type(type) { } diff --git a/src/app/commands/cmd_fit_screen.cpp b/src/app/commands/cmd_fit_screen.cpp index cc9072e20..64b953992 100644 --- a/src/app/commands/cmd_fit_screen.cpp +++ b/src/app/commands/cmd_fit_screen.cpp @@ -25,7 +25,7 @@ protected: void onExecute(Context* context) override; }; -FitScreenCommand::FitScreenCommand() : Command(CommandId::FitScreen(), CmdUIOnlyFlag) +FitScreenCommand::FitScreenCommand() : Command(CommandId::FitScreen()) { } diff --git a/src/app/commands/cmd_flatten_layers.cpp b/src/app/commands/cmd_flatten_layers.cpp index 6f53390c8..3680d2568 100644 --- a/src/app/commands/cmd_flatten_layers.cpp +++ b/src/app/commands/cmd_flatten_layers.cpp @@ -36,7 +36,7 @@ protected: bool m_visibleOnly; }; -FlattenLayersCommand::FlattenLayersCommand() : Command(CommandId::FlattenLayers(), CmdUIOnlyFlag) +FlattenLayersCommand::FlattenLayersCommand() : Command(CommandId::FlattenLayers()) { m_visibleOnly = false; } diff --git a/src/app/commands/cmd_flip.cpp b/src/app/commands/cmd_flip.cpp index 8dc8d5a21..8948a54d9 100644 --- a/src/app/commands/cmd_flip.cpp +++ b/src/app/commands/cmd_flip.cpp @@ -42,7 +42,7 @@ namespace app { -FlipCommand::FlipCommand() : Command(CommandId::Flip(), CmdRecordableFlag) +FlipCommand::FlipCommand() : Command(CommandId::Flip()) { 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 32a5ebc26..e2b18cbb4 100644 --- a/src/app/commands/cmd_frame_properties.cpp +++ b/src/app/commands/cmd_frame_properties.cpp @@ -44,12 +44,11 @@ private: // Frame to be shown. It can be ALL_FRAMES, CURRENT_RANGE, or a // number indicating a specific frame (1 is the first frame). - Target m_target; - frame_t m_frame; + Target m_target = CURRENT_RANGE; + frame_t m_frame = 1; }; -FramePropertiesCommand::FramePropertiesCommand() - : Command(CommandId::FrameProperties(), CmdUIOnlyFlag) +FramePropertiesCommand::FramePropertiesCommand() : Command(CommandId::FrameProperties()) { } @@ -62,15 +61,19 @@ void FramePropertiesCommand::onLoadParams(const Params& params) else if (frame == "current") { m_target = CURRENT_RANGE; } - else { - m_target = SPECIFIC_FRAME; - m_frame = frame_t(base::convert_to(frame)); - } + + const int frameNumber = frame_t(base::convert_to(frame)); + // Will open with the default target (CURRENT_RANGE) if the frame number cannot be parsed. + if (frameNumber < 1) + return; + + m_frame = frameNumber; + m_target = SPECIFIC_FRAME; } bool FramePropertiesCommand::onEnabled(Context* context) { - return context->checkFlags(ContextFlags::ActiveDocumentIsWritable); + return context->isUIAvailable() && context->checkFlags(ContextFlags::ActiveDocumentIsWritable); } void FramePropertiesCommand::onExecute(Context* context) diff --git a/src/app/commands/cmd_frame_tag_properties.cpp b/src/app/commands/cmd_frame_tag_properties.cpp index 0dfad1bd4..0a6fb502a 100644 --- a/src/app/commands/cmd_frame_tag_properties.cpp +++ b/src/app/commands/cmd_frame_tag_properties.cpp @@ -48,7 +48,7 @@ private: }; FrameTagPropertiesCommand::FrameTagPropertiesCommand() - : Command(CommandId::FrameTagProperties(), CmdUIOnlyFlag) + : Command(CommandId::FrameTagProperties()) , m_tagId(NullId) { } @@ -66,7 +66,7 @@ void FrameTagPropertiesCommand::onLoadParams(const Params& params) bool FrameTagPropertiesCommand::onEnabled(Context* context) { - return context->checkFlags(ContextFlags::ActiveDocumentIsWritable); + return context->isUIAvailable() && context->checkFlags(ContextFlags::ActiveDocumentIsWritable); } void FrameTagPropertiesCommand::onExecute(Context* context) diff --git a/src/app/commands/cmd_fullscreen_mode.cpp b/src/app/commands/cmd_fullscreen_mode.cpp index 96c724514..6da63f8c1 100644 --- a/src/app/commands/cmd_fullscreen_mode.cpp +++ b/src/app/commands/cmd_fullscreen_mode.cpp @@ -27,7 +27,7 @@ protected: void onExecute(Context* context) override; }; -FullscreenModeCommand::FullscreenModeCommand() : Command(CommandId::FullscreenMode(), CmdUIOnlyFlag) +FullscreenModeCommand::FullscreenModeCommand() : Command(CommandId::FullscreenMode()) { } diff --git a/src/app/commands/cmd_fullscreen_preview.cpp b/src/app/commands/cmd_fullscreen_preview.cpp index 96874c23a..6783d76eb 100644 --- a/src/app/commands/cmd_fullscreen_preview.cpp +++ b/src/app/commands/cmd_fullscreen_preview.cpp @@ -308,8 +308,7 @@ protected: void onExecute(Context* context) override; }; -FullscreenPreviewCommand::FullscreenPreviewCommand() - : Command(CommandId::FullscreenPreview(), CmdUIOnlyFlag) +FullscreenPreviewCommand::FullscreenPreviewCommand() : Command(CommandId::FullscreenPreview()) { } diff --git a/src/app/commands/cmd_goto_frame.cpp b/src/app/commands/cmd_goto_frame.cpp index b82ae136b..ea3cd7827 100644 --- a/src/app/commands/cmd_goto_frame.cpp +++ b/src/app/commands/cmd_goto_frame.cpp @@ -31,7 +31,7 @@ using namespace doc; class GotoCommand : public Command { protected: - GotoCommand(const char* id) : Command(id, CmdRecordableFlag) {} + GotoCommand(const char* id) : Command(id) {} bool onEnabled(Context* context) override { return (Editor::activeEditor() != nullptr); } diff --git a/src/app/commands/cmd_goto_layer.cpp b/src/app/commands/cmd_goto_layer.cpp index 55a15911a..580c62924 100644 --- a/src/app/commands/cmd_goto_layer.cpp +++ b/src/app/commands/cmd_goto_layer.cpp @@ -24,11 +24,7 @@ namespace app { class GotoLayerCommand : public Command { public: - GotoLayerCommand(int offset, const char* id, CommandFlags flags) - : Command(id, flags) - , m_offset(offset) - { - } + GotoLayerCommand(int offset, const char* id) : Command(id), m_offset(offset) {} protected: bool onEnabled(Context* context) override @@ -88,12 +84,12 @@ private: class GotoPreviousLayerCommand : public GotoLayerCommand { public: - GotoPreviousLayerCommand() : GotoLayerCommand(-1, "GotoPreviousLayer", CmdUIOnlyFlag) {} + GotoPreviousLayerCommand() : GotoLayerCommand(-1, "GotoPreviousLayer") {} }; class GotoNextLayerCommand : public GotoLayerCommand { public: - GotoNextLayerCommand() : GotoLayerCommand(+1, "GotoNextLayer", CmdUIOnlyFlag) {} + GotoNextLayerCommand() : GotoLayerCommand(+1, "GotoNextLayer") {} }; Command* CommandFactory::createGotoPreviousLayerCommand() diff --git a/src/app/commands/cmd_goto_tab.cpp b/src/app/commands/cmd_goto_tab.cpp index 1c8da8a02..1178ff460 100644 --- a/src/app/commands/cmd_goto_tab.cpp +++ b/src/app/commands/cmd_goto_tab.cpp @@ -24,7 +24,7 @@ protected: void onExecute(Context* context) override; }; -GotoNextTabCommand::GotoNextTabCommand() : Command(CommandId::GotoNextTab(), CmdUIOnlyFlag) +GotoNextTabCommand::GotoNextTabCommand() : Command(CommandId::GotoNextTab()) { } @@ -50,8 +50,7 @@ protected: void onExecute(Context* context) override; }; -GotoPreviousTabCommand::GotoPreviousTabCommand() - : Command(CommandId::GotoPreviousTab(), CmdRecordableFlag) +GotoPreviousTabCommand::GotoPreviousTabCommand() : Command(CommandId::GotoPreviousTab()) { } diff --git a/src/app/commands/cmd_grid.cpp b/src/app/commands/cmd_grid.cpp index 686ddc58f..1abb0b2d2 100644 --- a/src/app/commands/cmd_grid.cpp +++ b/src/app/commands/cmd_grid.cpp @@ -36,7 +36,7 @@ using namespace gfx; class SnapToGridCommand : public Command { public: - SnapToGridCommand() : Command(CommandId::SnapToGrid(), CmdUIOnlyFlag) {} + SnapToGridCommand() : Command(CommandId::SnapToGrid()) {} protected: bool onChecked(Context* ctx) override @@ -51,13 +51,14 @@ protected: bool newValue = !docPref.grid.snap(); docPref.grid.snap(newValue); - StatusBar::instance()->showSnapToGridWarning(newValue); + if (ctx->isUIAvailable()) + StatusBar::instance()->showSnapToGridWarning(newValue); } }; class SelectionAsGridCommand : public Command { public: - SelectionAsGridCommand() : Command(CommandId::SelectionAsGrid(), CmdUIOnlyFlag) {} + SelectionAsGridCommand() : Command(CommandId::SelectionAsGrid()) {} protected: bool onEnabled(Context* ctx) override @@ -92,13 +93,13 @@ protected: void onExecute(Context* context) override; }; -GridSettingsCommand::GridSettingsCommand() : Command(CommandId::GridSettings(), CmdUIOnlyFlag) +GridSettingsCommand::GridSettingsCommand() : Command(CommandId::GridSettings()) { } bool GridSettingsCommand::onEnabled(Context* context) { - return true; + return context->isUIAvailable(); } void GridSettingsCommand::onExecute(Context* context) diff --git a/src/app/commands/cmd_home.cpp b/src/app/commands/cmd_home.cpp index 2bd528178..91a91e520 100644 --- a/src/app/commands/cmd_home.cpp +++ b/src/app/commands/cmd_home.cpp @@ -10,6 +10,7 @@ #include "app/app.h" #include "app/commands/command.h" +#include "app/context.h" #include "app/ui/main_window.h" namespace app { @@ -26,7 +27,7 @@ protected: bool onEnabled(Context* context) override; }; -HomeCommand::HomeCommand() : Command(CommandId::Home(), CmdUIOnlyFlag) +HomeCommand::HomeCommand() : Command(CommandId::Home()) { } @@ -41,7 +42,7 @@ void HomeCommand::onExecute(Context* context) bool HomeCommand::onEnabled(Context* context) { - return !App::instance()->mainWindow()->isHomeSelected(); + return context->isUIAvailable() && !App::instance()->mainWindow()->isHomeSelected(); } Command* CommandFactory::createHomeCommand() diff --git a/src/app/commands/cmd_import_sprite_sheet.cpp b/src/app/commands/cmd_import_sprite_sheet.cpp index 05e12bb76..86a574d5d 100644 --- a/src/app/commands/cmd_import_sprite_sheet.cpp +++ b/src/app/commands/cmd_import_sprite_sheet.cpp @@ -518,7 +518,7 @@ protected: }; ImportSpriteSheetCommand::ImportSpriteSheetCommand() - : CommandWithNewParams(CommandId::ImportSpriteSheet(), CmdRecordableFlag) + : CommandWithNewParams(CommandId::ImportSpriteSheet()) { } diff --git a/src/app/commands/cmd_invert_mask.cpp b/src/app/commands/cmd_invert_mask.cpp index c240b4d2a..d630903a2 100644 --- a/src/app/commands/cmd_invert_mask.cpp +++ b/src/app/commands/cmd_invert_mask.cpp @@ -31,7 +31,7 @@ protected: void onExecute(Context* context) override; }; -InvertMaskCommand::InvertMaskCommand() : Command(CommandId::InvertMask(), CmdRecordableFlag) +InvertMaskCommand::InvertMaskCommand() : Command(CommandId::InvertMask()) { } diff --git a/src/app/commands/cmd_keyboard_shortcuts.cpp b/src/app/commands/cmd_keyboard_shortcuts.cpp index e3d3042d0..fbe426c84 100644 --- a/src/app/commands/cmd_keyboard_shortcuts.cpp +++ b/src/app/commands/cmd_keyboard_shortcuts.cpp @@ -977,6 +977,7 @@ public: KeyboardShortcutsCommand(); protected: + bool onEnabled(Context* context) override; void onLoadParams(const Params& params) override; void onExecute(Context* context) override; @@ -986,11 +987,15 @@ private: std::string m_search; }; -KeyboardShortcutsCommand::KeyboardShortcutsCommand() - : Command(CommandId::KeyboardShortcuts(), CmdUIOnlyFlag) +KeyboardShortcutsCommand::KeyboardShortcutsCommand() : Command(CommandId::KeyboardShortcuts()) { } +bool KeyboardShortcutsCommand::onEnabled(Context* context) +{ + return context->isUIAvailable(); +} + void KeyboardShortcutsCommand::onLoadParams(const Params& params) { m_search = params.get("search"); diff --git a/src/app/commands/cmd_launch.cpp b/src/app/commands/cmd_launch.cpp index b9046eb7f..2aa6264c2 100644 --- a/src/app/commands/cmd_launch.cpp +++ b/src/app/commands/cmd_launch.cpp @@ -34,10 +34,7 @@ private: std::string m_path; }; -LaunchCommand::LaunchCommand() - : Command(CommandId::Launch(), CmdUIOnlyFlag) - , m_type(Url) - , m_path("") +LaunchCommand::LaunchCommand() : Command(CommandId::Launch()), m_type(Url), m_path("") { } @@ -45,7 +42,7 @@ void LaunchCommand::onLoadParams(const Params& params) { m_path = params.get("path"); - if (m_type == Url && !m_path.empty() && m_path[0] == '/') { + if (m_type == Url && !m_path.empty() && m_path[0] == '/' && !base::is_absolute_path(m_path)) { m_path = std::string(get_app_url()) + m_path.substr(1); } } diff --git a/src/app/commands/cmd_layer_from_background.cpp b/src/app/commands/cmd_layer_from_background.cpp index 987d7ae61..8fd0b12a3 100644 --- a/src/app/commands/cmd_layer_from_background.cpp +++ b/src/app/commands/cmd_layer_from_background.cpp @@ -28,8 +28,7 @@ protected: void onExecute(Context* context) override; }; -LayerFromBackgroundCommand::LayerFromBackgroundCommand() - : Command(CommandId::LayerFromBackground(), CmdRecordableFlag) +LayerFromBackgroundCommand::LayerFromBackgroundCommand() : Command(CommandId::LayerFromBackground()) { } diff --git a/src/app/commands/cmd_layer_lock.cpp b/src/app/commands/cmd_layer_lock.cpp index 672ca599a..f21f21e62 100644 --- a/src/app/commands/cmd_layer_lock.cpp +++ b/src/app/commands/cmd_layer_lock.cpp @@ -30,7 +30,7 @@ protected: void onExecute(Context* context) override; }; -LayerLockCommand::LayerLockCommand() : Command(CommandId::LayerLock(), CmdRecordableFlag) +LayerLockCommand::LayerLockCommand() : Command(CommandId::LayerLock()) { } diff --git a/src/app/commands/cmd_layer_opacity.cpp b/src/app/commands/cmd_layer_opacity.cpp index 60aeb92c3..4438d8e65 100644 --- a/src/app/commands/cmd_layer_opacity.cpp +++ b/src/app/commands/cmd_layer_opacity.cpp @@ -40,7 +40,7 @@ private: int m_opacity; }; -LayerOpacityCommand::LayerOpacityCommand() : Command(CommandId::LayerOpacity(), CmdUIOnlyFlag) +LayerOpacityCommand::LayerOpacityCommand() : Command(CommandId::LayerOpacity()) { m_opacity = 255; } diff --git a/src/app/commands/cmd_layer_properties.cpp b/src/app/commands/cmd_layer_properties.cpp index dd06d370f..aba78887b 100644 --- a/src/app/commands/cmd_layer_properties.cpp +++ b/src/app/commands/cmd_layer_properties.cpp @@ -500,14 +500,14 @@ private: bool m_remapAfterConfigure = false; }; -LayerPropertiesCommand::LayerPropertiesCommand() - : Command(CommandId::LayerProperties(), CmdRecordableFlag) +LayerPropertiesCommand::LayerPropertiesCommand() : Command(CommandId::LayerProperties()) { } bool LayerPropertiesCommand::onEnabled(Context* context) { - return context->checkFlags(ContextFlags::ActiveDocumentIsWritable | ContextFlags::HasActiveLayer); + return context->isUIAvailable() && + context->checkFlags(ContextFlags::ActiveDocumentIsWritable | ContextFlags::HasActiveLayer); } void LayerPropertiesCommand::onExecute(Context* context) diff --git a/src/app/commands/cmd_layer_visibility.cpp b/src/app/commands/cmd_layer_visibility.cpp index e9572966b..876c7e811 100644 --- a/src/app/commands/cmd_layer_visibility.cpp +++ b/src/app/commands/cmd_layer_visibility.cpp @@ -29,8 +29,7 @@ protected: void onExecute(Context* context) override; }; -LayerVisibilityCommand::LayerVisibilityCommand() - : Command(CommandId::LayerVisibility(), CmdRecordableFlag) +LayerVisibilityCommand::LayerVisibilityCommand() : Command(CommandId::LayerVisibility()) { } diff --git a/src/app/commands/cmd_link_cels.cpp b/src/app/commands/cmd_link_cels.cpp index 1baaef7a8..d07ea5218 100644 --- a/src/app/commands/cmd_link_cels.cpp +++ b/src/app/commands/cmd_link_cels.cpp @@ -31,7 +31,7 @@ protected: void onExecute(Context* context) override; }; -LinkCelsCommand::LinkCelsCommand() : Command(CommandId::LinkCels(), CmdRecordableFlag) +LinkCelsCommand::LinkCelsCommand() : Command(CommandId::LinkCels()) { } @@ -88,7 +88,7 @@ void LinkCelsCommand::onExecute(Context* context) tx.commit(); } - if (nonEditableLayers) + if (context->isUIAvailable() && nonEditableLayers) StatusBar::instance()->showTip(1000, Strings::statusbar_tips_locked_layers()); update_screen_for_document(document); diff --git a/src/app/commands/cmd_load_mask.cpp b/src/app/commands/cmd_load_mask.cpp index 077ced661..387c766c8 100644 --- a/src/app/commands/cmd_load_mask.cpp +++ b/src/app/commands/cmd_load_mask.cpp @@ -26,6 +26,7 @@ namespace app { class LoadMaskCommand : public Command { std::string m_filename; + bool m_ui = true; public: LoadMaskCommand(); @@ -36,13 +37,16 @@ protected: void onExecute(Context* context) override; }; -LoadMaskCommand::LoadMaskCommand() : Command(CommandId::LoadMask(), CmdRecordableFlag) +LoadMaskCommand::LoadMaskCommand() : Command(CommandId::LoadMask()) { - m_filename = ""; } void LoadMaskCommand::onLoadParams(const Params& params) { + if (params.has_param("ui")) + m_ui = params.get_as("ui"); + else + m_ui = true; m_filename = params.get("filename"); } @@ -55,7 +59,7 @@ void LoadMaskCommand::onExecute(Context* context) { const ContextReader reader(context); - if (context->isUIAvailable()) { + if (context->isUIAvailable() && m_ui) { base::paths exts = { "msk" }; base::paths selectedFilename; if (!app::show_file_selector(Strings::load_selection_title(), @@ -70,7 +74,8 @@ void LoadMaskCommand::onExecute(Context* context) std::unique_ptr mask(load_msk_file(m_filename.c_str())); if (!mask) { - ui::Alert::show(Strings::alerts_error_loading_file(m_filename)); + if (context->isUIAvailable()) + ui::Alert::show(Strings::alerts_error_loading_file(m_filename)); return; } diff --git a/src/app/commands/cmd_load_palette.cpp b/src/app/commands/cmd_load_palette.cpp index 6d42d7174..f346aa701 100644 --- a/src/app/commands/cmd_load_palette.cpp +++ b/src/app/commands/cmd_load_palette.cpp @@ -37,14 +37,19 @@ protected: private: std::string m_preset; std::string m_filename; + bool m_ui = true; }; -LoadPaletteCommand::LoadPaletteCommand() : Command(CommandId::LoadPalette(), CmdRecordableFlag) +LoadPaletteCommand::LoadPaletteCommand() : Command(CommandId::LoadPalette()) { } void LoadPaletteCommand::onLoadParams(const Params& params) { + if (params.has_param("ui")) + m_ui = params.get_as("ui"); + else + m_ui = true; m_preset = params.get("preset"); m_filename = params.get("filename"); } @@ -58,20 +63,20 @@ void LoadPaletteCommand::onExecute(Context* context) if (!base::is_file(filename)) filename = get_preset_palette_filename(m_preset, ".gpl"); } - else if (!m_filename.empty()) { - filename = m_filename; - } - else if (context->isUIAvailable()) { - base::paths exts = get_readable_palette_extensions(); + else if (context->isUIAvailable() && m_ui) { + const base::paths exts = get_readable_palette_extensions(); base::paths filenames; if (app::show_file_selector(Strings::load_palette_title(), - "", + m_filename, exts, FileSelectorType::Open, filenames)) { filename = filenames.front(); } } + else if (!m_filename.empty()) { + filename = m_filename; + } // Do nothing if (filename.empty()) diff --git a/src/app/commands/cmd_mask_all.cpp b/src/app/commands/cmd_mask_all.cpp index 8dba4d296..c5876ed45 100644 --- a/src/app/commands/cmd_mask_all.cpp +++ b/src/app/commands/cmd_mask_all.cpp @@ -29,7 +29,7 @@ protected: void onExecute(Context* context) override; }; -MaskAllCommand::MaskAllCommand() : Command(CommandId::MaskAll(), CmdRecordableFlag) +MaskAllCommand::MaskAllCommand() : Command(CommandId::MaskAll()) { } diff --git a/src/app/commands/cmd_mask_by_color.cpp b/src/app/commands/cmd_mask_by_color.cpp index b3290ec3b..9bb5d0d67 100644 --- a/src/app/commands/cmd_mask_by_color.cpp +++ b/src/app/commands/cmd_mask_by_color.cpp @@ -203,8 +203,7 @@ protected: void onExecute(Context* context) override; }; -MaskByColorCommand::MaskByColorCommand() - : CommandWithNewParams(CommandId::MaskByColor(), CmdUIOnlyFlag) +MaskByColorCommand::MaskByColorCommand() : CommandWithNewParams(CommandId::MaskByColor()) { } diff --git a/src/app/commands/cmd_mask_content.cpp b/src/app/commands/cmd_mask_content.cpp index d6ba1fd0c..e4a8decc4 100644 --- a/src/app/commands/cmd_mask_content.cpp +++ b/src/app/commands/cmd_mask_content.cpp @@ -38,7 +38,7 @@ protected: void onExecute(Context* context) override; }; -MaskContentCommand::MaskContentCommand() : Command(CommandId::MaskContent(), CmdRecordableFlag) +MaskContentCommand::MaskContentCommand() : Command(CommandId::MaskContent()) { } @@ -87,9 +87,11 @@ void MaskContentCommand::onExecute(Context* context) } // Select marquee tool - if (tools::Tool* tool = App::instance()->toolBox()->getToolById( - tools::WellKnownTools::RectangularMarquee)) { - ToolBar::instance()->selectTool(tool); + if (context->isUIAvailable()) { + if (tools::Tool* tool = App::instance()->toolBox()->getToolById( + tools::WellKnownTools::RectangularMarquee)) { + ToolBar::instance()->selectTool(tool); + } } update_screen_for_document(document); diff --git a/src/app/commands/cmd_merge_down_layer.cpp b/src/app/commands/cmd_merge_down_layer.cpp index e05c95ab1..604c0ffc4 100644 --- a/src/app/commands/cmd_merge_down_layer.cpp +++ b/src/app/commands/cmd_merge_down_layer.cpp @@ -35,8 +35,7 @@ protected: void onExecute(Context* context) override; }; -MergeDownLayerCommand::MergeDownLayerCommand() - : Command(CommandId::MergeDownLayer(), CmdRecordableFlag) +MergeDownLayerCommand::MergeDownLayerCommand() : Command(CommandId::MergeDownLayer()) { } diff --git a/src/app/commands/cmd_modify_selection.cpp b/src/app/commands/cmd_modify_selection.cpp index 6d70fb546..7f8bb7b26 100644 --- a/src/app/commands/cmd_modify_selection.cpp +++ b/src/app/commands/cmd_modify_selection.cpp @@ -52,13 +52,15 @@ private: Modifier m_modifier; int m_quantity; doc::BrushType m_brushType; + bool m_ui; }; ModifySelectionCommand::ModifySelectionCommand() - : Command(CommandId::ModifySelection(), CmdRecordableFlag) + : Command(CommandId::ModifySelection()) , m_modifier(Modifier::Expand) , m_quantity(0) , m_brushType(doc::kCircleBrushType) + , m_ui(true) { } @@ -80,6 +82,11 @@ void ModifySelectionCommand::onLoadParams(const Params& params) m_brushType = doc::kCircleBrushType; else if (brush == "square") m_brushType = doc::kSquareBrushType; + + if (params.has_param("ui")) + m_ui = params.get_as("ui"); + else + m_ui = true; } bool ModifySelectionCommand::onEnabled(Context* context) @@ -92,7 +99,7 @@ void ModifySelectionCommand::onExecute(Context* context) int quantity = m_quantity; doc::BrushType brush = m_brushType; - if (quantity == 0) { + if (quantity == 0 && m_ui && context->isUIAvailable()) { Preferences& pref = Preferences::instance(); ModifySelectionWindow window; diff --git a/src/app/commands/cmd_move_cel.cpp b/src/app/commands/cmd_move_cel.cpp index 7324ec51a..380467ad4 100644 --- a/src/app/commands/cmd_move_cel.cpp +++ b/src/app/commands/cmd_move_cel.cpp @@ -25,13 +25,13 @@ protected: void onExecute(Context* context) override; }; -MoveCelCommand::MoveCelCommand() : Command(CommandId::MoveCel(), CmdUIOnlyFlag) +MoveCelCommand::MoveCelCommand() : Command(CommandId::MoveCel()) { } bool MoveCelCommand::onEnabled(Context* context) { - return App::instance()->timeline()->isMovingCel(); + return context->isUIAvailable() && App::instance()->timeline()->isMovingCel(); } void MoveCelCommand::onExecute(Context* context) diff --git a/src/app/commands/cmd_move_mask.cpp b/src/app/commands/cmd_move_mask.cpp index 55292cb6f..ccc88e033 100644 --- a/src/app/commands/cmd_move_mask.cpp +++ b/src/app/commands/cmd_move_mask.cpp @@ -30,7 +30,7 @@ namespace app { -MoveMaskCommand::MoveMaskCommand() : Command(CommandId::MoveMask(), CmdRecordableFlag) +MoveMaskCommand::MoveMaskCommand() : Command(CommandId::MoveMask()) { } diff --git a/src/app/commands/cmd_new_brush.cpp b/src/app/commands/cmd_new_brush.cpp index f1164c04c..50994ddb3 100644 --- a/src/app/commands/cmd_new_brush.cpp +++ b/src/app/commands/cmd_new_brush.cpp @@ -52,13 +52,13 @@ private: void selectPencilTool(); }; -NewBrushCommand::NewBrushCommand() : Command(CommandId::NewBrush(), CmdUIOnlyFlag) +NewBrushCommand::NewBrushCommand() : Command(CommandId::NewBrush()) { } bool NewBrushCommand::onEnabled(Context* context) { - return context->checkFlags(ContextFlags::ActiveDocumentIsWritable); + return context->isUIAvailable() && context->checkFlags(ContextFlags::ActiveDocumentIsWritable); } void NewBrushCommand::onExecute(Context* context) diff --git a/src/app/commands/cmd_new_file.cpp b/src/app/commands/cmd_new_file.cpp index ea4fabfa8..4b2421d0d 100644 --- a/src/app/commands/cmd_new_file.cpp +++ b/src/app/commands/cmd_new_file.cpp @@ -64,7 +64,7 @@ protected: // static int NewFileCommand::g_spriteCounter = 0; -NewFileCommand::NewFileCommand() : CommandWithNewParams(CommandId::NewFile(), CmdRecordableFlag) +NewFileCommand::NewFileCommand() : CommandWithNewParams(CommandId::NewFile()) { } diff --git a/src/app/commands/cmd_new_frame.cpp b/src/app/commands/cmd_new_frame.cpp index 58af3358c..3164e3704 100644 --- a/src/app/commands/cmd_new_frame.cpp +++ b/src/app/commands/cmd_new_frame.cpp @@ -57,7 +57,7 @@ private: Content m_content; }; -NewFrameCommand::NewFrameCommand() : Command(CommandId::NewFrame(), CmdRecordableFlag) +NewFrameCommand::NewFrameCommand() : Command(CommandId::NewFrame()) { } diff --git a/src/app/commands/cmd_new_frame_tag.cpp b/src/app/commands/cmd_new_frame_tag.cpp index a107ad8ba..63dfab11f 100644 --- a/src/app/commands/cmd_new_frame_tag.cpp +++ b/src/app/commands/cmd_new_frame_tag.cpp @@ -33,14 +33,14 @@ protected: void onExecute(Context* context) override; }; -NewFrameTagCommand::NewFrameTagCommand() : Command(CommandId::NewFrameTag(), CmdRecordableFlag) +NewFrameTagCommand::NewFrameTagCommand() : Command(CommandId::NewFrameTag()) { } bool NewFrameTagCommand::onEnabled(Context* context) { - return context->checkFlags(ContextFlags::ActiveDocumentIsWritable | - ContextFlags::HasActiveSprite); + return context->isUIAvailable() && context->checkFlags(ContextFlags::ActiveDocumentIsWritable | + ContextFlags::HasActiveSprite); } void NewFrameTagCommand::onExecute(Context* context) diff --git a/src/app/commands/cmd_new_layer.cpp b/src/app/commands/cmd_new_layer.cpp index 19d2e2046..6e92cd78e 100644 --- a/src/app/commands/cmd_new_layer.cpp +++ b/src/app/commands/cmd_new_layer.cpp @@ -99,7 +99,7 @@ private: Place m_place; }; -NewLayerCommand::NewLayerCommand() : CommandWithNewParams(CommandId::NewLayer(), CmdRecordableFlag) +NewLayerCommand::NewLayerCommand() : CommandWithNewParams(CommandId::NewLayer()) { } diff --git a/src/app/commands/cmd_new_sprite_from_selection.cpp b/src/app/commands/cmd_new_sprite_from_selection.cpp index 880cb2633..4b1449506 100644 --- a/src/app/commands/cmd_new_sprite_from_selection.cpp +++ b/src/app/commands/cmd_new_sprite_from_selection.cpp @@ -39,7 +39,7 @@ protected: }; NewSpriteFromSelectionCommand::NewSpriteFromSelectionCommand() - : Command(CommandId::NewSpriteFromSelection(), CmdUIOnlyFlag) + : Command(CommandId::NewSpriteFromSelection()) { } diff --git a/src/app/commands/cmd_onionskin.cpp b/src/app/commands/cmd_onionskin.cpp index a417f5f91..9607fad80 100644 --- a/src/app/commands/cmd_onionskin.cpp +++ b/src/app/commands/cmd_onionskin.cpp @@ -20,7 +20,7 @@ using namespace gfx; class ShowOnionSkinCommand : public Command { public: - ShowOnionSkinCommand() : Command(CommandId::ShowOnionSkin(), CmdUIOnlyFlag) {} + ShowOnionSkinCommand() : Command(CommandId::ShowOnionSkin()) {} protected: bool onChecked(Context* context) override diff --git a/src/app/commands/cmd_open_browser.cpp b/src/app/commands/cmd_open_browser.cpp index 596a25183..0fff12365 100644 --- a/src/app/commands/cmd_open_browser.cpp +++ b/src/app/commands/cmd_open_browser.cpp @@ -22,6 +22,7 @@ public: OpenBrowserCommand(); protected: + bool onEnabled(Context* context) override; void onLoadParams(const Params& params) override; void onExecute(Context* context) override; std::string onGetFriendlyName() const override; @@ -31,10 +32,15 @@ private: std::string m_filename; }; -OpenBrowserCommand::OpenBrowserCommand() : Command(CommandId::OpenBrowser(), CmdUIOnlyFlag) +OpenBrowserCommand::OpenBrowserCommand() : Command(CommandId::OpenBrowser()) { } +bool OpenBrowserCommand::onEnabled(Context* context) +{ + return context->isUIAvailable(); +} + void OpenBrowserCommand::onLoadParams(const Params& params) { m_filename = params.get("filename"); diff --git a/src/app/commands/cmd_open_file.cpp b/src/app/commands/cmd_open_file.cpp index f8f088371..c25d06831 100644 --- a/src/app/commands/cmd_open_file.cpp +++ b/src/app/commands/cmd_open_file.cpp @@ -35,7 +35,7 @@ namespace app { OpenFileCommand::OpenFileCommand() - : Command(CommandId::OpenFile(), CmdRecordableFlag) + : Command(CommandId::OpenFile()) , m_ui(true) , m_repeatCheckbox(false) , m_oneFrame(false) diff --git a/src/app/commands/cmd_open_group.cpp b/src/app/commands/cmd_open_group.cpp index b6cea415e..b24bf5750 100644 --- a/src/app/commands/cmd_open_group.cpp +++ b/src/app/commands/cmd_open_group.cpp @@ -32,7 +32,7 @@ protected: // std::string onGetFriendlyName() const override; }; -OpenGroupCommand::OpenGroupCommand() : Command(CommandId::OpenGroup(), CmdRecordableFlag) +OpenGroupCommand::OpenGroupCommand() : Command(CommandId::OpenGroup()) { } diff --git a/src/app/commands/cmd_open_in_folder.cpp b/src/app/commands/cmd_open_in_folder.cpp index b9dd732c9..cfc800a2e 100644 --- a/src/app/commands/cmd_open_in_folder.cpp +++ b/src/app/commands/cmd_open_in_folder.cpp @@ -25,7 +25,7 @@ protected: void onExecute(Context* context) override; }; -OpenInFolderCommand::OpenInFolderCommand() : Command(CommandId::OpenInFolder(), CmdUIOnlyFlag) +OpenInFolderCommand::OpenInFolderCommand() : Command(CommandId::OpenInFolder()) { } diff --git a/src/app/commands/cmd_open_script_folder.cpp b/src/app/commands/cmd_open_script_folder.cpp index 38135939f..c6bfec94a 100644 --- a/src/app/commands/cmd_open_script_folder.cpp +++ b/src/app/commands/cmd_open_script_folder.cpp @@ -33,8 +33,7 @@ protected: void onExecute(Context* context); }; -OpenScriptFolderCommand::OpenScriptFolderCommand() - : Command(CommandId::OpenScriptFolder(), CmdUIOnlyFlag) +OpenScriptFolderCommand::OpenScriptFolderCommand() : Command(CommandId::OpenScriptFolder()) { } diff --git a/src/app/commands/cmd_open_with_app.cpp b/src/app/commands/cmd_open_with_app.cpp index ff1b908a4..73f2bc43d 100644 --- a/src/app/commands/cmd_open_with_app.cpp +++ b/src/app/commands/cmd_open_with_app.cpp @@ -25,7 +25,7 @@ protected: void onExecute(Context* context) override; }; -OpenWithAppCommand::OpenWithAppCommand() : Command(CommandId::OpenWithApp(), CmdUIOnlyFlag) +OpenWithAppCommand::OpenWithAppCommand() : Command(CommandId::OpenWithApp()) { } diff --git a/src/app/commands/cmd_options.cpp b/src/app/commands/cmd_options.cpp index 9f258f94b..1a0925d5c 100644 --- a/src/app/commands/cmd_options.cpp +++ b/src/app/commands/cmd_options.cpp @@ -2177,7 +2177,7 @@ private: std::string m_installExtensionFilename; }; -OptionsCommand::OptionsCommand() : Command(CommandId::Options(), CmdUIOnlyFlag) +OptionsCommand::OptionsCommand() : Command(CommandId::Options()) { Preferences& preferences = Preferences::instance(); diff --git a/src/app/commands/cmd_palette_editor.cpp b/src/app/commands/cmd_palette_editor.cpp index 3c2eb3fa1..91047cbb3 100644 --- a/src/app/commands/cmd_palette_editor.cpp +++ b/src/app/commands/cmd_palette_editor.cpp @@ -11,6 +11,7 @@ #include "app/commands/command.h" #include "app/commands/params.h" +#include "app/context.h" #include "app/i18n/strings.h" #include "app/ui/color_bar.h" #include "base/replace_string.h" @@ -23,6 +24,7 @@ public: PaletteEditorCommand(); protected: + bool onEnabled(Context* context) override; void onLoadParams(const Params& params) override; bool onChecked(Context* context) override; void onExecute(Context* context) override; @@ -34,14 +36,18 @@ private: bool m_background; }; -PaletteEditorCommand::PaletteEditorCommand() - : Command(CommandId::PaletteEditor(), CmdRecordableFlag) +PaletteEditorCommand::PaletteEditorCommand() : Command(CommandId::PaletteEditor()) { m_edit = true; m_popup = false; m_background = false; } +bool PaletteEditorCommand::onEnabled(Context* context) +{ + return context->isUIAvailable(); +} + void PaletteEditorCommand::onLoadParams(const Params& params) { m_edit = (params.empty() || params.get("edit") == "switch" || diff --git a/src/app/commands/cmd_palette_size.cpp b/src/app/commands/cmd_palette_size.cpp index 86e0e7a0b..b98f47deb 100644 --- a/src/app/commands/cmd_palette_size.cpp +++ b/src/app/commands/cmd_palette_size.cpp @@ -33,17 +33,21 @@ protected: void onExecute(Context* context) override; private: - int m_size; + int m_size = 0; + bool m_ui = true; }; -PaletteSizeCommand::PaletteSizeCommand() : Command(CommandId::PaletteSize(), CmdRecordableFlag) +PaletteSizeCommand::PaletteSizeCommand() : Command(CommandId::PaletteSize()) { - m_size = 0; } void PaletteSizeCommand::onLoadParams(const Params& params) { m_size = params.get_as("size"); + if (params.has_param("ui")) + m_ui = params.get_as("ui"); + else + m_ui = true; } bool PaletteSizeCommand::onEnabled(Context* context) @@ -59,7 +63,7 @@ void PaletteSizeCommand::onExecute(Context* context) Palette palette(*reader.palette()); int ncolors = (m_size != 0 ? m_size : palette.size()); - if (m_size == 0 && context->isUIAvailable()) { + if (m_size == 0 && m_ui && context->isUIAvailable()) { app::gen::PaletteSize window; window.colors()->setTextf("%d", ncolors); window.openWindowInForeground(); diff --git a/src/app/commands/cmd_paste.cpp b/src/app/commands/cmd_paste.cpp index 77762e78b..0604a5ebf 100644 --- a/src/app/commands/cmd_paste.cpp +++ b/src/app/commands/cmd_paste.cpp @@ -31,7 +31,7 @@ private: std::unique_ptr m_position; }; -PasteCommand::PasteCommand() : Command(CommandId::Paste(), CmdUIOnlyFlag) +PasteCommand::PasteCommand() : Command(CommandId::Paste()) { } diff --git a/src/app/commands/cmd_paste_text.cpp b/src/app/commands/cmd_paste_text.cpp index 976d1d3e3..d5620d6f3 100644 --- a/src/app/commands/cmd_paste_text.cpp +++ b/src/app/commands/cmd_paste_text.cpp @@ -43,14 +43,14 @@ protected: void onExecute(Context* ctx) override; }; -PasteTextCommand::PasteTextCommand() : Command(CommandId::PasteText(), CmdUIOnlyFlag) +PasteTextCommand::PasteTextCommand() : Command(CommandId::PasteText()) { } bool PasteTextCommand::onEnabled(Context* ctx) { - return ctx->checkFlags(ContextFlags::ActiveDocumentIsWritable | - ContextFlags::ActiveLayerIsEditable); + return ctx->isUIAvailable() && ctx->checkFlags(ContextFlags::ActiveDocumentIsWritable | + ContextFlags::ActiveLayerIsEditable); } class PasteTextWindow : public app::gen::PasteText { diff --git a/src/app/commands/cmd_pixel_perfect_mode.cpp b/src/app/commands/cmd_pixel_perfect_mode.cpp index 7ed76ea6d..e17858fa4 100644 --- a/src/app/commands/cmd_pixel_perfect_mode.cpp +++ b/src/app/commands/cmd_pixel_perfect_mode.cpp @@ -28,8 +28,7 @@ protected: void onExecute(Context* context) override; }; -PixelPerfectModeCommand::PixelPerfectModeCommand() - : Command(CommandId::PixelPerfectMode(), CmdUIOnlyFlag) +PixelPerfectModeCommand::PixelPerfectModeCommand() : Command(CommandId::PixelPerfectMode()) { } diff --git a/src/app/commands/cmd_play_animation.cpp b/src/app/commands/cmd_play_animation.cpp index e085d63f9..b9f479c1a 100644 --- a/src/app/commands/cmd_play_animation.cpp +++ b/src/app/commands/cmd_play_animation.cpp @@ -34,13 +34,14 @@ protected: void onExecute(Context* ctx) override; }; -PlayAnimationCommand::PlayAnimationCommand() : Command(CommandId::PlayAnimation(), CmdUIOnlyFlag) +PlayAnimationCommand::PlayAnimationCommand() : Command(CommandId::PlayAnimation()) { } bool PlayAnimationCommand::onEnabled(Context* ctx) { - return ctx->checkFlags(ContextFlags::ActiveDocumentIsReadable | ContextFlags::HasActiveSprite); + return ctx->isUIAvailable() && + ctx->checkFlags(ContextFlags::ActiveDocumentIsReadable | ContextFlags::HasActiveSprite); } bool PlayAnimationCommand::onChecked(Context* ctx) @@ -85,13 +86,14 @@ protected: }; PlayPreviewAnimationCommand::PlayPreviewAnimationCommand() - : Command(CommandId::PlayPreviewAnimation(), CmdUIOnlyFlag) + : Command(CommandId::PlayPreviewAnimation()) { } bool PlayPreviewAnimationCommand::onEnabled(Context* ctx) { - return ctx->checkFlags(ContextFlags::ActiveDocumentIsWritable | ContextFlags::HasActiveSprite); + return ctx->isUIAvailable() && + ctx->checkFlags(ContextFlags::ActiveDocumentIsWritable | ContextFlags::HasActiveSprite); } bool PlayPreviewAnimationCommand::onChecked(Context* ctx) diff --git a/src/app/commands/cmd_refresh.cpp b/src/app/commands/cmd_refresh.cpp index 83439c4e4..da6269f07 100644 --- a/src/app/commands/cmd_refresh.cpp +++ b/src/app/commands/cmd_refresh.cpp @@ -39,7 +39,7 @@ private: void postCancelMenuLoop(); }; -RefreshCommand::RefreshCommand() : Command(CommandId::Refresh(), CmdUIOnlyFlag) +RefreshCommand::RefreshCommand() : Command(CommandId::Refresh()) { } diff --git a/src/app/commands/cmd_remove_frame.cpp b/src/app/commands/cmd_remove_frame.cpp index 740034322..6a79aae8a 100644 --- a/src/app/commands/cmd_remove_frame.cpp +++ b/src/app/commands/cmd_remove_frame.cpp @@ -29,7 +29,7 @@ protected: void onExecute(Context* context) override; }; -RemoveFrameCommand::RemoveFrameCommand() : Command(CommandId::RemoveFrame(), CmdRecordableFlag) +RemoveFrameCommand::RemoveFrameCommand() : Command(CommandId::RemoveFrame()) { } diff --git a/src/app/commands/cmd_remove_frame_tag.cpp b/src/app/commands/cmd_remove_frame_tag.cpp index 5a1cf3199..7a6295430 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(CommandId::RemoveFrameTag(), CmdRecordableFlag) + : Command(CommandId::RemoveFrameTag()) , m_tagId(NullId) { } diff --git a/src/app/commands/cmd_remove_layer.cpp b/src/app/commands/cmd_remove_layer.cpp index a7db748c8..3f85cef70 100644 --- a/src/app/commands/cmd_remove_layer.cpp +++ b/src/app/commands/cmd_remove_layer.cpp @@ -105,7 +105,7 @@ protected: void onExecute(Context* context) override; }; -RemoveLayerCommand::RemoveLayerCommand() : Command(CommandId::RemoveLayer(), CmdRecordableFlag) +RemoveLayerCommand::RemoveLayerCommand() : Command(CommandId::RemoveLayer()) { } diff --git a/src/app/commands/cmd_remove_slice.cpp b/src/app/commands/cmd_remove_slice.cpp index 07373e36e..c1be6bce8 100644 --- a/src/app/commands/cmd_remove_slice.cpp +++ b/src/app/commands/cmd_remove_slice.cpp @@ -41,7 +41,7 @@ private: ObjectId m_sliceId; }; -RemoveSliceCommand::RemoveSliceCommand() : Command(CommandId::RemoveSlice(), CmdRecordableFlag) +RemoveSliceCommand::RemoveSliceCommand() : Command(CommandId::RemoveSlice()) { } @@ -117,13 +117,15 @@ void RemoveSliceCommand::onExecute(Context* context) document->notifyGeneralUpdate(); } - StatusBar::instance()->invalidate(); - if (!sliceName.empty()) { - StatusBar::instance()->showTip(1000, Strings::remove_slice_x_removed(sliceName)); - } - else { - StatusBar::instance()->showTip(1000, - Strings::remove_slice_n_slices_removed(slicesToDelete.size())); + if (context->isUIAvailable()) { + StatusBar::instance()->invalidate(); + if (!sliceName.empty()) { + StatusBar::instance()->showTip(1000, Strings::remove_slice_x_removed(sliceName)); + } + else { + StatusBar::instance()->showTip(1000, + Strings::remove_slice_n_slices_removed(slicesToDelete.size())); + } } } diff --git a/src/app/commands/cmd_reopen_closed_file.cpp b/src/app/commands/cmd_reopen_closed_file.cpp index e8c272fdc..f25899073 100644 --- a/src/app/commands/cmd_reopen_closed_file.cpp +++ b/src/app/commands/cmd_reopen_closed_file.cpp @@ -27,8 +27,7 @@ protected: void onExecute(Context* context) override; }; -ReopenClosedFileCommand::ReopenClosedFileCommand() - : Command(CommandId::ReopenClosedFile(), CmdUIOnlyFlag) +ReopenClosedFileCommand::ReopenClosedFileCommand() : Command(CommandId::ReopenClosedFile()) { } diff --git a/src/app/commands/cmd_repeat_last_export.cpp b/src/app/commands/cmd_repeat_last_export.cpp index 82dc747d3..a68dbdd6a 100644 --- a/src/app/commands/cmd_repeat_last_export.cpp +++ b/src/app/commands/cmd_repeat_last_export.cpp @@ -27,8 +27,7 @@ protected: virtual void onExecute(Context* context) override; }; -RepeatLastExportCommand::RepeatLastExportCommand() - : Command(CommandId::RepeatLastExport(), CmdRecordableFlag) +RepeatLastExportCommand::RepeatLastExportCommand() : Command(CommandId::RepeatLastExport()) { } diff --git a/src/app/commands/cmd_reselect_mask.cpp b/src/app/commands/cmd_reselect_mask.cpp index 517e6dae2..65e20ab3a 100644 --- a/src/app/commands/cmd_reselect_mask.cpp +++ b/src/app/commands/cmd_reselect_mask.cpp @@ -28,7 +28,7 @@ protected: void onExecute(Context* context) override; }; -ReselectMaskCommand::ReselectMaskCommand() : Command(CommandId::ReselectMask(), CmdRecordableFlag) +ReselectMaskCommand::ReselectMaskCommand() : Command(CommandId::ReselectMask()) { } diff --git a/src/app/commands/cmd_reverse_frames.cpp b/src/app/commands/cmd_reverse_frames.cpp index f30652205..16634fd8c 100644 --- a/src/app/commands/cmd_reverse_frames.cpp +++ b/src/app/commands/cmd_reverse_frames.cpp @@ -27,7 +27,7 @@ protected: void onExecute(Context* context) override; }; -ReverseFramesCommand::ReverseFramesCommand() : Command(CommandId::ReverseFrames(), CmdUIOnlyFlag) +ReverseFramesCommand::ReverseFramesCommand() : Command(CommandId::ReverseFrames()) { } diff --git a/src/app/commands/cmd_rotate.cpp b/src/app/commands/cmd_rotate.cpp index bc264f700..f4a60f51c 100644 --- a/src/app/commands/cmd_rotate.cpp +++ b/src/app/commands/cmd_rotate.cpp @@ -166,7 +166,7 @@ protected: } }; -RotateCommand::RotateCommand() : Command(CommandId::Rotate(), CmdRecordableFlag) +RotateCommand::RotateCommand() : Command(CommandId::Rotate()) { m_ui = true; m_flipMask = false; @@ -190,6 +190,10 @@ void RotateCommand::onLoadParams(const Params& params) bool RotateCommand::onEnabled(Context* context) { + // Because we use the toolbox & editor to transform the selection, this won't work without a UI + if (m_flipMask && !context->isUIAvailable()) + return false; + return context->checkFlags(ContextFlags::ActiveDocumentIsWritable | ContextFlags::HasActiveSprite); } diff --git a/src/app/commands/cmd_run_script.cpp b/src/app/commands/cmd_run_script.cpp index 15540cc4f..0bd95dea8 100644 --- a/src/app/commands/cmd_run_script.cpp +++ b/src/app/commands/cmd_run_script.cpp @@ -46,7 +46,7 @@ private: Params m_params; }; -RunScriptCommand::RunScriptCommand() : Command(CommandId::RunScript(), CmdRecordableFlag) +RunScriptCommand::RunScriptCommand() : Command(CommandId::RunScript()) { } diff --git a/src/app/commands/cmd_save_file.cpp b/src/app/commands/cmd_save_file.cpp index cdebc7e2b..235a861c5 100644 --- a/src/app/commands/cmd_save_file.cpp +++ b/src/app/commands/cmd_save_file.cpp @@ -86,8 +86,7 @@ private: ////////////////////////////////////////////////////////////////////// -SaveFileBaseCommand::SaveFileBaseCommand(const char* id, CommandFlags flags) - : CommandWithNewParams(id, flags) +SaveFileBaseCommand::SaveFileBaseCommand(const char* id) : CommandWithNewParams(id) { } @@ -269,7 +268,7 @@ protected: void onExecute(Context* context) override; }; -SaveFileCommand::SaveFileCommand() : SaveFileBaseCommand(CommandId::SaveFile(), CmdRecordableFlag) +SaveFileCommand::SaveFileCommand() : SaveFileBaseCommand(CommandId::SaveFile()) { } @@ -310,8 +309,7 @@ protected: void onExecute(Context* context) override; }; -SaveFileAsCommand::SaveFileAsCommand() - : SaveFileBaseCommand(CommandId::SaveFileAs(), CmdRecordableFlag) +SaveFileAsCommand::SaveFileAsCommand() : SaveFileBaseCommand(CommandId::SaveFileAs()) { } @@ -335,8 +333,7 @@ private: void moveToUndoState(Doc* doc, const undo::UndoState* state); }; -SaveFileCopyAsCommand::SaveFileCopyAsCommand() - : SaveFileBaseCommand(CommandId::SaveFileCopyAs(), CmdRecordableFlag) +SaveFileCopyAsCommand::SaveFileCopyAsCommand() : SaveFileBaseCommand(CommandId::SaveFileCopyAs()) { } diff --git a/src/app/commands/cmd_save_file.h b/src/app/commands/cmd_save_file.h index eab6837f7..3c8fe56bc 100644 --- a/src/app/commands/cmd_save_file.h +++ b/src/app/commands/cmd_save_file.h @@ -67,7 +67,7 @@ public: enum class SaveInBackground { Off, On }; enum class ResizeOnTheFly { Off, On }; - SaveFileBaseCommand(const char* id, CommandFlags flags); + SaveFileBaseCommand(const char* id); protected: void onLoadParams(const Params& params) override; diff --git a/src/app/commands/cmd_save_mask.cpp b/src/app/commands/cmd_save_mask.cpp index 73aa56591..a55cb9df7 100644 --- a/src/app/commands/cmd_save_mask.cpp +++ b/src/app/commands/cmd_save_mask.cpp @@ -15,13 +15,20 @@ #include "app/i18n/strings.h" #include "app/util/msk_file.h" #include "base/fs.h" +#include "doc/file/act_file.h" #include "doc/mask.h" #include "doc/sprite.h" +#include "new_params.h" #include "ui/alert.h" namespace app { -class SaveMaskCommand : public Command { +struct SaveMaskParams : public NewParams { + Param ui{ this, true, "ui" }; + Param filename{ this, "default.msk", "filename" }; +}; + +class SaveMaskCommand : public CommandWithNewParams { public: SaveMaskCommand(); @@ -30,7 +37,7 @@ protected: void onExecute(Context* context) override; }; -SaveMaskCommand::SaveMaskCommand() : Command(CommandId::SaveMask(), CmdUIOnlyFlag) +SaveMaskCommand::SaveMaskCommand() : CommandWithNewParams(CommandId::SaveMask()) { } @@ -41,21 +48,27 @@ bool SaveMaskCommand::onEnabled(Context* context) void SaveMaskCommand::onExecute(Context* context) { + const bool ui = (params().ui() && context->isUIAvailable()); + std::string filename = params().filename(); + const ContextReader reader(context); const Doc* document(reader.document()); - base::paths exts = { "msk" }; - base::paths selFilename; - if (!app::show_file_selector(Strings::save_selection_title(), - "default.msk", - exts, - FileSelectorType::Save, - selFilename)) - return; + if (ui) { + base::paths exts = { "msk" }; + base::paths selFilename; + if (!app::show_file_selector(Strings::save_selection_title(), + filename, + exts, + FileSelectorType::Save, + selFilename)) + return; - std::string filename = selFilename.front(); + filename = selFilename.front(); + } - if (save_msk_file(document->mask(), filename.c_str()) != 0) + const bool result = save_msk_file(document->mask(), filename.c_str()) != 0; + if (result && ui) ui::Alert::show(Strings::alerts_error_saving_file(filename)); } diff --git a/src/app/commands/cmd_save_palette.cpp b/src/app/commands/cmd_save_palette.cpp index 6f52f46ae..88c1672d6 100644 --- a/src/app/commands/cmd_save_palette.cpp +++ b/src/app/commands/cmd_save_palette.cpp @@ -21,56 +21,62 @@ #include "app/modules/palettes.h" #include "base/fs.h" #include "doc/palette.h" +#include "new_params.h" #include "ui/alert.h" namespace app { using namespace ui; -class SavePaletteCommand : public Command { +struct SavePaletteParams : public NewParams { + Param ui{ this, true, "ui" }; + Param filename{ this, "", "filename" }; + Param preset{ this, "", "preset" }; + Param saveAsPreset{ this, false, "saveAsPreset" }; + Param columns{ this, 16, "columns" }; +}; + +class SavePaletteCommand : public CommandWithNewParams { public: SavePaletteCommand(); protected: - void onLoadParams(const Params& params) override; - void onExecute(Context* context) override; + void onExecute(Context* ctx) override; std::string onGetFriendlyName() const override; - -private: - std::string m_preset; - bool m_saveAsPreset = false; }; -SavePaletteCommand::SavePaletteCommand() : Command(CommandId::SavePalette(), CmdRecordableFlag) +SavePaletteCommand::SavePaletteCommand() : CommandWithNewParams(CommandId::SavePalette()) { } -void SavePaletteCommand::onLoadParams(const Params& params) -{ - m_preset = params.get("preset"); - m_saveAsPreset = (params.get("saveAsPreset") == "true"); -} - void SavePaletteCommand::onExecute(Context* ctx) { const doc::Palette* palette = get_current_palette(); + const bool ui = (params().ui() && ctx->isUIAvailable()); std::string filename; - if (!m_preset.empty()) { - filename = get_preset_palette_filename(m_preset, ".ase"); + if (!params().preset().empty()) { + filename = get_preset_palette_filename(params().preset(), ".ase"); } else { base::paths exts = get_writable_palette_extensions(); - base::paths selFilename; - std::string initialPath = (m_saveAsPreset ? get_preset_palettes_dir() : ""); - if (!app::show_file_selector(Strings::save_palette_title(), - initialPath, - exts, - FileSelectorType::Save, - selFilename)) - return; - filename = selFilename.front(); + if (ui) { + base::paths selFilename; + std::string initialPath = params().saveAsPreset() ? get_preset_palettes_dir() : + params().filename(); + if (!app::show_file_selector(Strings::save_palette_title(), + initialPath, + exts, + FileSelectorType::Save, + selFilename)) + return; + + filename = selFilename.front(); + } + else { + filename = params().filename(); + } // Check that the file format supports saving indexed images/color // palettes (e.g. if the user specified .jpg we should show that @@ -84,28 +90,31 @@ void SavePaletteCommand::onExecute(Context* ctx) } } gfx::ColorSpaceRef colorSpace = nullptr; - auto activeDoc = ctx->activeDocument(); + auto* activeDoc = ctx->activeDocument(); if (activeDoc) colorSpace = activeDoc->sprite()->colorSpace(); - if (!save_palette(filename.c_str(), palette, 16, colorSpace)) // TODO 16 should be configurable + const bool result = save_palette(filename.c_str(), palette, params().columns(), colorSpace); + + if (ui && !result) ui::Alert::show(Strings::alerts_error_saving_file(filename)); - if (m_preset == get_default_palette_preset_name()) { + if (params().preset() == get_default_palette_preset_name()) { set_default_palette(palette); if (!activeDoc) set_current_palette(palette, false); } - if (m_saveAsPreset) { + + if (params().saveAsPreset()) { App::instance()->PalettePresetsChange(); } } std::string SavePaletteCommand::onGetFriendlyName() const { - if (m_preset == "default") + if (params().preset() == get_default_palette_preset_name()) return Strings::commands_SavePaletteAsDefault(); - else if (m_saveAsPreset) + if (params().saveAsPreset()) return Strings::commands_SavePaletteAsPreset(); return Command::onGetFriendlyName(); } diff --git a/src/app/commands/cmd_scroll.cpp b/src/app/commands/cmd_scroll.cpp index 66780f3f3..7764a5604 100644 --- a/src/app/commands/cmd_scroll.cpp +++ b/src/app/commands/cmd_scroll.cpp @@ -36,7 +36,7 @@ private: MoveThing m_moveThing; }; -ScrollCommand::ScrollCommand() : Command(CommandId::Scroll(), CmdUIOnlyFlag) +ScrollCommand::ScrollCommand() : Command(CommandId::Scroll()) { } @@ -47,7 +47,7 @@ void ScrollCommand::onLoadParams(const Params& params) bool ScrollCommand::onEnabled(Context* context) { - return context->checkFlags(ContextFlags::HasActiveDocument); + return context->isUIAvailable() && context->checkFlags(ContextFlags::HasActiveDocument); } void ScrollCommand::onExecute(Context* context) diff --git a/src/app/commands/cmd_scroll_center.cpp b/src/app/commands/cmd_scroll_center.cpp index 86b94e539..93d709865 100644 --- a/src/app/commands/cmd_scroll_center.cpp +++ b/src/app/commands/cmd_scroll_center.cpp @@ -25,7 +25,7 @@ protected: void onExecute(Context* context) override; }; -ScrollCenterCommand::ScrollCenterCommand() : Command(CommandId::ScrollCenter(), CmdUIOnlyFlag) +ScrollCenterCommand::ScrollCenterCommand() : Command(CommandId::ScrollCenter()) { } diff --git a/src/app/commands/cmd_select_palette.cpp b/src/app/commands/cmd_select_palette.cpp index 63742a7df..a21fdb1aa 100644 --- a/src/app/commands/cmd_select_palette.cpp +++ b/src/app/commands/cmd_select_palette.cpp @@ -51,7 +51,7 @@ private: }; SelectPaletteColorsCommand::SelectPaletteColorsCommand() - : Command(CommandId::SelectPaletteColors(), CmdRecordableFlag) + : Command(CommandId::SelectPaletteColors()) , m_modifier(Modifier::UsedColors) { } diff --git a/src/app/commands/cmd_select_tile.cpp b/src/app/commands/cmd_select_tile.cpp index 53f211087..65c4b6b44 100644 --- a/src/app/commands/cmd_select_tile.cpp +++ b/src/app/commands/cmd_select_tile.cpp @@ -40,7 +40,7 @@ private: }; SelectTileCommand::SelectTileCommand() - : Command(CommandId::SelectTile(), CmdRecordableFlag) + : Command(CommandId::SelectTile()) , m_mode(gen::SelectionMode::DEFAULT) { } @@ -60,7 +60,8 @@ void SelectTileCommand::onLoadParams(const Params& params) bool SelectTileCommand::onEnabled(Context* ctx) { - return ctx->checkFlags(ContextFlags::ActiveDocumentIsWritable); + return ctx->checkFlags(ContextFlags::ActiveDocumentIsWritable) && ctx->isUIAvailable() && + Editor::activeEditor()->hasMouse(); } void SelectTileCommand::onExecute(Context* ctx) diff --git a/src/app/commands/cmd_set_color_selector.cpp b/src/app/commands/cmd_set_color_selector.cpp index 5732167bc..b76b44b7e 100644 --- a/src/app/commands/cmd_set_color_selector.cpp +++ b/src/app/commands/cmd_set_color_selector.cpp @@ -12,6 +12,7 @@ #include "app/app.h" #include "app/commands/command.h" #include "app/commands/params.h" +#include "app/context.h" #include "app/i18n/strings.h" #include "app/ui/color_bar.h" @@ -22,6 +23,7 @@ public: SetColorSelectorCommand(); protected: + bool onEnabled(Context* context) override; bool onNeedsParams() const override { return true; } void onLoadParams(const Params& params) override; bool onChecked(Context* context) override; @@ -33,11 +35,16 @@ private: }; SetColorSelectorCommand::SetColorSelectorCommand() - : Command(CommandId::SetColorSelector(), CmdUIOnlyFlag) + : Command(CommandId::SetColorSelector()) , m_type(ColorBar::ColorSelector::SPECTRUM) { } +bool SetColorSelectorCommand::onEnabled(Context* context) +{ + return context->isUIAvailable(); +} + void SetColorSelectorCommand::onLoadParams(const Params& params) { std::string type = params.get("type"); diff --git a/src/app/commands/cmd_set_ink_type.cpp b/src/app/commands/cmd_set_ink_type.cpp index fadd5a3a5..39906f431 100644 --- a/src/app/commands/cmd_set_ink_type.cpp +++ b/src/app/commands/cmd_set_ink_type.cpp @@ -28,17 +28,22 @@ public: SetInkTypeCommand(); protected: + bool onEnabled(Context* context) override; bool onNeedsParams() const override { return true; } bool onChecked(Context* context) override; void onExecute(Context* context) override; std::string onGetFriendlyName() const override; }; -SetInkTypeCommand::SetInkTypeCommand() - : CommandWithNewParams(CommandId::SetInkType(), CmdUIOnlyFlag) +SetInkTypeCommand::SetInkTypeCommand() : CommandWithNewParams(CommandId::SetInkType()) { } +bool SetInkTypeCommand::onEnabled(Context* context) +{ + return context->isUIAvailable(); +} + bool SetInkTypeCommand::onChecked(Context* context) { tools::Tool* tool = App::instance()->activeTool(); diff --git a/src/app/commands/cmd_set_loop_section.cpp b/src/app/commands/cmd_set_loop_section.cpp index 21e13bc46..5fd81437e 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(CommandId::SetLoopSection(), CmdRecordableFlag) + : Command(CommandId::SetLoopSection()) , m_action(Action::Auto) , m_begin(0) , m_end(0) @@ -129,7 +129,8 @@ void SetLoopSectionCommand::onExecute(Context* ctx) } } - App::instance()->timeline()->invalidate(); + if (App::instance()->timeline()) + App::instance()->timeline()->invalidate(); } Command* CommandFactory::createSetLoopSectionCommand() diff --git a/src/app/commands/cmd_set_palette.cpp b/src/app/commands/cmd_set_palette.cpp index 6badeabd1..cdecc38ea 100644 --- a/src/app/commands/cmd_set_palette.cpp +++ b/src/app/commands/cmd_set_palette.cpp @@ -23,9 +23,7 @@ namespace app { using namespace ui; -SetPaletteCommand::SetPaletteCommand() - : Command(CommandId::SetPalette(), CmdRecordableFlag) - , m_palette(NULL) +SetPaletteCommand::SetPaletteCommand() : Command(CommandId::SetPalette()), 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 b266e8b70..a9aaca230 100644 --- a/src/app/commands/cmd_set_palette_entry_size.cpp +++ b/src/app/commands/cmd_set_palette_entry_size.cpp @@ -12,6 +12,7 @@ #include "app/app.h" #include "app/commands/command.h" #include "app/commands/params.h" +#include "app/context.h" #include "app/ui/color_bar.h" namespace app { @@ -21,6 +22,7 @@ public: SetPaletteEntrySizeCommand(); protected: + bool onEnabled(Context* context) override; void onLoadParams(const Params& params) override; bool onChecked(Context* context) override; void onExecute(Context* context) override; @@ -32,11 +34,16 @@ private: }; SetPaletteEntrySizeCommand::SetPaletteEntrySizeCommand() - : Command(CommandId::SetPaletteEntrySize(), CmdUIOnlyFlag) + : Command(CommandId::SetPaletteEntrySize()) , m_size(7) { } +bool SetPaletteEntrySizeCommand::onEnabled(Context* context) +{ + return context->isUIAvailable(); +} + void SetPaletteEntrySizeCommand::onLoadParams(const Params& params) { if (params.has_param("size")) diff --git a/src/app/commands/cmd_set_same_ink.cpp b/src/app/commands/cmd_set_same_ink.cpp index 5fc23ec6b..ffdcc424b 100644 --- a/src/app/commands/cmd_set_same_ink.cpp +++ b/src/app/commands/cmd_set_same_ink.cpp @@ -27,7 +27,7 @@ protected: void onExecute(Context* context) override; }; -SetSameInkCommand::SetSameInkCommand() : Command(CommandId::SetSameInk(), CmdUIOnlyFlag) +SetSameInkCommand::SetSameInkCommand() : Command(CommandId::SetSameInk()) { } diff --git a/src/app/commands/cmd_show.cpp b/src/app/commands/cmd_show.cpp index d2fb98a94..a15faad35 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(CommandId::ShowExtras(), CmdUIOnlyFlag) {} + ShowExtrasCommand() : Command(CommandId::ShowExtras()) {} protected: bool onChecked(Context* ctx) override @@ -49,7 +49,7 @@ protected: class ShowLayerEdgesCommand : public Command { public: - ShowLayerEdgesCommand() : Command(CommandId::ShowLayerEdges(), CmdUIOnlyFlag) {} + ShowLayerEdgesCommand() : Command(CommandId::ShowLayerEdges()) {} protected: bool onChecked(Context* ctx) override @@ -67,7 +67,7 @@ protected: class ShowGridCommand : public Command { public: - ShowGridCommand() : Command(CommandId::ShowGrid(), CmdUIOnlyFlag) {} + ShowGridCommand() : Command(CommandId::ShowGrid()) {} protected: bool onChecked(Context* ctx) override @@ -85,7 +85,7 @@ protected: class ShowPixelGridCommand : public Command { public: - ShowPixelGridCommand() : Command(CommandId::ShowPixelGrid(), CmdUIOnlyFlag) {} + ShowPixelGridCommand() : Command(CommandId::ShowPixelGrid()) {} protected: bool onChecked(Context* ctx) override @@ -103,7 +103,7 @@ protected: class ShowSelectionEdgesCommand : public Command { public: - ShowSelectionEdgesCommand() : Command(CommandId::ShowSelectionEdges(), CmdUIOnlyFlag) {} + ShowSelectionEdgesCommand() : Command(CommandId::ShowSelectionEdges()) {} protected: bool onChecked(Context* ctx) override @@ -121,7 +121,7 @@ protected: class ShowBrushPreviewCommand : public Command { public: - ShowBrushPreviewCommand() : Command(CommandId::ShowBrushPreview(), CmdUIOnlyFlag) {} + ShowBrushPreviewCommand() : Command(CommandId::ShowBrushPreview()) {} protected: bool onChecked(Context* ctx) override @@ -146,10 +146,7 @@ protected: // Preview in the Preview window), not based on the active document. class ShowBrushPreviewInPreviewCommand : public Command { public: - ShowBrushPreviewInPreviewCommand() - : Command(CommandId::ShowBrushPreviewInPreview(), CmdUIOnlyFlag) - { - } + ShowBrushPreviewInPreviewCommand() : Command(CommandId::ShowBrushPreviewInPreview()) {} protected: bool onChecked(Context* ctx) override @@ -167,7 +164,7 @@ protected: class ShowAutoGuidesCommand : public Command { public: - ShowAutoGuidesCommand() : Command(CommandId::ShowAutoGuides(), CmdUIOnlyFlag) {} + ShowAutoGuidesCommand() : Command(CommandId::ShowAutoGuides()) {} protected: bool onChecked(Context* ctx) override @@ -185,7 +182,7 @@ protected: class ShowSlicesCommand : public Command { public: - ShowSlicesCommand() : Command(CommandId::ShowSlices(), CmdUIOnlyFlag) {} + ShowSlicesCommand() : Command(CommandId::ShowSlices()) {} protected: bool onChecked(Context* ctx) override @@ -203,7 +200,7 @@ protected: class ShowTileNumbersCommand : public Command { public: - ShowTileNumbersCommand() : Command(CommandId::ShowTileNumbers(), CmdUIOnlyFlag) {} + ShowTileNumbersCommand() : Command(CommandId::ShowTileNumbers()) {} protected: bool onChecked(Context* ctx) override diff --git a/src/app/commands/cmd_slice_properties.cpp b/src/app/commands/cmd_slice_properties.cpp index 27ce7e45c..8a42dd9a6 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(CommandId::SliceProperties(), CmdUIOnlyFlag) + : Command(CommandId::SliceProperties()) , m_sliceId(NullId) { } @@ -57,7 +57,7 @@ void SlicePropertiesCommand::onLoadParams(const Params& params) bool SlicePropertiesCommand::onEnabled(Context* context) { - return context->checkFlags(ContextFlags::ActiveDocumentIsWritable); + return context->isUIAvailable() && context->checkFlags(ContextFlags::ActiveDocumentIsWritable); } void SlicePropertiesCommand::onExecute(Context* context) diff --git a/src/app/commands/cmd_sprite_properties.cpp b/src/app/commands/cmd_sprite_properties.cpp index 31fd74244..3667e7d83 100644 --- a/src/app/commands/cmd_sprite_properties.cpp +++ b/src/app/commands/cmd_sprite_properties.cpp @@ -235,15 +235,14 @@ protected: void onExecute(Context* context) override; }; -SpritePropertiesCommand::SpritePropertiesCommand() - : Command(CommandId::SpriteProperties(), CmdUIOnlyFlag) +SpritePropertiesCommand::SpritePropertiesCommand() : Command(CommandId::SpriteProperties()) { } bool SpritePropertiesCommand::onEnabled(Context* context) { - return context->checkFlags(ContextFlags::ActiveDocumentIsWritable | - ContextFlags::HasActiveSprite); + return context->isUIAvailable() && context->checkFlags(ContextFlags::ActiveDocumentIsWritable | + ContextFlags::HasActiveSprite); } void SpritePropertiesCommand::onExecute(Context* context) diff --git a/src/app/commands/cmd_sprite_size.cpp b/src/app/commands/cmd_sprite_size.cpp index fa975d82b..a4665d301 100644 --- a/src/app/commands/cmd_sprite_size.cpp +++ b/src/app/commands/cmd_sprite_size.cpp @@ -372,7 +372,7 @@ protected: }; SpriteSizeCommand::SpriteSizeCommand() - : CommandWithNewParams(CommandId::SpriteSize(), CmdRecordableFlag) + : CommandWithNewParams(CommandId::SpriteSize()) { } diff --git a/src/app/commands/cmd_swap_checkerboard_colors.cpp b/src/app/commands/cmd_swap_checkerboard_colors.cpp index d9b5424c3..cc0360f7e 100644 --- a/src/app/commands/cmd_swap_checkerboard_colors.cpp +++ b/src/app/commands/cmd_swap_checkerboard_colors.cpp @@ -26,7 +26,7 @@ protected: }; SwapCheckerboardColorsCommand::SwapCheckerboardColorsCommand() - : Command(CommandId::SwapCheckerboardColors(), CmdUIOnlyFlag) + : Command(CommandId::SwapCheckerboardColors()) { } diff --git a/src/app/commands/cmd_switch_colors.cpp b/src/app/commands/cmd_switch_colors.cpp index 23a7b8ccc..42345cea3 100644 --- a/src/app/commands/cmd_switch_colors.cpp +++ b/src/app/commands/cmd_switch_colors.cpp @@ -27,7 +27,7 @@ protected: void onExecute(Context* context) override; }; -SwitchColorsCommand::SwitchColorsCommand() : Command(CommandId::SwitchColors(), CmdUIOnlyFlag) +SwitchColorsCommand::SwitchColorsCommand() : Command(CommandId::SwitchColors()) { } diff --git a/src/app/commands/cmd_symmetry_mode.cpp b/src/app/commands/cmd_symmetry_mode.cpp index 43491f9e6..a9222988a 100644 --- a/src/app/commands/cmd_symmetry_mode.cpp +++ b/src/app/commands/cmd_symmetry_mode.cpp @@ -37,7 +37,7 @@ private: app::gen::SymmetryMode m_mode = app::gen::SymmetryMode::NONE; }; -SymmetryModeCommand::SymmetryModeCommand() : Command(CommandId::SymmetryMode(), CmdUIOnlyFlag) +SymmetryModeCommand::SymmetryModeCommand() : Command(CommandId::SymmetryMode()) { } @@ -120,7 +120,8 @@ void SymmetryModeCommand::onExecute(Context* ctx) // TODO Same with context bar, in the future the context bar could // be listening the DocPref changes to be automatically // invalidated (like it already does with symmetryMode.enabled) - App::instance()->contextBar()->updateForActiveTool(); + if (App::instance()->contextBar()) + App::instance()->contextBar()->updateForActiveTool(); } } diff --git a/src/app/commands/cmd_tiled_mode.cpp b/src/app/commands/cmd_tiled_mode.cpp index f06ebf64c..48a5f020f 100644 --- a/src/app/commands/cmd_tiled_mode.cpp +++ b/src/app/commands/cmd_tiled_mode.cpp @@ -35,7 +35,7 @@ protected: }; TiledModeCommand::TiledModeCommand() - : Command(CommandId::TiledMode(), CmdUIOnlyFlag) + : Command(CommandId::TiledMode()) , m_mode(filters::TiledMode::NONE) { } diff --git a/src/app/commands/cmd_timeline.cpp b/src/app/commands/cmd_timeline.cpp index 3be19233d..64cd78ea3 100644 --- a/src/app/commands/cmd_timeline.cpp +++ b/src/app/commands/cmd_timeline.cpp @@ -24,6 +24,7 @@ public: TimelineCommand(); protected: + bool onEnabled(Context* context) override; bool onNeedsParams() const override { return true; } void onLoadParams(const Params& params) override; void onExecute(Context* context) override; @@ -34,13 +35,18 @@ protected: bool m_switch; }; -TimelineCommand::TimelineCommand() : Command(CommandId::Timeline(), CmdUIOnlyFlag) +TimelineCommand::TimelineCommand() : Command(CommandId::Timeline()) { m_open = true; m_close = false; m_switch = false; } +bool TimelineCommand::onEnabled(Context* context) +{ + return context->isUIAvailable(); +} + void TimelineCommand::onLoadParams(const Params& params) { m_open = params.get_as("open"); diff --git a/src/app/commands/cmd_toggle_preview.cpp b/src/app/commands/cmd_toggle_preview.cpp index 9fd291b70..030e8d54a 100644 --- a/src/app/commands/cmd_toggle_preview.cpp +++ b/src/app/commands/cmd_toggle_preview.cpp @@ -26,14 +26,14 @@ protected: void onExecute(Context* context) override; }; -TogglePreviewCommand::TogglePreviewCommand() : Command(CommandId::TogglePreview(), CmdUIOnlyFlag) +TogglePreviewCommand::TogglePreviewCommand() : Command(CommandId::TogglePreview()) { } bool TogglePreviewCommand::onEnabled(Context* context) { - return context->checkFlags(ContextFlags::ActiveDocumentIsWritable | - ContextFlags::HasActiveSprite); + return context->isUIAvailable() && context->checkFlags(ContextFlags::ActiveDocumentIsWritable | + ContextFlags::HasActiveSprite); } bool TogglePreviewCommand::onChecked(Context* context) diff --git a/src/app/commands/cmd_toggle_tiles_mode.cpp b/src/app/commands/cmd_toggle_tiles_mode.cpp index 5cee869fa..f322a13d5 100644 --- a/src/app/commands/cmd_toggle_tiles_mode.cpp +++ b/src/app/commands/cmd_toggle_tiles_mode.cpp @@ -18,7 +18,7 @@ using namespace gfx; class ToggleTilesModeCommand : public Command { public: - ToggleTilesModeCommand() : Command(CommandId::ToggleTilesMode(), CmdUIOnlyFlag) {} + ToggleTilesModeCommand() : Command(CommandId::ToggleTilesMode()) {} protected: bool onChecked(Context* context) override diff --git a/src/app/commands/cmd_toggle_timeline_thumbnails.cpp b/src/app/commands/cmd_toggle_timeline_thumbnails.cpp index 31112f98b..20f1baef2 100644 --- a/src/app/commands/cmd_toggle_timeline_thumbnails.cpp +++ b/src/app/commands/cmd_toggle_timeline_thumbnails.cpp @@ -22,9 +22,7 @@ using namespace gfx; class ToggleTimelineThumbnailsCommand : public Command { public: - ToggleTimelineThumbnailsCommand() : Command(CommandId::ToggleTimelineThumbnails(), CmdUIOnlyFlag) - { - } + ToggleTimelineThumbnailsCommand() : Command(CommandId::ToggleTimelineThumbnails()) {} protected: bool onChecked(Context* context) override diff --git a/src/app/commands/cmd_undo.cpp b/src/app/commands/cmd_undo.cpp index 96f31117e..4241cff0b 100644 --- a/src/app/commands/cmd_undo.cpp +++ b/src/app/commands/cmd_undo.cpp @@ -42,7 +42,7 @@ private: }; UndoCommand::UndoCommand(Type type) - : Command((type == Undo ? CommandId::Undo() : CommandId::Redo()), CmdUIOnlyFlag) + : Command((type == Undo ? CommandId::Undo() : CommandId::Redo())) , m_type(type) { } diff --git a/src/app/commands/cmd_undo_history.cpp b/src/app/commands/cmd_undo_history.cpp index 5fac6f5b4..36022196a 100644 --- a/src/app/commands/cmd_undo_history.cpp +++ b/src/app/commands/cmd_undo_history.cpp @@ -497,15 +497,21 @@ public: UndoHistoryCommand(); protected: + bool onEnabled(Context* context) override; void onExecute(Context* ctx) override; }; static UndoHistoryWindow* g_window = NULL; -UndoHistoryCommand::UndoHistoryCommand() : Command(CommandId::UndoHistory(), CmdUIOnlyFlag) +UndoHistoryCommand::UndoHistoryCommand() : Command(CommandId::UndoHistory()) { } +bool UndoHistoryCommand::onEnabled(Context* context) +{ + return context->isUIAvailable(); +} + void UndoHistoryCommand::onExecute(Context* ctx) { if (!g_window) diff --git a/src/app/commands/cmd_unlink_cel.cpp b/src/app/commands/cmd_unlink_cel.cpp index 25e751d44..1bf1d6240 100644 --- a/src/app/commands/cmd_unlink_cel.cpp +++ b/src/app/commands/cmd_unlink_cel.cpp @@ -32,7 +32,7 @@ protected: void onExecute(Context* context) override; }; -UnlinkCelCommand::UnlinkCelCommand() : Command(CommandId::UnlinkCel(), CmdRecordableFlag) +UnlinkCelCommand::UnlinkCelCommand() : Command(CommandId::UnlinkCel()) { } diff --git a/src/app/commands/cmd_zoom.cpp b/src/app/commands/cmd_zoom.cpp index 96aee22c6..a7374c3a9 100644 --- a/src/app/commands/cmd_zoom.cpp +++ b/src/app/commands/cmd_zoom.cpp @@ -43,7 +43,7 @@ private: }; ZoomCommand::ZoomCommand() - : Command(CommandId::Zoom(), CmdUIOnlyFlag) + : Command(CommandId::Zoom()) , m_action(Action::In) , m_zoom(1, 1) , m_focus(Focus::Default) diff --git a/src/app/commands/command.cpp b/src/app/commands/command.cpp index f94ef5b8f..f6625f6af 100644 --- a/src/app/commands/command.cpp +++ b/src/app/commands/command.cpp @@ -16,7 +16,7 @@ namespace app { -Command::Command(const char* id, CommandFlags flags) : m_id(id), m_flags(flags) +Command::Command(const char* id) : m_id(id) { } diff --git a/src/app/commands/command.h b/src/app/commands/command.h index 9d01d385b..2f13a868e 100644 --- a/src/app/commands/command.h +++ b/src/app/commands/command.h @@ -20,14 +20,9 @@ namespace app { class Context; class Params; -enum CommandFlags { - CmdUIOnlyFlag = 0x00000001, - CmdRecordableFlag = 0x00000002, -}; - class Command { public: - Command(const char* id, CommandFlags flags); + Command(const char* id); virtual ~Command(); const std::string& id() const { return m_id; } @@ -55,7 +50,6 @@ private: void execute(Context* context); std::string m_id; - CommandFlags m_flags; }; } // namespace app diff --git a/src/app/commands/convert_layer.cpp b/src/app/commands/convert_layer.cpp index c80cab48d..4414bc4ba 100644 --- a/src/app/commands/convert_layer.cpp +++ b/src/app/commands/convert_layer.cpp @@ -79,7 +79,7 @@ private: }; ConvertLayerCommand::ConvertLayerCommand() - : CommandWithNewParams(CommandId::ConvertLayer(), CmdRecordableFlag) + : CommandWithNewParams(CommandId::ConvertLayer()) { } diff --git a/src/app/commands/copy_path.cpp b/src/app/commands/copy_path.cpp index 4586ebf9f..02c4602f7 100644 --- a/src/app/commands/copy_path.cpp +++ b/src/app/commands/copy_path.cpp @@ -26,7 +26,7 @@ protected: void onExecute(Context* ctx) override; }; -CopyPathCommand::CopyPathCommand() : Command(CommandId::CopyPath(), CmdRecordableFlag) +CopyPathCommand::CopyPathCommand() : Command(CommandId::CopyPath()) { } diff --git a/src/app/commands/debugger.cpp b/src/app/commands/debugger.cpp index fb66d9ffe..095fb1e25 100644 --- a/src/app/commands/debugger.cpp +++ b/src/app/commands/debugger.cpp @@ -775,7 +775,7 @@ private: bool m_fileOk = true; }; -DebuggerCommand::DebuggerCommand() : Command(CommandId::Debugger(), CmdRecordableFlag) +DebuggerCommand::DebuggerCommand() : Command(CommandId::Debugger()) { } diff --git a/src/app/commands/filters/cmd_brightness_contrast.cpp b/src/app/commands/filters/cmd_brightness_contrast.cpp index db7928bfc..a7e05babe 100644 --- a/src/app/commands/filters/cmd_brightness_contrast.cpp +++ b/src/app/commands/filters/cmd_brightness_contrast.cpp @@ -85,8 +85,7 @@ protected: }; BrightnessContrastCommand::BrightnessContrastCommand() - : CommandWithNewParams(CommandId::BrightnessContrast(), - CmdRecordableFlag) + : CommandWithNewParams(CommandId::BrightnessContrast()) { } diff --git a/src/app/commands/filters/cmd_color_curve.cpp b/src/app/commands/filters/cmd_color_curve.cpp index e1e4deefb..af12a9058 100644 --- a/src/app/commands/filters/cmd_color_curve.cpp +++ b/src/app/commands/filters/cmd_color_curve.cpp @@ -82,7 +82,7 @@ protected: }; ColorCurveCommand::ColorCurveCommand() - : CommandWithNewParams(CommandId::ColorCurve(), CmdRecordableFlag) + : CommandWithNewParams(CommandId::ColorCurve()) { } diff --git a/src/app/commands/filters/cmd_convolution_matrix.cpp b/src/app/commands/filters/cmd_convolution_matrix.cpp index 18a79de78..6185fc5b4 100644 --- a/src/app/commands/filters/cmd_convolution_matrix.cpp +++ b/src/app/commands/filters/cmd_convolution_matrix.cpp @@ -162,7 +162,7 @@ protected: }; ConvolutionMatrixCommand::ConvolutionMatrixCommand() - : CommandWithNewParams(CommandId::ConvolutionMatrix(), CmdRecordableFlag) + : CommandWithNewParams(CommandId::ConvolutionMatrix()) { } diff --git a/src/app/commands/filters/cmd_despeckle.cpp b/src/app/commands/filters/cmd_despeckle.cpp index c202db84a..8618c9f2a 100644 --- a/src/app/commands/filters/cmd_despeckle.cpp +++ b/src/app/commands/filters/cmd_despeckle.cpp @@ -106,8 +106,7 @@ protected: void onExecute(Context* context) override; }; -DespeckleCommand::DespeckleCommand() - : CommandWithNewParams(CommandId::Despeckle(), CmdRecordableFlag) +DespeckleCommand::DespeckleCommand() : CommandWithNewParams(CommandId::Despeckle()) { } diff --git a/src/app/commands/filters/cmd_hue_saturation.cpp b/src/app/commands/filters/cmd_hue_saturation.cpp index 9073b4099..044063eae 100644 --- a/src/app/commands/filters/cmd_hue_saturation.cpp +++ b/src/app/commands/filters/cmd_hue_saturation.cpp @@ -139,7 +139,7 @@ protected: }; HueSaturationCommand::HueSaturationCommand() - : CommandWithNewParams(CommandId::HueSaturation(), CmdRecordableFlag) + : CommandWithNewParams(CommandId::HueSaturation()) { } diff --git a/src/app/commands/filters/cmd_invert_color.cpp b/src/app/commands/filters/cmd_invert_color.cpp index bcf9024ee..7e58ca148 100644 --- a/src/app/commands/filters/cmd_invert_color.cpp +++ b/src/app/commands/filters/cmd_invert_color.cpp @@ -59,7 +59,7 @@ protected: }; InvertColorCommand::InvertColorCommand() - : CommandWithNewParams(CommandId::InvertColor(), CmdRecordableFlag) + : CommandWithNewParams(CommandId::InvertColor()) { } diff --git a/src/app/commands/filters/cmd_outline.cpp b/src/app/commands/filters/cmd_outline.cpp index 0ef971300..925895d61 100644 --- a/src/app/commands/filters/cmd_outline.cpp +++ b/src/app/commands/filters/cmd_outline.cpp @@ -195,8 +195,7 @@ protected: void onExecute(Context* context) override; }; -OutlineCommand::OutlineCommand() - : CommandWithNewParams(CommandId::Outline(), CmdRecordableFlag) +OutlineCommand::OutlineCommand() : CommandWithNewParams(CommandId::Outline()) { } diff --git a/src/app/commands/filters/cmd_replace_color.cpp b/src/app/commands/filters/cmd_replace_color.cpp index 6eb4d04d8..86c0619fc 100644 --- a/src/app/commands/filters/cmd_replace_color.cpp +++ b/src/app/commands/filters/cmd_replace_color.cpp @@ -158,7 +158,7 @@ protected: }; ReplaceColorCommand::ReplaceColorCommand() - : CommandWithNewParams(CommandId::ReplaceColor(), CmdRecordableFlag) + : CommandWithNewParams(CommandId::ReplaceColor()) { } diff --git a/src/app/commands/move_colors_command.cpp b/src/app/commands/move_colors_command.cpp index aa22189ac..bad3398bf 100644 --- a/src/app/commands/move_colors_command.cpp +++ b/src/app/commands/move_colors_command.cpp @@ -33,8 +33,7 @@ class MoveColorsCommand : public CommandWithNewParams { public: MoveColorsCommand(bool copy) : CommandWithNewParams( - (copy ? CommandId::CopyColors() : CommandId::MoveColors()), - CmdRecordableFlag) + (copy ? CommandId::CopyColors() : CommandId::MoveColors())) , m_copy(copy) { } diff --git a/src/app/commands/move_tiles_command.cpp b/src/app/commands/move_tiles_command.cpp index 45aa2cabd..b9b456987 100644 --- a/src/app/commands/move_tiles_command.cpp +++ b/src/app/commands/move_tiles_command.cpp @@ -31,8 +31,7 @@ class MoveTilesCommand : public CommandWithNewParams { public: MoveTilesCommand(const bool copy) : CommandWithNewParams( - (copy ? CommandId::CopyTiles() : CommandId::MoveTiles()), - CmdRecordableFlag) + (copy ? CommandId::CopyTiles() : CommandId::MoveTiles())) , m_copy(copy) { } diff --git a/src/app/commands/quick_command.cpp b/src/app/commands/quick_command.cpp index b3015a24e..da499421f 100644 --- a/src/app/commands/quick_command.cpp +++ b/src/app/commands/quick_command.cpp @@ -13,7 +13,7 @@ namespace app { QuickCommand::QuickCommand(const char* id, std::function execute) - : Command(id, CmdUIOnlyFlag) + : Command(id) , m_execute(execute) { } diff --git a/src/app/commands/screenshot.cpp b/src/app/commands/screenshot.cpp index cca841583..a9e59b624 100644 --- a/src/app/commands/screenshot.cpp +++ b/src/app/commands/screenshot.cpp @@ -58,7 +58,7 @@ protected: }; ScreenshotCommand::ScreenshotCommand() - : CommandWithNewParams(CommandId::Screenshot(), CmdUIOnlyFlag) + : CommandWithNewParams(CommandId::Screenshot()) { } diff --git a/src/app/commands/set_playback_speed.cpp b/src/app/commands/set_playback_speed.cpp index 84e58ff5b..02114aa86 100644 --- a/src/app/commands/set_playback_speed.cpp +++ b/src/app/commands/set_playback_speed.cpp @@ -31,7 +31,7 @@ protected: }; SetPlaybackSpeedCommand::SetPlaybackSpeedCommand() - : CommandWithNewParams(CommandId::SetPlaybackSpeed(), CmdUIOnlyFlag) + : CommandWithNewParams(CommandId::SetPlaybackSpeed()) { } diff --git a/src/app/commands/show_menu.cpp b/src/app/commands/show_menu.cpp index 4e0c844a6..3a0749191 100644 --- a/src/app/commands/show_menu.cpp +++ b/src/app/commands/show_menu.cpp @@ -33,8 +33,7 @@ protected: void openSubmenuById(Menu* menu, const std::string& id); }; -ShowMenuCommand::ShowMenuCommand() - : CommandWithNewParams(CommandId::ShowMenu(), CmdUIOnlyFlag) +ShowMenuCommand::ShowMenuCommand() : CommandWithNewParams(CommandId::ShowMenu()) { } diff --git a/src/app/commands/tileset_mode.cpp b/src/app/commands/tileset_mode.cpp index 614019c30..d91572481 100644 --- a/src/app/commands/tileset_mode.cpp +++ b/src/app/commands/tileset_mode.cpp @@ -20,10 +20,7 @@ using namespace gfx; class TilesetModeCommand : public Command { public: - TilesetModeCommand() : Command(CommandId::TilesetMode(), CmdUIOnlyFlag) - { - m_mode = TilesetMode::Auto; - } + TilesetModeCommand() : Command(CommandId::TilesetMode()) { m_mode = TilesetMode::Auto; } protected: void onLoadParams(const Params& params) override diff --git a/src/app/commands/toggle_other_layers_opacity.cpp b/src/app/commands/toggle_other_layers_opacity.cpp index c92ac8fec..64991eacf 100644 --- a/src/app/commands/toggle_other_layers_opacity.cpp +++ b/src/app/commands/toggle_other_layers_opacity.cpp @@ -39,8 +39,7 @@ private: }; ToggleOtherLayersOpacityCommand::ToggleOtherLayersOpacityCommand() - : CommandWithNewParams(CommandId::ToggleOtherLayersOpacity(), - CmdUIOnlyFlag) + : CommandWithNewParams(CommandId::ToggleOtherLayersOpacity()) { } diff --git a/src/app/commands/toggle_play_option.cpp b/src/app/commands/toggle_play_option.cpp index 1f7d02adc..cd96d6d81 100644 --- a/src/app/commands/toggle_play_option.cpp +++ b/src/app/commands/toggle_play_option.cpp @@ -39,7 +39,7 @@ protected: TogglePlayOptionCommand::TogglePlayOptionCommand(const char* id, Option* general, Option* preview) - : Command(id, CmdUIOnlyFlag) + : Command(id) , m_general(general) , m_preview(preview) { diff --git a/src/app/inline_command_execution.h b/src/app/inline_command_execution.h index 6ebd51bb7..5a6e9dd74 100644 --- a/src/app/inline_command_execution.h +++ b/src/app/inline_command_execution.h @@ -19,7 +19,7 @@ namespace app { class InlineCommandExecution : public Command { public: - InlineCommandExecution(Context* ctx) : Command("", CmdUIOnlyFlag), m_context(ctx) + InlineCommandExecution(Context* ctx) : Command(""), m_context(ctx) { CommandExecutionEvent ev(this, m_noParams); m_context->BeforeCommandExecution(ev); diff --git a/src/app/script/plugin_class.cpp b/src/app/script/plugin_class.cpp index 2f62f9d45..1d7163f23 100644 --- a/src/app/script/plugin_class.cpp +++ b/src/app/script/plugin_class.cpp @@ -30,7 +30,7 @@ struct Plugin { class PluginCommand : public Command { public: PluginCommand(const std::string& id, const std::string& title, int onclickRef, int onenabledRef) - : Command(id.c_str(), CmdUIOnlyFlag) + : Command(id.c_str()) , m_title(title) , m_onclickRef(onclickRef) , m_onenabledRef(onenabledRef)