diff --git a/krita/image/kis_cached_gradient_shape_strategy.cpp b/krita/image/kis_cached_gradient_shape_strategy.cpp --- a/krita/image/kis_cached_gradient_shape_strategy.cpp +++ b/krita/image/kis_cached_gradient_shape_strategy.cpp @@ -23,8 +23,7 @@ #include -#include -#include +#include #include "kis_algebra_2d.h" #include "kis_debug.h" @@ -48,6 +47,8 @@ : KisGradientShapeStrategy(), m_d(new Private()) { + using namespace std::placeholders; // for _1, _2, _3... + KIS_ASSERT_RECOVER_NOOP(rc.width() >= 3 && rc.height() >= 3); m_d->rc = rc; @@ -82,8 +83,8 @@ yStart, yEnd, numSamplesY, Natural)); - boost::function valueOp = - boost::bind(&KisGradientShapeStrategy::valueAt, m_d->baseStrategy.data(), _1, _2); + std::function valueOp = + std::bind(&KisGradientShapeStrategy::valueAt, m_d->baseStrategy.data(), _1, _2); m_d->spline->initializeSpline(valueOp); diff --git a/krita/image/kis_image.cc b/krita/image/kis_image.cc --- a/krita/image/kis_image.cc +++ b/krita/image/kis_image.cc @@ -88,8 +88,6 @@ #include "kis_suspend_projection_updates_stroke_strategy.h" #include "kis_sync_lod_cache_stroke_strategy.h" -#include -#include #include "kis_projection_updates_filter.h" @@ -99,7 +97,8 @@ #include "kis_image_barrier_locker.h" #include -#include + +#include #include "kis_time_range.h" @@ -210,12 +209,14 @@ m_d->scheduler.setProgressProxy(&m_d->compositeProgressProxy); } + // Each of these lambdas defines a new factory function. + // C++11 has a special syntax for lambdas that capture only "this" ptr. m_d->scheduler.setLod0ToNStrokeStrategyFactory( - boost::bind(boost::factory(), KisImageWSP(this))); + [this](){return new KisSyncLodCacheStrokeStrategy(KisImageWSP(this));}); m_d->scheduler.setSuspendUpdatesStrokeStrategyFactory( - boost::bind(boost::factory(), KisImageWSP(this), true)); + [this](){return new KisSuspendProjectionUpdatesStrokeStrategy(KisImageWSP(this), true);}); m_d->scheduler.setResumeUpdatesStrokeStrategyFactory( - boost::bind(boost::factory(), KisImageWSP(this), false)); + [this](){return new KisSuspendProjectionUpdatesStrokeStrategy(KisImageWSP(this), false);}); } setRootLayer(new KisGroupLayer(this, "root", OPACITY_OPAQUE_U8)); @@ -1608,7 +1609,7 @@ QRect patchRect(x, y, patchWidth, patchHeight); patchRect &= rc; - QtConcurrent::run(boost::bind(&KisImage::notifyProjectionUpdated, q, patchRect)); + QtConcurrent::run(std::bind(&KisImage::notifyProjectionUpdated, q, patchRect)); } } } diff --git a/krita/image/kis_liquify_transform_worker.cpp b/krita/image/kis_liquify_transform_worker.cpp --- a/krita/image/kis_liquify_transform_worker.cpp +++ b/krita/image/kis_liquify_transform_worker.cpp @@ -428,15 +428,17 @@ m_d->transformedPoints); } -#include -#include +#include #include -typedef boost::function PointMapFunction; +using PointMapFunction = std::function; + PointMapFunction bindPointMapTransform(const QTransform &transform) { + using namespace std::placeholders; + typedef QPointF (QTransform::*MapFuncType)(const QPointF&) const; - return boost::bind(static_cast(&QTransform::map), &transform, _1); + return std::bind(static_cast(&QTransform::map), &transform, _1); } QImage KisLiquifyTransformWorker::runOnQImage(const QImage &srcImage, diff --git a/krita/image/kis_signal_compressor_with_param.h b/krita/image/kis_signal_compressor_with_param.h --- a/krita/image/kis_signal_compressor_with_param.h +++ b/krita/image/kis_signal_compressor_with_param.h @@ -20,29 +20,27 @@ #define __KIS_SIGNAL_COMPRESSOR_WITH_PARAM_H #include +#include -#include -#include /** - * A special class that converts a Qt signal into a boost::function - * call. + * A special class that converts a Qt signal into a std::function call. * * Example: * - * boost::function destinationFunctionCall(boost::bind(someNiceFunc, firstParam, secondParam)); + * std::function destinationFunctionCall(boost::bind(someNiceFunc, firstParam, secondParam)); * SignalToFunctionProxy proxy(destinationFunctionCall); * connect(srcObject, SIGNAL(sigSomethingChanged()), &proxy, SLOT(start())); * * Now every time sigSomethingChanged() is emitted, someNiceFunc is - * called. boost::bind allows us to call any method of any class without + * called. std::bind allows us to call any method of any class without * changing signature of the class or creating special wrappers. */ class KRITAIMAGE_EXPORT SignalToFunctionProxy : public QObject { Q_OBJECT public: - typedef boost::function TrivialFunction; + using TrivialFunction = std::function; public: SignalToFunctionProxy(TrivialFunction function) @@ -64,18 +62,20 @@ * A special class for deferring and comressing events with one * parameter of type T. This works like KisSignalCompressor but can * handle events with one parameter. Due to limitation of the Qt this - * doesn't allow signal/slots, so it uses boost::funxtion instead. + * doesn't allow signal/slots, so it uses std::function instead. * * In the end (after a timeout) the latest param value is returned to * the callback. * * Usage: * * \code{.cpp} * + * using namespace std::placeholders; // For _1 placeholder + * * // prepare the callback function - * boost::function callback( - * boost::bind(&LutDockerDock::setCurrentExposureImpl, this, _1)); + * std::function callback( + * std::bind(&LutDockerDock::setCurrentExposureImpl, this, _1)); * * // Create the compressor object * KisSignalCompressorWithParam compressor(40, callback); @@ -90,15 +90,15 @@ class KisSignalCompressorWithParam { public: - typedef boost::function CallbackFunction; + using CallbackFunction = std::function; public: KisSignalCompressorWithParam(int delay, CallbackFunction function) : m_compressor(delay, KisSignalCompressor::FIRST_ACTIVE), m_function(function) { - boost::function callback( - boost::bind(&KisSignalCompressorWithParam::fakeSlotTimeout, this)); + std::function callback( + std::bind(&KisSignalCompressorWithParam::fakeSlotTimeout, this)); m_signalProxy.reset(new SignalToFunctionProxy(callback)); m_compressor.connect(&m_compressor, SIGNAL(timeout()), m_signalProxy.data(), SLOT(start())); diff --git a/krita/image/kis_stroke_strategy_factory.h b/krita/image/kis_stroke_strategy_factory.h --- a/krita/image/kis_stroke_strategy_factory.h +++ b/krita/image/kis_stroke_strategy_factory.h @@ -19,7 +19,7 @@ #ifndef __KIS_STROKE_STRATEGY_FACTORY_H #define __KIS_STROKE_STRATEGY_FACTORY_H -#include -typedef boost::function< KisStrokeStrategy*() > KisStrokeStrategyFactory; +#include +using KisStrokeStrategyFactory = std::function; #endif /* __KIS_STROKE_STRATEGY_FACTORY_H */ diff --git a/krita/image/kis_transform_mask_params_factory_registry.h b/krita/image/kis_transform_mask_params_factory_registry.h --- a/krita/image/kis_transform_mask_params_factory_registry.h +++ b/krita/image/kis_transform_mask_params_factory_registry.h @@ -21,18 +21,17 @@ #include -#include -#include +#include #include "kis_types.h" #include "kritaimage_export.h" class QDomElement; -typedef boost::function KisTransformMaskParamsFactory; -typedef QMap KisTransformMaskParamsFactoryMap; +using KisTransformMaskParamsFactory = std::function; +using KisTransformMaskParamsFactoryMap = QMap; class KRITAIMAGE_EXPORT KisTransformMaskParamsFactoryRegistry { diff --git a/krita/image/tests/kis_image_test.cpp b/krita/image/tests/kis_image_test.cpp --- a/krita/image/tests/kis_image_test.cpp +++ b/krita/image/tests/kis_image_test.cpp @@ -77,14 +77,13 @@ #include "testutil.h" #include "kis_stroke_strategy.h" -#include -#include +#include class ForbiddenLodStrokeStrategy : public KisStrokeStrategy { public: - ForbiddenLodStrokeStrategy(boost::function lodCallback) + ForbiddenLodStrokeStrategy(std::function lodCallback) : m_lodCallback(lodCallback) { } @@ -96,7 +95,7 @@ } private: - boost::function m_lodCallback; + std::function m_lodCallback; }; void notifyVar(bool *value) { @@ -118,7 +117,7 @@ bool lodCreated = false; KisStrokeId id = p.image->startStroke( new ForbiddenLodStrokeStrategy( - boost::bind(¬ifyVar, &lodCreated))); + std::bind(¬ifyVar, &lodCreated))); p.image->endStroke(id); p.image->waitForDone(); @@ -131,7 +130,7 @@ bool lodCreated = false; KisStrokeId id = p.image->startStroke( new ForbiddenLodStrokeStrategy( - boost::bind(¬ifyVar, &lodCreated))); + std::bind(¬ifyVar, &lodCreated))); p.image->endStroke(id); p.image->waitForDone(); @@ -145,7 +144,7 @@ bool lodCreated = false; KisStrokeId id = p.image->startStroke( new ForbiddenLodStrokeStrategy( - boost::bind(¬ifyVar, &lodCreated))); + std::bind(¬ifyVar, &lodCreated))); p.image->endStroke(id); p.image->waitForDone(); diff --git a/krita/plugins/extensions/dockers/lut/lutdocker_dock.cpp b/krita/plugins/extensions/dockers/lut/lutdocker_dock.cpp --- a/krita/plugins/extensions/dockers/lut/lutdocker_dock.cpp +++ b/krita/plugins/extensions/dockers/lut/lutdocker_dock.cpp @@ -92,8 +92,11 @@ , m_canvas(0) , m_draggingSlider(false) { - m_exposureCompressor.reset(new KisSignalCompressorWithParam(40, boost::bind(&LutDockerDock::setCurrentExposureImpl, this, _1))); - m_gammaCompressor.reset(new KisSignalCompressorWithParam(40, boost::bind(&LutDockerDock::setCurrentGammaImpl, this, _1))); + using namespace std::placeholders; // For _1 + m_exposureCompressor.reset( + new KisSignalCompressorWithParam(40, std::bind(&LutDockerDock::setCurrentExposureImpl, this, _1))); + m_gammaCompressor.reset( + new KisSignalCompressorWithParam(40, std::bind(&LutDockerDock::setCurrentGammaImpl, this, _1))); m_page = new QWidget(this); setupUi(m_page); diff --git a/krita/ui/dialogs/slider_and_spin_box_sync.h b/krita/ui/dialogs/slider_and_spin_box_sync.h --- a/krita/ui/dialogs/slider_and_spin_box_sync.h +++ b/krita/ui/dialogs/slider_and_spin_box_sync.h @@ -20,7 +20,7 @@ #define __SLIDER_AND_SPIN_BOX_SYNC_H #include -#include +#include class QSpinBox; class KisDoubleSliderSpinBox; @@ -40,10 +40,12 @@ class SliderAndSpinBoxSync : public QObject { Q_OBJECT + using IntFunction = std::function; + public: SliderAndSpinBoxSync(KisDoubleSliderSpinBox *slider, QSpinBox *spinBox, - boost::function parentValueOp); + IntFunction parentValueOp); ~SliderAndSpinBoxSync(); @@ -57,7 +59,7 @@ private: KisDoubleSliderSpinBox *m_slider; QSpinBox *m_spinBox; - boost::function m_parentValueOp; + IntFunction m_parentValueOp; bool m_blockUpdates; }; diff --git a/krita/ui/dialogs/slider_and_spin_box_sync.cpp b/krita/ui/dialogs/slider_and_spin_box_sync.cpp --- a/krita/ui/dialogs/slider_and_spin_box_sync.cpp +++ b/krita/ui/dialogs/slider_and_spin_box_sync.cpp @@ -27,7 +27,7 @@ SliderAndSpinBoxSync::SliderAndSpinBoxSync(KisDoubleSliderSpinBox *slider, QSpinBox *spinBox, - boost::function parentValueOp) + IntFunction parentValueOp) : m_slider(slider), m_spinBox(spinBox), m_parentValueOp(parentValueOp), diff --git a/krita/ui/kis_animation_cache_populator.cpp b/krita/ui/kis_animation_cache_populator.cpp --- a/krita/ui/kis_animation_cache_populator.cpp +++ b/krita/ui/kis_animation_cache_populator.cpp @@ -18,7 +18,7 @@ #include "kis_animation_cache_populator.h" -#include +#include #include #include @@ -101,8 +101,8 @@ QFuture requestFuture = QtConcurrent::run( - boost::bind(&KisAnimationCachePopulator::Private::processFrameInfo, - requestInfo)); + std::bind(&KisAnimationCachePopulator::Private::processFrameInfo, + requestInfo)); infoConversionWatcher.setFuture(requestFuture); diff --git a/krita/ui/kis_deferred_signal.h b/krita/ui/kis_deferred_signal.h --- a/krita/ui/kis_deferred_signal.h +++ b/krita/ui/kis_deferred_signal.h @@ -21,53 +21,51 @@ #include -#include -#include +#include /** * \class KisDeferredSignal is used for calling a specified callback - * function (which is a boost::function) after a specified time + * function (which is a std::function) after a specified time * delay. The callback is called from the QTimer event, so the * usage of the class does not block the Qt's event loop. * * Usage: * * \code{.cpp} * * // prepare the callback function - * boost::function callback( - * boost::bind(&KisCanvas2::setMonitorProfile, this, + * std::function callback( + * std::bind(&KisCanvas2::setMonitorProfile, this, * monitorProfile, renderingIntent, conversionFlags)); * * // create the timer connected to the function * KisDeferredSignal::deferSignal(1000, callback); * * \endcode * - * TODO: 1) rename KisDeferredSignal -> KisDeferredCallback - * 2) rename TrivialFunction -> CallbackFunction + * TODO: rename KisDeferredSignal -> KisDeferredCallback */ class KisDeferredSignal : public QObject { Q_OBJECT public: - typedef boost::function TrivialFunction; + using CallbackFunction = std::function; public: /** * Creates a timer which will call \p function after \p delay * milliseconds */ - static void deferSignal(int delay, TrivialFunction function); + static void deferSignal(int delay, CallbackFunction function); private Q_SLOTS: void timeout(); private: - KisDeferredSignal(int delay, TrivialFunction function); + KisDeferredSignal(int delay, CallbackFunction function); private: - TrivialFunction m_function; + CallbackFunction m_function; }; #endif /* __KIS_DEFERRED_SIGNAL_H */ diff --git a/krita/ui/kis_image_manager.cc b/krita/ui/kis_image_manager.cc --- a/krita/ui/kis_image_manager.cc +++ b/krita/ui/kis_image_manager.cc @@ -214,7 +214,7 @@ KisSignalCompressor compressor(200, KisSignalCompressor::FIRST_INACTIVE); - boost::function updateCall(boost::bind(updateImageBackgroundColor, image, &dlg)); + std::function updateCall(std::bind(updateImageBackgroundColor, image, &dlg)); SignalToFunctionProxy proxy(updateCall); connect(&dlg, SIGNAL(colorSelected(const QColor&)), &compressor, SLOT(start())); diff --git a/krita/ui/kis_layer_manager.cc b/krita/ui/kis_layer_manager.cc --- a/krita/ui/kis_layer_manager.cc +++ b/krita/ui/kis_layer_manager.cc @@ -982,7 +982,6 @@ KisDlgLayerStyle dlg(oldStyle->clone(), m_view->resourceProvider()); - boost::function updateCall(boost::bind(updateLayerStyles, layer, &dlg)); SignalToFunctionProxy proxy(updateCall); connect(&dlg, SIGNAL(configChanged()), &proxy, SLOT(start()));