Commit a16ad3a2 authored by Sven Langkamp's avatar Sven Langkamp

fix painting of brushop outline

BUG:221274

svn path=/trunk/koffice/; revision=1072354
parent e120cfac
......@@ -163,3 +163,11 @@ QString KisPaintOpSettings::modelName() const
}
#endif
KisPaintOpSettingsWidget* KisPaintOpSettings::optionsWidget() const
{
if(d->settingsWidget.isNull())
return 0;
return d->settingsWidget.data();
}
......@@ -136,6 +136,12 @@ public:
virtual QString modelName() const;
#endif
protected:
/**
* @return the option widget of the paintop (can be 0 is no option widgets is set)
*/
KisPaintOpSettingsWidget* optionsWidget() const;
private:
struct Private;
......
......@@ -24,10 +24,6 @@
#include "kis_brushop_settings_widget.h"
#include <kis_brush_option_widget.h>
#include <kis_paintop_options_widget.h>
#include <kis_pressure_darken_option.h>
#include <kis_pressure_opacity_option.h>
#include <kis_pressure_size_option.h>
#include <kis_paint_action_type_option.h>
#include "kis_image.h"
#include <KoViewConverter.h>
......@@ -36,7 +32,6 @@
#include <kis_paint_device.h> // TODO remove me when KisBoundary is used as pointers
KisBrushOpSettings::KisBrushOpSettings()
: m_options(0)
{
}
......@@ -51,8 +46,12 @@ bool KisBrushOpSettings::paintIncremental()
QRectF KisBrushOpSettings::paintOutlineRect(const QPointF& pos, KisImageWSP image, OutlineMode _mode) const
{
KisBrushOpSettingsWidget* options = dynamic_cast<KisBrushOpSettingsWidget*>(optionsWidget());
if(!options)
return QRectF();
if (_mode != CURSOR_IS_OUTLINE) return QRectF();
KisBrushSP brush = m_options->m_brushOption->brush();
KisBrushSP brush = options->m_brushOption->brush();
QPointF hotSpot = brush->hotSpot(1.0, 1.0);
return image->pixelToDocument(
QRectF(0, 0, brush->width() + 1, brush->height() + 1).translated(-(hotSpot + QPointF(0.5, 0.5)))
......@@ -61,21 +60,15 @@ QRectF KisBrushOpSettings::paintOutlineRect(const QPointF& pos, KisImageWSP imag
void KisBrushOpSettings::paintOutline(const QPointF& pos, KisImageWSP image, QPainter &painter, const KoViewConverter &converter, OutlineMode _mode) const
{
KisBrushOpSettingsWidget* options = dynamic_cast<KisBrushOpSettingsWidget*>(optionsWidget());
if(!options)
return;
if (_mode != CURSOR_IS_OUTLINE) return;
KisBrushSP brush = m_options->m_brushOption->brush();
KisBrushSP brush = options->m_brushOption->brush();
QPointF hotSpot = brush->hotSpot(1.0, 1.0);
painter.setPen(Qt::black);
painter.setBackground(Qt::black);
painter.translate(converter.documentToView(pos - image->pixelToDocument(hotSpot + QPointF(0.5, 0.5))));
KisBoundaryPainter::paint(brush->boundary(), image, painter, converter);
}
void KisBrushOpSettings::changePaintOpSize(qreal x, qreal y) const
{
Q_UNUSED(y);
qreal currentDiameter = m_options->m_brushOption->autoBrushDiameter();
m_options->m_brushOption->setAutoBrushDiameter(currentDiameter + qRound(x));
}
......@@ -26,10 +26,6 @@
#include <kis_paintop_settings.h>
#include <kis_types.h>
#include "kis_brushop_settings_widget.h"
class QDomElement;
class KisBrushOpSettings : public KisPaintOpSettings
{
......@@ -41,13 +37,6 @@ public:
virtual QRectF paintOutlineRect(const QPointF& pos, KisImageWSP image, OutlineMode _mode) const;
virtual void paintOutline(const QPointF& pos, KisImageWSP image, QPainter &painter, const KoViewConverter &converter, OutlineMode _mode) const;
virtual void changePaintOpSize(qreal x, qreal y) const;
public:
KisBrushOpSettingsWidget *m_options;
};
......
......@@ -63,4 +63,12 @@ KisPropertiesConfiguration* KisBrushOpSettingsWidget::configuration() const
return config;
}
void KisBrushOpSettingsWidget::changePaintOpSize(qreal x, qreal y)
{
Q_UNUSED(y);
qreal currentDiameter = m_brushOption->autoBrushDiameter();
m_brushOption->setAutoBrushDiameter(currentDiameter + qRound(x));
}
#include "kis_brushop_settings_widget.moc"
......@@ -41,6 +41,8 @@ public:
KisPropertiesConfiguration* configuration() const;
void changePaintOpSize(qreal x, qreal y);
public:
KisBrushOptionWidget * m_brushOption;
......
......@@ -32,6 +32,7 @@
#include "kis_airbrushop_settings_widget.h"
#include "kis_brushop.h"
#include "kis_brushop_settings.h"
#include "kis_brushop_settings_widget.h"
#include "kis_duplicateop_factory.h"
#include "kis_eraseop.h"
#include "kis_eraseop_settings.h"
......
......@@ -18,6 +18,8 @@
* Boston, MA 02110-1301, USA.
*/
#ifndef KIS_BRUSH_OPTION_H_
#define KIS_BRUSH_OPTION_H_
#include "kis_brush.h"
......@@ -33,7 +35,9 @@ public:
KisBrushSP brush() const;
void setBrush(KisBrushSP brush);
private:
KisBrushSP m_brush;
};
#endif
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