mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-01 01:13:40 +00:00
Move keyboard shortcuts to change pen size from Editor widget to commands.
* Now +/- keys are configurable because they are defined in gui.xml as calls to the new "change_pen" command.
This commit is contained in:
parent
b1e96b8e84
commit
d9790b3834
48
data/gui.xml
48
data/gui.xml
@ -1,10 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- ASE menus, tools and keyboard shortcuts -->
|
||||
<gui>
|
||||
<!-- keyboard shortcuts -->
|
||||
<!-- Keyboard shortcuts -->
|
||||
<keyboard>
|
||||
|
||||
<!-- Keyboard shortcuts for commands (menu options) -->
|
||||
<commands>
|
||||
<!-- file -->
|
||||
<!-- File -->
|
||||
<key command="new_file" shortcut="Ctrl+N" />
|
||||
<key command="open_file" shortcut="Ctrl+O" />
|
||||
<key command="save_file" shortcut="Ctrl+S" />
|
||||
@ -15,7 +17,7 @@
|
||||
<key command="screen_shot" shortcut="F12" />
|
||||
<key command="exit" shortcut="Ctrl+Q" />
|
||||
<key command="exit" shortcut="Esc" />
|
||||
<!-- edit -->
|
||||
<!-- Edit -->
|
||||
<key command="undo" shortcut="Ctrl+Z" /> <key command="undo" shortcut="Ctrl+U" />
|
||||
<key command="redo" shortcut="Ctrl+R" />
|
||||
<key command="redo" shortcut="Ctrl+Shift+Z" />
|
||||
@ -33,14 +35,19 @@
|
||||
</key>
|
||||
<key command="replace_color" shortcut="Shift+R" />
|
||||
<key command="invert_color" shortcut="Ctrl+I" />
|
||||
<!-- sprite -->
|
||||
<key command="convolution_matrix" shortcut="F9" />
|
||||
<key command="color_curve" shortcut="Ctrl+M" />
|
||||
<key command="color_curve" shortcut="F10" />
|
||||
<key command="configure_tools" shortcut="C" />
|
||||
<key command="options" shortcut="Ctrl+Shift+O" />
|
||||
<!-- Sprite -->
|
||||
<key command="sprite_properties" shortcut="Ctrl+P" />
|
||||
<!-- layer -->
|
||||
<!-- Layer -->
|
||||
<key command="layer_properties" shortcut="Shift+P" />
|
||||
<key command="new_layer" shortcut="Shift+N" />
|
||||
<key command="goto_previous_layer" shortcut="Down" />
|
||||
<key command="goto_next_layer" shortcut="Up" />
|
||||
<!-- frame -->
|
||||
<!-- Frame -->
|
||||
<key command="new_frame" shortcut="N" />
|
||||
<key command="frame_properties" shortcut="P" />
|
||||
<key command="goto_first_frame" shortcut="Home" />
|
||||
@ -48,12 +55,12 @@
|
||||
<key command="goto_next_frame" shortcut="Right" />
|
||||
<key command="goto_last_frame" shortcut="End" />
|
||||
<key command="play_animation" shortcut="Enter" />
|
||||
<!-- mask -->
|
||||
<!-- Select -->
|
||||
<key command="mask_all" shortcut="Ctrl+A" />
|
||||
<key command="deselect_mask" shortcut="Ctrl+D" />
|
||||
<key command="reselect_mask" shortcut="Ctrl+Shift+D" />
|
||||
<key command="invert_mask" shortcut="Ctrl+Shift+I" />
|
||||
<!-- view -->
|
||||
<!-- View -->
|
||||
<key command="refresh" shortcut="F5" />
|
||||
<key command="make_unique_editor" shortcut="Ctrl+1" />
|
||||
<key command="split_editor_vertically" shortcut="Ctrl+2" />
|
||||
@ -62,18 +69,11 @@
|
||||
<key command="preview" shortcut="F8" />
|
||||
<key command="show_grid" shortcut="Shift+G" />
|
||||
<key command="snap_to_grid" shortcut="Shift+S" />
|
||||
<!-- tools -->
|
||||
<key command="configure_tools" shortcut="C" />
|
||||
<key command="film_editor" shortcut="Tab" />
|
||||
<key command="palette_editor" shortcut="F4">
|
||||
<param name="switch" value="true" />
|
||||
</key>
|
||||
<key command="convolution_matrix" shortcut="F9" />
|
||||
<key command="color_curve" shortcut="Ctrl+M" />
|
||||
<key command="color_curve" shortcut="F10" />
|
||||
<key command="options" shortcut="Ctrl+Shift+O" />
|
||||
|
||||
<!-- others -->
|
||||
<!-- Others -->
|
||||
<key command="switch_colors" shortcut="X" />
|
||||
<key command="change_color" shortcut="9">
|
||||
<param name="target" value="foreground" />
|
||||
@ -99,7 +99,23 @@
|
||||
<param name="target" value="background" />
|
||||
<param name="change" value="increment-index" />
|
||||
</key>
|
||||
|
||||
<!-- Modify pen size with +/- signs -->
|
||||
<key command="change_pen" shortcut="+">
|
||||
<param name="change" value="increment-size" />
|
||||
</key>
|
||||
<key command="change_pen" shortcut="-">
|
||||
<param name="change" value="decrement-size" />
|
||||
</key>
|
||||
<key command="change_pen" shortcut="Plus Pad">
|
||||
<param name="change" value="increment-size" />
|
||||
</key>
|
||||
<key command="change_pen" shortcut="Minus Pad">
|
||||
<param name="change" value="decrement-size" />
|
||||
</key>
|
||||
</commands>
|
||||
|
||||
<!-- Keyboard shortcuts to select tools -->
|
||||
<tools>
|
||||
<key tool="rectangular_marquee" shortcut="M" />
|
||||
<key tool="elliptical_marquee" shortcut="M" />
|
||||
|
@ -25,6 +25,7 @@ COMMON_SOURCES = \
|
||||
src/commands/cmd_cel_properties.cpp \
|
||||
src/commands/cmd_change_color.cpp \
|
||||
src/commands/cmd_change_image_type.cpp \
|
||||
src/commands/cmd_change_pen.cpp \
|
||||
src/commands/cmd_check_updates.cpp \
|
||||
src/commands/cmd_clear.cpp \
|
||||
src/commands/cmd_close_file.cpp \
|
||||
|
@ -47,6 +47,7 @@ add_executable(aseprite WIN32
|
||||
commands/cmd_cel_properties.cpp
|
||||
commands/cmd_change_color.cpp
|
||||
commands/cmd_change_image_type.cpp
|
||||
commands/cmd_change_pen.cpp
|
||||
commands/cmd_check_updates.cpp
|
||||
commands/cmd_clear.cpp
|
||||
commands/cmd_close_file.cpp
|
||||
|
90
src/commands/cmd_change_pen.cpp
Normal file
90
src/commands/cmd_change_pen.cpp
Normal file
@ -0,0 +1,90 @@
|
||||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2010 David Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "app.h"
|
||||
#include "commands/command.h"
|
||||
#include "commands/params.h"
|
||||
#include "context.h"
|
||||
#include "settings/settings.h"
|
||||
#include "tools/tool.h"
|
||||
|
||||
class ChangePenCommand : public Command
|
||||
{
|
||||
enum Change {
|
||||
None,
|
||||
IncrementSize,
|
||||
DecrementSize,
|
||||
};
|
||||
|
||||
Change m_change;
|
||||
|
||||
public:
|
||||
ChangePenCommand();
|
||||
|
||||
protected:
|
||||
void onLoadParams(Params* params);
|
||||
void onExecute(Context* context);
|
||||
};
|
||||
|
||||
ChangePenCommand::ChangePenCommand()
|
||||
: Command("change_pen",
|
||||
"Change Pen",
|
||||
CmdUIOnlyFlag)
|
||||
{
|
||||
m_change = None;
|
||||
}
|
||||
|
||||
void ChangePenCommand::onLoadParams(Params* params)
|
||||
{
|
||||
std::string change = params->get("change");
|
||||
if (change == "increment-size") m_change = IncrementSize;
|
||||
else if (change == "decrement-size") m_change = DecrementSize;
|
||||
}
|
||||
|
||||
void ChangePenCommand::onExecute(Context* context)
|
||||
{
|
||||
Tool* current_tool = context->getSettings()->getCurrentTool();
|
||||
IToolSettings* tool_settings = context->getSettings()->getToolSettings(current_tool);
|
||||
IPenSettings* pen = tool_settings->getPen();
|
||||
|
||||
switch (m_change) {
|
||||
case None:
|
||||
// Do nothing
|
||||
break;
|
||||
case IncrementSize:
|
||||
if (pen->getSize() < 32)
|
||||
pen->setSize(pen->getSize()+1);
|
||||
break;
|
||||
case DecrementSize:
|
||||
if (pen->getSize() > 1)
|
||||
pen->setSize(pen->getSize()-1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// CommandFactory
|
||||
|
||||
Command* CommandFactory::create_change_pen_command()
|
||||
{
|
||||
return new ChangePenCommand;
|
||||
}
|
@ -24,6 +24,7 @@ FOR_EACH_COMMAND(canvas_size)
|
||||
FOR_EACH_COMMAND(cel_properties)
|
||||
FOR_EACH_COMMAND(change_color)
|
||||
FOR_EACH_COMMAND(change_image_type)
|
||||
FOR_EACH_COMMAND(change_pen)
|
||||
FOR_EACH_COMMAND(check_updates)
|
||||
FOR_EACH_COMMAND(clear)
|
||||
FOR_EACH_COMMAND(close_all_files)
|
||||
|
@ -118,39 +118,35 @@ static void proc_one_word(JAccel accel, char *word)
|
||||
int scancode = 0;
|
||||
char* tok;
|
||||
|
||||
// Special case: plus sign
|
||||
if (word[0] == '+' && word[1] == 0) {
|
||||
jaccel_add_key(accel, 0, '+', 0);
|
||||
return;
|
||||
}
|
||||
|
||||
for (tok=ustrtok(word, "+"); tok;
|
||||
tok=ustrtok(NULL, "+")) {
|
||||
/************************************************************************/
|
||||
/* key_shifts */
|
||||
// key_shifts
|
||||
|
||||
if (ustricmp (tok, "Shift") == 0)
|
||||
if (ustricmp (tok, "Shift") == 0) {
|
||||
shifts |= KB_SHIFT_FLAG;
|
||||
else if (ustricmp (tok, "Ctrl") == 0)
|
||||
}
|
||||
else if (ustricmp (tok, "Ctrl") == 0) {
|
||||
shifts |= KB_CTRL_FLAG;
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
/* scancode */
|
||||
// scancode
|
||||
|
||||
/* word with one character */
|
||||
// word with one character
|
||||
else if (tok[1] == 0) {
|
||||
#if 1
|
||||
if (((*tok >= 'a') && (*tok <= 'z')) ||
|
||||
((*tok >= 'A') && (*tok <= 'Z'))) {
|
||||
/* if (shifts & KB_CTRL_FLAG) */
|
||||
/* ascii = tolower(*tok) - 'a' + 1; */
|
||||
/* else */
|
||||
ascii = tolower(*tok);
|
||||
}
|
||||
/* else if ((*tok >= '0') && (*tok <= '9')) { */
|
||||
/* if (shifts & KB_CTRL_FLAG) */
|
||||
/* scancode = KEY_0 + *tok - '0'; */
|
||||
/* else */
|
||||
/* ascii = *tok; */
|
||||
/* } */
|
||||
else {
|
||||
ascii = *tok;
|
||||
}
|
||||
#else
|
||||
|
||||
if (((*tok >= 'a') && (*tok <= 'z')) ||
|
||||
((*tok >= 'A') && (*tok <= 'Z')))
|
||||
scancode = KEY_A + tolower(*tok) - 'a';
|
||||
@ -169,9 +165,9 @@ static void proc_one_word(JAccel accel, char *word)
|
||||
case ',': scancode = KEY_COMMA; break;
|
||||
case '.': scancode = KEY_STOP; break;
|
||||
case '/': scancode = KEY_SLASH; break;
|
||||
case '*': scancode = KEY_ASTERISK; break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/* other ones */
|
||||
else {
|
||||
@ -181,7 +177,8 @@ static void proc_one_word(JAccel accel, char *word)
|
||||
if ((num >= 1) && (num <= 12))
|
||||
scancode = KEY_F1 + num - 1;
|
||||
}
|
||||
else if (ustricmp(tok, "Esc") == 0)
|
||||
else if ((ustricmp(tok, "Escape") == 0) ||
|
||||
(ustricmp(tok, "Esc") == 0))
|
||||
scancode = KEY_ESC;
|
||||
else if (ustricmp(tok, "Backspace") == 0)
|
||||
scancode = KEY_BACKSPACE;
|
||||
@ -201,9 +198,11 @@ static void proc_one_word(JAccel accel, char *word)
|
||||
scancode = KEY_HOME;
|
||||
else if (ustricmp(tok, "End") == 0)
|
||||
scancode = KEY_END;
|
||||
else if (ustricmp(tok, "PgUp") == 0)
|
||||
else if ((ustricmp(tok, "Page Up") == 0) ||
|
||||
(ustricmp(tok, "PgUp") == 0))
|
||||
scancode = KEY_PGUP;
|
||||
else if (ustricmp(tok, "PgDn") == 0)
|
||||
else if ((ustricmp(tok, "Page Down") == 0) ||
|
||||
(ustricmp(tok, "PgDn") == 0))
|
||||
scancode = KEY_PGDN;
|
||||
else if (ustricmp(tok, "Left") == 0)
|
||||
scancode = KEY_LEFT;
|
||||
@ -213,8 +212,36 @@ static void proc_one_word(JAccel accel, char *word)
|
||||
scancode = KEY_UP;
|
||||
else if (ustricmp(tok, "Down") == 0)
|
||||
scancode = KEY_DOWN;
|
||||
|
||||
/* TODO all "Pad" stuff and "PrtScr" and "Pause" */
|
||||
else if (ustricmp(tok, "0 Pad") == 0)
|
||||
scancode = KEY_0_PAD;
|
||||
else if (ustricmp(tok, "1 Pad") == 0)
|
||||
scancode = KEY_1_PAD;
|
||||
else if (ustricmp(tok, "2 Pad") == 0)
|
||||
scancode = KEY_2_PAD;
|
||||
else if (ustricmp(tok, "3 Pad") == 0)
|
||||
scancode = KEY_3_PAD;
|
||||
else if (ustricmp(tok, "4 Pad") == 0)
|
||||
scancode = KEY_4_PAD;
|
||||
else if (ustricmp(tok, "5 Pad") == 0)
|
||||
scancode = KEY_5_PAD;
|
||||
else if (ustricmp(tok, "6 Pad") == 0)
|
||||
scancode = KEY_6_PAD;
|
||||
else if (ustricmp(tok, "7 Pad") == 0)
|
||||
scancode = KEY_7_PAD;
|
||||
else if (ustricmp(tok, "8 Pad") == 0)
|
||||
scancode = KEY_8_PAD;
|
||||
else if (ustricmp(tok, "9 Pad") == 0)
|
||||
scancode = KEY_9_PAD;
|
||||
else if (ustricmp(tok, "Slash Pad") == 0)
|
||||
scancode = KEY_SLASH_PAD;
|
||||
else if (ustricmp(tok, "Asterisk") == 0)
|
||||
scancode = KEY_ASTERISK;
|
||||
else if (ustricmp(tok, "Minus Pad") == 0)
|
||||
scancode = KEY_MINUS_PAD;
|
||||
else if (ustricmp(tok, "Plus Pad") == 0)
|
||||
scancode = KEY_PLUS_PAD;
|
||||
else if (ustricmp(tok, "Del Pad") == 0)
|
||||
scancode = KEY_DEL_PAD;
|
||||
else if (ustricmp(tok, "Enter Pad") == 0)
|
||||
scancode = KEY_ENTER_PAD;
|
||||
}
|
||||
|
@ -175,7 +175,6 @@ private:
|
||||
// keys.c
|
||||
|
||||
bool editor_keys_toset_zoom(int scancode);
|
||||
bool editor_keys_toset_pensize(int scancode);
|
||||
|
||||
public:
|
||||
|
||||
|
@ -1306,8 +1306,7 @@ bool Editor::onProcessMessage(JMessage msg)
|
||||
case JM_KEYPRESSED:
|
||||
if (m_state == EDITOR_STATE_STANDBY ||
|
||||
m_state == EDITOR_STATE_DRAWING) {
|
||||
if (editor_keys_toset_zoom(msg->key.scancode) ||
|
||||
editor_keys_toset_pensize(msg->key.scancode))
|
||||
if (editor_keys_toset_zoom(msg->key.scancode))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -69,29 +69,3 @@ bool Editor::editor_keys_toset_zoom(int scancode)
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Editor::editor_keys_toset_pensize(int scancode)
|
||||
{
|
||||
Tool* current_tool = UIContext::instance()->getSettings()->getCurrentTool();
|
||||
IToolSettings* tool_settings = UIContext::instance()->getSettings()->getToolSettings(current_tool);
|
||||
IPenSettings* pen = tool_settings->getPen();
|
||||
|
||||
if ((m_sprite) &&
|
||||
(this->hasMouse()) &&
|
||||
!(key_shifts & (KB_SHIFT_FLAG | KB_CTRL_FLAG | KB_ALT_FLAG))) {
|
||||
if (scancode == KEY_MINUS_PAD) { // TODO configurable keys
|
||||
if (pen->getSize() > 1) {
|
||||
pen->setSize(pen->getSize()-1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (scancode == KEY_PLUS_PAD) {
|
||||
if (pen->getSize() < 32) {
|
||||
pen->setSize(pen->getSize()+1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user