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 <coarsepanel.h>
22 extern Glib::ustring argv0
;
24 using namespace rtengine
;
25 using namespace rtengine::procparams
;
27 CoarsePanel::CoarsePanel () : ToolPanel () {
31 Gtk::Image
* rotateli
= Gtk::manage (new Gtk::Image (GET_DATA_PATH(argv0
)+"/images/stock-rotate-270-16.png"));
32 rotate_left
= Gtk::manage (new Gtk::Button ());
33 rotate_left
->add (*rotateli
);
34 rotate_left
->set_relief(Gtk::RELIEF_NONE
);
35 pack_start (*rotate_left
);
37 Gtk::Image
* rotateri
= Gtk::manage (new Gtk::Image (GET_DATA_PATH(argv0
)+"/images/stock-rotate-90-16.png"));
38 rotate_right
= Gtk::manage (new Gtk::Button ());
39 rotate_right
->add (*rotateri
);
40 rotate_right
->set_relief(Gtk::RELIEF_NONE
);
41 pack_start (*rotate_right
);
43 Gtk::Image
* fliphi
= Gtk::manage (new Gtk::Image (GET_DATA_PATH(argv0
)+"/images/stock-flip-horizontal-16.png"));
44 hflip
= Gtk::manage (new Gtk::ToggleButton ());
46 hflip
->set_relief(Gtk::RELIEF_NONE
);
49 Gtk::Image
* flipvi
= Gtk::manage (new Gtk::Image (GET_DATA_PATH(argv0
)+"/images/stock-flip-vertical-16.png"));
50 vflip
= Gtk::manage (new Gtk::ToggleButton ());
52 vflip
->set_relief(Gtk::RELIEF_NONE
);
55 rotate_left
->set_tooltip_text (M("TP_COARSETRAF_TOOLTIP_ROTLEFT"));
56 rotate_right
->set_tooltip_text (M("TP_COARSETRAF_TOOLTIP_ROTRIGHT"));
57 vflip
->set_tooltip_text (M("TP_COARSETRAF_TOOLTIP_VFLIP"));
58 hflip
->set_tooltip_text (M("TP_COARSETRAF_TOOLTIP_HFLIP"));
60 rotate_left
->signal_pressed().connect( sigc::mem_fun(*this, &CoarsePanel::rotateLeft
) );
61 rotate_right
->signal_pressed().connect( sigc::mem_fun(*this, &CoarsePanel::rotateRight
) );
62 hflip
->signal_toggled().connect( sigc::mem_fun(*this, &CoarsePanel::flipHorizontal
) );
63 vflip
->signal_toggled().connect( sigc::mem_fun(*this, &CoarsePanel::flipVertical
) );
68 void CoarsePanel::read (const ProcParams
* pp
, const ParamsEdited
* pedited
) {
74 hflip
->set_active (pedited
->coarse
.hflip
? pp
->coarse
.hflip
: false);
75 vflip
->set_active (pedited
->coarse
.vflip
? pp
->coarse
.vflip
: false);
76 oldhflip
= pp
->coarse
.hflip
;
77 oldvflip
= pp
->coarse
.vflip
;
80 degree
= pp
->coarse
.rotate
;
81 hflip
->set_active (pp
->coarse
.hflip
);
82 vflip
->set_active (pp
->coarse
.vflip
);
87 void CoarsePanel::write (ProcParams
* pp
, ParamsEdited
* pedited
) {
89 pp
->coarse
.rotate
= degree
;
92 pedited
->coarse
.rotate
= degree
!=0;
93 pedited
->coarse
.hflip
= oldhflip
!= hflip
->get_active ();
94 pedited
->coarse
.vflip
= oldvflip
!= vflip
->get_active ();
95 pp
->coarse
.hflip
= oldhflip
!= hflip
->get_active ();
96 pp
->coarse
.vflip
= oldvflip
!= vflip
->get_active ();
99 pp
->coarse
.hflip
= hflip
->get_active ();
100 pp
->coarse
.vflip
= vflip
->get_active ();
104 void CoarsePanel::initBatchBehavior () {
109 hflip
->set_active (false);
110 vflip
->set_active (false);
115 void CoarsePanel::rotateLeft () {
117 degree
= (degree
+ 270) % 360;
119 listener
->panelChanged (EvCTRotate
, Glib::ustring::format (degree
));
122 void CoarsePanel::rotateRight () {
124 degree
= (degree
+ 90) % 360;
126 listener
->panelChanged (EvCTRotate
, Glib::ustring::format (degree
));
129 void CoarsePanel::flipHorizontal () {
132 if (hflip
->get_active ())
133 listener
->panelChanged (EvCTHFlip
, M("GENERAL_ENABLED"));
135 listener
->panelChanged (EvCTHFlip
, M("GENERAL_DISABLED"));
139 void CoarsePanel::flipVertical () {
142 if (vflip
->get_active ())
143 listener
->panelChanged (EvCTVFlip
, M("GENERAL_ENABLED"));
145 listener
->panelChanged (EvCTVFlip
, M("GENERAL_DISABLED"));