added a more flexible way of managing ProcEvents
modifying the global ProcEvent enum and refreshmap array is not needed anymore. You can now register new events dynamically, using a ProcEventMapper instance. See rtgui/localcontrast.cc for an example. Hopefully this solves the problem of recurring merge conflicts when different devs add different proc events
This commit is contained in:
@@ -725,11 +725,11 @@ HISTORY_MSG_490;HDR TM - Amount
|
||||
HISTORY_MSG_491;White Balance
|
||||
HISTORY_MSG_492;RGB Curves
|
||||
HISTORY_MSG_493;L*a*b* Adjustments
|
||||
HISTORY_MSG_494;Local Contrast
|
||||
HISTORY_MSG_495;Local Contrast - Radius
|
||||
HISTORY_MSG_496;Local Contrast - Amount
|
||||
HISTORY_MSG_497;Local Contrast - Darkness
|
||||
HISTORY_MSG_498;Local Contrast - Lightness
|
||||
HISTORY_MSG_LOCALCONTRAST_ENABLED;Local Contrast
|
||||
HISTORY_MSG_LOCALCONTRAST_RADIUS;Local Contrast - Radius
|
||||
HISTORY_MSG_LOCALCONTRAST_AMOUNT;Local Contrast - Amount
|
||||
HISTORY_MSG_LOCALCONTRAST_DARKNESS;Local Contrast - Darkness
|
||||
HISTORY_MSG_LOCALCONTRAST_LIGHTNESS;Local Contrast - Lightness
|
||||
HISTORY_NEWSNAPSHOT;Add
|
||||
HISTORY_NEWSNAPSHOT_TOOLTIP;Shortcut: <b>Alt-s</b>
|
||||
HISTORY_SNAPSHOT;Snapshot
|
||||
|
@@ -1378,7 +1378,8 @@ ProcParams* ImProcCoordinator::beginUpdateParams ()
|
||||
|
||||
void ImProcCoordinator::endUpdateParams (ProcEvent change)
|
||||
{
|
||||
endUpdateParams ( refreshmap[ (int)change] );
|
||||
int action = RefreshMapper::getInstance()->getAction(change);
|
||||
endUpdateParams(action);
|
||||
}
|
||||
|
||||
void ImProcCoordinator::endUpdateParams (int changeFlags)
|
||||
|
@@ -26,7 +26,7 @@ namespace rtengine
|
||||
|
||||
|
||||
// Aligned so the first entry starts on line 30
|
||||
enum ProcEvent {
|
||||
enum ProcEventCode {
|
||||
EvPhotoLoaded = 0,
|
||||
EvProfileLoaded = 1,
|
||||
EvProfileChanged = 2,
|
||||
@@ -520,15 +520,31 @@ enum ProcEvent {
|
||||
EvWBEnabled = 490,
|
||||
EvRGBEnabled = 491,
|
||||
EvLEnabled = 492,
|
||||
EvLocalContrastEnabled = 493,
|
||||
EvLocalContrastRadius = 494,
|
||||
EvLocalContrastAmount = 495,
|
||||
EvLocalContrastDarkness = 496,
|
||||
EvLocalContrastLightness = 497,
|
||||
|
||||
NUMOFEVENTS
|
||||
|
||||
};
|
||||
|
||||
|
||||
class ProcEvent {
|
||||
public:
|
||||
ProcEvent(): code_(0) {}
|
||||
ProcEvent(ProcEventCode code): code_(code) {}
|
||||
explicit ProcEvent(int code): code_(code) {}
|
||||
operator int() { return code_; }
|
||||
|
||||
private:
|
||||
int code_;
|
||||
};
|
||||
|
||||
|
||||
inline bool operator==(ProcEvent a, ProcEvent b) { return int(a) == int(b); }
|
||||
inline bool operator==(ProcEvent a, ProcEventCode b) { return int(a) == int(b); }
|
||||
inline bool operator==(ProcEventCode a, ProcEvent b) { return int(a) == int(b); }
|
||||
inline bool operator!=(ProcEvent a, ProcEvent b) { return int(a) != int(b); }
|
||||
inline bool operator!=(ProcEvent a, ProcEventCode b) { return int(a) != int(b); }
|
||||
inline bool operator!=(ProcEventCode a, ProcEvent b) { return int(a) != int(b); }
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@@ -519,11 +519,48 @@ int refreshmap[rtengine::NUMOFEVENTS] = {
|
||||
HDR, // EvTMFattalAmount
|
||||
ALLNORAW, // EvWBEnabled
|
||||
RGBCURVE, // EvRGBEnabled
|
||||
LUMINANCECURVE, // EvLEnabled
|
||||
RGBCURVE, // EvLocalContastEnabled
|
||||
RGBCURVE, // EvLocalContrastRadius
|
||||
RGBCURVE, // EvLocalContrastAmount
|
||||
RGBCURVE, // EvLocalContrastDarkness
|
||||
RGBCURVE // EvLocalContrastLightness
|
||||
LUMINANCECURVE // EvLEnabled
|
||||
};
|
||||
|
||||
|
||||
namespace rtengine {
|
||||
|
||||
RefreshMapper::RefreshMapper():
|
||||
next_event_(rtengine::NUMOFEVENTS)
|
||||
{
|
||||
for (int event = 0; event < rtengine::NUMOFEVENTS; ++event) {
|
||||
actions_[event] = refreshmap[event];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ProcEvent RefreshMapper::newEvent()
|
||||
{
|
||||
return ProcEvent(++next_event_);
|
||||
}
|
||||
|
||||
|
||||
void RefreshMapper::mapEvent(ProcEvent event, int action)
|
||||
{
|
||||
actions_[event] = action;
|
||||
}
|
||||
|
||||
|
||||
int RefreshMapper::getAction(ProcEvent event) const
|
||||
{
|
||||
auto it = actions_.find(event);
|
||||
if (it == actions_.end()) {
|
||||
return 0;
|
||||
} else {
|
||||
return it->second;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RefreshMapper *RefreshMapper::getInstance()
|
||||
{
|
||||
static RefreshMapper instance;
|
||||
return &instance;
|
||||
}
|
||||
|
||||
} // namespace rtengine
|
||||
|
@@ -19,6 +19,9 @@
|
||||
#ifndef __REFRESHMAP__
|
||||
#define __REFRESHMAP__
|
||||
|
||||
#include <unordered_map>
|
||||
#include "procevents.h"
|
||||
|
||||
// Use M_VOID if you wish to update the proc params without updating the preview at all !
|
||||
#define M_VOID (1<<17)
|
||||
// Use M_MINUPDATE if you wish to update the preview without modifying the image (think about it like a "refreshPreview")
|
||||
@@ -74,4 +77,23 @@
|
||||
#define OUTPUTPROFILE M_MONITOR
|
||||
|
||||
extern int refreshmap[];
|
||||
|
||||
namespace rtengine {
|
||||
|
||||
class RefreshMapper {
|
||||
public:
|
||||
static RefreshMapper *getInstance();
|
||||
ProcEvent newEvent();
|
||||
void mapEvent(ProcEvent event, int action);
|
||||
int getAction(ProcEvent event) const;
|
||||
|
||||
private:
|
||||
RefreshMapper();
|
||||
|
||||
int next_event_;
|
||||
std::unordered_map<int, int> actions_;
|
||||
};
|
||||
|
||||
} // namespace rtengine
|
||||
|
||||
#endif
|
||||
|
@@ -149,6 +149,7 @@ set(NONCLISOURCEFILES
|
||||
zoompanel.cc
|
||||
fattaltonemap.cc
|
||||
localcontrast.cc
|
||||
eventmapper.cc
|
||||
)
|
||||
|
||||
include_directories(BEFORE "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
63
rtgui/eventmapper.cc
Normal file
63
rtgui/eventmapper.cc
Normal file
@@ -0,0 +1,63 @@
|
||||
/* -*- C++ -*-
|
||||
*
|
||||
* This file is part of RawTherapee.
|
||||
*
|
||||
* Copyright (c) 2017 Alberto Griggio <alberto.griggio@gmail.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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "eventmapper.h"
|
||||
|
||||
|
||||
ProcEventMapper::ProcEventMapper()
|
||||
{
|
||||
for (int event = 0; event < rtengine::NUMOFEVENTS; ++event) {
|
||||
history_msgs_[event] = "HISTORY_MSG_" + std::to_string(event + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ProcEventMapper *ProcEventMapper::getInstance()
|
||||
{
|
||||
static ProcEventMapper instance;
|
||||
return &instance;
|
||||
}
|
||||
|
||||
|
||||
rtengine::ProcEvent ProcEventMapper::newEvent(int action, const std::string &history_msg)
|
||||
{
|
||||
rtengine::ProcEvent event = rtengine::RefreshMapper::getInstance()->newEvent();
|
||||
rtengine::RefreshMapper::getInstance()->mapEvent(event, action);
|
||||
|
||||
if (history_msg.empty()) {
|
||||
history_msgs_[event] = "HISTORY_MSG_" + std::to_string(event + 1);
|
||||
} else {
|
||||
history_msgs_[event] = history_msg;
|
||||
}
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
|
||||
const std::string &ProcEventMapper::getHistoryMsg(rtengine::ProcEvent event) const
|
||||
{
|
||||
static std::string empty;
|
||||
auto it = history_msgs_.find(event);
|
||||
if (it == history_msgs_.end()) {
|
||||
return empty;
|
||||
} else {
|
||||
return it->second;
|
||||
}
|
||||
}
|
37
rtgui/eventmapper.h
Normal file
37
rtgui/eventmapper.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/* -*- C++ -*-
|
||||
*
|
||||
* This file is part of RawTherapee.
|
||||
*
|
||||
* Copyright (c) 2017 Alberto Griggio <alberto.griggio@gmail.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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include "../rtengine/refreshmap.h"
|
||||
|
||||
|
||||
class ProcEventMapper {
|
||||
public:
|
||||
static ProcEventMapper *getInstance();
|
||||
rtengine::ProcEvent newEvent(int action, const std::string &history_msg="");
|
||||
const std::string &getHistoryMsg(rtengine::ProcEvent event) const;
|
||||
|
||||
private:
|
||||
ProcEventMapper();
|
||||
|
||||
std::unordered_map<int, std::string> history_msgs_;
|
||||
};
|
@@ -20,6 +20,7 @@
|
||||
#include "multilangmgr.h"
|
||||
#include "rtimage.h"
|
||||
#include "guiutils.h"
|
||||
#include "eventmapper.h"
|
||||
|
||||
using namespace rtengine;
|
||||
using namespace rtengine::procparams;
|
||||
@@ -231,7 +232,7 @@ void History::procParamsChanged (ProcParams* params, ProcEvent ev, Glib::ustring
|
||||
}
|
||||
|
||||
// construct formatted list content
|
||||
Glib::ustring text = M("HISTORY_MSG_" + std::to_string(ev + 1));
|
||||
Glib::ustring text = M(ProcEventMapper::getInstance()->getHistoryMsg(ev));
|
||||
|
||||
Glib::RefPtr<Gtk::TreeSelection> selection = hTreeView->get_selection();
|
||||
Gtk::TreeModel::iterator iter = selection->get_selected();
|
||||
|
@@ -18,6 +18,7 @@
|
||||
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "localcontrast.h"
|
||||
#include "eventmapper.h"
|
||||
#include <iomanip>
|
||||
#include <cmath>
|
||||
|
||||
@@ -26,6 +27,13 @@ using namespace rtengine::procparams;
|
||||
|
||||
LocalContrast::LocalContrast(): FoldableToolPanel(this, "localcontrast", M("TP_LOCALCONTRAST_LABEL"), false, true)
|
||||
{
|
||||
auto m = ProcEventMapper::getInstance();
|
||||
EvLocalContrastEnabled = m->newEvent(RGBCURVE, "HISTORY_MSG_LOCALCONTRAST_ENABLED");
|
||||
EvLocalContrastRadius = m->newEvent(RGBCURVE, "HISTORY_MSG_LOCALCONTRAST_RADIUS");
|
||||
EvLocalContrastAmount = m->newEvent(RGBCURVE, "HISTORY_MSG_LOCALCONTRAST_AMOUNT");
|
||||
EvLocalContrastDarkness = m->newEvent(RGBCURVE, "HISTORY_MSG_LOCALCONTRAST_DARKNESS");
|
||||
EvLocalContrastLightness = m->newEvent(RGBCURVE, "HISTORY_MSG_LOCALCONTRAST_LIGHTNESS");
|
||||
|
||||
radius = Gtk::manage(new Adjuster(M("TP_LOCALCONTRAST_RADIUS"), 3., 200., 1., 8.));
|
||||
amount = Gtk::manage(new Adjuster(M("TP_LOCALCONTRAST_AMOUNT"), 0., 1., 0.01, 0.2));
|
||||
darkness = Gtk::manage(new Adjuster(M("TP_LOCALCONTRAST_DARKNESS"), 0., 4., 0.1, 1.));
|
||||
|
@@ -25,12 +25,18 @@
|
||||
|
||||
class LocalContrast: public ToolParamBlock, public AdjusterListener, public FoldableToolPanel
|
||||
{
|
||||
protected:
|
||||
private:
|
||||
Adjuster *radius;
|
||||
Adjuster *amount;
|
||||
Adjuster *darkness;
|
||||
Adjuster *lightness;
|
||||
|
||||
rtengine::ProcEvent EvLocalContrastEnabled;
|
||||
rtengine::ProcEvent EvLocalContrastRadius;
|
||||
rtengine::ProcEvent EvLocalContrastAmount;
|
||||
rtengine::ProcEvent EvLocalContrastDarkness;
|
||||
rtengine::ProcEvent EvLocalContrastLightness;
|
||||
|
||||
public:
|
||||
|
||||
LocalContrast();
|
||||
|
@@ -315,7 +315,7 @@ void ToolPanelCoordinator::panelChanged (rtengine::ProcEvent event, const Glib::
|
||||
return;
|
||||
}
|
||||
|
||||
int changeFlags = refreshmap[ (int)event];
|
||||
int changeFlags = rtengine::RefreshMapper::getInstance()->getAction(event);
|
||||
|
||||
ProcParams* params = ipc->beginUpdateParams ();
|
||||
|
||||
@@ -327,7 +327,7 @@ void ToolPanelCoordinator::panelChanged (rtengine::ProcEvent event, const Glib::
|
||||
if (event == rtengine::EvCTHFlip || event == rtengine::EvCTVFlip) {
|
||||
if (fabs (params->rotate.degree) > 0.001) {
|
||||
params->rotate.degree *= -1;
|
||||
changeFlags |= refreshmap[ (int)rtengine::EvROTDegree];
|
||||
changeFlags |= rtengine::RefreshMapper::getInstance()->getAction(rtengine::EvROTDegree);
|
||||
rotate->read (params);
|
||||
}
|
||||
}
|
||||
@@ -446,7 +446,7 @@ void ToolPanelCoordinator::profileChange (const PartialProfile *nparams, rtengi
|
||||
|
||||
// start the IPC processing
|
||||
if (filterRawRefresh) {
|
||||
ipc->endUpdateParams ( refreshmap[ (int)event] & ALLNORAW );
|
||||
ipc->endUpdateParams ( rtengine::RefreshMapper::getInstance()->getAction(event) & ALLNORAW );
|
||||
} else {
|
||||
ipc->endUpdateParams (event);
|
||||
}
|
||||
|
Reference in New Issue
Block a user