Proper check for rawzor libraries.
[rawtherapee-fixes.git] / rtgui / toolbar.cc
blobe761927111f11d8208ce1c5c71306f81b2e13768
1 /*
2 * This file is part of RawTherapee.
4 * Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
6 * RawTherapee is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * RawTherapee is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
19 #include "toolbar.h"
20 #include <multilangmgr.h>
21 #include "config.h"
23 extern Glib::ustring argv0;
25 ToolBar::ToolBar () : listener (NULL) {
27 handTool = Gtk::manage (new Gtk::ToggleButton ());
28 Gtk::Image* handimg = Gtk::manage (new Gtk::Image (GET_DATA_PATH(argv0)+"/images/openhand22.png"));
29 handTool->add (*handimg);
30 handimg->show ();
31 handTool->set_relief(Gtk::RELIEF_NONE);
32 handTool->show ();
34 pack_start (*handTool);
36 wbTool = Gtk::manage (new Gtk::ToggleButton ());
37 Gtk::Image* wbimg = Gtk::manage (new Gtk::Image (GET_DATA_PATH(argv0)+"/images/wbpicker22.png"));
38 wbTool->add (*wbimg);
39 wbimg->show ();
40 wbTool->set_relief(Gtk::RELIEF_NONE);
41 wbTool->show ();
43 pack_start (*wbTool);
45 cropTool = Gtk::manage (new Gtk::ToggleButton ());
46 Gtk::Image* cropimg = Gtk::manage (new Gtk::Image (GET_DATA_PATH(argv0)+"/images/crop22.png"));
47 cropTool->add (*cropimg);
48 cropimg->show ();
49 cropTool->set_relief(Gtk::RELIEF_NONE);
50 cropTool->show ();
52 pack_start (*cropTool);
54 straTool = Gtk::manage (new Gtk::ToggleButton ());
55 Gtk::Image* straimg = Gtk::manage (new Gtk::Image (GET_DATA_PATH(argv0)+"/images/straighten22.png"));
56 straTool->add (*straimg);
57 straimg->show ();
58 straTool->set_relief(Gtk::RELIEF_NONE);
59 straTool->show ();
61 pack_start (*straTool);
64 handTool->set_active (true);
65 current = TMHand;
67 handConn = handTool->signal_toggled().connect( sigc::mem_fun(*this, &ToolBar::hand_pressed));
68 wbConn = wbTool->signal_toggled().connect( sigc::mem_fun(*this, &ToolBar::wb_pressed));
69 cropConn = cropTool->signal_toggled().connect( sigc::mem_fun(*this, &ToolBar::crop_pressed));
70 straConn = straTool->signal_toggled().connect( sigc::mem_fun(*this, &ToolBar::stra_pressed));
72 handTool->set_tooltip_text (M("TOOLBAR_TOOLTIP_HAND"));
73 wbTool->set_tooltip_text (M("TOOLBAR_TOOLTIP_WB"));
74 cropTool->set_tooltip_text (M("TOOLBAR_TOOLTIP_CROP"));
75 straTool->set_tooltip_text (M("TOOLBAR_TOOLTIP_STRAIGHTEN"));
79 // Selects the desired tool without notifying the listener
81 void ToolBar::setTool (ToolMode tool) {
83 handConn.block (true);
84 cropConn.block (true);
85 wbConn.block (true);
86 straConn.block (true);
88 handTool->set_active (false);
89 wbTool->set_active (false);
90 cropTool->set_active (false);
91 straTool->set_active (false);
93 if (tool==TMHand)
94 handTool->set_active (true);
95 else if (tool==TMSpotWB)
96 wbTool->set_active (true);
97 else if (tool==TMCropSelect)
98 cropTool->set_active (true);
99 else if (tool==TMStraighten)
100 straTool->set_active (true);
102 current = tool;
104 handConn.block (false);
105 cropConn.block (false);
106 wbConn.block (false);
107 straConn.block (false);
110 void ToolBar::hand_pressed () {
112 handConn.block (true);
113 cropConn.block (true);
114 wbConn.block (true);
115 straConn.block (true);
116 if (current!=TMHand) {
117 wbTool->set_active (false);
118 cropTool->set_active (false);
119 straTool->set_active (false);
120 current = TMHand;
122 handTool->set_active (true);
123 handConn.block (false);
124 cropConn.block (false);
125 wbConn.block (false);
126 straConn.block (false);
128 if (listener)
129 listener->toolSelected (TMHand);
132 void ToolBar::wb_pressed () {
134 handConn.block (true);
135 cropConn.block (true);
136 wbConn.block (true);
137 straConn.block (true);
138 if (current!=TMSpotWB) {
139 handTool->set_active (false);
140 cropTool->set_active (false);
141 straTool->set_active (false);
142 current = TMSpotWB;
144 wbTool->set_active (true);
145 handConn.block (false);
146 cropConn.block (false);
147 wbConn.block (false);
148 straConn.block (false);
150 if (listener)
151 listener->toolSelected (TMSpotWB);
154 void ToolBar::crop_pressed () {
156 handConn.block (true);
157 cropConn.block (true);
158 wbConn.block (true);
159 straConn.block (true);
160 if (current!=TMCropSelect) {
161 handTool->set_active (false);
162 wbTool->set_active (false);
163 straTool->set_active (false);
164 current = TMCropSelect;
166 cropTool->set_active (true);
167 handConn.block (false);
168 cropConn.block (false);
169 wbConn.block (false);
170 straConn.block (false);
172 if (listener)
173 listener->toolSelected (TMCropSelect);
176 void ToolBar::stra_pressed () {
178 handConn.block (true);
179 cropConn.block (true);
180 wbConn.block (true);
181 straConn.block (true);
182 if (current!=TMStraighten) {
183 handTool->set_active (false);
184 wbTool->set_active (false);
185 cropTool->set_active (false);
186 current = TMStraighten;
188 straTool->set_active (true);
189 handConn.block (false);
190 cropConn.block (false);
191 wbConn.block (false);
192 straConn.block (false);
194 if (listener)
195 listener->toolSelected (TMStraighten);