Commit e4788a6b authored by Dmitry Kazakov's avatar Dmitry Kazakov
Browse files

Probably fix the Ascension sensor in Hover mode

This patch passes the real tablet event to the outline generator
in hovering mode, so if your tablet supports rotational sensors it
the outline will be generated accordingly.

Please someone test it with a proper Tablet Device.

CCBUG:329625
parent 498ad949
......@@ -132,9 +132,20 @@ bool KisPaintInformation::isHoveringMode() const
return d->isHoveringMode;
}
KisPaintInformation KisPaintInformation::createHoveringModeInfo(const QPointF &pos)
KisPaintInformation
KisPaintInformation::createHoveringModeInfo(const QPointF &pos,
qreal pressure,
qreal xTilt, qreal yTilt,
qreal rotation,
qreal tangentialPressure,
qreal perspective)
{
KisPaintInformation info(pos);
KisPaintInformation info(pos,
pressure,
xTilt, yTilt,
rotation,
tangentialPressure,
perspective, 0);
info.d->isHoveringMode = true;
return info;
}
......
......@@ -171,7 +171,12 @@ public:
*
* \see isHoveringMode()
*/
static KisPaintInformation createHoveringModeInfo(const QPointF &pos);
static KisPaintInformation createHoveringModeInfo(const QPointF &pos,
qreal pressure = PRESSURE_DEFAULT,
qreal xTilt = 0.0, qreal yTilt = 0.0,
qreal rotation = 0.0,
qreal tangentialPressure = 0.0,
qreal perspective = 1.0);
void toXML(QDomDocument&, QDomElement&) const;
......
......@@ -140,7 +140,7 @@ void KisToolLine::continuePrimaryAction(KoPointerEvent *event)
m_maxPressure = qMax(m_maxPressure, float(pressureToCurve(event->pressure())));
updatePreview();
KisToolPaint::requestUpdateOutline(event->point);
KisToolPaint::requestUpdateOutline(event->point, event);
}
void KisToolLine::endPrimaryAction(KoPointerEvent *event)
......
......@@ -71,7 +71,7 @@ void KisToolMultihand::beginPrimaryAction(KoPointerEvent *event)
if(m_setupAxisFlag) {
setMode(KisTool::OTHER);
m_axisPoint = convertToPixelCoord(event->point);
requestUpdateOutline(event->point);
requestUpdateOutline(event->point, 0);
updateCanvas();
}
else {
......@@ -84,7 +84,7 @@ void KisToolMultihand::continuePrimaryAction(KoPointerEvent *event)
{
if(mode() == KisTool::OTHER) {
m_axisPoint = convertToPixelCoord(event->point);
requestUpdateOutline(event->point);
requestUpdateOutline(event->point, 0);
updateCanvas();
}
else {
......@@ -96,7 +96,7 @@ void KisToolMultihand::endPrimaryAction(KoPointerEvent *event)
{
if(mode() == KisTool::OTHER) {
setMode(KisTool::HOVER_MODE);
requestUpdateOutline(event->point);
requestUpdateOutline(event->point, 0);
finishAxisSetup();
}
else {
......
......@@ -98,6 +98,23 @@ KisPaintInformation KisPaintingInformationBuilder::createPaintingInformation(KoP
timeElapsed);
}
KisPaintInformation KisPaintingInformationBuilder::hover(const QPointF &imagePoint,
const KoPointerEvent *event)
{
qreal perspective = calculatePerspective(imagePoint);
if (event) {
return KisPaintInformation::createHoveringModeInfo(imagePoint,
pressureToCurve(event->pressure()),
event->xTilt(), event->yTilt(),
event->rotation(),
event->tangentialPressure(),
perspective);
} else {
return KisPaintInformation(imagePoint);
}
}
qreal KisPaintingInformationBuilder::pressureToCurve(qreal pressure)
{
return m_pressureSamples.at(qRound(pressure * LEVEL_OF_PRESSURE_RESOLUTION));
......
......@@ -41,6 +41,10 @@ public:
KisPaintInformation continueStroke(KoPointerEvent *event,
int timeElapsed);
KisPaintInformation hover(const QPointF &imagePoint,
const KoPointerEvent *event);
protected slots:
void updateSettings();
......
......@@ -175,7 +175,7 @@ void KisToolFreehand::beginPrimaryAction(KoPointerEvent *event)
// FIXME: workaround for the Duplicate Op
tryPickByPaintOp(event, PickFgImage);
requestUpdateOutline(event->point);
requestUpdateOutline(event->point, event);
if (!nodeEditable() || nodePaintAbility() != PAINT) {
event->ignore();
......@@ -201,7 +201,7 @@ void KisToolFreehand::continuePrimaryAction(KoPointerEvent *event)
{
CHECK_MODE_SANITY_OR_RETURN(KisTool::PAINT_MODE);
requestUpdateOutline(event->point);
requestUpdateOutline(event->point, event);
/**
* Actual painting
......@@ -294,7 +294,7 @@ void KisToolFreehand::continueAlternateAction(KoPointerEvent *event, AlternateAc
QPointF scaledOffset = canvas()->viewConverter()->viewToDocument(offset);
currentPaintOpPreset()->settings()->changePaintOpSize(scaledOffset.x(), scaledOffset.y());
requestUpdateOutline(m_initialGestureDocPoint);
requestUpdateOutline(m_initialGestureDocPoint, 0);
m_lastDocumentPoint = event->point;
}
......@@ -309,7 +309,7 @@ void KisToolFreehand::endAlternateAction(KoPointerEvent *event, AlternateAction
}
QCursor::setPos(m_initialGestureGlobalPoint);
requestUpdateOutline(m_initialGestureDocPoint);
requestUpdateOutline(m_initialGestureDocPoint, 0);
setMode(HOVER_MODE);
resetCursorStyle();
......@@ -347,11 +347,13 @@ qreal KisToolFreehand::calculatePerspective(const QPointF &documentPoint)
}
QPainterPath KisToolFreehand::getOutlinePath(const QPointF &documentPos,
KisPaintOpSettings::OutlineMode outlineMode)
const KoPointerEvent *event,
KisPaintOpSettings::OutlineMode outlineMode)
{
QPointF imagePos = currentImage()->documentToPixel(documentPos);
return m_helper->paintOpOutline(imagePos,
event,
currentPaintOpPreset()->settings(),
outlineMode);
}
......
......@@ -76,6 +76,7 @@ protected:
virtual void endStroke();
virtual QPainterPath getOutlinePath(const QPointF &documentPos,
const KoPointerEvent *event,
KisPaintOpSettings::OutlineMode outlineMode);
......
......@@ -136,11 +136,12 @@ void KisToolFreehandHelper::setSmoothness(const KisSmoothingOptions &smoothingOp
}
QPainterPath KisToolFreehandHelper::paintOpOutline(const QPointF &savedCursorPos,
const KoPointerEvent *event,
const KisPaintOpSettings *globalSettings,
KisPaintOpSettings::OutlineMode mode) const
{
const KisPaintOpSettings *settings = globalSettings;
KisPaintInformation info = KisPaintInformation::createHoveringModeInfo(savedCursorPos);
KisPaintInformation info = m_d->infoBuilder->hover(savedCursorPos, event);
KisDistanceInformation distanceInfo(m_d->lastOutlinePos.pushThroughHistory(savedCursorPos), 0);
if (!m_d->painterInfos.isEmpty()) {
......
......@@ -65,7 +65,10 @@ public:
void endPaint();
const KisPaintOp* currentPaintOp() const;
QPainterPath paintOpOutline(const QPointF &savedCursorPos, const KisPaintOpSettings *globalSettings, KisPaintOpSettings::OutlineMode mode) const;
QPainterPath paintOpOutline(const QPointF &savedCursorPos,
const KoPointerEvent *event,
const KisPaintOpSettings *globalSettings,
KisPaintOpSettings::OutlineMode mode) const;
protected:
......
......@@ -209,7 +209,7 @@ void KisToolPaint::beginAlternateAction(KoPointerEvent *event, AlternateAction a
{
if (pickColor(event->point, action)) {
setMode(SECONDARY_PAINT_MODE);
requestUpdateOutline(event->point);
requestUpdateOutline(event->point, event);
useCursor(KisCursor::pickerCursor());
} else {
KisTool::beginAlternateAction(event, action);
......@@ -229,7 +229,7 @@ void KisToolPaint::endAlternateAction(KoPointerEvent *event, AlternateAction act
if (pickColor(event->point, action)) {
setMode(KisTool::HOVER_MODE);
resetCursorStyle();
requestUpdateOutline(event->point);
requestUpdateOutline(event->point, event);
} else {
KisTool::endAlternateAction(event, action);
}
......@@ -267,7 +267,7 @@ void KisToolPaint::mousePressEvent(KoPointerEvent *event)
{
KisTool::mousePressEvent(event);
if (mode() == KisTool::HOVER_MODE) {
requestUpdateOutline(event->point);
requestUpdateOutline(event->point, event);
}
}
......@@ -275,7 +275,7 @@ void KisToolPaint::mouseMoveEvent(KoPointerEvent *event)
{
KisTool::mouseMoveEvent(event);
if (mode() == KisTool::HOVER_MODE) {
requestUpdateOutline(event->point);
requestUpdateOutline(event->point, event);
}
}
......@@ -283,7 +283,7 @@ void KisToolPaint::mouseReleaseEvent(KoPointerEvent *event)
{
KisTool::mouseReleaseEvent(event);
if (mode() == KisTool::HOVER_MODE) {
requestUpdateOutline(event->point);
requestUpdateOutline(event->point, event);
}
}
......@@ -413,7 +413,7 @@ void KisToolPaint::increaseBrushSize()
increment = 10;
}
currentPaintOpPreset()->settings()->changePaintOpSize(increment, 0);
requestUpdateOutline(m_outlineDocPoint);
requestUpdateOutline(m_outlineDocPoint, 0);
}
void KisToolPaint::decreaseBrushSize()
......@@ -426,10 +426,10 @@ void KisToolPaint::decreaseBrushSize()
decrement = -10;
}
currentPaintOpPreset()->settings()->changePaintOpSize(decrement, 0);
requestUpdateOutline(m_outlineDocPoint);
requestUpdateOutline(m_outlineDocPoint, 0);
}
void KisToolPaint::requestUpdateOutline(const QPointF &outlineDocPoint)
void KisToolPaint::requestUpdateOutline(const QPointF &outlineDocPoint, const KoPointerEvent *event)
{
if (!m_supportOutline) return;
......@@ -446,7 +446,7 @@ void KisToolPaint::requestUpdateOutline(const QPointF &outlineDocPoint)
}
m_outlineDocPoint = outlineDocPoint;
m_currentOutline = getOutlinePath(m_outlineDocPoint, outlineMode);
m_currentOutline = getOutlinePath(m_outlineDocPoint, event, outlineMode);
QRectF outlinePixelRect = m_currentOutline.boundingRect();
QRectF outlineDocRect = currentImage()->pixelToDocument(outlinePixelRect);
......@@ -473,8 +473,11 @@ void KisToolPaint::requestUpdateOutline(const QPointF &outlineDocPoint)
}
QPainterPath KisToolPaint::getOutlinePath(const QPointF &documentPos,
const KoPointerEvent *event,
KisPaintOpSettings::OutlineMode outlineMode)
{
Q_UNUSED(event);
QPointF imagePos = currentImage()->documentToPixel(documentPos);
QPainterPath path = currentPaintOpPreset()->settings()->
brushOutline(KisPaintInformation(imagePos), outlineMode);
......
......@@ -86,7 +86,7 @@ protected:
virtual void mouseReleaseEvent(KoPointerEvent *event);
virtual void mouseMoveEvent(KoPointerEvent *event);
virtual void requestUpdateOutline(const QPointF &outlineDocPoint);
virtual void requestUpdateOutline(const QPointF &outlineDocPoint, const KoPointerEvent *event);
/** If the paint tool support outline like brushes, set to true.
* If not (e.g. gradient tool), set to false. Default is false.
......@@ -96,7 +96,8 @@ protected:
}
virtual QPainterPath getOutlinePath(const QPointF &documentPos,
KisPaintOpSettings::OutlineMode outlineMode);
const KoPointerEvent *event,
KisPaintOpSettings::OutlineMode outlineMode);
protected:
bool pickColor(const QPointF &documentPixel, AlternateAction action);
......
......@@ -139,7 +139,7 @@ void KisToolPolylineBase::mouseMoveEvent(KoPointerEvent *event)
(basePoint - pixelToView(m_dragEnd)).manhattanLength() < SNAPPING_THRESHOLD;
updateCanvasViewRect(QRectF(basePoint, 2 * QSize(SNAPPING_HANDLE_RADIUS + PREVIEW_LINE_WIDTH, SNAPPING_HANDLE_RADIUS + PREVIEW_LINE_WIDTH)).translated(-SNAPPING_HANDLE_RADIUS + PREVIEW_LINE_WIDTH,-SNAPPING_HANDLE_RADIUS + PREVIEW_LINE_WIDTH));
KisToolPaint::requestUpdateOutline(event->point);
KisToolPaint::requestUpdateOutline(event->point, event);
} else {
KisToolPaint::mouseMoveEvent(event);
}
......
......@@ -92,7 +92,7 @@ void KisToolRectangleBase::continuePrimaryAction(KoPointerEvent *event)
m_dragCenter = QPointF((m_dragStart.x() + m_dragEnd.x()) / 2,
(m_dragStart.y() + m_dragEnd.y()) / 2);
KisToolPaint::requestUpdateOutline(event->point);
KisToolPaint::requestUpdateOutline(event->point, event);
}
void KisToolRectangleBase::endPrimaryAction(KoPointerEvent *event)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment