mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-06 07:13:20 +00:00
Add immediate feedback when Ctrl/Shift modifiers are pressed in TwoPointsController
This commit is contained in:
parent
c0ce7e8cad
commit
b9e362ac5c
@ -33,9 +33,10 @@ namespace app {
|
||||
|
||||
virtual void prepareController() { }
|
||||
|
||||
// Called when the user presses or releases a key.
|
||||
virtual void pressKey(ui::KeyScancode key) { }
|
||||
virtual void releaseKey(ui::KeyScancode key) { }
|
||||
// Called when the user presses or releases a key. Returns true
|
||||
// if the key is used (so a new mouse point is generated).
|
||||
virtual bool pressKey(ui::KeyScancode key) { return false; }
|
||||
virtual bool releaseKey(ui::KeyScancode key) { return false; }
|
||||
|
||||
// Called when the user starts drawing and each time a new button is
|
||||
// pressed. The controller could be sure that this method is called
|
||||
|
@ -75,14 +75,14 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
void pressKey(ui::KeyScancode key) override {
|
||||
bool pressKey(ui::KeyScancode key) override {
|
||||
TRACE("pressKey(%d)\n", key);
|
||||
processKey(key, true);
|
||||
return processKey(key, true);
|
||||
}
|
||||
|
||||
void releaseKey(ui::KeyScancode key) override {
|
||||
bool releaseKey(ui::KeyScancode key) override {
|
||||
TRACE("releaseKey(%d)\n", key);
|
||||
processKey(key, false);
|
||||
return processKey(key, false);
|
||||
}
|
||||
|
||||
void movement(ToolLoop* loop, Points& points, const Point& point) {
|
||||
@ -188,17 +188,18 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
void processKey(ui::KeyScancode key, bool state) {
|
||||
bool processKey(ui::KeyScancode key, bool state) {
|
||||
switch (key) {
|
||||
case ui::kKeyLShift:
|
||||
case ui::kKeyRShift:
|
||||
m_squareAspect = state;
|
||||
break;
|
||||
return true;
|
||||
case ui::kKeyLControl:
|
||||
case ui::kKeyRControl:
|
||||
m_fromCenter = state;
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Point m_first;
|
||||
|
@ -76,7 +76,10 @@ void ToolLoopManager::pressKey(ui::KeyScancode key)
|
||||
if (isCanceled())
|
||||
return;
|
||||
|
||||
m_toolLoop->getController()->pressKey(key);
|
||||
if (m_toolLoop->getController()->pressKey(key)) {
|
||||
if (m_lastPointer.getButton() != Pointer::None)
|
||||
movement(m_lastPointer);
|
||||
}
|
||||
}
|
||||
|
||||
void ToolLoopManager::releaseKey(ui::KeyScancode key)
|
||||
@ -89,11 +92,16 @@ void ToolLoopManager::releaseKey(ui::KeyScancode key)
|
||||
return;
|
||||
}
|
||||
|
||||
m_toolLoop->getController()->releaseKey(key);
|
||||
if (m_toolLoop->getController()->releaseKey(key)) {
|
||||
if (m_lastPointer.getButton() != Pointer::None)
|
||||
movement(m_lastPointer);
|
||||
}
|
||||
}
|
||||
|
||||
void ToolLoopManager::pressButton(const Pointer& pointer)
|
||||
{
|
||||
m_lastPointer = pointer;
|
||||
|
||||
if (isCanceled())
|
||||
return;
|
||||
|
||||
@ -122,6 +130,8 @@ void ToolLoopManager::pressButton(const Pointer& pointer)
|
||||
|
||||
bool ToolLoopManager::releaseButton(const Pointer& pointer)
|
||||
{
|
||||
m_lastPointer = pointer;
|
||||
|
||||
if (isCanceled())
|
||||
return false;
|
||||
|
||||
@ -141,6 +151,8 @@ bool ToolLoopManager::releaseButton(const Pointer& pointer)
|
||||
|
||||
void ToolLoopManager::movement(const Pointer& pointer)
|
||||
{
|
||||
m_lastPointer = pointer;
|
||||
|
||||
if (isCanceled())
|
||||
return;
|
||||
|
||||
|
@ -44,7 +44,10 @@ namespace app {
|
||||
// Simple container of mouse events information.
|
||||
class Pointer {
|
||||
public:
|
||||
enum Button { Left, Middle, Right };
|
||||
enum Button { None, Left, Middle, Right };
|
||||
|
||||
Pointer()
|
||||
: m_x(0), m_y(0), m_button(None) { }
|
||||
|
||||
Pointer(int x, int y, Button button)
|
||||
: m_x(x), m_y(y), m_button(button) { }
|
||||
@ -99,6 +102,7 @@ namespace app {
|
||||
|
||||
ToolLoop* m_toolLoop;
|
||||
Points m_points;
|
||||
Pointer m_lastPointer;
|
||||
gfx::Point m_oldPoint;
|
||||
gfx::Region& m_dirtyArea;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user