1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
|
/*
* This file is part of RawTherapee.
*
* Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
*
* RawTherapee is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* RawTherapee is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with RawTherapee. If not, see <https://www.gnu.org/licenses/>.
*
* 2024-2024 Daniel Gao <daniel.gao.work@gmail.com>
*/
#pragma once
#include "adjuster.h"
#include "guiutils.h"
#include "toolpanel.h"
#include "rtengine/procevents.h"
#include <memory>
class ColorPreview;
class Framing final :
public ToolParamBlock,
public AdjusterListener,
public FoldableToolPanel
{
public:
static const Glib::ustring TOOL_NAME;
Framing();
~Framing();
// FoldableToolPanel
void read(const rtengine::procparams::ProcParams* pp,
const ParamsEdited* pedited = nullptr) override;
void write(rtengine::procparams::ProcParams* pp,
ParamsEdited* pedited = nullptr) override;
void setDefaults(const rtengine::procparams::ProcParams* defParams,
const ParamsEdited* pedited = nullptr) override;
void trimValues(rtengine::procparams::ProcParams* pp) override;
void setBatchMode(bool batchMode) override;
void enabledChanged() override;
void update(int originalWidth = 0, int originalHeight = 0);
void setAdjusterBehavior(bool addRelativeBorderSize, bool addRed, bool addGreen, bool addBlue);
// AdjusterListener
void adjusterChanged(Adjuster* adj, double newVal) override;
// Signal connections
void onFramingMethodChanged();
void onAspectRatioChanged();
void onOrientationChanged();
void onWidthChanged();
void onHeightChanged();
void onAllowUpscalingToggled();
void onBorderSizeMethodChanged();
void onBasisChanged();
void onMinSizeToggled();
void onMinWidthChanged();
void onMinHeightChanged();
void onAbsWidthChanged();
void onAbsHeightChanged();
private:
class AspectRatios;
// Helper struct for repeated patterns
struct DimensionGui
{
using CallbackFunc = void(Framing::*)();
DimensionGui() = default;
DimensionGui(Gtk::Box* parent, const char* text);
void setValue(int newValue) { value->set_value(newValue); }
void setRange(int min, int max) { value->set_range(min, max); }
void connect(Framing& framing, CallbackFunc callback);
void show() { box->show(); }
void hide() { box->hide(); }
Gtk::Box* box;
MySpinButton* value;
sigc::connection connection;
bool isDirty;
};
void setupEvents();
void setupFramingMethodGui();
void setupBorderSizeGui();
void setupBorderColorsGui();
void readParams(const rtengine::procparams::ProcParams* pp);
void readEdited(const ParamsEdited* pedited);
void writeParams(rtengine::procparams::ProcParams* pp);
void writeEdited(ParamsEdited* pedited);
void setDimensions();
void updateFramingMethodGui();
void updateBorderSizeGui();
void updateBorderColorGui();
// Framing method
MyComboBoxText* framingMethod;
sigc::connection framingMethodChanged;
Gtk::Label* aspectRatioLabel;
MyComboBoxText* aspectRatio;
sigc::connection aspectRatioChanged;
Gtk::Label* orientationLabel;
MyComboBoxText* orientation;
sigc::connection orientationChanged;
DimensionGui width;
DimensionGui height;
Gtk::CheckButton* allowUpscaling;
sigc::connection allowUpscalingConnection;
// Border sizing
MyComboBoxText* borderSizeMethod;
sigc::connection borderSizeMethodChanged;
Gtk::Label* basisLabel;
MyComboBoxText* basis;
sigc::connection basisChanged;
Adjuster* relativeBorderSize;
Gtk::Frame* minSizeFrame;
Gtk::Box* minSizeFrameContent;
Gtk::CheckButton* minSizeEnabled;
sigc::connection minSizeEnabledConnection;
DimensionGui minWidth;
DimensionGui minHeight;
DimensionGui absWidth;
DimensionGui absHeight;
// Border colors
Adjuster* redAdj;
Adjuster* greenAdj;
Adjuster* blueAdj;
ColorPreview* colorPreview;
// Events
rtengine::ProcEvent EvFramingEnabled;
rtengine::ProcEvent EvFramingMethod;
rtengine::ProcEvent EvFramingAspectRatio;
rtengine::ProcEvent EvFramingOrientation;
rtengine::ProcEvent EvFramingFramedWidth;
rtengine::ProcEvent EvFramingFramedHeight;
rtengine::ProcEvent EvFramingAllowUpscaling;
rtengine::ProcEvent EvFramingBorderSizingMethod;
rtengine::ProcEvent EvFramingBasis;
rtengine::ProcEvent EvFramingRelativeBorderSize;
rtengine::ProcEvent EvFramingMinSizeEnabled;
rtengine::ProcEvent EvFramingMinWidth;
rtengine::ProcEvent EvFramingMinHeight;
rtengine::ProcEvent EvFramingAbsWidth;
rtengine::ProcEvent EvFramingAbsHeight;
rtengine::ProcEvent EvFramingBorderRed;
rtengine::ProcEvent EvFramingBorderGreen;
rtengine::ProcEvent EvFramingBorderBlue;
IdleRegister idleRegister;
std::unique_ptr<AspectRatios> aspectRatioData;
int imgWidth;
int imgHeight;
bool lastAllowUpscaling;
bool lastMinSizeEnabled;
};
|