mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-12 07:13:23 +00:00
Disable quicktool when the mouse wheel is used with a modifier that active an "wheel action" for the selected tool
If we assign Ctrl to change brush size, and Ctrl to quickly select Move tool, when we press Ctrl (quicktool=Move) and use the mouse wheel to change the brush size, we prefer to see the selected tool (e.g. Pencil tool) instead of the quicktool (Move tool).
This commit is contained in:
parent
3c8220aa7d
commit
f4db850fb4
@ -1881,7 +1881,10 @@ void Editor::onInvalidateRegion(const gfx::Region& region)
|
||||
void Editor::onActiveToolChange(tools::Tool* tool)
|
||||
{
|
||||
m_state->onActiveToolChange(this, tool);
|
||||
updateStatusBar();
|
||||
if (hasMouse()) {
|
||||
updateStatusBar();
|
||||
setCursor(ui::get_mouse_position());
|
||||
}
|
||||
}
|
||||
|
||||
void Editor::onFgColorChange()
|
||||
@ -1960,6 +1963,10 @@ void Editor::onRemoveFrameTag(DocEvent& ev)
|
||||
|
||||
void Editor::setCursor(const gfx::Point& mouseScreenPos)
|
||||
{
|
||||
Rect vp = View::getView(this)->viewportBounds();
|
||||
if (!vp.contains(mouseScreenPos))
|
||||
return;
|
||||
|
||||
bool used = false;
|
||||
if (m_sprite)
|
||||
used = m_state->onSetCursor(this, mouseScreenPos);
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "doc/layer.h"
|
||||
#include "doc/palette.h"
|
||||
#include "ui/message.h"
|
||||
#include "ui/system.h"
|
||||
#include "ui/theme.h"
|
||||
|
||||
namespace app {
|
||||
@ -178,7 +179,7 @@ bool StateWithWheelBehavior::onMouseWheel(Editor* editor, MouseMessage* msg)
|
||||
}
|
||||
|
||||
case WheelAction::BrushSize: {
|
||||
tools::Tool* tool = App::instance()->activeToolManager()->activeTool();
|
||||
tools::Tool* tool = getActiveTool();
|
||||
ToolPreferences::Brush& brush =
|
||||
Preferences::instance().tool(tool).brush;
|
||||
|
||||
@ -189,7 +190,7 @@ bool StateWithWheelBehavior::onMouseWheel(Editor* editor, MouseMessage* msg)
|
||||
}
|
||||
|
||||
case WheelAction::BrushAngle: {
|
||||
tools::Tool* tool = App::instance()->activeToolManager()->activeTool();
|
||||
tools::Tool* tool = getActiveTool();
|
||||
ToolPreferences::Brush& brush =
|
||||
Preferences::instance().tool(tool).brush;
|
||||
|
||||
@ -203,7 +204,7 @@ bool StateWithWheelBehavior::onMouseWheel(Editor* editor, MouseMessage* msg)
|
||||
}
|
||||
|
||||
case WheelAction::ToolSameGroup: {
|
||||
tools::Tool* tool = App::instance()->activeToolManager()->selectedTool();
|
||||
tools::Tool* tool = getActiveTool();
|
||||
|
||||
auto toolBox = App::instance()->toolBox();
|
||||
std::vector<tools::Tool*> tools;
|
||||
@ -233,7 +234,7 @@ bool StateWithWheelBehavior::onMouseWheel(Editor* editor, MouseMessage* msg)
|
||||
}
|
||||
|
||||
case WheelAction::ToolOtherGroup: {
|
||||
tools::Tool* tool = App::instance()->activeToolManager()->selectedTool();
|
||||
tools::Tool* tool = getActiveTool();
|
||||
auto toolBox = App::instance()->toolBox();
|
||||
auto begin = toolBox->begin_group();
|
||||
auto end = toolBox->end_group();
|
||||
@ -266,7 +267,7 @@ bool StateWithWheelBehavior::onMouseWheel(Editor* editor, MouseMessage* msg)
|
||||
}
|
||||
|
||||
case WheelAction::InkOpacity: {
|
||||
tools::Tool* tool = App::instance()->activeToolManager()->activeTool();
|
||||
tools::Tool* tool = getActiveTool();
|
||||
auto& toolPref = Preferences::instance().tool(tool);
|
||||
int opacity = toolPref.opacity();
|
||||
opacity = MID(0, opacity+dz*255/10, 255);
|
||||
@ -313,6 +314,8 @@ bool StateWithWheelBehavior::onMouseWheel(Editor* editor, MouseMessage* msg)
|
||||
}
|
||||
|
||||
case WheelAction::Alpha: {
|
||||
disableQuickTool();
|
||||
|
||||
ColorBar* colorBar = ColorBar::instance();
|
||||
Color c = colorBar->getFgColor();
|
||||
int a = c.getAlpha();
|
||||
@ -325,6 +328,8 @@ bool StateWithWheelBehavior::onMouseWheel(Editor* editor, MouseMessage* msg)
|
||||
case WheelAction::HslHue:
|
||||
case WheelAction::HslSaturation:
|
||||
case WheelAction::HslLightness: {
|
||||
disableQuickTool();
|
||||
|
||||
ColorBar* colorBar = ColorBar::instance();
|
||||
Color c = colorBar->getFgColor();
|
||||
double
|
||||
@ -345,6 +350,8 @@ bool StateWithWheelBehavior::onMouseWheel(Editor* editor, MouseMessage* msg)
|
||||
case WheelAction::HsvHue:
|
||||
case WheelAction::HsvSaturation:
|
||||
case WheelAction::HsvValue: {
|
||||
disableQuickTool();
|
||||
|
||||
ColorBar* colorBar = ColorBar::instance();
|
||||
Color c = colorBar->getFgColor();
|
||||
double
|
||||
@ -389,4 +396,21 @@ void StateWithWheelBehavior::setZoom(Editor* editor,
|
||||
Editor::ZoomBehavior::MOUSE));
|
||||
}
|
||||
|
||||
tools::Tool* StateWithWheelBehavior::getActiveTool()
|
||||
{
|
||||
disableQuickTool();
|
||||
return App::instance()->activeToolManager()->activeTool();
|
||||
}
|
||||
|
||||
void StateWithWheelBehavior::disableQuickTool()
|
||||
{
|
||||
auto atm = App::instance()->activeToolManager();
|
||||
if (atm->quickTool()) {
|
||||
// As Ctrl key could active the Move tool, and Ctrl+mouse wheel can
|
||||
// change the size of the tool, we want to remove the quick tool so
|
||||
// the effect is for the selected tool.
|
||||
atm->newQuickToolSelectedFromEditor(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace app
|
||||
|
@ -14,6 +14,10 @@ namespace render {
|
||||
class Zoom;
|
||||
}
|
||||
|
||||
namespace tools {
|
||||
class Tool;
|
||||
}
|
||||
|
||||
namespace app {
|
||||
|
||||
class StateWithWheelBehavior : public EditorState {
|
||||
@ -22,6 +26,8 @@ namespace app {
|
||||
virtual bool onTouchMagnify(Editor* editor, ui::TouchMessage* msg) override;
|
||||
private:
|
||||
void setZoom(Editor* editor, const render::Zoom& zoom, const gfx::Point& mousePos);
|
||||
tools::Tool* getActiveTool();
|
||||
void disableQuickTool();
|
||||
};
|
||||
|
||||
} // namespace app
|
||||
|
@ -1057,11 +1057,19 @@ LRESULT WinWindow::wndProc(UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
int vk = wparam;
|
||||
int scancode = (lparam >> 16) & 0xff;
|
||||
bool sendMsg = true;
|
||||
const KeyScancode sheScancode = win32vk_to_scancode(vk);
|
||||
|
||||
// We only create one KeyDown event for modifiers. Bit 30
|
||||
// indicates the previous state of the key, if the modifier was
|
||||
// already pressed don't generate the event.
|
||||
if ((sheScancode >= kKeyFirstModifierScancode) &&
|
||||
(lparam & (1 << 30)))
|
||||
return 0;
|
||||
|
||||
Event ev;
|
||||
ev.setType(Event::KeyDown);
|
||||
ev.setModifiers(get_modifiers_from_last_win32_message());
|
||||
ev.setScancode(win32vk_to_scancode(vk));
|
||||
ev.setScancode(sheScancode);
|
||||
ev.setUnicodeChar(0);
|
||||
ev.setRepeat(MAX(0, (lparam & 0xffff)-1));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user