Fix several regressions with key shortcuts#5590
Conversation
Can be used for debugging purposes/log events.
…atest mouse down event (fix aseprite#5588) E.g. if we have a key like "F" assigned to quick select the eyedropper, when we click the left mouse button, we have to prioritize the quick tool selected with the "F" key, as the left mouse button alone doesn't have any modifier/no quick tool associated, it should just trigger the current quick tool. With this patch, the pressed shortcut with more modifiers wins over the shortcut with less modifiers to select a new quick tool.
…seprite#5589) The shift+pencil to paint a straight line wasn't making possible to associate a button like shift+x2 to (e.g.) drag the brush size.
aseprite-bot
left a comment
There was a problem hiding this comment.
clang-tidy made some suggestions
|
|
||
| atm->newQuickToolSelectedFromEditor(newQuicktool); | ||
| tools::Tool* prevQuicktool = atm->quickTool(); | ||
| ui::Shortcut prevShortcut = atm->quickToolFromShortcut(); |
There was a problem hiding this comment.
warning: variable 'prevShortcut' of type 'ui::Shortcut' can be declared 'const' [misc-const-correctness]
| ui::Shortcut prevShortcut = atm->quickToolFromShortcut(); | |
| ui::Shortcut const prevShortcut = atm->quickToolFromShortcut(); |
| } | ||
|
|
||
| bool StandbyState::handleDragActionsFromMessage(Editor* editor, const ui::Message* msg) | ||
| EditorStatePtr StandbyState::handleDragActionsFromMessage(Editor* editor, const ui::Message* msg) |
There was a problem hiding this comment.
warning: method 'handleDragActionsFromMessage' can be made static [readability-convert-member-functions-to-static]
src/app/ui/editor/standby_state.h:58:
- EditorStatePtr handleDragActionsFromMessage(Editor* editor, const ui::Message* msg);
+ static EditorStatePtr handleDragActionsFromMessage(Editor* editor, const ui::Message* msg);| if (hasFocus() && !isReadOnly()) { | ||
| KeyMessage* keymsg = static_cast<KeyMessage*>(msg); | ||
| if (!keymsg->scancode() && keymsg->unicodeChar() < 32) | ||
| Shortcut shortcut = msg->shortcut(); |
There was a problem hiding this comment.
warning: variable 'shortcut' of type 'Shortcut' can be declared 'const' [misc-const-correctness]
| Shortcut shortcut = msg->shortcut(); | |
| Shortcut const shortcut = msg->shortcut(); |
| case kKeyRControl: newModifier = kKeyCtrlModifier; break; | ||
| case kKeyAlt: newModifier = kKeyAltModifier; break; | ||
| case kKeyAltGr: | ||
| newModifier = (KeyModifiers)((int)kKeyAltModifier | (int)kKeyCtrlModifier); |
There was a problem hiding this comment.
warning: The value '6' provided to the cast expression is not in the valid range of values for 'KeyModifiers' [clang-analyzer-optin.core.EnumCastOutOfRange]
newModifier = (KeyModifiers)((int)kKeyAltModifier | (int)kKeyCtrlModifier);
^Additional context
laf/os/keys.h:12: enum declared here
enum KeyModifiers {
^src/ui/shortcut.cpp:408: Control jumps to 'case kKeyAltGr:' at line 415
switch (m_scancode) {
^src/ui/shortcut.cpp:415: The value '6' provided to the cast expression is not in the valid range of values for 'KeyModifiers'
newModifier = (KeyModifiers)((int)kKeyAltModifier | (int)kKeyCtrlModifier);
^
fix #5585
fix #5588
fix #5589
fix #5591