MCPcopy Create free account
hub / github.com/Cubitect/cubiomes-viewer / paintEvent

Method paintEvent

src/widgets.cpp:201–251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199}
200
201void RangeSlider::paintEvent(QPaintEvent *)
202{
203 QPainter painter(this);
204
205 QStyleOptionSlider opt;
206 initStyleOption(&opt);
207
208 // draw the back groove of the slider without range highlighting
209 opt.subControls = QStyle::SC_SliderGroove;
210 opt.sliderValue = opt.sliderPosition = vmin;
211 style()->drawComplexControl(QStyle::CC_Slider, &opt, &painter, this);
212
213 // draw the range highlighting between the handles
214 QRect groove = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderGroove, this);
215 opt.sliderValue = opt.sliderPosition = pos0;
216 QRect handle0 = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this);
217 opt.sliderValue = opt.sliderPosition = pos1;
218 QRect handle1 = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this);
219
220 if (colinner.isValid())
221 {
222 painter.setBrush(QBrush(colinner));
223 painter.setPen(QPen(colinner, 0));
224 int x0 = handle0.center().x();
225 int x1 = handle1.center().x();
226 int y = handle0.center().y() - 1;
227 QRect span = QRect(x0, y, x1-x0, 3);
228 painter.drawRect(groove.intersected(span));
229 }
230 if (colouter.isValid())
231 {
232 painter.setBrush(QBrush(colouter));
233 painter.setPen(QPen(colouter, 0));
234 int x0 = handle0.center().x();
235 int x1 = handle1.center().x();
236 int y = handle0.center().y() - 1;
237 QRect left = QRect(groove.x()+1, y, x0-groove.x()-2, 3);
238 painter.drawRect(groove.intersected(left));
239 QRect right = QRect(x1+1, y, groove.right()-x1-2, 3);
240 painter.drawRect(groove.intersected(right));
241 }
242
243 int pmin = pos0 < pos1 ? pos0 : pos1;
244 int pmax = pos0 > pos1 ? pos0 : pos1;
245 // draw handles
246 opt.subControls = QStyle::SC_SliderHandle;
247 opt.sliderValue = opt.sliderPosition = pmax;
248 style()->drawComplexControl(QStyle::CC_Slider, &opt, &painter, this);
249 opt.sliderValue = opt.sliderPosition = pmin;
250 style()->drawComplexControl(QStyle::CC_Slider, &opt, &painter, this);
251}
252
253void RangeSlider::mousePressEvent(QMouseEvent *e)
254{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected