Commit a73b00a7 authored by Halla Rempt's avatar Halla Rempt
Browse files

Fix outline cursor

The outline cursor now listens to rotation and size again, plus there's
an option to show a small dot in the middle of the outline.

BUG:325234
BUG:325235
parent ef98f72a
......@@ -44,7 +44,8 @@ enum enumCursorStyle {
CURSOR_STYLE_POINTER = 2,
CURSOR_STYLE_OUTLINE = 3,
CURSOR_STYLE_NO_CURSOR = 4,
CURSOR_STYLE_SMALL_ROUND = 5
CURSOR_STYLE_SMALL_ROUND = 5,
CURSOR_STYLE_OUTLINE_CENTER_DOT = 6
};
/*
......
......@@ -93,7 +93,13 @@ GeneralTab::GeneralTab(QWidget *_parent, const char *_name)
{
KisConfig cfg;
m_cmbCursorShape->addItem(i18n("Tool Icon"));
m_cmbCursorShape->addItem(i18n("Crosshair"));
m_cmbCursorShape->addItem(i18n("Arrow"));
m_cmbCursorShape->addItem(i18n("Brush Outline"));
m_cmbCursorShape->addItem(i18n("No Cursor"));
m_cmbCursorShape->addItem(i18n("Small Circle"));
m_cmbCursorShape->addItem(i18n("Brush Outline with Small Circle"));
#ifdef NEPOMUK
grpResourceTagging->show();
......
......@@ -22,33 +22,7 @@
</widget>
</item>
<item row="0" column="2">
<widget class="QComboBox" name="m_cmbCursorShape">
<item>
<property name="text">
<string>Tool Icon</string>
</property>
</item>
<item>
<property name="text">
<string>Crosshair</string>
</property>
</item>
<item>
<property name="text">
<string>Arrow</string>
</property>
</item>
<item>
<property name="text">
<string>Brush Outline</string>
</property>
</item>
<item>
<property name="text">
<string>No Cursor</string>
</property>
</item>
</widget>
<widget class="QComboBox" name="m_cmbCursorShape"/>
</item>
<item row="0" column="3">
<spacer name="spacer1">
......
......@@ -719,26 +719,37 @@ void KisTool::paintToolOutline(QPainter* painter, const QPainterPath &path)
void KisTool::resetCursorStyle()
{
KisConfig cfg;
useCursor(d->cursor);
switch (cfg.cursorStyle()) {
case CURSOR_STYLE_TOOLICON:
qDebug() << "toolicon";
useCursor(d->cursor);
break;
case CURSOR_STYLE_CROSSHAIR:
qDebug() << "crosshair";
useCursor(KisCursor::crossCursor());
break;
case CURSOR_STYLE_SMALL_ROUND:
useCursor(KisCursor::roundCursor());
break;
case CURSOR_STYLE_POINTER:
useCursor(KisCursor::upArrowCursor());
qDebug() << "pointer";
useCursor(KisCursor::arrowCursor());
break;
case CURSOR_STYLE_NO_CURSOR:
qDebug() << "blank";
useCursor(KisCursor::blankCursor());
break;
case CURSOR_STYLE_SMALL_ROUND:
case CURSOR_STYLE_OUTLINE_CENTER_DOT:
qDebug() << "round";
useCursor(KisCursor::roundCursor());
break;
case CURSOR_STYLE_OUTLINE:
qDebug() << "outline";
break;
default:
qDebug() << "Default";
// use tool cursor as default, if the tool supports outline, it will set the cursor to blank and show outline
useCursor(d->cursor);
}
}
......
......@@ -208,7 +208,6 @@ void KisToolFreehand::mousePressEvent(KoPointerEvent *e)
}
else {
KisToolPaint::mousePressEvent(e);
//requestUpdateOutline(e->point);
}
}
......@@ -223,14 +222,7 @@ void KisToolFreehand::mouseMoveEvent(KoPointerEvent *e)
}
if (mode() != KisTool::PAINT_MODE) {
if(mode() == KisTool::SECONDARY_PAINT_MODE) {
KisToolPaint::pickColor(e->point, e->modifiers() & Qt::AltModifier,
m_toForegroundColor);
e->accept();
}
else {
KisTool::mouseMoveEvent(e);
}
KisToolPaint::mouseMoveEvent(e);
return;
}
......@@ -334,48 +326,6 @@ qreal KisToolFreehand::calculatePerspective(const QPointF &documentPoint)
return perspective;
}
void KisToolFreehand::requestUpdateOutline(const QPointF &outlineDocPoint)
{
KisConfig cfg;
KisPaintOpSettings::OutlineMode outlineMode;
outlineMode = KisPaintOpSettings::CursorIsNotOutline;
if (m_explicitShowOutline ||
mode() == KisTool::GESTURE_MODE ||
(cfg.cursorStyle() == CURSOR_STYLE_OUTLINE &&
((mode() == HOVER_MODE && !specialHoverModeActive()) ||
(mode() == PAINT_MODE && cfg.showOutlineWhilePainting())))) {
outlineMode = KisPaintOpSettings::CursorIsOutline;
}
m_outlineDocPoint = outlineDocPoint;
m_currentOutline = getOutlinePath(m_outlineDocPoint, outlineMode);
QRectF outlinePixelRect = m_currentOutline.boundingRect();
QRectF outlineDocRect = currentImage()->pixelToDocument(outlinePixelRect);
// This adjusted call is needed as we paint with a 3 pixel wide brush and the pen is outside the bounds of the path
// Pen uses view coordinates so we have to zoom the document value to match 2 pixel in view coordiates
// See BUG 275829
qreal zoomX;
qreal zoomY;
canvas()->viewConverter()->zoom(&zoomX, &zoomY);
qreal xoffset = 2.0/zoomX;
qreal yoffset = 2.0/zoomY;
QRectF newOutlineRect = outlineDocRect.adjusted(-xoffset,-yoffset,xoffset,yoffset);
if (!m_oldOutlineRect.isEmpty()) {
canvas()->updateCanvas(m_oldOutlineRect);
}
if (!newOutlineRect.isEmpty()) {
canvas()->updateCanvas(newOutlineRect);
}
m_oldOutlineRect = newOutlineRect;
}
void KisToolFreehand::showOutlineTemporary()
{
m_explicitShowOutline = true;
......@@ -389,5 +339,28 @@ void KisToolFreehand::hideOutline()
requestUpdateOutline(m_outlineDocPoint);
}
QPainterPath KisToolFreehand::getOutlinePath(const QPointF &documentPos,
KisPaintOpSettings::OutlineMode outlineMode)
{
qreal scale = 1.0;
qreal rotation = 0;
if (mode() == KisTool::HOVER_MODE) {
rotation += static_cast<KisCanvas2*>(canvas())->rotationAngle() * M_PI / 180.0;
}
const KisPaintOp *paintOp = m_helper->currentPaintOp();
if (paintOp){
scale = paintOp->currentScale();
rotation = paintOp->currentRotation();
}
QPointF imagePos = currentImage()->documentToPixel(documentPos);
QPainterPath path = currentPaintOpPreset()->settings()->
brushOutline(imagePos, outlineMode, scale, rotation);
return path;
}
#include "kis_tool_freehand.moc"
......@@ -74,11 +74,13 @@ protected:
virtual void paint(QPainter& gc, const KoViewConverter &converter);
virtual QPainterPath getOutlinePath(const QPointF &documentPos,
KisPaintOpSettings::OutlineMode outlineMode);
KisPaintingInformationBuilder* paintingInformationBuilder() const;
KisRecordingAdapter* recordingAdapter() const;
void resetHelper(KisToolFreehandHelper *helper);
void requestUpdateOutline(const QPointF &outlineDocPoint);
protected slots:
......@@ -101,8 +103,6 @@ private:
void showOutlineTemporary();
private slots:
void hideOutline();
......
......@@ -402,10 +402,7 @@ void KisToolPaint::resetCursorStyle()
if (cfg.cursorStyle() == CURSOR_STYLE_OUTLINE) {
if (m_supportOutline) {
// do not show cursor, tool will paint outline
useCursor(KisCursor::blankCursor());
} else {
// if the tool does not support outline, use tool icon cursor
useCursor(cursor());
useCursor(KisCursor::blankCursor());
}
}
}
......@@ -525,7 +522,7 @@ void KisToolPaint::requestUpdateOutline(const QPointF &outlineDocPoint)
outlineMode = KisPaintOpSettings::CursorIsNotOutline;
if (mode() == KisTool::GESTURE_MODE ||
(cfg.cursorStyle() == CURSOR_STYLE_OUTLINE &&
((cfg.cursorStyle() == CURSOR_STYLE_OUTLINE || cfg.cursorStyle() == CURSOR_STYLE_OUTLINE_CENTER_DOT )&&
((mode() == HOVER_MODE && !specialHoverModeActive()) ||
(mode() == PAINT_MODE && cfg.showOutlineWhilePainting())))) {
......@@ -560,7 +557,7 @@ void KisToolPaint::requestUpdateOutline(const QPointF &outlineDocPoint)
}
QPainterPath KisToolPaint::getOutlinePath(const QPointF &documentPos,
KisPaintOpSettings::OutlineMode outlineMode)
KisPaintOpSettings::OutlineMode outlineMode)
{
qreal scale = 1.0;
qreal rotation = 0;
......
......@@ -92,7 +92,8 @@ protected:
void setSupportOutline(bool supportOutline) {
m_supportOutline = supportOutline;
}
QPainterPath getOutlinePath(const QPointF &documentPos,
virtual QPainterPath getOutlinePath(const QPointF &documentPos,
KisPaintOpSettings::OutlineMode outlineMode);
protected:
......
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