mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-14 12:40:55 +00:00
Now Shift+V works correctly when we are moving pixels.
This commit is contained in:
parent
a27d1d3eeb
commit
2e87676d70
@ -181,7 +181,8 @@ void PreviewCommand::onExecute(Context* context)
|
||||
if (keypressed()) {
|
||||
int readkey_value = readkey();
|
||||
Message* msg = jmessage_new_key_related(JM_KEYPRESSED, readkey_value);
|
||||
Command* command = get_command_from_key_message(msg);
|
||||
Command* command = NULL;
|
||||
get_command_from_key_message(msg, &command, NULL);
|
||||
jmessage_free(msg);
|
||||
|
||||
// Change frame
|
||||
|
@ -698,7 +698,9 @@ bool AnimationEditor::onProcessMessage(Message* msg)
|
||||
break;
|
||||
|
||||
case JM_KEYPRESSED: {
|
||||
Command *command = get_command_from_key_message(msg);
|
||||
Command* command = NULL;
|
||||
Params* params = NULL;
|
||||
get_command_from_key_message(msg, &command, ¶ms);
|
||||
|
||||
// Close animation editor.
|
||||
if ((command && (strcmp(command->short_name(), CommandId::FilmEditor) == 0)) ||
|
||||
@ -757,7 +759,7 @@ bool AnimationEditor::onProcessMessage(Message* msg)
|
||||
strcmp(command->short_name(), CommandId::GotoNextLayer) == 0 ||
|
||||
strcmp(command->short_name(), CommandId::GotoLastFrame) == 0) {
|
||||
// execute the command
|
||||
UIContext::instance()->executeCommand(command);
|
||||
UIContext::instance()->executeCommand(command, params);
|
||||
|
||||
showCurrentCel();
|
||||
invalidate();
|
||||
|
@ -905,20 +905,19 @@ JAccel add_keyboard_shortcut_to_spriteeditor(const char* shortcut_string, const
|
||||
return shortcut->accel;
|
||||
}
|
||||
|
||||
Command* get_command_from_key_message(Message* msg)
|
||||
bool get_command_from_key_message(Message* msg, Command** command, Params** params)
|
||||
{
|
||||
for (std::vector<Shortcut*>::iterator
|
||||
it = shortcuts->begin(); it != shortcuts->end(); ++it) {
|
||||
Shortcut* shortcut = *it;
|
||||
|
||||
if (shortcut->type == Shortcut_ExecuteCommand &&
|
||||
// TODO why?
|
||||
// shortcut->argument.empty() &&
|
||||
shortcut->is_pressed(msg)) {
|
||||
return shortcut->command;
|
||||
if (shortcut->type == Shortcut_ExecuteCommand && shortcut->is_pressed(msg)) {
|
||||
if (command) *command = shortcut->command;
|
||||
if (params) *params = shortcut->params;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
JAccel get_accel_to_execute_command(const char* command_name, Params* params)
|
||||
|
@ -113,7 +113,7 @@ JAccel add_keyboard_shortcut_to_change_tool(const char* shortcut, tools::Tool* t
|
||||
JAccel add_keyboard_shortcut_to_quicktool(const char* shortcut, tools::Tool* tool);
|
||||
JAccel add_keyboard_shortcut_to_spriteeditor(const char* shortcut, const char* action_name);
|
||||
|
||||
Command* get_command_from_key_message(Message* msg);
|
||||
bool get_command_from_key_message(Message* msg, Command** command, Params** params);
|
||||
JAccel get_accel_to_execute_command(const char* command, Params* params = NULL);
|
||||
JAccel get_accel_to_change_tool(tools::Tool* tool);
|
||||
JAccel get_accel_to_copy_selection();
|
||||
|
@ -314,12 +314,13 @@ bool MovingPixelsState::onKeyDown(Editor* editor, Message* msg)
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
Command* cmd = get_command_from_key_message(msg);
|
||||
if (cmd) {
|
||||
Command* command = NULL;
|
||||
Params* params = NULL;
|
||||
if (get_command_from_key_message(msg, &command, ¶ms)) {
|
||||
// Intercept the "Cut" or "Copy" command to handle them locally
|
||||
// with the current m_pixelsMovement data.
|
||||
if (strcmp(cmd->short_name(), CommandId::Cut) == 0 ||
|
||||
strcmp(cmd->short_name(), CommandId::Copy) == 0) {
|
||||
if (strcmp(command->short_name(), CommandId::Cut) == 0 ||
|
||||
strcmp(command->short_name(), CommandId::Copy) == 0) {
|
||||
// Copy the floating image to the clipboard.
|
||||
{
|
||||
Document* document = editor->getDocument();
|
||||
@ -331,7 +332,7 @@ bool MovingPixelsState::onKeyDown(Editor* editor, Message* msg)
|
||||
}
|
||||
|
||||
// In case of "Cut" command.
|
||||
if (strcmp(cmd->short_name(), CommandId::Cut) == 0) {
|
||||
if (strcmp(command->short_name(), CommandId::Cut) == 0) {
|
||||
// Discard the dragged image.
|
||||
m_pixelsMovement->discardImage();
|
||||
m_discarded = true;
|
||||
@ -345,8 +346,9 @@ bool MovingPixelsState::onKeyDown(Editor* editor, Message* msg)
|
||||
}
|
||||
// Flip Horizontally/Vertically commands are handled manually to
|
||||
// avoid dropping the floating region of pixels.
|
||||
else if (strcmp(cmd->short_name(), CommandId::Flip) == 0) {
|
||||
if (FlipCommand* flipCommand = dynamic_cast<FlipCommand*>(cmd)) {
|
||||
else if (strcmp(command->short_name(), CommandId::Flip) == 0) {
|
||||
if (FlipCommand* flipCommand = dynamic_cast<FlipCommand*>(command)) {
|
||||
flipCommand->loadParams(params);
|
||||
m_pixelsMovement->flipImage(flipCommand->getFlipType());
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user