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/>.
20 #include <multilangmgr.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
);
31 handTool
->set_relief(Gtk::RELIEF_NONE
);
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"));
40 wbTool
->set_relief(Gtk::RELIEF_NONE
);
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
);
49 cropTool
->set_relief(Gtk::RELIEF_NONE
);
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
);
58 straTool
->set_relief(Gtk::RELIEF_NONE
);
61 pack_start (*straTool
);
64 handTool
->set_active (true);
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);
86 straConn
.block (true);
88 handTool
->set_active (false);
89 wbTool
->set_active (false);
90 cropTool
->set_active (false);
91 straTool
->set_active (false);
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);
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);
115 straConn
.block (true);
116 if (current
!=TMHand
) {
117 wbTool
->set_active (false);
118 cropTool
->set_active (false);
119 straTool
->set_active (false);
122 handTool
->set_active (true);
123 handConn
.block (false);
124 cropConn
.block (false);
125 wbConn
.block (false);
126 straConn
.block (false);
129 listener
->toolSelected (TMHand
);
132 void ToolBar::wb_pressed () {
134 handConn
.block (true);
135 cropConn
.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);
144 wbTool
->set_active (true);
145 handConn
.block (false);
146 cropConn
.block (false);
147 wbConn
.block (false);
148 straConn
.block (false);
151 listener
->toolSelected (TMSpotWB
);
154 void ToolBar::crop_pressed () {
156 handConn
.block (true);
157 cropConn
.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);
173 listener
->toolSelected (TMCropSelect
);
176 void ToolBar::stra_pressed () {
178 handConn
.block (true);
179 cropConn
.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);
195 listener
->toolSelected (TMStraighten
);