mirror of https://github.com/aseprite/aseprite.git
[WIP] Command refresh
This commit is contained in:
parent
6d89a6bc15
commit
424ce6899a
|
@ -17,6 +17,7 @@
|
||||||
#include "ver/info.h"
|
#include "ver/info.h"
|
||||||
|
|
||||||
#include "about.xml.h"
|
#include "about.xml.h"
|
||||||
|
#include "app/context.h"
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
|
@ -27,13 +28,19 @@ public:
|
||||||
AboutCommand();
|
AboutCommand();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
bool onEnabled(Context* context) override;
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
AboutCommand::AboutCommand() : Command(CommandId::About(), CmdUIOnlyFlag)
|
AboutCommand::AboutCommand() : Command(CommandId::About())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AboutCommand::onEnabled(Context* context)
|
||||||
|
{
|
||||||
|
return context->isUIAvailable();
|
||||||
|
}
|
||||||
|
|
||||||
void AboutCommand::onExecute(Context* context)
|
void AboutCommand::onExecute(Context* context)
|
||||||
{
|
{
|
||||||
gen::About window;
|
gen::About window;
|
||||||
|
|
|
@ -63,8 +63,7 @@ protected:
|
||||||
std::string onGetFriendlyName() const override;
|
std::string onGetFriendlyName() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
AddColorCommand::AddColorCommand()
|
AddColorCommand::AddColorCommand() : CommandWithNewParams<AddColorParams>(CommandId::AddColor())
|
||||||
: CommandWithNewParams<AddColorParams>(CommandId::AddColor(), CmdUIOnlyFlag)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "ui/ui.h"
|
#include "ui/ui.h"
|
||||||
|
|
||||||
#include "advanced_mode.xml.h"
|
#include "advanced_mode.xml.h"
|
||||||
|
#include "app/context.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
|
@ -29,13 +30,19 @@ public:
|
||||||
AdvancedModeCommand();
|
AdvancedModeCommand();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
bool onEnabled(Context* context) override;
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
AdvancedModeCommand::AdvancedModeCommand() : Command(CommandId::AdvancedMode(), CmdUIOnlyFlag)
|
AdvancedModeCommand::AdvancedModeCommand() : Command(CommandId::AdvancedMode())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AdvancedModeCommand::onEnabled(Context* context)
|
||||||
|
{
|
||||||
|
return context->isUIAvailable();
|
||||||
|
}
|
||||||
|
|
||||||
void AdvancedModeCommand::onExecute(Context* context)
|
void AdvancedModeCommand::onExecute(Context* context)
|
||||||
{
|
{
|
||||||
// Switch advanced mode.
|
// Switch advanced mode.
|
||||||
|
|
|
@ -28,8 +28,7 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
BackgroundFromLayerCommand::BackgroundFromLayerCommand()
|
BackgroundFromLayerCommand::BackgroundFromLayerCommand() : Command(CommandId::BackgroundFromLayer())
|
||||||
: Command(CommandId::BackgroundFromLayer(), CmdRecordableFlag)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ private:
|
||||||
Type m_type;
|
Type m_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
CancelCommand::CancelCommand() : Command(CommandId::Cancel(), CmdUIOnlyFlag), m_type(NoOp)
|
CancelCommand::CancelCommand() : Command(CommandId::Cancel()), m_type(NoOp)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -282,8 +282,7 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
CanvasSizeCommand::CanvasSizeCommand()
|
CanvasSizeCommand::CanvasSizeCommand() : CommandWithNewParams(CommandId::CanvasSize())
|
||||||
: CommandWithNewParams(CommandId::CanvasSize(), CmdRecordableFlag)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,6 @@
|
||||||
#include "app/tx.h"
|
#include "app/tx.h"
|
||||||
#include "app/ui/timeline/timeline.h"
|
#include "app/ui/timeline/timeline.h"
|
||||||
#include "doc/cel.h"
|
#include "doc/cel.h"
|
||||||
#include "doc/cels_range.h"
|
|
||||||
#include "doc/sprite.h"
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@ -42,7 +40,7 @@ private:
|
||||||
int m_opacity;
|
int m_opacity;
|
||||||
};
|
};
|
||||||
|
|
||||||
CelOpacityCommand::CelOpacityCommand() : Command(CommandId::CelOpacity(), CmdUIOnlyFlag)
|
CelOpacityCommand::CelOpacityCommand() : Command(CommandId::CelOpacity())
|
||||||
{
|
{
|
||||||
m_opacity = 255;
|
m_opacity = 255;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include "app/ui/timeline/timeline.h"
|
#include "app/ui/timeline/timeline.h"
|
||||||
#include "app/ui/user_data_view.h"
|
#include "app/ui/user_data_view.h"
|
||||||
#include "app/ui_context.h"
|
#include "app/ui_context.h"
|
||||||
#include "base/mem_utils.h"
|
|
||||||
#include "base/scoped_value.h"
|
#include "base/scoped_value.h"
|
||||||
#include "doc/cel.h"
|
#include "doc/cel.h"
|
||||||
#include "doc/cels_range.h"
|
#include "doc/cels_range.h"
|
||||||
|
@ -385,14 +384,14 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
CelPropertiesCommand::CelPropertiesCommand() : Command(CommandId::CelProperties(), CmdUIOnlyFlag)
|
CelPropertiesCommand::CelPropertiesCommand() : Command(CommandId::CelProperties())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CelPropertiesCommand::onEnabled(Context* context)
|
bool CelPropertiesCommand::onEnabled(Context* context)
|
||||||
{
|
{
|
||||||
return context->checkFlags(ContextFlags::ActiveDocumentIsWritable |
|
return context->isUIAvailable() && context->checkFlags(ContextFlags::ActiveDocumentIsWritable |
|
||||||
ContextFlags::ActiveLayerIsImage);
|
ContextFlags::ActiveLayerIsImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CelPropertiesCommand::onExecute(Context* context)
|
void CelPropertiesCommand::onExecute(Context* context)
|
||||||
|
|
|
@ -64,7 +64,7 @@ private:
|
||||||
int m_slot;
|
int m_slot;
|
||||||
};
|
};
|
||||||
|
|
||||||
ChangeBrushCommand::ChangeBrushCommand() : Command(CommandId::ChangeBrush(), CmdUIOnlyFlag)
|
ChangeBrushCommand::ChangeBrushCommand() : Command(CommandId::ChangeBrush())
|
||||||
{
|
{
|
||||||
m_change = None;
|
m_change = None;
|
||||||
m_slot = 0;
|
m_slot = 0;
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
#include "app/commands/command.h"
|
#include "app/commands/command.h"
|
||||||
#include "app/commands/params.h"
|
#include "app/commands/params.h"
|
||||||
|
#include "app/context.h"
|
||||||
#include "app/i18n/strings.h"
|
#include "app/i18n/strings.h"
|
||||||
#include "app/modules/palettes.h"
|
#include "app/modules/palettes.h"
|
||||||
#include "app/ui/color_bar.h"
|
#include "app/ui/color_bar.h"
|
||||||
|
@ -39,18 +40,24 @@ public:
|
||||||
ChangeColorCommand();
|
ChangeColorCommand();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
bool onEnabled(Context* context) override;
|
||||||
bool onNeedsParams() const override { return true; }
|
bool onNeedsParams() const override { return true; }
|
||||||
void onLoadParams(const Params& params) override;
|
void onLoadParams(const Params& params) override;
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
std::string onGetFriendlyName() const override;
|
std::string onGetFriendlyName() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
ChangeColorCommand::ChangeColorCommand() : Command(CommandId::ChangeColor(), CmdUIOnlyFlag)
|
ChangeColorCommand::ChangeColorCommand() : Command(CommandId::ChangeColor())
|
||||||
{
|
{
|
||||||
m_background = false;
|
m_background = false;
|
||||||
m_change = None;
|
m_change = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ChangeColorCommand::onEnabled(Context* context)
|
||||||
|
{
|
||||||
|
return context->isUIAvailable();
|
||||||
|
}
|
||||||
|
|
||||||
void ChangeColorCommand::onLoadParams(const Params& params)
|
void ChangeColorCommand::onLoadParams(const Params& params)
|
||||||
{
|
{
|
||||||
std::string target = params.get("target");
|
std::string target = params.get("target");
|
||||||
|
|
|
@ -507,7 +507,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
ChangePixelFormatCommand::ChangePixelFormatCommand()
|
ChangePixelFormatCommand::ChangePixelFormatCommand()
|
||||||
: CommandWithNewParams(CommandId::ChangePixelFormat(), CmdUIOnlyFlag)
|
: CommandWithNewParams(CommandId::ChangePixelFormat())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ protected:
|
||||||
void onExecute(Context* ctx) override;
|
void onExecute(Context* ctx) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
ClearCommand::ClearCommand() : Command(CommandId::Clear(), CmdUIOnlyFlag)
|
ClearCommand::ClearCommand() : Command(CommandId::Clear())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
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();
|
tx.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nonEditableLayers)
|
if (context->isUIAvailable() && nonEditableLayers)
|
||||||
StatusBar::instance()->showTip(1000, Strings::statusbar_tips_locked_layers());
|
StatusBar::instance()->showTip(1000, Strings::statusbar_tips_locked_layers());
|
||||||
|
|
||||||
update_screen_for_document(document);
|
update_screen_for_document(document);
|
||||||
|
|
|
@ -23,8 +23,7 @@ protected:
|
||||||
void onExecute(Context* ctx) override;
|
void onExecute(Context* ctx) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
ClearRecentFilesCommand::ClearRecentFilesCommand()
|
ClearRecentFilesCommand::ClearRecentFilesCommand() : Command(CommandId::ClearRecentFiles())
|
||||||
: Command(CommandId::ClearRecentFiles(), CmdUIOnlyFlag)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ using namespace ui;
|
||||||
|
|
||||||
class CloseFileCommand : public Command {
|
class CloseFileCommand : public Command {
|
||||||
public:
|
public:
|
||||||
CloseFileCommand() : Command(CommandId::CloseFile(), CmdUIOnlyFlag) {}
|
CloseFileCommand() : Command(CommandId::CloseFile()) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool onEnabled(Context* context) override
|
bool onEnabled(Context* context) override
|
||||||
|
@ -51,12 +51,15 @@ protected:
|
||||||
|
|
||||||
class CloseAllFilesCommand : public Command {
|
class CloseAllFilesCommand : public Command {
|
||||||
public:
|
public:
|
||||||
CloseAllFilesCommand() : Command(CommandId::CloseAllFiles(), CmdRecordableFlag)
|
CloseAllFilesCommand() : Command(CommandId::CloseAllFiles()) { m_quitting = false; }
|
||||||
{
|
|
||||||
m_quitting = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
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<bool>("quitting"); }
|
void onLoadParams(const Params& params) override { m_quitting = params.get_as<bool>("quitting"); }
|
||||||
|
|
||||||
void onExecute(Context* context) override
|
void onExecute(Context* context) override
|
||||||
|
|
|
@ -71,7 +71,7 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
ColorQuantizationCommand::ColorQuantizationCommand()
|
ColorQuantizationCommand::ColorQuantizationCommand()
|
||||||
: CommandWithNewParams<ColorQuantizationParams>(CommandId::ColorQuantization(), CmdRecordableFlag)
|
: CommandWithNewParams<ColorQuantizationParams>(CommandId::ColorQuantization())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
ContiguousFillCommand::ContiguousFillCommand() : Command(CommandId::ContiguousFill(), CmdUIOnlyFlag)
|
ContiguousFillCommand::ContiguousFillCommand() : Command(CommandId::ContiguousFill())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ protected:
|
||||||
void onExecute(Context* ctx) override;
|
void onExecute(Context* ctx) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
CopyCommand::CopyCommand() : Command(CommandId::Copy(), CmdUIOnlyFlag)
|
CopyCommand::CopyCommand() : Command(CommandId::Copy())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,13 +25,13 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
CopyCelCommand::CopyCelCommand() : Command(CommandId::CopyCel(), CmdUIOnlyFlag)
|
CopyCelCommand::CopyCelCommand() : Command(CommandId::CopyCel())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CopyCelCommand::onEnabled(Context* context)
|
bool CopyCelCommand::onEnabled(Context* context)
|
||||||
{
|
{
|
||||||
return App::instance()->timeline()->isMovingCel();
|
return App::instance()->timeline() && App::instance()->timeline()->isMovingCel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CopyCelCommand::onExecute(Context* context)
|
void CopyCelCommand::onExecute(Context* context)
|
||||||
|
|
|
@ -24,7 +24,7 @@ protected:
|
||||||
void onExecute(Context* ctx) override;
|
void onExecute(Context* ctx) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
CopyMergedCommand::CopyMergedCommand() : Command(CommandId::CopyMerged(), CmdUIOnlyFlag)
|
CopyMergedCommand::CopyMergedCommand() : Command(CommandId::CopyMerged())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ private:
|
||||||
gfx::Rect m_bounds;
|
gfx::Rect m_bounds;
|
||||||
};
|
};
|
||||||
|
|
||||||
CropSpriteCommand::CropSpriteCommand() : Command(CommandId::CropSprite(), CmdRecordableFlag)
|
CropSpriteCommand::CropSpriteCommand() : Command(CommandId::CropSprite())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,8 +95,7 @@ private:
|
||||||
bool m_byGrid = false;
|
bool m_byGrid = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
AutocropSpriteCommand::AutocropSpriteCommand()
|
AutocropSpriteCommand::AutocropSpriteCommand() : Command(CommandId::AutocropSprite())
|
||||||
: Command(CommandId::AutocropSprite(), CmdRecordableFlag)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ protected:
|
||||||
void onExecute(Context* ctx) override;
|
void onExecute(Context* ctx) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
CutCommand::CutCommand() : Command(CommandId::Cut(), CmdUIOnlyFlag)
|
CutCommand::CutCommand() : Command(CommandId::Cut())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
DeselectMaskCommand::DeselectMaskCommand() : Command(CommandId::DeselectMask(), CmdRecordableFlag)
|
DeselectMaskCommand::DeselectMaskCommand() : Command(CommandId::DeselectMask())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,7 @@ protected:
|
||||||
void onExecute(Context* context);
|
void onExecute(Context* context);
|
||||||
};
|
};
|
||||||
|
|
||||||
DeveloperConsoleCommand::DeveloperConsoleCommand()
|
DeveloperConsoleCommand::DeveloperConsoleCommand() : Command(CommandId::DeveloperConsole())
|
||||||
: Command(CommandId::DeveloperConsole(), CmdUIOnlyFlag)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,12 +28,15 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
DiscardBrushCommand::DiscardBrushCommand() : Command(CommandId::DiscardBrush(), CmdUIOnlyFlag)
|
DiscardBrushCommand::DiscardBrushCommand() : Command(CommandId::DiscardBrush())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DiscardBrushCommand::onEnabled(Context* context)
|
bool DiscardBrushCommand::onEnabled(Context* context)
|
||||||
{
|
{
|
||||||
|
if (!context->isUIAvailable())
|
||||||
|
return false;
|
||||||
|
|
||||||
ContextBar* ctxBar = App::instance()->contextBar();
|
ContextBar* ctxBar = App::instance()->contextBar();
|
||||||
return (ctxBar->activeBrush()->type() == kImageBrushType);
|
return (ctxBar->activeBrush()->type() == kImageBrushType);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,8 +32,7 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
DuplicateLayerCommand::DuplicateLayerCommand()
|
DuplicateLayerCommand::DuplicateLayerCommand() : Command(CommandId::DuplicateLayer())
|
||||||
: Command(CommandId::DuplicateLayer(), CmdRecordableFlag)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
DuplicateSpriteCommand::DuplicateSpriteCommand()
|
DuplicateSpriteCommand::DuplicateSpriteCommand()
|
||||||
: CommandWithNewParams<DuplicateSpriteParams>(CommandId::DuplicateSprite(), CmdRecordableFlag)
|
: CommandWithNewParams<DuplicateSpriteParams>(CommandId::DuplicateSprite())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
DuplicateViewCommand::DuplicateViewCommand() : Command(CommandId::DuplicateView(), CmdUIOnlyFlag)
|
DuplicateViewCommand::DuplicateViewCommand() : Command(CommandId::DuplicateView())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
EnterLicenseCommand::EnterLicenseCommand() : Command(CommandId::EnterLicense(), CmdUIOnlyFlag)
|
EnterLicenseCommand::EnterLicenseCommand() : Command(CommandId::EnterLicense())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
ExitCommand::ExitCommand() : Command(CommandId::Exit(), CmdUIOnlyFlag)
|
ExitCommand::ExitCommand() : Command(CommandId::Exit())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1187,8 +1187,7 @@ private:
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
ExportSpriteSheetCommand::ExportSpriteSheetCommand(const char* id)
|
ExportSpriteSheetCommand::ExportSpriteSheetCommand(const char* id) : CommandWithNewParams(id)
|
||||||
: CommandWithNewParams(id, CmdRecordableFlag)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace app {
|
||||||
|
|
||||||
using namespace ui;
|
using namespace ui;
|
||||||
|
|
||||||
EyedropperCommand::EyedropperCommand() : Command(CommandId::Eyedropper(), CmdUIOnlyFlag)
|
EyedropperCommand::EyedropperCommand() : Command(CommandId::Eyedropper())
|
||||||
{
|
{
|
||||||
m_background = false;
|
m_background = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
FillCommand::FillCommand(Type type)
|
FillCommand::FillCommand(Type type)
|
||||||
: Command(type == Stroke ? CommandId::Stroke() : CommandId::Fill(), CmdUIOnlyFlag)
|
: Command(type == Stroke ? CommandId::Stroke() : CommandId::Fill())
|
||||||
, m_type(type)
|
, m_type(type)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
FitScreenCommand::FitScreenCommand() : Command(CommandId::FitScreen(), CmdUIOnlyFlag)
|
FitScreenCommand::FitScreenCommand() : Command(CommandId::FitScreen())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ protected:
|
||||||
bool m_visibleOnly;
|
bool m_visibleOnly;
|
||||||
};
|
};
|
||||||
|
|
||||||
FlattenLayersCommand::FlattenLayersCommand() : Command(CommandId::FlattenLayers(), CmdUIOnlyFlag)
|
FlattenLayersCommand::FlattenLayersCommand() : Command(CommandId::FlattenLayers())
|
||||||
{
|
{
|
||||||
m_visibleOnly = false;
|
m_visibleOnly = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
FlipCommand::FlipCommand() : Command(CommandId::Flip(), CmdRecordableFlag)
|
FlipCommand::FlipCommand() : Command(CommandId::Flip())
|
||||||
{
|
{
|
||||||
m_flipMask = false;
|
m_flipMask = false;
|
||||||
m_flipType = doc::algorithm::FlipHorizontal;
|
m_flipType = doc::algorithm::FlipHorizontal;
|
||||||
|
|
|
@ -44,12 +44,11 @@ private:
|
||||||
|
|
||||||
// Frame to be shown. It can be ALL_FRAMES, CURRENT_RANGE, or a
|
// Frame to be shown. It can be ALL_FRAMES, CURRENT_RANGE, or a
|
||||||
// number indicating a specific frame (1 is the first frame).
|
// number indicating a specific frame (1 is the first frame).
|
||||||
Target m_target;
|
Target m_target = CURRENT_RANGE;
|
||||||
frame_t m_frame;
|
frame_t m_frame = 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
FramePropertiesCommand::FramePropertiesCommand()
|
FramePropertiesCommand::FramePropertiesCommand() : Command(CommandId::FrameProperties())
|
||||||
: Command(CommandId::FrameProperties(), CmdUIOnlyFlag)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,15 +61,20 @@ void FramePropertiesCommand::onLoadParams(const Params& params)
|
||||||
else if (frame == "current") {
|
else if (frame == "current") {
|
||||||
m_target = CURRENT_RANGE;
|
m_target = CURRENT_RANGE;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
m_target = SPECIFIC_FRAME;
|
const auto frameNumber = base::convert_to<frame_t>(frame);
|
||||||
m_frame = frame_t(base::convert_to<int>(frame));
|
if (frameNumber < 1) {
|
||||||
|
// Will open with the default target (CURRENT_RANGE) if the frame number cannot be parsed.
|
||||||
|
m_frame = CURRENT_RANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_target = SPECIFIC_FRAME;
|
||||||
|
m_frame = frameNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FramePropertiesCommand::onEnabled(Context* context)
|
bool FramePropertiesCommand::onEnabled(Context* context)
|
||||||
{
|
{
|
||||||
return context->checkFlags(ContextFlags::ActiveDocumentIsWritable);
|
return context->isUIAvailable() && context->checkFlags(ContextFlags::ActiveDocumentIsWritable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramePropertiesCommand::onExecute(Context* context)
|
void FramePropertiesCommand::onExecute(Context* context)
|
||||||
|
|
|
@ -48,7 +48,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
FrameTagPropertiesCommand::FrameTagPropertiesCommand()
|
FrameTagPropertiesCommand::FrameTagPropertiesCommand()
|
||||||
: Command(CommandId::FrameTagProperties(), CmdUIOnlyFlag)
|
: Command(CommandId::FrameTagProperties())
|
||||||
, m_tagId(NullId)
|
, m_tagId(NullId)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ void FrameTagPropertiesCommand::onLoadParams(const Params& params)
|
||||||
|
|
||||||
bool FrameTagPropertiesCommand::onEnabled(Context* context)
|
bool FrameTagPropertiesCommand::onEnabled(Context* context)
|
||||||
{
|
{
|
||||||
return context->checkFlags(ContextFlags::ActiveDocumentIsWritable);
|
return context->isUIAvailable() && context->checkFlags(ContextFlags::ActiveDocumentIsWritable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FrameTagPropertiesCommand::onExecute(Context* context)
|
void FrameTagPropertiesCommand::onExecute(Context* context)
|
||||||
|
|
|
@ -27,7 +27,7 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
FullscreenModeCommand::FullscreenModeCommand() : Command(CommandId::FullscreenMode(), CmdUIOnlyFlag)
|
FullscreenModeCommand::FullscreenModeCommand() : Command(CommandId::FullscreenMode())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -308,8 +308,7 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
FullscreenPreviewCommand::FullscreenPreviewCommand()
|
FullscreenPreviewCommand::FullscreenPreviewCommand() : Command(CommandId::FullscreenPreview())
|
||||||
: Command(CommandId::FullscreenPreview(), CmdUIOnlyFlag)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ using namespace doc;
|
||||||
|
|
||||||
class GotoCommand : public Command {
|
class GotoCommand : public Command {
|
||||||
protected:
|
protected:
|
||||||
GotoCommand(const char* id) : Command(id, CmdRecordableFlag) {}
|
GotoCommand(const char* id) : Command(id) {}
|
||||||
|
|
||||||
bool onEnabled(Context* context) override { return (Editor::activeEditor() != nullptr); }
|
bool onEnabled(Context* context) override { return (Editor::activeEditor() != nullptr); }
|
||||||
|
|
||||||
|
|
|
@ -24,11 +24,7 @@ namespace app {
|
||||||
|
|
||||||
class GotoLayerCommand : public Command {
|
class GotoLayerCommand : public Command {
|
||||||
public:
|
public:
|
||||||
GotoLayerCommand(int offset, const char* id, CommandFlags flags)
|
GotoLayerCommand(int offset, const char* id) : Command(id), m_offset(offset) {}
|
||||||
: Command(id, flags)
|
|
||||||
, m_offset(offset)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool onEnabled(Context* context) override
|
bool onEnabled(Context* context) override
|
||||||
|
@ -88,12 +84,12 @@ private:
|
||||||
|
|
||||||
class GotoPreviousLayerCommand : public GotoLayerCommand {
|
class GotoPreviousLayerCommand : public GotoLayerCommand {
|
||||||
public:
|
public:
|
||||||
GotoPreviousLayerCommand() : GotoLayerCommand(-1, "GotoPreviousLayer", CmdUIOnlyFlag) {}
|
GotoPreviousLayerCommand() : GotoLayerCommand(-1, "GotoPreviousLayer") {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class GotoNextLayerCommand : public GotoLayerCommand {
|
class GotoNextLayerCommand : public GotoLayerCommand {
|
||||||
public:
|
public:
|
||||||
GotoNextLayerCommand() : GotoLayerCommand(+1, "GotoNextLayer", CmdUIOnlyFlag) {}
|
GotoNextLayerCommand() : GotoLayerCommand(+1, "GotoNextLayer") {}
|
||||||
};
|
};
|
||||||
|
|
||||||
Command* CommandFactory::createGotoPreviousLayerCommand()
|
Command* CommandFactory::createGotoPreviousLayerCommand()
|
||||||
|
|
|
@ -24,7 +24,7 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
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;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
GotoPreviousTabCommand::GotoPreviousTabCommand()
|
GotoPreviousTabCommand::GotoPreviousTabCommand() : Command(CommandId::GotoPreviousTab())
|
||||||
: Command(CommandId::GotoPreviousTab(), CmdRecordableFlag)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ using namespace gfx;
|
||||||
|
|
||||||
class SnapToGridCommand : public Command {
|
class SnapToGridCommand : public Command {
|
||||||
public:
|
public:
|
||||||
SnapToGridCommand() : Command(CommandId::SnapToGrid(), CmdUIOnlyFlag) {}
|
SnapToGridCommand() : Command(CommandId::SnapToGrid()) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool onChecked(Context* ctx) override
|
bool onChecked(Context* ctx) override
|
||||||
|
@ -51,13 +51,14 @@ protected:
|
||||||
bool newValue = !docPref.grid.snap();
|
bool newValue = !docPref.grid.snap();
|
||||||
docPref.grid.snap(newValue);
|
docPref.grid.snap(newValue);
|
||||||
|
|
||||||
StatusBar::instance()->showSnapToGridWarning(newValue);
|
if (ctx->isUIAvailable())
|
||||||
|
StatusBar::instance()->showSnapToGridWarning(newValue);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class SelectionAsGridCommand : public Command {
|
class SelectionAsGridCommand : public Command {
|
||||||
public:
|
public:
|
||||||
SelectionAsGridCommand() : Command(CommandId::SelectionAsGrid(), CmdUIOnlyFlag) {}
|
SelectionAsGridCommand() : Command(CommandId::SelectionAsGrid()) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool onEnabled(Context* ctx) override
|
bool onEnabled(Context* ctx) override
|
||||||
|
@ -92,13 +93,13 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
GridSettingsCommand::GridSettingsCommand() : Command(CommandId::GridSettings(), CmdUIOnlyFlag)
|
GridSettingsCommand::GridSettingsCommand() : Command(CommandId::GridSettings())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GridSettingsCommand::onEnabled(Context* context)
|
bool GridSettingsCommand::onEnabled(Context* context)
|
||||||
{
|
{
|
||||||
return true;
|
return context->isUIAvailable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GridSettingsCommand::onExecute(Context* context)
|
void GridSettingsCommand::onExecute(Context* context)
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
#include "app/commands/command.h"
|
#include "app/commands/command.h"
|
||||||
|
#include "app/context.h"
|
||||||
#include "app/ui/main_window.h"
|
#include "app/ui/main_window.h"
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
|
@ -26,7 +27,7 @@ protected:
|
||||||
bool onEnabled(Context* context) override;
|
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)
|
bool HomeCommand::onEnabled(Context* context)
|
||||||
{
|
{
|
||||||
return !App::instance()->mainWindow()->isHomeSelected();
|
return context->isUIAvailable() && !App::instance()->mainWindow()->isHomeSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
Command* CommandFactory::createHomeCommand()
|
Command* CommandFactory::createHomeCommand()
|
||||||
|
|
|
@ -518,7 +518,7 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
ImportSpriteSheetCommand::ImportSpriteSheetCommand()
|
ImportSpriteSheetCommand::ImportSpriteSheetCommand()
|
||||||
: CommandWithNewParams(CommandId::ImportSpriteSheet(), CmdRecordableFlag)
|
: CommandWithNewParams(CommandId::ImportSpriteSheet())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
InvertMaskCommand::InvertMaskCommand() : Command(CommandId::InvertMask(), CmdRecordableFlag)
|
InvertMaskCommand::InvertMaskCommand() : Command(CommandId::InvertMask())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -977,6 +977,7 @@ public:
|
||||||
KeyboardShortcutsCommand();
|
KeyboardShortcutsCommand();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
bool onEnabled(Context* context) override;
|
||||||
void onLoadParams(const Params& params) override;
|
void onLoadParams(const Params& params) override;
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
|
|
||||||
|
@ -986,11 +987,15 @@ private:
|
||||||
std::string m_search;
|
std::string m_search;
|
||||||
};
|
};
|
||||||
|
|
||||||
KeyboardShortcutsCommand::KeyboardShortcutsCommand()
|
KeyboardShortcutsCommand::KeyboardShortcutsCommand() : Command(CommandId::KeyboardShortcuts())
|
||||||
: Command(CommandId::KeyboardShortcuts(), CmdUIOnlyFlag)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool KeyboardShortcutsCommand::onEnabled(Context* context)
|
||||||
|
{
|
||||||
|
return context->isUIAvailable();
|
||||||
|
}
|
||||||
|
|
||||||
void KeyboardShortcutsCommand::onLoadParams(const Params& params)
|
void KeyboardShortcutsCommand::onLoadParams(const Params& params)
|
||||||
{
|
{
|
||||||
m_search = params.get("search");
|
m_search = params.get("search");
|
||||||
|
|
|
@ -34,10 +34,7 @@ private:
|
||||||
std::string m_path;
|
std::string m_path;
|
||||||
};
|
};
|
||||||
|
|
||||||
LaunchCommand::LaunchCommand()
|
LaunchCommand::LaunchCommand() : Command(CommandId::Launch()), m_type(Url), m_path("")
|
||||||
: Command(CommandId::Launch(), CmdUIOnlyFlag)
|
|
||||||
, m_type(Url)
|
|
||||||
, m_path("")
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +42,7 @@ void LaunchCommand::onLoadParams(const Params& params)
|
||||||
{
|
{
|
||||||
m_path = params.get("path");
|
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);
|
m_path = std::string(get_app_url()) + m_path.substr(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,7 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
LayerFromBackgroundCommand::LayerFromBackgroundCommand()
|
LayerFromBackgroundCommand::LayerFromBackgroundCommand() : Command(CommandId::LayerFromBackground())
|
||||||
: Command(CommandId::LayerFromBackground(), CmdRecordableFlag)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
LayerLockCommand::LayerLockCommand() : Command(CommandId::LayerLock(), CmdRecordableFlag)
|
LayerLockCommand::LayerLockCommand() : Command(CommandId::LayerLock())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ private:
|
||||||
int m_opacity;
|
int m_opacity;
|
||||||
};
|
};
|
||||||
|
|
||||||
LayerOpacityCommand::LayerOpacityCommand() : Command(CommandId::LayerOpacity(), CmdUIOnlyFlag)
|
LayerOpacityCommand::LayerOpacityCommand() : Command(CommandId::LayerOpacity())
|
||||||
{
|
{
|
||||||
m_opacity = 255;
|
m_opacity = 255;
|
||||||
}
|
}
|
||||||
|
|
|
@ -500,14 +500,14 @@ private:
|
||||||
bool m_remapAfterConfigure = false;
|
bool m_remapAfterConfigure = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
LayerPropertiesCommand::LayerPropertiesCommand()
|
LayerPropertiesCommand::LayerPropertiesCommand() : Command(CommandId::LayerProperties())
|
||||||
: Command(CommandId::LayerProperties(), CmdRecordableFlag)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LayerPropertiesCommand::onEnabled(Context* context)
|
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)
|
void LayerPropertiesCommand::onExecute(Context* context)
|
||||||
|
|
|
@ -29,8 +29,7 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
LayerVisibilityCommand::LayerVisibilityCommand()
|
LayerVisibilityCommand::LayerVisibilityCommand() : Command(CommandId::LayerVisibility())
|
||||||
: Command(CommandId::LayerVisibility(), CmdRecordableFlag)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
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();
|
tx.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nonEditableLayers)
|
if (context->isUIAvailable() && nonEditableLayers)
|
||||||
StatusBar::instance()->showTip(1000, Strings::statusbar_tips_locked_layers());
|
StatusBar::instance()->showTip(1000, Strings::statusbar_tips_locked_layers());
|
||||||
|
|
||||||
update_screen_for_document(document);
|
update_screen_for_document(document);
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace app {
|
||||||
|
|
||||||
class LoadMaskCommand : public Command {
|
class LoadMaskCommand : public Command {
|
||||||
std::string m_filename;
|
std::string m_filename;
|
||||||
|
bool m_ui = true;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LoadMaskCommand();
|
LoadMaskCommand();
|
||||||
|
@ -36,13 +37,16 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
LoadMaskCommand::LoadMaskCommand() : Command(CommandId::LoadMask(), CmdRecordableFlag)
|
LoadMaskCommand::LoadMaskCommand() : Command(CommandId::LoadMask())
|
||||||
{
|
{
|
||||||
m_filename = "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadMaskCommand::onLoadParams(const Params& params)
|
void LoadMaskCommand::onLoadParams(const Params& params)
|
||||||
{
|
{
|
||||||
|
if (params.has_param("ui"))
|
||||||
|
m_ui = params.get_as<bool>("ui");
|
||||||
|
else
|
||||||
|
m_ui = true;
|
||||||
m_filename = params.get("filename");
|
m_filename = params.get("filename");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +59,7 @@ void LoadMaskCommand::onExecute(Context* context)
|
||||||
{
|
{
|
||||||
const ContextReader reader(context);
|
const ContextReader reader(context);
|
||||||
|
|
||||||
if (context->isUIAvailable()) {
|
if (context->isUIAvailable() && m_ui) {
|
||||||
base::paths exts = { "msk" };
|
base::paths exts = { "msk" };
|
||||||
base::paths selectedFilename;
|
base::paths selectedFilename;
|
||||||
if (!app::show_file_selector(Strings::load_selection_title(),
|
if (!app::show_file_selector(Strings::load_selection_title(),
|
||||||
|
@ -70,7 +74,8 @@ void LoadMaskCommand::onExecute(Context* context)
|
||||||
|
|
||||||
std::unique_ptr<Mask> mask(load_msk_file(m_filename.c_str()));
|
std::unique_ptr<Mask> mask(load_msk_file(m_filename.c_str()));
|
||||||
if (!mask) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,14 +37,19 @@ protected:
|
||||||
private:
|
private:
|
||||||
std::string m_preset;
|
std::string m_preset;
|
||||||
std::string m_filename;
|
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)
|
void LoadPaletteCommand::onLoadParams(const Params& params)
|
||||||
{
|
{
|
||||||
|
if (params.has_param("ui"))
|
||||||
|
m_ui = params.get_as<bool>("ui");
|
||||||
|
else
|
||||||
|
m_ui = true;
|
||||||
m_preset = params.get("preset");
|
m_preset = params.get("preset");
|
||||||
m_filename = params.get("filename");
|
m_filename = params.get("filename");
|
||||||
}
|
}
|
||||||
|
@ -58,20 +63,20 @@ void LoadPaletteCommand::onExecute(Context* context)
|
||||||
if (!base::is_file(filename))
|
if (!base::is_file(filename))
|
||||||
filename = get_preset_palette_filename(m_preset, ".gpl");
|
filename = get_preset_palette_filename(m_preset, ".gpl");
|
||||||
}
|
}
|
||||||
else if (!m_filename.empty()) {
|
else if (context->isUIAvailable() && m_ui) {
|
||||||
filename = m_filename;
|
const base::paths exts = get_readable_palette_extensions();
|
||||||
}
|
|
||||||
else if (context->isUIAvailable()) {
|
|
||||||
base::paths exts = get_readable_palette_extensions();
|
|
||||||
base::paths filenames;
|
base::paths filenames;
|
||||||
if (app::show_file_selector(Strings::load_palette_title(),
|
if (app::show_file_selector(Strings::load_palette_title(),
|
||||||
"",
|
m_filename,
|
||||||
exts,
|
exts,
|
||||||
FileSelectorType::Open,
|
FileSelectorType::Open,
|
||||||
filenames)) {
|
filenames)) {
|
||||||
filename = filenames.front();
|
filename = filenames.front();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (!m_filename.empty()) {
|
||||||
|
filename = m_filename;
|
||||||
|
}
|
||||||
|
|
||||||
// Do nothing
|
// Do nothing
|
||||||
if (filename.empty())
|
if (filename.empty())
|
||||||
|
|
|
@ -29,7 +29,7 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
MaskAllCommand::MaskAllCommand() : Command(CommandId::MaskAll(), CmdRecordableFlag)
|
MaskAllCommand::MaskAllCommand() : Command(CommandId::MaskAll())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -203,8 +203,7 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
MaskByColorCommand::MaskByColorCommand()
|
MaskByColorCommand::MaskByColorCommand() : CommandWithNewParams(CommandId::MaskByColor())
|
||||||
: CommandWithNewParams(CommandId::MaskByColor(), CmdUIOnlyFlag)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
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
|
// Select marquee tool
|
||||||
if (tools::Tool* tool = App::instance()->toolBox()->getToolById(
|
if (context->isUIAvailable()) {
|
||||||
tools::WellKnownTools::RectangularMarquee)) {
|
if (tools::Tool* tool = App::instance()->toolBox()->getToolById(
|
||||||
ToolBar::instance()->selectTool(tool);
|
tools::WellKnownTools::RectangularMarquee)) {
|
||||||
|
ToolBar::instance()->selectTool(tool);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
update_screen_for_document(document);
|
update_screen_for_document(document);
|
||||||
|
|
|
@ -35,8 +35,7 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
MergeDownLayerCommand::MergeDownLayerCommand()
|
MergeDownLayerCommand::MergeDownLayerCommand() : Command(CommandId::MergeDownLayer())
|
||||||
: Command(CommandId::MergeDownLayer(), CmdRecordableFlag)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,13 +52,15 @@ private:
|
||||||
Modifier m_modifier;
|
Modifier m_modifier;
|
||||||
int m_quantity;
|
int m_quantity;
|
||||||
doc::BrushType m_brushType;
|
doc::BrushType m_brushType;
|
||||||
|
bool m_ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
ModifySelectionCommand::ModifySelectionCommand()
|
ModifySelectionCommand::ModifySelectionCommand()
|
||||||
: Command(CommandId::ModifySelection(), CmdRecordableFlag)
|
: Command(CommandId::ModifySelection())
|
||||||
, m_modifier(Modifier::Expand)
|
, m_modifier(Modifier::Expand)
|
||||||
, m_quantity(0)
|
, m_quantity(0)
|
||||||
, m_brushType(doc::kCircleBrushType)
|
, m_brushType(doc::kCircleBrushType)
|
||||||
|
, m_ui(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,6 +82,11 @@ void ModifySelectionCommand::onLoadParams(const Params& params)
|
||||||
m_brushType = doc::kCircleBrushType;
|
m_brushType = doc::kCircleBrushType;
|
||||||
else if (brush == "square")
|
else if (brush == "square")
|
||||||
m_brushType = doc::kSquareBrushType;
|
m_brushType = doc::kSquareBrushType;
|
||||||
|
|
||||||
|
if (params.has_param("ui"))
|
||||||
|
m_ui = params.get_as<bool>("ui");
|
||||||
|
else
|
||||||
|
m_ui = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModifySelectionCommand::onEnabled(Context* context)
|
bool ModifySelectionCommand::onEnabled(Context* context)
|
||||||
|
@ -92,7 +99,7 @@ void ModifySelectionCommand::onExecute(Context* context)
|
||||||
int quantity = m_quantity;
|
int quantity = m_quantity;
|
||||||
doc::BrushType brush = m_brushType;
|
doc::BrushType brush = m_brushType;
|
||||||
|
|
||||||
if (quantity == 0) {
|
if (quantity == 0 && m_ui && context->isUIAvailable()) {
|
||||||
Preferences& pref = Preferences::instance();
|
Preferences& pref = Preferences::instance();
|
||||||
ModifySelectionWindow window;
|
ModifySelectionWindow window;
|
||||||
|
|
||||||
|
|
|
@ -25,13 +25,13 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
MoveCelCommand::MoveCelCommand() : Command(CommandId::MoveCel(), CmdUIOnlyFlag)
|
MoveCelCommand::MoveCelCommand() : Command(CommandId::MoveCel())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MoveCelCommand::onEnabled(Context* context)
|
bool MoveCelCommand::onEnabled(Context* context)
|
||||||
{
|
{
|
||||||
return App::instance()->timeline()->isMovingCel();
|
return context->isUIAvailable() && App::instance()->timeline()->isMovingCel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveCelCommand::onExecute(Context* context)
|
void MoveCelCommand::onExecute(Context* context)
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
MoveMaskCommand::MoveMaskCommand() : Command(CommandId::MoveMask(), CmdRecordableFlag)
|
MoveMaskCommand::MoveMaskCommand() : Command(CommandId::MoveMask())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,13 +52,13 @@ private:
|
||||||
void selectPencilTool();
|
void selectPencilTool();
|
||||||
};
|
};
|
||||||
|
|
||||||
NewBrushCommand::NewBrushCommand() : Command(CommandId::NewBrush(), CmdUIOnlyFlag)
|
NewBrushCommand::NewBrushCommand() : Command(CommandId::NewBrush())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NewBrushCommand::onEnabled(Context* context)
|
bool NewBrushCommand::onEnabled(Context* context)
|
||||||
{
|
{
|
||||||
return context->checkFlags(ContextFlags::ActiveDocumentIsWritable);
|
return context->isUIAvailable() && context->checkFlags(ContextFlags::ActiveDocumentIsWritable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewBrushCommand::onExecute(Context* context)
|
void NewBrushCommand::onExecute(Context* context)
|
||||||
|
|
|
@ -64,7 +64,7 @@ protected:
|
||||||
// static
|
// static
|
||||||
int NewFileCommand::g_spriteCounter = 0;
|
int NewFileCommand::g_spriteCounter = 0;
|
||||||
|
|
||||||
NewFileCommand::NewFileCommand() : CommandWithNewParams(CommandId::NewFile(), CmdRecordableFlag)
|
NewFileCommand::NewFileCommand() : CommandWithNewParams(CommandId::NewFile())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ private:
|
||||||
Content m_content;
|
Content m_content;
|
||||||
};
|
};
|
||||||
|
|
||||||
NewFrameCommand::NewFrameCommand() : Command(CommandId::NewFrame(), CmdRecordableFlag)
|
NewFrameCommand::NewFrameCommand() : Command(CommandId::NewFrame())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,14 +33,14 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
NewFrameTagCommand::NewFrameTagCommand() : Command(CommandId::NewFrameTag(), CmdRecordableFlag)
|
NewFrameTagCommand::NewFrameTagCommand() : Command(CommandId::NewFrameTag())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NewFrameTagCommand::onEnabled(Context* context)
|
bool NewFrameTagCommand::onEnabled(Context* context)
|
||||||
{
|
{
|
||||||
return context->checkFlags(ContextFlags::ActiveDocumentIsWritable |
|
return context->isUIAvailable() && context->checkFlags(ContextFlags::ActiveDocumentIsWritable |
|
||||||
ContextFlags::HasActiveSprite);
|
ContextFlags::HasActiveSprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewFrameTagCommand::onExecute(Context* context)
|
void NewFrameTagCommand::onExecute(Context* context)
|
||||||
|
|
|
@ -99,7 +99,7 @@ private:
|
||||||
Place m_place;
|
Place m_place;
|
||||||
};
|
};
|
||||||
|
|
||||||
NewLayerCommand::NewLayerCommand() : CommandWithNewParams(CommandId::NewLayer(), CmdRecordableFlag)
|
NewLayerCommand::NewLayerCommand() : CommandWithNewParams(CommandId::NewLayer())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
NewSpriteFromSelectionCommand::NewSpriteFromSelectionCommand()
|
NewSpriteFromSelectionCommand::NewSpriteFromSelectionCommand()
|
||||||
: Command(CommandId::NewSpriteFromSelection(), CmdUIOnlyFlag)
|
: Command(CommandId::NewSpriteFromSelection())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ using namespace gfx;
|
||||||
|
|
||||||
class ShowOnionSkinCommand : public Command {
|
class ShowOnionSkinCommand : public Command {
|
||||||
public:
|
public:
|
||||||
ShowOnionSkinCommand() : Command(CommandId::ShowOnionSkin(), CmdUIOnlyFlag) {}
|
ShowOnionSkinCommand() : Command(CommandId::ShowOnionSkin()) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool onChecked(Context* context) override
|
bool onChecked(Context* context) override
|
||||||
|
|
|
@ -22,6 +22,7 @@ public:
|
||||||
OpenBrowserCommand();
|
OpenBrowserCommand();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
bool onEnabled(Context* context) override;
|
||||||
void onLoadParams(const Params& params) override;
|
void onLoadParams(const Params& params) override;
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
std::string onGetFriendlyName() const override;
|
std::string onGetFriendlyName() const override;
|
||||||
|
@ -31,10 +32,15 @@ private:
|
||||||
std::string m_filename;
|
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)
|
void OpenBrowserCommand::onLoadParams(const Params& params)
|
||||||
{
|
{
|
||||||
m_filename = params.get("filename");
|
m_filename = params.get("filename");
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
OpenFileCommand::OpenFileCommand()
|
OpenFileCommand::OpenFileCommand()
|
||||||
: Command(CommandId::OpenFile(), CmdRecordableFlag)
|
: Command(CommandId::OpenFile())
|
||||||
, m_ui(true)
|
, m_ui(true)
|
||||||
, m_repeatCheckbox(false)
|
, m_repeatCheckbox(false)
|
||||||
, m_oneFrame(false)
|
, m_oneFrame(false)
|
||||||
|
|
|
@ -32,7 +32,7 @@ protected:
|
||||||
// std::string onGetFriendlyName() const override;
|
// std::string onGetFriendlyName() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
OpenGroupCommand::OpenGroupCommand() : Command(CommandId::OpenGroup(), CmdRecordableFlag)
|
OpenGroupCommand::OpenGroupCommand() : Command(CommandId::OpenGroup())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
OpenInFolderCommand::OpenInFolderCommand() : Command(CommandId::OpenInFolder(), CmdUIOnlyFlag)
|
OpenInFolderCommand::OpenInFolderCommand() : Command(CommandId::OpenInFolder())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,7 @@ protected:
|
||||||
void onExecute(Context* context);
|
void onExecute(Context* context);
|
||||||
};
|
};
|
||||||
|
|
||||||
OpenScriptFolderCommand::OpenScriptFolderCommand()
|
OpenScriptFolderCommand::OpenScriptFolderCommand() : Command(CommandId::OpenScriptFolder())
|
||||||
: Command(CommandId::OpenScriptFolder(), CmdUIOnlyFlag)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
OpenWithAppCommand::OpenWithAppCommand() : Command(CommandId::OpenWithApp(), CmdUIOnlyFlag)
|
OpenWithAppCommand::OpenWithAppCommand() : Command(CommandId::OpenWithApp())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2177,7 +2177,7 @@ private:
|
||||||
std::string m_installExtensionFilename;
|
std::string m_installExtensionFilename;
|
||||||
};
|
};
|
||||||
|
|
||||||
OptionsCommand::OptionsCommand() : Command(CommandId::Options(), CmdUIOnlyFlag)
|
OptionsCommand::OptionsCommand() : Command(CommandId::Options())
|
||||||
{
|
{
|
||||||
Preferences& preferences = Preferences::instance();
|
Preferences& preferences = Preferences::instance();
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
#include "app/commands/command.h"
|
#include "app/commands/command.h"
|
||||||
#include "app/commands/params.h"
|
#include "app/commands/params.h"
|
||||||
|
#include "app/context.h"
|
||||||
#include "app/i18n/strings.h"
|
#include "app/i18n/strings.h"
|
||||||
#include "app/ui/color_bar.h"
|
#include "app/ui/color_bar.h"
|
||||||
#include "base/replace_string.h"
|
#include "base/replace_string.h"
|
||||||
|
@ -23,6 +24,7 @@ public:
|
||||||
PaletteEditorCommand();
|
PaletteEditorCommand();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
bool onEnabled(Context* context) override;
|
||||||
void onLoadParams(const Params& params) override;
|
void onLoadParams(const Params& params) override;
|
||||||
bool onChecked(Context* context) override;
|
bool onChecked(Context* context) override;
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
|
@ -34,14 +36,18 @@ private:
|
||||||
bool m_background;
|
bool m_background;
|
||||||
};
|
};
|
||||||
|
|
||||||
PaletteEditorCommand::PaletteEditorCommand()
|
PaletteEditorCommand::PaletteEditorCommand() : Command(CommandId::PaletteEditor())
|
||||||
: Command(CommandId::PaletteEditor(), CmdRecordableFlag)
|
|
||||||
{
|
{
|
||||||
m_edit = true;
|
m_edit = true;
|
||||||
m_popup = false;
|
m_popup = false;
|
||||||
m_background = false;
|
m_background = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PaletteEditorCommand::onEnabled(Context* context)
|
||||||
|
{
|
||||||
|
return context->isUIAvailable();
|
||||||
|
}
|
||||||
|
|
||||||
void PaletteEditorCommand::onLoadParams(const Params& params)
|
void PaletteEditorCommand::onLoadParams(const Params& params)
|
||||||
{
|
{
|
||||||
m_edit = (params.empty() || params.get("edit") == "switch" ||
|
m_edit = (params.empty() || params.get("edit") == "switch" ||
|
||||||
|
|
|
@ -33,17 +33,21 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
|
|
||||||
private:
|
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)
|
void PaletteSizeCommand::onLoadParams(const Params& params)
|
||||||
{
|
{
|
||||||
m_size = params.get_as<int>("size");
|
m_size = params.get_as<int>("size");
|
||||||
|
if (params.has_param("ui"))
|
||||||
|
m_ui = params.get_as<bool>("ui");
|
||||||
|
else
|
||||||
|
m_ui = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PaletteSizeCommand::onEnabled(Context* context)
|
bool PaletteSizeCommand::onEnabled(Context* context)
|
||||||
|
@ -59,7 +63,7 @@ void PaletteSizeCommand::onExecute(Context* context)
|
||||||
Palette palette(*reader.palette());
|
Palette palette(*reader.palette());
|
||||||
int ncolors = (m_size != 0 ? m_size : palette.size());
|
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;
|
app::gen::PaletteSize window;
|
||||||
window.colors()->setTextf("%d", ncolors);
|
window.colors()->setTextf("%d", ncolors);
|
||||||
window.openWindowInForeground();
|
window.openWindowInForeground();
|
||||||
|
|
|
@ -31,7 +31,7 @@ private:
|
||||||
std::unique_ptr<gfx::Point> m_position;
|
std::unique_ptr<gfx::Point> m_position;
|
||||||
};
|
};
|
||||||
|
|
||||||
PasteCommand::PasteCommand() : Command(CommandId::Paste(), CmdUIOnlyFlag)
|
PasteCommand::PasteCommand() : Command(CommandId::Paste())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,14 +43,14 @@ protected:
|
||||||
void onExecute(Context* ctx) override;
|
void onExecute(Context* ctx) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
PasteTextCommand::PasteTextCommand() : Command(CommandId::PasteText(), CmdUIOnlyFlag)
|
PasteTextCommand::PasteTextCommand() : Command(CommandId::PasteText())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PasteTextCommand::onEnabled(Context* ctx)
|
bool PasteTextCommand::onEnabled(Context* ctx)
|
||||||
{
|
{
|
||||||
return ctx->checkFlags(ContextFlags::ActiveDocumentIsWritable |
|
return ctx->isUIAvailable() && ctx->checkFlags(ContextFlags::ActiveDocumentIsWritable |
|
||||||
ContextFlags::ActiveLayerIsEditable);
|
ContextFlags::ActiveLayerIsEditable);
|
||||||
}
|
}
|
||||||
|
|
||||||
class PasteTextWindow : public app::gen::PasteText {
|
class PasteTextWindow : public app::gen::PasteText {
|
||||||
|
|
|
@ -28,8 +28,7 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
PixelPerfectModeCommand::PixelPerfectModeCommand()
|
PixelPerfectModeCommand::PixelPerfectModeCommand() : Command(CommandId::PixelPerfectMode())
|
||||||
: Command(CommandId::PixelPerfectMode(), CmdUIOnlyFlag)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,13 +34,14 @@ protected:
|
||||||
void onExecute(Context* ctx) override;
|
void onExecute(Context* ctx) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
PlayAnimationCommand::PlayAnimationCommand() : Command(CommandId::PlayAnimation(), CmdUIOnlyFlag)
|
PlayAnimationCommand::PlayAnimationCommand() : Command(CommandId::PlayAnimation())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlayAnimationCommand::onEnabled(Context* ctx)
|
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)
|
bool PlayAnimationCommand::onChecked(Context* ctx)
|
||||||
|
@ -85,13 +86,14 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
PlayPreviewAnimationCommand::PlayPreviewAnimationCommand()
|
PlayPreviewAnimationCommand::PlayPreviewAnimationCommand()
|
||||||
: Command(CommandId::PlayPreviewAnimation(), CmdUIOnlyFlag)
|
: Command(CommandId::PlayPreviewAnimation())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlayPreviewAnimationCommand::onEnabled(Context* ctx)
|
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)
|
bool PlayPreviewAnimationCommand::onChecked(Context* ctx)
|
||||||
|
|
|
@ -39,7 +39,7 @@ private:
|
||||||
void postCancelMenuLoop();
|
void postCancelMenuLoop();
|
||||||
};
|
};
|
||||||
|
|
||||||
RefreshCommand::RefreshCommand() : Command(CommandId::Refresh(), CmdUIOnlyFlag)
|
RefreshCommand::RefreshCommand() : Command(CommandId::Refresh())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
RemoveFrameCommand::RemoveFrameCommand() : Command(CommandId::RemoveFrame(), CmdRecordableFlag)
|
RemoveFrameCommand::RemoveFrameCommand() : Command(CommandId::RemoveFrame())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
RemoveFrameTagCommand::RemoveFrameTagCommand()
|
RemoveFrameTagCommand::RemoveFrameTagCommand()
|
||||||
: Command(CommandId::RemoveFrameTag(), CmdRecordableFlag)
|
: Command(CommandId::RemoveFrameTag())
|
||||||
, m_tagId(NullId)
|
, m_tagId(NullId)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
RemoveLayerCommand::RemoveLayerCommand() : Command(CommandId::RemoveLayer(), CmdRecordableFlag)
|
RemoveLayerCommand::RemoveLayerCommand() : Command(CommandId::RemoveLayer())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ private:
|
||||||
ObjectId m_sliceId;
|
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();
|
document->notifyGeneralUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusBar::instance()->invalidate();
|
if (context->isUIAvailable()) {
|
||||||
if (!sliceName.empty()) {
|
StatusBar::instance()->invalidate();
|
||||||
StatusBar::instance()->showTip(1000, Strings::remove_slice_x_removed(sliceName));
|
if (!sliceName.empty()) {
|
||||||
}
|
StatusBar::instance()->showTip(1000, Strings::remove_slice_x_removed(sliceName));
|
||||||
else {
|
}
|
||||||
StatusBar::instance()->showTip(1000,
|
else {
|
||||||
Strings::remove_slice_n_slices_removed(slicesToDelete.size()));
|
StatusBar::instance()->showTip(1000,
|
||||||
|
Strings::remove_slice_n_slices_removed(slicesToDelete.size()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,7 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
ReopenClosedFileCommand::ReopenClosedFileCommand()
|
ReopenClosedFileCommand::ReopenClosedFileCommand() : Command(CommandId::ReopenClosedFile())
|
||||||
: Command(CommandId::ReopenClosedFile(), CmdUIOnlyFlag)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,7 @@ protected:
|
||||||
virtual void onExecute(Context* context) override;
|
virtual void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
RepeatLastExportCommand::RepeatLastExportCommand()
|
RepeatLastExportCommand::RepeatLastExportCommand() : Command(CommandId::RepeatLastExport())
|
||||||
: Command(CommandId::RepeatLastExport(), CmdRecordableFlag)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
ReselectMaskCommand::ReselectMaskCommand() : Command(CommandId::ReselectMask(), CmdRecordableFlag)
|
ReselectMaskCommand::ReselectMaskCommand() : Command(CommandId::ReselectMask())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
ReverseFramesCommand::ReverseFramesCommand() : Command(CommandId::ReverseFrames(), CmdUIOnlyFlag)
|
ReverseFramesCommand::ReverseFramesCommand() : Command(CommandId::ReverseFrames())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -166,7 +166,7 @@ protected:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
RotateCommand::RotateCommand() : Command(CommandId::Rotate(), CmdRecordableFlag)
|
RotateCommand::RotateCommand() : Command(CommandId::Rotate())
|
||||||
{
|
{
|
||||||
m_ui = true;
|
m_ui = true;
|
||||||
m_flipMask = false;
|
m_flipMask = false;
|
||||||
|
@ -190,6 +190,10 @@ void RotateCommand::onLoadParams(const Params& params)
|
||||||
|
|
||||||
bool RotateCommand::onEnabled(Context* context)
|
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 |
|
return context->checkFlags(ContextFlags::ActiveDocumentIsWritable |
|
||||||
ContextFlags::HasActiveSprite);
|
ContextFlags::HasActiveSprite);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ private:
|
||||||
Params m_params;
|
Params m_params;
|
||||||
};
|
};
|
||||||
|
|
||||||
RunScriptCommand::RunScriptCommand() : Command(CommandId::RunScript(), CmdRecordableFlag)
|
RunScriptCommand::RunScriptCommand() : Command(CommandId::RunScript())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,8 +86,7 @@ private:
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
SaveFileBaseCommand::SaveFileBaseCommand(const char* id, CommandFlags flags)
|
SaveFileBaseCommand::SaveFileBaseCommand(const char* id) : CommandWithNewParams<SaveFileParams>(id)
|
||||||
: CommandWithNewParams<SaveFileParams>(id, flags)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,7 +268,7 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
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;
|
void onExecute(Context* context) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
SaveFileAsCommand::SaveFileAsCommand()
|
SaveFileAsCommand::SaveFileAsCommand() : SaveFileBaseCommand(CommandId::SaveFileAs())
|
||||||
: SaveFileBaseCommand(CommandId::SaveFileAs(), CmdRecordableFlag)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,8 +333,7 @@ private:
|
||||||
void moveToUndoState(Doc* doc, const undo::UndoState* state);
|
void moveToUndoState(Doc* doc, const undo::UndoState* state);
|
||||||
};
|
};
|
||||||
|
|
||||||
SaveFileCopyAsCommand::SaveFileCopyAsCommand()
|
SaveFileCopyAsCommand::SaveFileCopyAsCommand() : SaveFileBaseCommand(CommandId::SaveFileCopyAs())
|
||||||
: SaveFileBaseCommand(CommandId::SaveFileCopyAs(), CmdRecordableFlag)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ public:
|
||||||
enum class SaveInBackground { Off, On };
|
enum class SaveInBackground { Off, On };
|
||||||
enum class ResizeOnTheFly { Off, On };
|
enum class ResizeOnTheFly { Off, On };
|
||||||
|
|
||||||
SaveFileBaseCommand(const char* id, CommandFlags flags);
|
SaveFileBaseCommand(const char* id);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onLoadParams(const Params& params) override;
|
void onLoadParams(const Params& params) override;
|
||||||
|
|
|
@ -15,13 +15,20 @@
|
||||||
#include "app/i18n/strings.h"
|
#include "app/i18n/strings.h"
|
||||||
#include "app/util/msk_file.h"
|
#include "app/util/msk_file.h"
|
||||||
#include "base/fs.h"
|
#include "base/fs.h"
|
||||||
|
#include "doc/file/act_file.h"
|
||||||
#include "doc/mask.h"
|
#include "doc/mask.h"
|
||||||
#include "doc/sprite.h"
|
#include "doc/sprite.h"
|
||||||
|
#include "new_params.h"
|
||||||
#include "ui/alert.h"
|
#include "ui/alert.h"
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
class SaveMaskCommand : public Command {
|
struct SaveMaskParams : public NewParams {
|
||||||
|
Param<bool> ui{ this, true, "ui" };
|
||||||
|
Param<std::string> filename{ this, "default.msk", "filename" };
|
||||||
|
};
|
||||||
|
|
||||||
|
class SaveMaskCommand : public CommandWithNewParams<SaveMaskParams> {
|
||||||
public:
|
public:
|
||||||
SaveMaskCommand();
|
SaveMaskCommand();
|
||||||
|
|
||||||
|
@ -30,7 +37,7 @@ protected:
|
||||||
void onExecute(Context* context) override;
|
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)
|
void SaveMaskCommand::onExecute(Context* context)
|
||||||
{
|
{
|
||||||
|
const bool ui = (params().ui() && context->isUIAvailable());
|
||||||
|
std::string filename = params().filename();
|
||||||
|
|
||||||
const ContextReader reader(context);
|
const ContextReader reader(context);
|
||||||
const Doc* document(reader.document());
|
const Doc* document(reader.document());
|
||||||
|
|
||||||
base::paths exts = { "msk" };
|
if (ui) {
|
||||||
base::paths selFilename;
|
base::paths exts = { "msk" };
|
||||||
if (!app::show_file_selector(Strings::save_selection_title(),
|
base::paths selFilename;
|
||||||
"default.msk",
|
if (!app::show_file_selector(Strings::save_selection_title(),
|
||||||
exts,
|
filename,
|
||||||
FileSelectorType::Save,
|
exts,
|
||||||
selFilename))
|
FileSelectorType::Save,
|
||||||
return;
|
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));
|
ui::Alert::show(Strings::alerts_error_saving_file(filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,56 +21,62 @@
|
||||||
#include "app/modules/palettes.h"
|
#include "app/modules/palettes.h"
|
||||||
#include "base/fs.h"
|
#include "base/fs.h"
|
||||||
#include "doc/palette.h"
|
#include "doc/palette.h"
|
||||||
|
#include "new_params.h"
|
||||||
#include "ui/alert.h"
|
#include "ui/alert.h"
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
using namespace ui;
|
using namespace ui;
|
||||||
|
|
||||||
class SavePaletteCommand : public Command {
|
struct SavePaletteParams : public NewParams {
|
||||||
|
Param<bool> ui{ this, true, "ui" };
|
||||||
|
Param<std::string> filename{ this, "", "filename" };
|
||||||
|
Param<std::string> preset{ this, "", "preset" };
|
||||||
|
Param<bool> saveAsPreset{ this, false, "saveAsPreset" };
|
||||||
|
Param<int> columns{ this, 16, "columns" };
|
||||||
|
};
|
||||||
|
|
||||||
|
class SavePaletteCommand : public CommandWithNewParams<SavePaletteParams> {
|
||||||
public:
|
public:
|
||||||
SavePaletteCommand();
|
SavePaletteCommand();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onLoadParams(const Params& params) override;
|
void onExecute(Context* ctx) override;
|
||||||
void onExecute(Context* context) override;
|
|
||||||
std::string onGetFriendlyName() const 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)
|
void SavePaletteCommand::onExecute(Context* ctx)
|
||||||
{
|
{
|
||||||
const doc::Palette* palette = get_current_palette();
|
const doc::Palette* palette = get_current_palette();
|
||||||
|
const bool ui = (params().ui() && ctx->isUIAvailable());
|
||||||
std::string filename;
|
std::string filename;
|
||||||
|
|
||||||
if (!m_preset.empty()) {
|
if (!params().preset().empty()) {
|
||||||
filename = get_preset_palette_filename(m_preset, ".ase");
|
filename = get_preset_palette_filename(params().preset(), ".ase");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
base::paths exts = get_writable_palette_extensions();
|
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
|
// Check that the file format supports saving indexed images/color
|
||||||
// palettes (e.g. if the user specified .jpg we should show that
|
// 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;
|
gfx::ColorSpaceRef colorSpace = nullptr;
|
||||||
auto activeDoc = ctx->activeDocument();
|
auto* activeDoc = ctx->activeDocument();
|
||||||
if (activeDoc)
|
if (activeDoc)
|
||||||
colorSpace = activeDoc->sprite()->colorSpace();
|
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));
|
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);
|
set_default_palette(palette);
|
||||||
if (!activeDoc)
|
if (!activeDoc)
|
||||||
set_current_palette(palette, false);
|
set_current_palette(palette, false);
|
||||||
}
|
}
|
||||||
if (m_saveAsPreset) {
|
|
||||||
|
if (params().saveAsPreset()) {
|
||||||
App::instance()->PalettePresetsChange();
|
App::instance()->PalettePresetsChange();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SavePaletteCommand::onGetFriendlyName() const
|
std::string SavePaletteCommand::onGetFriendlyName() const
|
||||||
{
|
{
|
||||||
if (m_preset == "default")
|
if (params().preset() == get_default_palette_preset_name())
|
||||||
return Strings::commands_SavePaletteAsDefault();
|
return Strings::commands_SavePaletteAsDefault();
|
||||||
else if (m_saveAsPreset)
|
if (params().saveAsPreset())
|
||||||
return Strings::commands_SavePaletteAsPreset();
|
return Strings::commands_SavePaletteAsPreset();
|
||||||
return Command::onGetFriendlyName();
|
return Command::onGetFriendlyName();
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ private:
|
||||||
MoveThing m_moveThing;
|
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)
|
bool ScrollCommand::onEnabled(Context* context)
|
||||||
{
|
{
|
||||||
return context->checkFlags(ContextFlags::HasActiveDocument);
|
return context->isUIAvailable() && context->checkFlags(ContextFlags::HasActiveDocument);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScrollCommand::onExecute(Context* context)
|
void ScrollCommand::onExecute(Context* context)
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue