it makes no sense to have the blur stuff in one header/namespace and the roundedRectangle stuff in another: it's all painting related. putting them together, however, makes "ImageEffects" really not accurate. ImageEffects will also clash, concept-wise, with a real effects lib.
therefore, introducing Plasma::PaintUtils. svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=827859
This commit is contained in:
parent
1c0edaceb7
commit
922c85c705
@ -39,8 +39,8 @@ set(plasma_LIB_SRCS
|
|||||||
dialog.cpp
|
dialog.cpp
|
||||||
#FOR FUTURE
|
#FOR FUTURE
|
||||||
#layouts/borderlayout.cpp
|
#layouts/borderlayout.cpp
|
||||||
imageeffects.cpp
|
|
||||||
packages.cpp
|
packages.cpp
|
||||||
|
paintutils.cpp
|
||||||
panelsvg.cpp
|
panelsvg.cpp
|
||||||
paneltoolbox.cpp
|
paneltoolbox.cpp
|
||||||
plasma.cpp
|
plasma.cpp
|
||||||
@ -128,7 +128,7 @@ set(plasma_LIB_INCLUDES
|
|||||||
dataenginemanager.h
|
dataenginemanager.h
|
||||||
delegate.h
|
delegate.h
|
||||||
dialog.h
|
dialog.h
|
||||||
imageeffects.h
|
paintutils.h
|
||||||
panelsvg.h
|
panelsvg.h
|
||||||
plasma.h
|
plasma.h
|
||||||
plasma_export.h
|
plasma_export.h
|
||||||
@ -202,13 +202,13 @@ includes/Dialog
|
|||||||
includes/Flash
|
includes/Flash
|
||||||
includes/GroupBox
|
includes/GroupBox
|
||||||
includes/Icon
|
includes/Icon
|
||||||
includes/ImageEffects
|
|
||||||
includes/Label
|
includes/Label
|
||||||
includes/LineEdit
|
includes/LineEdit
|
||||||
includes/Meter
|
includes/Meter
|
||||||
includes/Package
|
includes/Package
|
||||||
includes/PackageMetadata
|
includes/PackageMetadata
|
||||||
includes/PackageStructure
|
includes/PackageStructure
|
||||||
|
includes/PaintUtils
|
||||||
includes/PanelSvg
|
includes/PanelSvg
|
||||||
includes/Plasma
|
includes/Plasma
|
||||||
includes/PushButton
|
includes/PushButton
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#include "applet_p.h"
|
#include "applet_p.h"
|
||||||
#include "containment.h"
|
#include "containment.h"
|
||||||
#include "corona.h"
|
#include "corona.h"
|
||||||
|
#include "paintutils.h"
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
|
|
||||||
@ -170,7 +171,7 @@ void AppletHandle::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
|||||||
gr.setColorAt(0.1, KColorScheme::shade(m_gradientColor, KColorScheme::LightShade));
|
gr.setColorAt(0.1, KColorScheme::shade(m_gradientColor, KColorScheme::LightShade));
|
||||||
gr.setColorAt(1, KColorScheme::shade(m_gradientColor, KColorScheme::DarkShade));
|
gr.setColorAt(1, KColorScheme::shade(m_gradientColor, KColorScheme::DarkShade));
|
||||||
painter->setBrush(gr);
|
painter->setBrush(gr);
|
||||||
QPainterPath path = Plasma::roundedRectangle(boundingRect(), 10);
|
QPainterPath path = PaintUtils::roundedRectangle(boundingRect(), 10);
|
||||||
|
|
||||||
if (m_applet) {
|
if (m_applet) {
|
||||||
QPainterPath shape = m_applet->shape();
|
QPainterPath shape = m_applet->shape();
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
#include <KColorScheme>
|
#include <KColorScheme>
|
||||||
|
|
||||||
// plasma
|
// plasma
|
||||||
#include <plasma/plasma.h>
|
#include <plasma/paintutils.h>
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
@ -312,7 +312,7 @@ void Delegate::paint(QPainter *painter, const QStyleOptionViewItem& option, cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
painter->setPen(outlinePen);
|
painter->setPen(outlinePen);
|
||||||
painter->drawPath(Plasma::roundedRectangle(highlightRect, roundedRadius));
|
painter->drawPath(PaintUtils::roundedRectangle(highlightRect, roundedRadius));
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
@ -1 +0,0 @@
|
|||||||
#include "../../plasma/imageeffects.h"
|
|
1
includes/PaintUtils
Normal file
1
includes/PaintUtils
Normal file
@ -0,0 +1 @@
|
|||||||
|
#include "../../plasma/paintutils.h"
|
@ -18,16 +18,18 @@
|
|||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <imageeffects.h>
|
#include <paintutils.h>
|
||||||
#include "effects/blur.cpp"
|
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
|
||||||
|
#include "effects/blur.cpp"
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
namespace ImageEffects
|
namespace PaintUtils
|
||||||
{
|
{
|
||||||
|
|
||||||
void shadowBlur(QImage &image, int radius, const QColor &color)
|
void shadowBlur(QImage &image, int radius, const QColor &color)
|
||||||
@ -76,7 +78,22 @@ QPixmap shadowText(QString text, QColor textColor, QColor shadowColor, QPoint of
|
|||||||
return finalPixmap;
|
return finalPixmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
} //ImageEffects namespace
|
QPainterPath roundedRectangle(const QRectF& rect, qreal radius)
|
||||||
|
{
|
||||||
|
QPainterPath path(QPointF(rect.left(), rect.top() + radius));
|
||||||
|
path.quadTo(rect.left(), rect.top(), rect.left() + radius, rect.top()); // Top left corner
|
||||||
|
path.lineTo(rect.right() - radius, rect.top()); // Top side
|
||||||
|
path.quadTo(rect.right(), rect.top(), rect.right(), rect.top() + radius); // Top right corner
|
||||||
|
path.lineTo(rect.right(), rect.bottom() - radius); // Right side
|
||||||
|
path.quadTo(rect.right(), rect.bottom(), rect.right() - radius, rect.bottom()); // Bottom right corner
|
||||||
|
path.lineTo(rect.left() + radius, rect.bottom()); // Bottom side
|
||||||
|
path.quadTo(rect.left(), rect.bottom(), rect.left(), rect.bottom() - radius); // Bottom left corner
|
||||||
|
path.closeSubpath();
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // PaintUtils namespace
|
||||||
|
|
||||||
} // Plasma namespace
|
} // Plasma namespace
|
||||||
|
|
@ -33,7 +33,7 @@ namespace Plasma
|
|||||||
/**
|
/**
|
||||||
* Namespace for all Image Effects specific to Plasma
|
* Namespace for all Image Effects specific to Plasma
|
||||||
**/
|
**/
|
||||||
namespace ImageEffects
|
namespace PaintUtils
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -51,7 +51,12 @@ PLASMA_EXPORT QPixmap shadowText(QString text,
|
|||||||
QPoint offset = QPoint(1,1),
|
QPoint offset = QPoint(1,1),
|
||||||
int radius = 2);
|
int radius = 2);
|
||||||
|
|
||||||
} // ImageEffects namespace
|
/**
|
||||||
|
* Returns a nicely rounded rectanglular path for painting.
|
||||||
|
*/
|
||||||
|
PLASMA_EXPORT QPainterPath roundedRectangle(const QRectF& rect, qreal radius);
|
||||||
|
|
||||||
|
} // PaintUtils namespace
|
||||||
|
|
||||||
} // Plasma namespace
|
} // Plasma namespace
|
||||||
|
|
15
plasma.cpp
15
plasma.cpp
@ -62,19 +62,4 @@ Direction locationToDirection(Location location)
|
|||||||
return Down;
|
return Down;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPainterPath roundedRectangle(const QRectF& rect, qreal radius)
|
|
||||||
{
|
|
||||||
QPainterPath path(QPointF(rect.left(), rect.top() + radius));
|
|
||||||
path.quadTo(rect.left(), rect.top(), rect.left() + radius, rect.top()); // Top left corner
|
|
||||||
path.lineTo(rect.right() - radius, rect.top()); // Top side
|
|
||||||
path.quadTo(rect.right(), rect.top(), rect.right(), rect.top() + radius); // Top right corner
|
|
||||||
path.lineTo(rect.right(), rect.bottom() - radius); // Right side
|
|
||||||
path.quadTo(rect.right(), rect.bottom(), rect.right() - radius, rect.bottom()); // Bottom right corner
|
|
||||||
path.lineTo(rect.left() + radius, rect.bottom()); // Bottom side
|
|
||||||
path.quadTo(rect.left(), rect.bottom(), rect.left(), rect.bottom() - radius); // Bottom left corner
|
|
||||||
path.closeSubpath();
|
|
||||||
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // Plasma namespace
|
} // Plasma namespace
|
||||||
|
5
plasma.h
5
plasma.h
@ -193,11 +193,6 @@ PLASMA_EXPORT qreal scalingFactor(ZoomLevel level);
|
|||||||
**/
|
**/
|
||||||
PLASMA_EXPORT Direction locationToDirection(Location location);
|
PLASMA_EXPORT Direction locationToDirection(Location location);
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a nicely rounded rectanglular path for painting.
|
|
||||||
*/
|
|
||||||
PLASMA_EXPORT QPainterPath roundedRectangle(const QRectF& rect, qreal radius);
|
|
||||||
|
|
||||||
} // Plasma namespace
|
} // Plasma namespace
|
||||||
|
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::Constraints)
|
Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::Constraints)
|
||||||
|
@ -50,8 +50,8 @@
|
|||||||
#include <KDebug>
|
#include <KDebug>
|
||||||
#include <KColorScheme>
|
#include <KColorScheme>
|
||||||
|
|
||||||
|
#include <plasma/paintutils.h>
|
||||||
#include <plasma/theme.h>
|
#include <plasma/theme.h>
|
||||||
#include <plasma/imageeffects.h>
|
|
||||||
|
|
||||||
#include "animator.h"
|
#include "animator.h"
|
||||||
#include "svg.h"
|
#include "svg.h"
|
||||||
@ -394,7 +394,7 @@ QPainterPath Icon::shape() const
|
|||||||
return QGraphicsItem::shape();
|
return QGraphicsItem::shape();
|
||||||
}
|
}
|
||||||
|
|
||||||
return roundedRectangle(QRectF(QPointF(0.0, 0.0), d->currentSize).adjusted(-2, -2, 2, 2), 10.0);
|
return PaintUtils::roundedRectangle(QRectF(QPointF(0.0, 0.0), d->currentSize).adjusted(-2, -2, 2, 2), 10.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSizeF IconPrivate::displaySizeHint(const QStyleOptionGraphicsItem *option, const qreal width) const
|
QSizeF IconPrivate::displaySizeHint(const QStyleOptionGraphicsItem *option, const qreal width) const
|
||||||
@ -582,7 +582,7 @@ void IconPrivate::drawBackground(QPainter *painter, IconState state)
|
|||||||
painter->setRenderHint(QPainter::Antialiasing);
|
painter->setRenderHint(QPainter::Antialiasing);
|
||||||
painter->setBrush(shadow);
|
painter->setBrush(shadow);
|
||||||
painter->setPen(QPen(border, 1));
|
painter->setPen(QPen(border, 1));
|
||||||
painter->drawPath(roundedRectangle(QRectF(QPointF(1, 1), QSize((int)currentSize.width()-2, (int)currentSize.height()-2)), 5.0));
|
painter->drawPath(PaintUtils::roundedRectangle(QRectF(QPointF(1, 1), QSize((int)currentSize.width()-2, (int)currentSize.height()-2)), 5.0));
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -939,7 +939,7 @@ void Icon::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid
|
|||||||
shadowOffset = QPoint(0,0);
|
shadowOffset = QPoint(0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Plasma::ImageEffects::shadowBlur(shadow, 2, d->shadowColor);
|
PaintUtils::shadowBlur(shadow, 2, d->shadowColor);
|
||||||
painter->drawImage(textBoundingRect.topLeft()+shadowOffset, shadow);
|
painter->drawImage(textBoundingRect.topLeft()+shadowOffset, shadow);
|
||||||
d->drawTextItems(painter, option, labelLayout, infoLayout);
|
d->drawTextItems(painter, option, labelLayout, infoLayout);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user