Patch from issue 227 (Work In Progress)

This commit is contained in:
natureh 510
2014-01-22 21:18:50 +01:00
parent 8b2eac9a3d
commit a8e3f2cdfa
69 changed files with 4202 additions and 609 deletions

View File

@@ -18,13 +18,18 @@
*/
#include "toolbar.h"
#include "multilangmgr.h"
#include "rtimage.h"
#include "guiutils.h"
ToolBar::ToolBar () : listener (NULL) {
editingMode = false;
handimg = Gtk::manage (new RTImage ("openhand.png"));
handimg->reference();
editinghandimg = Gtk::manage (new RTImage ("editmodehand.png"));
editinghandimg->reference();
handTool = Gtk::manage (new Gtk::ToggleButton ());
Gtk::Image* handimg = Gtk::manage (new RTImage ("openhand.png"));
handTool->add (*handimg);
handimg->show ();
handTool->set_relief(Gtk::RELIEF_NONE);
@@ -74,6 +79,11 @@ ToolBar::ToolBar () : listener (NULL) {
straTool->set_tooltip_markup (M("TOOLBAR_TOOLTIP_STRAIGHTEN"));
}
ToolBar::~ToolBar () {
handimg->unreference();
editinghandimg->unreference();
}
//
// Selects the desired tool without notifying the listener
//
@@ -84,6 +94,8 @@ void ToolBar::setTool (ToolMode tool) {
if (wbTool) wbConn.block (true);
straConn.block (true);
bool stopEdit = tool==TMHand && handTool->get_active() && editingMode;
handTool->set_active (false);
if (wbTool) wbTool->set_active (false);
cropTool->set_active (false);
@@ -91,7 +103,7 @@ void ToolBar::setTool (ToolMode tool) {
if (tool==TMHand){
handTool->set_active (true);
handTool->grab_focus();; // switch focus to the handTool button
handTool->grab_focus(); // switch focus to the handTool button
}
else if (tool==TMSpotWB) {
if (wbTool) wbTool->set_active (true);
@@ -101,12 +113,44 @@ void ToolBar::setTool (ToolMode tool) {
else if (tool==TMStraighten)
straTool->set_active (true);
current = tool;
current = tool;
handConn.block (false);
cropConn.block (false);
if (wbTool) wbConn.block (false);
straConn.block (false);
if (stopEdit) {
stopEditMode();
if (listener)
listener->editModeSwitchedOff();
}
}
void ToolBar::startEditMode() {
if (!editingMode) {
handTool->set_active(true); // will call hand_pressed, with editingMode=false
editingMode = true;
handTool->set_image(*editinghandimg);
}
#ifndef NDEBUG
else
printf("Editing mode already active!\n");
#endif
}
void ToolBar::stopEditMode() {
if (editingMode) {
editingMode = false;
/* WARNING: Should we toggle the Hand button on?
* This method can be called while another tool is active, e.g. if the user toggle off
* the Subscriber's Edit button. For now, we keep that other tool active. If one want to
* switch to the Hand tool, uncommenting the following line should suffice (not tested).
*
* handTool->set_active(true);
*/
handTool->set_image(*handimg);
}
}
void ToolBar::hand_pressed () {
@@ -121,6 +165,12 @@ void ToolBar::hand_pressed () {
straTool->set_active (false);
current = TMHand;
}
else {
if (editingMode)
stopEditMode();
if (listener)
listener->editModeSwitchedOff ();
}
handTool->set_active (true);
handConn.block (false);
cropConn.block (false);