diff --git a/rtgui/filebrowserentry.cc b/rtgui/filebrowserentry.cc index c016717a3..d452b88cd 100644 --- a/rtgui/filebrowserentry.cc +++ b/rtgui/filebrowserentry.cc @@ -418,6 +418,10 @@ bool FileBrowserEntry::pressNotify (int button, int type, int bstate, int x, i int ix = x - startx - ofsX; int iy = y - starty - ofsY; + if (tm == TMNone) { + return b; + } + if (!b && selected && inside (x, y)) { if (button == 1 && type == GDK_BUTTON_PRESS && state == SNormal) { if (onArea (CropTopLeft, ix, iy)) { diff --git a/rtgui/toolbar.cc b/rtgui/toolbar.cc index 8d1ab2a99..e070a9162 100644 --- a/rtgui/toolbar.cc +++ b/rtgui/toolbar.cc @@ -82,6 +82,7 @@ ToolBar::ToolBar () : showColPickers(true), listener (nullptr) handTool->set_active (true); current = TMHand; + allowNoTool = false; handConn = handTool->signal_toggled().connect( sigc::mem_fun(*this, &ToolBar::hand_pressed)); wbConn = wbTool->signal_toggled().connect( sigc::mem_fun(*this, &ToolBar::wb_pressed)); @@ -221,25 +222,29 @@ void ToolBar::hand_pressed () listener->editModeSwitchedOff (); } } - if (current != TMHand) { - if (colPickerTool) { - colPickerTool->set_active(false); - } - if (wbTool) { - wbTool->set_active (false); - } - cropTool->set_active (false); - straTool->set_active (false); - current = TMHand; + if (colPickerTool) { + colPickerTool->set_active(false); + } + if (wbTool) { + wbTool->set_active (false); } + cropTool->set_active (false); + straTool->set_active (false); handTool->set_active (true); + if (current != TMHand) { + current = TMHand; + } else if (allowNoTool) { + current = TMNone; + handTool->set_active(false); + } + } if (listener) { - listener->toolSelected (TMHand); + listener->toolSelected (current); } } @@ -366,32 +371,35 @@ void ToolBar::crop_pressed () ConnectionBlocker cropBlocker(cropConn); ConnectionBlocker wbWasBlocked(wbTool, wbConn), cpWasBlocked(colPickerTool, cpConn); - if (current != TMCropSelect) { - if (editingMode) { - stopEditMode(); - if (listener) { - listener->editModeSwitchedOff (); - } + if (editingMode) { + stopEditMode(); + if (listener) { + listener->editModeSwitchedOff (); } - handTool->set_active (false); - if (colPickerTool) { - colPickerTool->set_active(false); - } - if (wbTool) { - wbTool->set_active (false); - } - - straTool->set_active (false); - current = TMCropSelect; + } + handTool->set_active (false); + if (colPickerTool) { + colPickerTool->set_active(false); + } + if (wbTool) { + wbTool->set_active (false); } + straTool->set_active (false); cropTool->set_active (true); - cropTool->grab_focus (); + + if (current != TMCropSelect) { + current = TMCropSelect; + cropTool->grab_focus (); + } else if (allowNoTool) { + current = TMNone; + cropTool->set_active(false); + } } if (listener) { - listener->toolSelected (TMCropSelect); + listener->toolSelected (current); } } @@ -403,31 +411,34 @@ void ToolBar::stra_pressed () ConnectionBlocker cropBlocker(cropConn); ConnectionBlocker wbWasBlocked(wbTool, wbConn), cpWasBlocked(colPickerTool, cpConn); - if (current != TMStraighten) { - if (editingMode) { - stopEditMode(); - if (listener) { - listener->editModeSwitchedOff (); - } + if (editingMode) { + stopEditMode(); + if (listener) { + listener->editModeSwitchedOff (); } - handTool->set_active (false); - if (colPickerTool) { - colPickerTool->set_active(false); - } - if (wbTool) { - wbTool->set_active (false); - } - - cropTool->set_active (false); - current = TMStraighten; + } + handTool->set_active (false); + if (colPickerTool) { + colPickerTool->set_active(false); + } + if (wbTool) { + wbTool->set_active (false); } + cropTool->set_active (false); straTool->set_active (true); + if (current != TMStraighten) { + current = TMStraighten; + } else if (allowNoTool) { + current = TMNone; + straTool->set_active(false); + } + } if (listener) { - listener->toolSelected (TMStraighten); + listener->toolSelected (current); } } @@ -484,5 +495,20 @@ void ToolBar::setBatchMode() removeIfThere(this, colPickerTool, false); colPickerTool = nullptr; } + + allowNoTool = true; + switch (current) { + case TMHand: + hand_pressed(); + break; + case TMCropSelect: + crop_pressed(); + break; + case TMStraighten: + stra_pressed(); + break; + default: + break; + } } diff --git a/rtgui/toolbar.h b/rtgui/toolbar.h index c5bc68696..93cefb555 100644 --- a/rtgui/toolbar.h +++ b/rtgui/toolbar.h @@ -62,6 +62,7 @@ protected: ToolBarListener* listener; LockablePickerToolListener* pickerListener; ToolMode current; + bool allowNoTool; bool editingMode; // true if the cursor is being used to remotely edit tool's values sigc::connection handConn; sigc::connection wbConn; diff --git a/rtgui/toolenum.h b/rtgui/toolenum.h index 06212682a..85a7b954a 100644 --- a/rtgui/toolenum.h +++ b/rtgui/toolenum.h @@ -19,6 +19,6 @@ #ifndef _TOOLENUM_ #define _TOOLENUM_ -enum ToolMode {TMHand = 0, TMSpotWB = 1, TMCropSelect = 2, TMStraighten = 3, TMColorPicker = 4}; +enum ToolMode {TMNone = -1, TMHand = 0, TMSpotWB = 1, TMCropSelect = 2, TMStraighten = 3, TMColorPicker = 4}; #endif