Changeset View
Changeset View
Standalone View
Standalone View
libs/ui/widgets/kis_curve_widget.cpp
Show First 20 Lines • Show All 309 Lines • ▼ Show 20 Line(s) | 304 | for (x = 0 ; x < wWidth ; x++) { | |||
---|---|---|---|---|---|
310 | * to ints mathematically, not just rounds down | 310 | * to ints mathematically, not just rounds down | ||
311 | * like in C | 311 | * like in C | ||
312 | */ | 312 | */ | ||
313 | poly.append(QPointF(x, curY)); | 313 | poly.append(QPointF(x, curY)); | ||
314 | } | 314 | } | ||
315 | poly.append(QPointF(x, wHeight - d->m_curve.value(1.0) * wHeight)); | 315 | poly.append(QPointF(x, wHeight - d->m_curve.value(1.0) * wHeight)); | ||
316 | p.drawPolyline(poly); | 316 | p.drawPolyline(poly); | ||
317 | 317 | | |||
318 | QPainterPath fillCurvePath; | ||||
319 | QPolygonF fillPoly = poly; | ||||
320 | fillPoly.append(QPoint(rect().width(), rect().height())); | ||||
321 | fillPoly.append(QPointF(0,rect().height())); | ||||
322 | | ||||
323 | // add a couple points to the edges so it fills in below always | ||||
324 | | ||||
325 | QColor fillColor = appPalette.color(QPalette::Text); | ||||
326 | fillColor.setAlphaF(0.2); | ||||
327 | | ||||
328 | fillCurvePath.addPolygon(fillPoly); | ||||
329 | p.fillPath(fillCurvePath, fillColor); | ||||
330 | | ||||
331 | | ||||
332 | | ||||
318 | // Drawing curve handles. | 333 | // Drawing curve handles. | ||
319 | double curveX; | 334 | double curveX; | ||
320 | double curveY; | 335 | double curveY; | ||
321 | if (!d->m_readOnlyMode) { | 336 | if (!d->m_readOnlyMode) { | ||
322 | for (int i = 0; i < d->m_curve.points().count(); ++i) { | 337 | for (int i = 0; i < d->m_curve.points().count(); ++i) { | ||
323 | curveX = d->m_curve.points().at(i).x(); | 338 | curveX = d->m_curve.points().at(i).x(); | ||
324 | curveY = d->m_curve.points().at(i).y(); | 339 | curveY = d->m_curve.points().at(i).y(); | ||
325 | 340 | | |||
326 | if (i == d->m_grab_point_index) { | 341 | if (i == d->m_grab_point_index) { | ||
327 | p.setPen(QPen(appPalette.color(QPalette::Text), 6, Qt::SolidLine)); | 342 | p.setPen(QPen(appPalette.color(QPalette::Text), 6, Qt::SolidLine)); | ||
328 | p.drawEllipse(QRectF(curveX * wWidth - 2, | 343 | p.drawEllipse(QRectF(curveX * wWidth - 2, | ||
329 | wHeight - 2 - curveY * wHeight, 4, 4)); | 344 | wHeight - 2 - curveY * wHeight, 4, 4)); | ||
330 | } else { | 345 | } else { | ||
331 | p.setPen(QPen(appPalette.color(QPalette::Text), 2, Qt::SolidLine)); | 346 | p.setPen(QPen(appPalette.color(QPalette::Text), 2, Qt::SolidLine)); | ||
332 | p.drawEllipse(QRectF(curveX * wWidth - 3, | 347 | p.drawEllipse(QRectF(curveX * wWidth - 3, | ||
333 | wHeight - 3 - curveY * wHeight, 6, 6)); | 348 | wHeight - 3 - curveY * wHeight, 6, 6)); | ||
334 | } | 349 | } | ||
335 | } | 350 | } | ||
336 | } | 351 | } | ||
352 | | ||||
353 | // add border around widget to help contain everything | ||||
354 | QPainterPath widgetBoundsPath; | ||||
355 | widgetBoundsPath.addRect(rect()); | ||||
356 | p.strokePath(widgetBoundsPath, appPalette.color(QPalette::Text)); | ||||
337 | } | 357 | } | ||
338 | 358 | | |||
339 | void KisCurveWidget::mousePressEvent(QMouseEvent * e) | 359 | void KisCurveWidget::mousePressEvent(QMouseEvent * e) | ||
340 | { | 360 | { | ||
341 | if (d->m_readOnlyMode) return; | 361 | if (d->m_readOnlyMode) return; | ||
342 | 362 | | |||
343 | if (e->button() != Qt::LeftButton) | 363 | if (e->button() != Qt::LeftButton) | ||
344 | return; | 364 | return; | ||
▲ Show 20 Lines • Show All 138 Lines • Show Last 20 Lines |