We can cancel the selection of the brush using the other mouse button

This commit is contained in:
David Capello 2015-04-27 15:28:17 -03:00
parent 8f500178fc
commit 274b903aad
3 changed files with 16 additions and 2 deletions

View File

@ -42,6 +42,7 @@ protected:
// SelectBoxDelegate impl
void onQuickboxEnd(const gfx::Rect& rect, ui::MouseButtons buttons) override;
void onQuickboxCancel() override;
private:
void createBrush(const Mask* mask);
@ -116,6 +117,11 @@ void NewBrushCommand::onQuickboxEnd(const gfx::Rect& rect, ui::MouseButtons butt
current_editor->backToPreviousState();
}
void NewBrushCommand::onQuickboxCancel()
{
current_editor->backToPreviousState();
}
void NewBrushCommand::createBrush(const Mask* mask)
{
doc::ImageRef image(new_image_from_mask(

View File

@ -80,6 +80,7 @@ bool SelectBoxState::onMouseDown(Editor* editor, MouseMessage* msg)
if (hasFlag(QUICKBOX) && m_movingRuler == -1) {
m_selectingBox = true;
m_selectingButtons = msg->buttons();
m_startingPos = editor->screenToEditor(msg->position());
setBoxBounds(gfx::Rect(m_startingPos, gfx::Size(1, 1)));
}
@ -96,8 +97,13 @@ bool SelectBoxState::onMouseUp(Editor* editor, MouseMessage* msg)
if (m_selectingBox) {
m_selectingBox = false;
if (m_delegate)
m_delegate->onQuickboxEnd(getBoxBounds(), msg->buttons());
if (m_delegate) {
if (m_selectingButtons == msg->buttons())
m_delegate->onQuickboxEnd(getBoxBounds(), msg->buttons());
else
m_delegate->onQuickboxCancel();
}
}
return StandbyState::onMouseUp(editor, msg);

View File

@ -29,6 +29,7 @@ namespace app {
// Called only in QUICKBOX mode, when the user released the mouse
// button.
virtual void onQuickboxEnd(const gfx::Rect& rect, ui::MouseButtons buttons) { }
virtual void onQuickboxCancel() { }
};
class SelectBoxState : public StandbyState
@ -77,6 +78,7 @@ namespace app {
Rulers m_rulers;
int m_movingRuler;
bool m_selectingBox;
ui::MouseButtons m_selectingButtons;
gfx::Point m_startingPos;
Flags m_flags;
};