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:
@@ -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