Krita Source Code Documentation
Loading...
Searching...
No Matches
MyPaintCurveOptionRangeControlsStrategy.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2022 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
8
9#include <klocalizedstring.h>
10
12#include <QVBoxLayout>
13#include <QHBoxLayout>
14
15#include <kis_slider_spin_box.h>
17#include <KisMpl.h>
18#include <kis_debug.h>
19
21 : m_rangeModel(dynamic_cast<MyPaintCurveRangeModel*>(rangeInterface))
22 , m_xValueSuffix(m_rangeModel->xValueSuffix())
23 , m_yValueSuffix(m_rangeModel->yValueSuffix())
24{
25 using namespace KisWidgetConnectionUtils;
27
28 KisDoubleSliderSpinBox *yLimitSlider = new KisDoubleSliderSpinBox(rangeControlsPlaceholder);
29 yLimitSlider->setPrefix(i18n("Y limit: "));
30 yLimitSlider->setRange(0.0, m_rangeModel->maxYRange(), 2);
31 m_yValueSuffix.bind(std::bind(&KisDoubleSliderSpinBox::setSuffix, yLimitSlider, std::placeholders::_1));
32 connectControl(yLimitSlider, m_rangeModel, "yLimit");
33
34 KisDoubleSliderSpinBox *xMin = new KisDoubleSliderSpinBox(rangeControlsPlaceholder);
35 xMin->setPrefix(i18n("X min: "));
36 m_xValueSuffix.bind(std::bind(&KisDoubleSliderSpinBox::setSuffix, xMin, std::placeholders::_1));
37 connectControlState(xMin, m_rangeModel, "xMinState", "xMin");
38
39 KisDoubleSliderSpinBox *xMax = new KisDoubleSliderSpinBox(rangeControlsPlaceholder);
40 xMax->setPrefix(i18n("X max: "));
41 m_xValueSuffix.bind(std::bind(&KisDoubleSliderSpinBox::setSuffix, xMax, std::placeholders::_1));
42 connectControlState(xMax, m_rangeModel, "xMaxState", "xMax");
43
44 QHBoxLayout *xRangeLayout = new QHBoxLayout();
45 xRangeLayout->addWidget(xMin);
46 xRangeLayout->addWidget(xMax);
47
48 QVBoxLayout *layout = new QVBoxLayout(rangeControlsPlaceholder);
49 layout->addWidget(yLimitSlider);
50 layout->addLayout(xRangeLayout);
51
52}
53
58
60{
61 return [] (KisCurveRangeModelInterface *rangeInterface, QWidget *rangeControlsPlaceholder) {
62 return new MyPaintCurveOptionRangeControlsStrategy(rangeInterface, rangeControlsPlaceholder);
63 };
64}
std::function< KisCurveOptionRangeControlsStrategyInterface *( KisCurveRangeModelInterface *, QWidget *)> KisCurveOptionRangeControlsStrategyFactory
This class is a spinbox in which you can click and drag to set the value. A slider like bar is displa...
void setRange(qreal newMinimum, qreal newMaximum, int newNumberOfDecimals=0, bool computeNewFastSliderStep=true)
Set the minimum and the maximum values of the range.
MyPaintCurveOptionRangeControlsStrategy(KisCurveRangeModelInterface *rangeInterface, QWidget *rangeControlsPlaceholder)
static KisCurveOptionRangeControlsStrategyFactory factory()
qreal maxYRange() const
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128