File indexing completed on 2024-05-19 04:26:58
0001 /* 0002 * SPDX-FileCopyrightText: 2010 Justin Noel <justin@ics.com> 0003 * SPDX-FileCopyrightText: 2021 Deif Lou <ginoba@gmail.com> 0004 * 0005 * SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #include "SliderSpinBox.h" 0009 #include "kis_debug.h" 0010 0011 struct SliderSpinBox::Private { 0012 Private() {} 0013 0014 KisSliderSpinBox *widget; 0015 }; 0016 0017 SliderSpinBox::SliderSpinBox() 0018 : IntParseSpinBox() 0019 , d(new Private) 0020 { 0021 d->widget = new KisSliderSpinBox(); 0022 0023 // Forward KisSliderSpinBox::draggingFinished to SliderSpinBox::draggingFinished 0024 connect(d->widget, SIGNAL(draggingFinished()), this, SIGNAL(draggingFinished())); 0025 } 0026 0027 SliderSpinBox::~SliderSpinBox() 0028 { 0029 delete d; 0030 } 0031 0032 QWidget* SliderSpinBox::widget() const 0033 { 0034 return d->widget; 0035 } 0036 int SliderSpinBox::fastSliderStep() const 0037 { 0038 return d->widget->fastSliderStep(); 0039 } 0040 0041 int SliderSpinBox::softMinimum() const 0042 { 0043 return d->widget->softMinimum(); 0044 } 0045 0046 int SliderSpinBox::softMaximum() const 0047 { 0048 return d->widget->softMaximum(); 0049 } 0050 0051 bool SliderSpinBox::isDragging() const 0052 { 0053 return d->widget->isDragging(); 0054 } 0055 0056 void SliderSpinBox::setValue(int newValue) 0057 { 0058 d->widget->setValue(newValue); 0059 } 0060 0061 void SliderSpinBox::setRange(int newMinimum, int newMaximum, bool computeNewFastSliderStep) 0062 { 0063 d->widget->setRange(newMinimum, newMaximum, computeNewFastSliderStep); 0064 } 0065 0066 void SliderSpinBox::setMinimum(int newMinimum, bool computeNewFastSliderStep) 0067 { 0068 d->widget->setMinimum(newMinimum, computeNewFastSliderStep); 0069 } 0070 0071 void SliderSpinBox::setMaximum(int newMaximum, bool computeNewFastSliderStep) 0072 { 0073 d->widget->setMaximum(newMaximum, computeNewFastSliderStep); 0074 } 0075 0076 void SliderSpinBox::setExponentRatio(double newExponentRatio) 0077 { 0078 if (newExponentRatio <= 0.0) { 0079 dbgScript << "Script using SliderSpinbox.setExponentRatio passed value <= 0.0 (" << newExponentRatio << "), ignoring."; 0080 return; 0081 } 0082 d->widget->setExponentRatio(newExponentRatio); 0083 } 0084 0085 void SliderSpinBox::setBlockUpdateSignalOnDrag(bool newBlockUpdateSignalOnDrag) 0086 { 0087 d->widget->setBlockUpdateSignalOnDrag(newBlockUpdateSignalOnDrag); 0088 } 0089 0090 void SliderSpinBox::setFastSliderStep(int newFastSliderStep) 0091 { 0092 d->widget->setFastSliderStep(newFastSliderStep); 0093 } 0094 0095 void SliderSpinBox::setSoftRange(int newSoftMinimum, int newSoftMaximum) 0096 { 0097 d->widget->setSoftRange(newSoftMinimum, newSoftMaximum); 0098 } 0099 0100 void SliderSpinBox::setSoftMinimum(int newSoftMinimum) 0101 { 0102 d->widget->setSoftMinimum(newSoftMinimum); 0103 } 0104 0105 void SliderSpinBox::setSoftMaximum(int newSoftMaximum) 0106 { 0107 d->widget->setSoftMaximum(newSoftMaximum); 0108 } 0109 0110 struct DoubleSliderSpinBox::Private { 0111 Private() {} 0112 0113 KisDoubleSliderSpinBox *widget; 0114 }; 0115 0116 DoubleSliderSpinBox::DoubleSliderSpinBox() 0117 : DoubleParseSpinBox() 0118 , d(new Private) 0119 { 0120 d->widget = new KisDoubleSliderSpinBox(); 0121 0122 // Forward KisDoubleSliderSpinBox::draggingFinished to DoubleSliderSpinBox::draggingFinished 0123 connect(d->widget, SIGNAL(draggingFinished()), this, SIGNAL(draggingFinished())); 0124 } 0125 0126 DoubleSliderSpinBox::~DoubleSliderSpinBox() 0127 { 0128 delete d; 0129 } 0130 0131 QWidget* DoubleSliderSpinBox::widget() const 0132 { 0133 return d->widget; 0134 } 0135 0136 double DoubleSliderSpinBox::fastSliderStep() const 0137 { 0138 return d->widget->fastSliderStep(); 0139 } 0140 0141 double DoubleSliderSpinBox::softMinimum() const 0142 { 0143 return d->widget->softMinimum(); 0144 } 0145 0146 double DoubleSliderSpinBox::softMaximum() const 0147 { 0148 return d->widget->softMaximum(); 0149 } 0150 0151 bool DoubleSliderSpinBox::isDragging() const 0152 { 0153 return d->widget->isDragging(); 0154 } 0155 0156 void DoubleSliderSpinBox::setValue(double newValue) 0157 { 0158 d->widget->setValue(newValue); 0159 } 0160 0161 void DoubleSliderSpinBox::setRange(double newMinimum, double newMaximum, int newNumberOfDecimals, bool computeNewFastSliderStep) 0162 { 0163 d->widget->setRange(newMinimum, newMaximum, newNumberOfDecimals, computeNewFastSliderStep); 0164 } 0165 0166 void DoubleSliderSpinBox::setMinimum(double newMinimum, bool computeNewFastSliderStep) 0167 { 0168 d->widget->setMinimum(newMinimum, computeNewFastSliderStep); 0169 } 0170 0171 void DoubleSliderSpinBox::setMaximum(double newMaximum, bool computeNewFastSliderStep) 0172 { 0173 d->widget->setMaximum(newMaximum, computeNewFastSliderStep); 0174 } 0175 0176 void DoubleSliderSpinBox::setExponentRatio(double newExponentRatio) 0177 { 0178 if (newExponentRatio <= 0.0) { 0179 dbgScript << "Script using DoubleSliderSpinbox.setExponentRatio passed value <= 0.0 (" << newExponentRatio << "), ignoring."; 0180 return; 0181 } 0182 d->widget->setExponentRatio(newExponentRatio); 0183 } 0184 0185 void DoubleSliderSpinBox::setBlockUpdateSignalOnDrag(bool newBlockUpdateSignalOnDrag) 0186 { 0187 d->widget->setBlockUpdateSignalOnDrag(newBlockUpdateSignalOnDrag); 0188 } 0189 0190 void DoubleSliderSpinBox::setFastSliderStep(double newFastSliderStep) 0191 { 0192 d->widget->setFastSliderStep(newFastSliderStep); 0193 } 0194 0195 void DoubleSliderSpinBox::setSoftRange(double newSoftMinimum, double newSoftMaximum) 0196 { 0197 d->widget->setSoftRange(newSoftMinimum, newSoftMaximum); 0198 } 0199 0200 void DoubleSliderSpinBox::setSoftMinimum(double newSoftMinimum) 0201 { 0202 setSoftRange(newSoftMinimum, d->widget->softMaximum()); 0203 } 0204 0205 void DoubleSliderSpinBox::setSoftMaximum(double newSoftMaximum) 0206 { 0207 setSoftRange(d->widget->softMinimum(), newSoftMaximum); 0208 }