Rename CommandsModule to Commands

This commit is contained in:
David Capello 2017-11-30 11:57:18 -03:00
parent c0ef5e2a15
commit eb3143ce21
36 changed files with 102 additions and 103 deletions

View File

@ -92,7 +92,7 @@ public:
FileSystemModule m_file_system_module;
tools::ToolBox m_toolbox;
tools::ActiveToolManager m_activeToolManager;
CommandsModule m_commands_modules;
Commands m_commands;
UIContext m_ui_context;
RecentFiles m_recent_files;
InputChain m_inputChain;

View File

@ -381,7 +381,8 @@ bool AppMenus::rebuildRecentList()
if (list_menuitem->hasSubmenuOpened())
return false;
Command* cmd_open_file = CommandsModule::instance()->getCommandByName(CommandId::OpenFile);
Command* cmd_open_file =
Commands::instance()->byId(CommandId::OpenFile);
Menu* submenu = list_menuitem->getSubmenu();
if (submenu) {
@ -478,10 +479,10 @@ Widget* AppMenus::convertXmlelemToMenuitem(TiXmlElement* elem)
if (strcmp(elem->Value(), "separator") == 0)
return new MenuSeparator;
const char* command_name = elem->Attribute("command");
const char* command_id = elem->Attribute("command");
Command* command =
command_name ? CommandsModule::instance()->getCommandByName(command_name):
NULL;
command_id ? Commands::instance()->byId(command_id):
nullptr;
// load params
Params params;
@ -630,7 +631,7 @@ void AppMenus::createNativeMenus()
about.shortcut = native.shortcut;
about.execute = [native]{
if (can_call_global_shortcut(&native)) {
Command* cmd = CommandsModule::instance()->getCommandByName(CommandId::About);
Command* cmd = Commands::instance()->byId(CommandId::About);
UIContext::instance()->executeCommand(cmd);
}
};
@ -640,7 +641,7 @@ void AppMenus::createNativeMenus()
preferences.shortcut = native.shortcut;
preferences.execute = [native]{
if (can_call_global_shortcut(&native)) {
Command* cmd = CommandsModule::instance()->getCommandByName(CommandId::Options);
Command* cmd = Commands::instance()->byId(CommandId::Options);
UIContext::instance()->executeCommand(cmd);
}
};

View File

@ -335,7 +335,7 @@ void CliProcessor::process()
}
// --scale <factor>
else if (opt == &m_options.scale()) {
Command* command = CommandsModule::instance()->getCommandByName(CommandId::SpriteSize);
Command* command = Commands::instance()->byId(CommandId::SpriteSize);
double scale = strtod(value.value().c_str(), NULL);
static_cast<SpriteSizeCommand*>(command)->setScale(scale, scale);
@ -364,7 +364,7 @@ void CliProcessor::process()
}
// --color-mode <mode>
else if (opt == &m_options.colorMode()) {
Command* command = CommandsModule::instance()->getCommandByName(CommandId::ChangePixelFormat);
Command* command = Commands::instance()->byId(CommandId::ChangePixelFormat);
Params params;
if (value.value() == "rgb") {
params.set("format", "rgb");
@ -422,7 +422,7 @@ void CliProcessor::process()
scaleHeight = (doc->height() > maxHeight ? maxHeight / doc->height() : 1.0);
if (scaleWidth < 1.0 || scaleHeight < 1.0) {
scale = MIN(scaleWidth, scaleHeight);
Command* command = CommandsModule::instance()->getCommandByName(CommandId::SpriteSize);
Command* command = Commands::instance()->byId(CommandId::SpriteSize);
static_cast<SpriteSizeCommand*>(command)->setScale(scale, scale);
ctx->executeCommand(command);
}
@ -494,7 +494,7 @@ bool CliProcessor::openFile(CliOpenFile& cof)
Context* ctx = UIContext::instance();
app::Document* oldDoc = ctx->activeDocument();
Command* openCommand = CommandsModule::instance()->getCommandByName(CommandId::OpenFile);
Command* openCommand = Commands::instance()->byId(CommandId::OpenFile);
Params params;
params.set("filename", cof.filename.c_str());
if (cof.oneFrame)
@ -581,8 +581,8 @@ void CliProcessor::saveFile(const CliOpenFile& cof)
UIContext* ctx = UIContext::instance();
ctx->setActiveDocument(cof.document);
Command* trimCommand = CommandsModule::instance()->getCommandByName(CommandId::AutocropSprite);
Command* undoCommand = CommandsModule::instance()->getCommandByName(CommandId::Undo);
Command* trimCommand = Commands::instance()->byId(CommandId::AutocropSprite);
Command* undoCommand = Commands::instance()->byId(CommandId::Undo);
app::Document* doc = cof.document;
bool clearUndo = false;
@ -593,7 +593,7 @@ void CliProcessor::saveFile(const CliOpenFile& cof)
cropParams.set("width", base::convert_to<std::string>(cof.crop.w).c_str());
cropParams.set("height", base::convert_to<std::string>(cof.crop.h).c_str());
ctx->executeCommand(
CommandsModule::instance()->getCommandByName(CommandId::CropSprite),
Commands::instance()->byId(CommandId::CropSprite),
cropParams);
}

View File

@ -76,7 +76,7 @@ void DefaultCliDelegate::afterOpenFile(const CliOpenFile& cof)
void DefaultCliDelegate::saveFile(const CliOpenFile& cof)
{
Context* ctx = UIContext::instance();
Command* saveAsCommand = CommandsModule::instance()->getCommandByName(CommandId::SaveFileCopyAs);
Command* saveAsCommand = Commands::instance()->byId(CommandId::SaveFileCopyAs);
Params params;
params.set("filename", cof.filename.c_str());
params.set("filename-format", cof.filenameFormat.c_str());
@ -101,7 +101,7 @@ void DefaultCliDelegate::loadPalette(const CliOpenFile& cof,
base::UniquePtr<doc::Palette> palette(load_palette(filename.c_str()));
if (palette) {
Context* ctx = UIContext::instance();
Command* loadPalCommand = CommandsModule::instance()->getCommandByName(CommandId::LoadPalette);
Command* loadPalCommand = Commands::instance()->byId(CommandId::LoadPalette);
Params params;
params.set("filename", filename.c_str());

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2015 David Capello
// Copyright (C) 2001-2015, 2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -63,7 +63,7 @@ void CancelCommand::onExecute(Context* context)
// TODO should the ContextBar be a InputChainElement to intercept onCancel()?
// Discard brush
{
Command* discardBrush = CommandsModule::instance()->getCommandByName(CommandId::DiscardBrush);
Command* discardBrush = Commands::instance()->byId(CommandId::DiscardBrush);
context->executeCommand(discardBrush);
}

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2016 David Capello
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -43,7 +43,7 @@ void ExitCommand::onExecute(Context* ctx)
return;
if (ctx->hasModifiedDocuments()) {
Command* closeAll = CommandsModule::instance()->getCommandByName(CommandId::CloseAllFiles);
Command* closeAll = Commands::instance()->byId(CommandId::CloseAllFiles);
Params params;
params.set("quitting", "1");
ctx->executeCommand(closeAll, params);

View File

@ -196,7 +196,7 @@ void EyedropperCommand::onExecute(Context* context)
// Discard current image brush
if (Preferences::instance().eyedropper.discardBrush()) {
Command* discardBrush = CommandsModule::instance()->getCommandByName(CommandId::DiscardBrush);
Command* discardBrush = Commands::instance()->byId(CommandId::DiscardBrush);
context->executeCommand(discardBrush);
}

View File

@ -120,7 +120,7 @@ protected:
void onSelectFile() {
Document* oldActiveDocument = m_context->activeDocument();
Command* openFile = CommandsModule::instance()->getCommandByName(CommandId::OpenFile);
Command* openFile = Commands::instance()->byId(CommandId::OpenFile);
Params params;
params.set("filename", "");
openFile->loadParams(params);

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2015 David Capello
// Copyright (C) 2001-2015, 2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -58,7 +58,7 @@ void InvertMaskCommand::onExecute(Context* context)
if (!hasMask) {
// so we select all
Command* mask_all_cmd =
CommandsModule::instance()->getCommandByName(CommandId::MaskAll);
Commands::instance()->byId(CommandId::MaskAll);
context->executeCommand(mask_all_cmd);
}
// invert the current mask

View File

@ -87,7 +87,7 @@ void LoadPaletteCommand::onExecute(Context* context)
}
SetPaletteCommand* cmd = static_cast<SetPaletteCommand*>(
CommandsModule::instance()->getCommandByName(CommandId::SetPalette));
Commands::instance()->byId(CommandId::SetPalette));
cmd->setPalette(palette);
context->executeCommand(cmd);
}

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2016 David Capello
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -98,7 +98,7 @@ void NewBrushCommand::onExecute(Context* context)
// Deselect mask
Command* cmd =
CommandsModule::instance()->getCommandByName(CommandId::DeselectMask);
Commands::instance()->byId(CommandId::DeselectMask);
UIContext::instance()->executeCommand(cmd);
}
}

View File

@ -132,7 +132,7 @@ void NewLayerCommand::onExecute(Context* context)
// Select a file to copy its content
if (m_fromFile) {
Document* oldActiveDocument = context->activeDocument();
Command* openFile = CommandsModule::instance()->getCommandByName(CommandId::OpenFile);
Command* openFile = Commands::instance()->byId(CommandId::OpenFile);
Params params;
params.set("filename", "");
context->executeCommand(openFile, params);

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2016 David Capello
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -42,7 +42,7 @@ bool RepeatLastExportCommand::onEnabled(Context* context)
void RepeatLastExportCommand::onExecute(Context* context)
{
Command* cmd = CommandsModule::instance()->getCommandByName(CommandId::ExportSpriteSheet);
Command* cmd = Commands::instance()->byId(CommandId::ExportSpriteSheet);
Params params;
{

View File

@ -240,7 +240,7 @@ bool SaveFileBaseCommand::saveAsDialog(
// Apply scale
bool undoResize = false;
if (xscale != 1.0 || yscale != 1.0) {
Command* resizeCmd = CommandsModule::instance()->getCommandByName(CommandId::SpriteSize);
Command* resizeCmd = Commands::instance()->byId(CommandId::SpriteSize);
ASSERT(resizeCmd);
if (resizeCmd) {
int width = document->sprite()->width();
@ -287,7 +287,7 @@ bool SaveFileBaseCommand::saveAsDialog(
// Undo resize
if (undoResize) {
Command* undoCmd = CommandsModule::instance()->getCommandByName(CommandId::Undo);
Command* undoCmd = Commands::instance()->byId(CommandId::Undo);
if (undoCmd)
context->executeCommand(undoCmd);
}

View File

@ -122,7 +122,7 @@ void SetLoopSectionCommand::onExecute(Context* ctx)
transaction.commit();
}
else {
Command* cmd = CommandsModule::instance()->getCommandByName(CommandId::FrameTagProperties);
Command* cmd = Commands::instance()->byId(CommandId::FrameTagProperties);
ctx->executeCommand(cmd);
}
}

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2015 David Capello
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -26,9 +26,9 @@ namespace app {
#include "app/commands/commands_list.h"
#undef FOR_EACH_COMMAND
CommandsModule* CommandsModule::m_instance = NULL;
Commands* Commands::m_instance = NULL;
CommandsModule::CommandsModule()
Commands::Commands()
{
ASSERT(m_instance == NULL);
m_instance = this;
@ -41,7 +41,7 @@ CommandsModule::CommandsModule()
#undef FOR_EACH_COMMAND
}
CommandsModule::~CommandsModule()
Commands::~Commands()
{
ASSERT(m_instance == this);
@ -52,24 +52,24 @@ CommandsModule::~CommandsModule()
m_instance = NULL;
}
CommandsModule* CommandsModule::instance()
Commands* Commands::instance()
{
ASSERT(m_instance != NULL);
return m_instance;
}
Command* CommandsModule::getCommandByName(const char* name)
Command* Commands::byId(const char* id)
{
if (!name)
return NULL;
if (!id)
return nullptr;
std::string lname = base::string_to_lower(name);
std::string lid = base::string_to_lower(id);
for (Command* cmd : m_commands) {
if (base::utf8_icmp(cmd->id(), lname) == 0)
if (base::utf8_icmp(cmd->id(), lid) == 0)
return cmd;
}
return NULL;
return nullptr;
}
} // namespace app

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2015 David Capello
// Copyright (C) 2001-2015, 2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -25,20 +25,17 @@ namespace app {
class Command;
typedef std::vector<Command*> CommandsList;
class CommandsModule {
static CommandsModule* m_instance;
class Commands {
static Commands* m_instance;
CommandsList m_commands;
public:
CommandsModule();
~CommandsModule();
Commands();
~Commands();
static CommandsModule* instance();
static Commands* instance();
Command* getCommandByName(const char* name);
CommandsList::iterator begin() { return m_commands.begin(); }
CommandsList::iterator end() { return m_commands.end(); }
Command* byId(const char* id);
};
} // namespace app

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2016 David Capello
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -47,7 +47,7 @@ bool Context::hasModifiedDocuments() const
void Context::executeCommand(const char* commandName)
{
Command* cmd = CommandsModule::instance()->getCommandByName(commandName);
Command* cmd = Commands::instance()->byId(commandName);
if (cmd)
executeCommand(cmd);
else

View File

@ -322,7 +322,7 @@ bool CustomizedGuiManager::onProcessMessage(Message* msg)
case kCloseDisplayMessage:
{
// Execute the "Exit" command.
Command* command = CommandsModule::instance()->getCommandByName(CommandId::Exit);
Command* command = Commands::instance()->byId(CommandId::Exit);
UIContext::instance()->executeCommand(command);
}
break;

View File

@ -29,7 +29,8 @@ void App_open(script::ContextHandle handle)
app::Document* oldDoc = UIContext::instance()->activeDocument();
Command* openCommand = CommandsModule::instance()->getCommandByName(CommandId::OpenFile);
Command* openCommand =
Commands::instance()->byId(CommandId::OpenFile);
Params params;
params.set("filename", filename);
UIContext::instance()->executeCommand(openCommand, params);
@ -46,7 +47,8 @@ void App_exit(script::ContextHandle handle)
script::Context ctx(handle);
UIContext* appCtx = UIContext::instance();
if (appCtx && appCtx->isUIAvailable()) {
Command* exitCommand = CommandsModule::instance()->getCommandByName(CommandId::Exit);
Command* exitCommand =
Commands::instance()->byId(CommandId::Exit);
appCtx->executeCommand(exitCommand);
}
ctx.pushUndefined();

View File

@ -107,7 +107,8 @@ void Sprite_save(script::ContextHandle handle)
auto doc = wrap->document();
auto uiCtx = UIContext::instance();
uiCtx->setActiveDocument(doc);
Command* saveCommand = CommandsModule::instance()->getCommandByName(CommandId::SaveFile);
Command* saveCommand =
Commands::instance()->byId(CommandId::SaveFile);
uiCtx->executeCommand(saveCommand);
}
@ -128,8 +129,7 @@ void Sprite_saveAs(script::ContextHandle handle)
uiCtx->setActiveDocument(doc);
Command* saveCommand =
CommandsModule::instance()->getCommandByName(
CommandId::SaveFile);
Commands::instance()->byId(CommandId::SaveFile);
Params params;
doc->setFilename(fn);
@ -153,8 +153,7 @@ void Sprite_saveCopyAs(script::ContextHandle handle)
uiCtx->setActiveDocument(doc);
Command* saveCommand =
CommandsModule::instance()->getCommandByName(
CommandId::SaveFileCopyAs);
Commands::instance()->byId(CommandId::SaveFileCopyAs);
Params params;
params.set("filename", fn);

View File

@ -126,13 +126,13 @@ private:
Params params;
params.set("change", "custom");
params.set("slot", base::convert_to<std::string>(m_slot).c_str());
Command* cmd = CommandsModule::instance()->getCommandByName(CommandId::ChangeBrush);
Command* cmd = Commands::instance()->byId(CommandId::ChangeBrush);
cmd->loadParams(params);
std::string search = cmd->friendlyName();
if (!search.empty()) {
params.clear();
params.set("search", search.c_str());
cmd = CommandsModule::instance()->getCommandByName(CommandId::KeyboardShortcuts);
cmd = Commands::instance()->byId(CommandId::KeyboardShortcuts);
ASSERT(cmd);
if (cmd)
UIContext::instance()->executeCommand(cmd, params);

View File

@ -1116,7 +1116,7 @@ void ColorBar::onFixWarningClick(ColorButton* colorButton, ui::Button* warningIc
Palette* palette = get_current_palette();
const int oldEntries = palette->size();
Command* command = CommandsModule::instance()->getCommandByName(CommandId::AddColor);
Command* command = Commands::instance()->byId(CommandId::AddColor);
Params params;
params.set("source", "color");
params.set("color", colorButton->getColor().toString().c_str());

View File

@ -91,7 +91,7 @@ private:
switch (selectedItem()) {
case 0: {
cmd = CommandsModule::instance()->getCommandByName(CommandId::Zoom);
cmd = Commands::instance()->byId(CommandId::Zoom);
params.set("action", "set");
params.set("percentage", "100");
params.set("focus", "center");
@ -100,12 +100,12 @@ private:
}
case 1: {
cmd = CommandsModule::instance()->getCommandByName(CommandId::ScrollCenter);
cmd = Commands::instance()->byId(CommandId::ScrollCenter);
break;
}
case 2: {
cmd = CommandsModule::instance()->getCommandByName(CommandId::FitScreen);
cmd = Commands::instance()->byId(CommandId::FitScreen);
break;
}
}
@ -129,8 +129,8 @@ protected:
void onItemChange(Item* item) override {
ButtonSet::onItemChange(item);
Command* discardBrush = CommandsModule::instance()
->getCommandByName(CommandId::DiscardBrush);
Command* discardBrush = Commands::instance()
->byId(CommandId::DiscardBrush);
UIContext::instance()->executeCommand(discardBrush);
}
};

View File

@ -309,7 +309,7 @@ bool DocumentView::onCloseView(Workspace* workspace, bool quitting)
ctx->updateFlags();
Command* save_command =
CommandsModule::instance()->getCommandByName(CommandId::SaveFile);
Commands::instance()->byId(CommandId::SaveFile);
ctx->executeCommand(save_command);
try_again = true;
@ -579,7 +579,7 @@ void DocumentView::onCancel(Context* ctx)
// Deselect mask
if (ctx->checkFlags(ContextFlags::ActiveDocumentIsWritable |
ContextFlags::HasVisibleMask)) {
Command* deselectMask = CommandsModule::instance()->getCommandByName(CommandId::DeselectMask);
Command* deselectMask = Commands::instance()->byId(CommandId::DeselectMask);
ctx->executeCommand(deselectMask);
}
}

View File

@ -423,7 +423,7 @@ bool MovingPixelsState::onKeyDown(Editor* editor, KeyMessage* msg)
// The escape key drop pixels and deselect the mask.
if (msg->scancode() == kKeyEsc) { // TODO make this key customizable
Command* cmd = CommandsModule::instance()->getCommandByName(CommandId::DeselectMask);
Command* cmd = Commands::instance()->byId(CommandId::DeselectMask);
UIContext::instance()->executeCommand(cmd);
}

View File

@ -378,7 +378,7 @@ bool StandbyState::onDoubleClick(Editor* editor, MouseMessage* msg)
// Select a tile with double-click
if (ink->isSelection()) {
Command* selectTileCmd =
CommandsModule::instance()->getCommandByName(CommandId::SelectTile);
Commands::instance()->byId(CommandId::SelectTile);
Params params;
if (int(editor->getToolLoopModifiers()) & int(tools::ToolLoopModifiers::kAddSelection))
@ -740,7 +740,7 @@ void StandbyState::callEyedropper(Editor* editor)
return;
Command* eyedropper_cmd =
CommandsModule::instance()->getCommandByName(CommandId::Eyedropper);
Commands::instance()->byId(CommandId::Eyedropper);
bool fg = (static_cast<tools::PickInk*>(clickedInk)->target() == tools::PickInk::Fg);
Params params;

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2016 David Capello
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -117,9 +117,9 @@ bool StateWithWheelBehavior::onMouseWheel(Editor* editor, MouseMessage* msg)
Command* command = nullptr;
if (dz < 0.0)
command = CommandsModule::instance()->getCommandByName(CommandId::GotoNextFrame);
command = Commands::instance()->byId(CommandId::GotoNextFrame);
else if (dz > 0.0)
command = CommandsModule::instance()->getCommandByName(CommandId::GotoPreviousFrame);
command = Commands::instance()->byId(CommandId::GotoPreviousFrame);
if (command)
UIContext::instance()->executeCommand(command);

View File

@ -113,13 +113,13 @@ void HomeView::onWorkspaceViewSelected()
void HomeView::onNewFile()
{
Command* command = CommandsModule::instance()->getCommandByName(CommandId::NewFile);
Command* command = Commands::instance()->byId(CommandId::NewFile);
UIContext::instance()->executeCommand(command);
}
void HomeView::onOpenFile()
{
Command* command = CommandsModule::instance()->getCommandByName(CommandId::OpenFile);
Command* command = Commands::instance()->byId(CommandId::OpenFile);
UIContext::instance()->executeCommand(command);
}

View File

@ -318,7 +318,7 @@ void KeyboardShortcuts::importFile(TiXmlElement* rootElement, KeySource source)
bool removed = bool_attr_is_true(xmlKey, "removed");
if (command_name) {
Command* command = CommandsModule::instance()->getCommandByName(command_name);
Command* command = Commands::instance()->byId(command_name);
if (command) {
// Read context
KeyContext keycontext = KeyContext::Any;
@ -559,7 +559,7 @@ void KeyboardShortcuts::reset()
Key* KeyboardShortcuts::command(const char* commandName, const Params& params, KeyContext keyContext)
{
Command* command = CommandsModule::instance()->getCommandByName(commandName);
Command* command = Commands::instance()->byId(commandName);
if (!command)
return NULL;

View File

@ -436,7 +436,7 @@ void MainWindow::onTabsContainerDoubleClicked(Tabs* tabs)
WorkspaceView* oldActiveView = mainPanel->activeView();
app::Document* oldDoc = static_cast<app::Document*>(UIContext::instance()->activeDocument());
Command* command = CommandsModule::instance()->getCommandByName(CommandId::NewFile);
Command* command = Commands::instance()->byId(CommandId::NewFile);
UIContext::instance()->executeCommand(command);
app::Document* newDoc = static_cast<app::Document*>(UIContext::instance()->activeDocument());

View File

@ -108,7 +108,7 @@ void PalettePopup::onLoadPal()
return;
SetPaletteCommand* cmd = static_cast<SetPaletteCommand*>(
CommandsModule::instance()->getCommandByName(CommandId::SetPalette));
Commands::instance()->byId(CommandId::SetPalette));
cmd->setPalette(palette);
UIContext::instance()->executeCommand(cmd);

View File

@ -146,7 +146,7 @@ void RecentFilesListBox::onRebuildList()
void RecentFilesListBox::onClick(const std::string& path)
{
Command* command = CommandsModule::instance()->getCommandByName(CommandId::OpenFile);
Command* command = Commands::instance()->byId(CommandId::OpenFile);
Params params;
params.set("filename", path.c_str());
UIContext::instance()->executeCommand(command, params);
@ -171,7 +171,7 @@ void RecentFoldersListBox::onRebuildList()
void RecentFoldersListBox::onClick(const std::string& path)
{
Command* command = CommandsModule::instance()->getCommandByName(CommandId::OpenFile);
Command* command = Commands::instance()->byId(CommandId::OpenFile);
Params params;
params.set("folder", path.c_str());
UIContext::instance()->executeCommand(command, params);

View File

@ -510,7 +510,7 @@ public:
if (hasFocus() &&
(scancode == kKeyEnter || // TODO customizable keys
scancode == kKeyEnterPad)) {
Command* cmd = CommandsModule::instance()->getCommandByName(CommandId::GotoFrame);
Command* cmd = Commands::instance()->byId(CommandId::GotoFrame);
Params params;
params.set("frame", text().c_str());
UIContext::instance()->executeCommand(cmd, params);
@ -806,7 +806,7 @@ void StatusBar::onPixelFormatChanged(DocumentEvent& ev)
void StatusBar::newFrame()
{
Command* cmd = CommandsModule::instance()->getCommandByName(CommandId::NewFrame);
Command* cmd = Commands::instance()->byId(CommandId::NewFrame);
UIContext::instance()->executeCommand(cmd);
}

View File

@ -82,7 +82,7 @@ void AniControls::onClickButton()
int item = selectedItem();
deselectItems();
Command* cmd = CommandsModule::instance()->getCommandByName(getCommandId(item));
Command* cmd = Commands::instance()->byId(getCommandId(item));
if (cmd) {
UIContext::instance()->executeCommand(cmd);
updateUsingEditor(current_editor);
@ -116,7 +116,7 @@ std::string AniControls::getTooltipFor(int index) const
{
std::string tooltip;
Command* cmd = CommandsModule::instance()->getCommandByName(getCommandId(index));
Command* cmd = Commands::instance()->byId(getCommandId(index));
if (cmd) {
tooltip = cmd->friendlyName();

View File

@ -1049,8 +1049,8 @@ bool Timeline::onProcessMessage(Message* msg)
}
}
else if (mouseMsg->left()) {
Command* command = CommandsModule::instance()
->getCommandByName(CommandId::FrameTagProperties);
Command* command = Commands::instance()
->byId(CommandId::FrameTagProperties);
UIContext::instance()->executeCommand(command, params);
}
}
@ -1103,16 +1103,16 @@ bool Timeline::onProcessMessage(Message* msg)
switch (m_hot.part) {
case PART_ROW_TEXT: {
Command* command = CommandsModule::instance()
->getCommandByName(CommandId::LayerProperties);
Command* command = Commands::instance()
->byId(CommandId::LayerProperties);
UIContext::instance()->executeCommand(command);
return true;
}
case PART_HEADER_FRAME: {
Command* command = CommandsModule::instance()
->getCommandByName(CommandId::FrameProperties);
Command* command = Commands::instance()
->byId(CommandId::FrameProperties);
Params params;
params.set("frame", "current");
@ -1121,8 +1121,8 @@ bool Timeline::onProcessMessage(Message* msg)
}
case PART_CEL: {
Command* command = CommandsModule::instance()
->getCommandByName(CommandId::CelProperties);
Command* command = Commands::instance()
->byId(CommandId::CelProperties);
UIContext::instance()->executeCommand(command);
return true;
@ -3609,13 +3609,13 @@ bool Timeline::onClear(Context* ctx)
switch (m_range.type()) {
case DocumentRange::kCels:
cmd = CommandsModule::instance()->getCommandByName(CommandId::ClearCel);
cmd = Commands::instance()->byId(CommandId::ClearCel);
break;
case DocumentRange::kFrames:
cmd = CommandsModule::instance()->getCommandByName(CommandId::RemoveFrame);
cmd = Commands::instance()->byId(CommandId::RemoveFrame);
break;
case DocumentRange::kLayers:
cmd = CommandsModule::instance()->getCommandByName(CommandId::RemoveLayer);
cmd = Commands::instance()->byId(CommandId::RemoveLayer);
break;
}