Improve framing tool usability
* Rename "Resize" to "Resize & Framing" from discoverability * Add ColorPreview class for displaying a solid color * Add border color preview
This commit is contained in:
parent
2458ba4a29
commit
57ef07f3f6
@ -3956,7 +3956,7 @@ TP_RESIZE_FITBOX;Bounding Box
|
||||
TP_RESIZE_FULLIMAGE;Full Image
|
||||
TP_RESIZE_H;Height:
|
||||
TP_RESIZE_HEIGHT;Height
|
||||
TP_RESIZE_LABEL;Resize
|
||||
TP_RESIZE_LABEL;Resize & Framing
|
||||
TP_RESIZE_LANCZOS;Lanczos
|
||||
TP_RESIZE_LE;Long Edge:
|
||||
TP_RESIZE_LONG;Long Edge
|
||||
|
@ -1069,7 +1069,9 @@ Imagefloat* ImProcFunctions::drawFrame(Imagefloat* rgb, const FramingParams& par
|
||||
|
||||
Imagefloat* framed = new Imagefloat(dims.framedWidth, dims.framedHeight);
|
||||
|
||||
auto clip = [](int v) { return std::max(0, std::min(v, 65535)); };
|
||||
// Color::gamma2curve expects a 16-bit value, but the GUI sliders are
|
||||
// using 8-bit values. Step up the user value to 16-bits.
|
||||
auto clip = [](int v) { return std::max(0, std::min(v, 255)) * 256; };
|
||||
|
||||
float r = Color::gamma2curve[clip(params.borderRed)];
|
||||
float g = Color::gamma2curve[clip(params.borderGreen)];
|
||||
|
@ -35,6 +35,7 @@ set(NONCLISOURCEFILES
|
||||
colorappearance.cc
|
||||
coloredbar.cc
|
||||
colortoning.cc
|
||||
colorpreview.cc
|
||||
controllines.cc
|
||||
controlspotpanel.cc
|
||||
coordinateadjuster.cc
|
||||
|
69
rtgui/colorpreview.cc
Normal file
69
rtgui/colorpreview.cc
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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>
|
||||
*/
|
||||
|
||||
#include "colorpreview.h"
|
||||
|
||||
#include "rtscalable.h"
|
||||
|
||||
ColorPreview::ColorPreview() : color_red(1.0), color_green(1.0), color_blue(1.0)
|
||||
{
|
||||
}
|
||||
|
||||
void ColorPreview::setRgb(double r, double g, double b)
|
||||
{
|
||||
color_red = r;
|
||||
color_green = g;
|
||||
color_blue = b;
|
||||
|
||||
queue_draw();
|
||||
}
|
||||
|
||||
bool ColorPreview::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
|
||||
{
|
||||
cr->set_source_rgb(color_red, color_green, color_blue);
|
||||
cr->paint();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ColorPreview::get_preferred_height_vfunc(int& minimum_height, int& natural_height) const
|
||||
{
|
||||
minimum_height = RTScalable::scalePixelSize(10);
|
||||
natural_height = RTScalable::scalePixelSize(100);
|
||||
}
|
||||
|
||||
void ColorPreview::get_preferred_width_vfunc(int& minimum_width, int& natural_width) const
|
||||
{
|
||||
minimum_width = RTScalable::scalePixelSize(10);
|
||||
natural_width = RTScalable::scalePixelSize(100);
|
||||
}
|
||||
|
||||
void ColorPreview::get_preferred_height_for_width_vfunc(int width, int& minimum_height,
|
||||
int& natural_height) const
|
||||
{
|
||||
get_preferred_height_vfunc(minimum_height, natural_height);
|
||||
}
|
||||
|
||||
void ColorPreview::get_preferred_width_for_height_vfunc(int height, int& minimum_width,
|
||||
int& natural_width) const
|
||||
{
|
||||
get_preferred_width_vfunc(minimum_width, natural_width);
|
||||
}
|
53
rtgui/colorpreview.h
Normal file
53
rtgui/colorpreview.h
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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 <gtkmm/drawingarea.h>
|
||||
|
||||
/**
|
||||
* This widget displays a singular color as its contents.
|
||||
*/
|
||||
class ColorPreview : public Gtk::DrawingArea
|
||||
{
|
||||
public:
|
||||
ColorPreview();
|
||||
|
||||
// Values between 0.0 and 1.0 as in
|
||||
// Cairo::Context::set_source_rgb()
|
||||
void setRgb(double r, double g, double b);
|
||||
|
||||
// Gtk::DrawingArea
|
||||
bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr) override;
|
||||
|
||||
// Gtk::Widget
|
||||
void get_preferred_height_vfunc(int& minimum_height, int& natural_height) const override;
|
||||
void get_preferred_width_vfunc(int& minimum_width, int& natural_width) const override;
|
||||
void get_preferred_height_for_width_vfunc(int width, int& minimum_height,
|
||||
int& natural_height) const override;
|
||||
void get_preferred_width_for_height_vfunc(int height, int & minimum_width,
|
||||
int& natural_width) const override;
|
||||
|
||||
private:
|
||||
double color_red;
|
||||
double color_green;
|
||||
double color_blue;
|
||||
};
|
@ -15,16 +15,18 @@
|
||||
*
|
||||
* 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>
|
||||
*/
|
||||
|
||||
#include "framing.h"
|
||||
|
||||
#include "aspectratios.h"
|
||||
#include "colorpreview.h"
|
||||
#include "paramsedited.h"
|
||||
#include "resize.h"
|
||||
|
||||
#include "../rtengine/color.h"
|
||||
#include "../rtengine/procparams.h"
|
||||
|
||||
#include <array>
|
||||
@ -211,6 +213,7 @@ FramingParams::Basis mapBasis(int comboIndex)
|
||||
|
||||
constexpr int INITIAL_IMG_WIDTH = 100000;
|
||||
constexpr int INITIAL_IMG_HEIGHT = 100000;
|
||||
constexpr int MAX_COLOR_VAL = 255;
|
||||
|
||||
constexpr int ROW_SPACING = 4;
|
||||
constexpr float FRAME_LABEL_ALIGN_X = 0.025;
|
||||
@ -457,16 +460,23 @@ void Framing::setupBorderColorsGui()
|
||||
frame->set_label_widget(*label);
|
||||
|
||||
Gtk::Box* const box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL));
|
||||
redAdj = Gtk::manage(new Adjuster(M("TP_FRAMING_RED"), 0, 65535, 1, 65535));
|
||||
redAdj = Gtk::manage(new Adjuster(M("TP_FRAMING_RED"), 0, MAX_COLOR_VAL, 1, MAX_COLOR_VAL));
|
||||
box->add(*redAdj);
|
||||
greenAdj = Gtk::manage(new Adjuster(M("TP_FRAMING_GREEN"), 0, 65535, 1, 65535));
|
||||
greenAdj = Gtk::manage(new Adjuster(M("TP_FRAMING_GREEN"), 0, MAX_COLOR_VAL, 1, MAX_COLOR_VAL));
|
||||
box->add(*greenAdj);
|
||||
blueAdj = Gtk::manage(new Adjuster(M("TP_FRAMING_BLUE"), 0, 65535, 1, 65535));
|
||||
blueAdj = Gtk::manage(new Adjuster(M("TP_FRAMING_BLUE"), 0, MAX_COLOR_VAL, 1, MAX_COLOR_VAL));
|
||||
box->add(*blueAdj);
|
||||
|
||||
Gtk::Frame* const colorFrame = Gtk::manage(new Gtk::Frame());
|
||||
colorPreview = Gtk::manage(new ColorPreview());
|
||||
colorFrame->add(*colorPreview);
|
||||
box->add(*colorFrame);
|
||||
|
||||
frame->add(*box);
|
||||
pack_start(*frame);
|
||||
|
||||
updateBorderColorGui();
|
||||
|
||||
redAdj->setAdjusterListener(this);
|
||||
greenAdj->setAdjusterListener(this);
|
||||
blueAdj->setAdjusterListener(this);
|
||||
@ -502,6 +512,7 @@ void Framing::read(const rtengine::procparams::ProcParams* pp, const ParamsEdite
|
||||
|
||||
updateFramingMethodGui();
|
||||
updateBorderSizeGui();
|
||||
updateBorderColorGui();
|
||||
setDimensions();
|
||||
}
|
||||
|
||||
@ -827,8 +838,26 @@ void Framing::updateBorderSizeGui()
|
||||
minSizeFrameContent->set_sensitive(minSizeEnabled->get_active());
|
||||
}
|
||||
|
||||
void Framing::updateBorderColorGui()
|
||||
{
|
||||
auto gamma = [](double val) {
|
||||
// adjuster is [0.0, 255.0]
|
||||
// gamma2curve expects [0, 65535]
|
||||
// setRgb expects [0.0, 1.0]
|
||||
return Color::gamma2curve[val * (MAX_COLOR_VAL + 1)] / 65535.0;
|
||||
};
|
||||
double r = gamma(redAdj->getValue());
|
||||
double g = gamma(greenAdj->getValue());
|
||||
double b = gamma(blueAdj->getValue());
|
||||
colorPreview->setRgb(r, g, b);
|
||||
}
|
||||
|
||||
void Framing::adjusterChanged(Adjuster* adj, double newVal)
|
||||
{
|
||||
if (adj == redAdj || adj == greenAdj || adj == blueAdj) {
|
||||
updateBorderColorGui();
|
||||
}
|
||||
|
||||
if (listener && (getEnabled() || batchMode)) {
|
||||
Glib::ustring costr;
|
||||
if (adj == relativeBorderSize) {
|
||||
|
@ -15,7 +15,7 @@
|
||||
*
|
||||
* 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>
|
||||
*/
|
||||
|
||||
@ -27,6 +27,8 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
class ColorPreview;
|
||||
|
||||
class Framing final :
|
||||
public ToolParamBlock,
|
||||
public AdjusterListener,
|
||||
@ -106,6 +108,7 @@ private:
|
||||
void setDimensions();
|
||||
void updateFramingMethodGui();
|
||||
void updateBorderSizeGui();
|
||||
void updateBorderColorGui();
|
||||
|
||||
// Framing method
|
||||
MyComboBoxText* framingMethod;
|
||||
@ -141,6 +144,7 @@ private:
|
||||
Adjuster* redAdj;
|
||||
Adjuster* greenAdj;
|
||||
Adjuster* blueAdj;
|
||||
ColorPreview* colorPreview;
|
||||
|
||||
IdleRegister idleRegister;
|
||||
std::unique_ptr<AspectRatios> aspectRatioData;
|
||||
|
Loading…
x
Reference in New Issue
Block a user