2009-01-13 22:46:07 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2008 by Aaron Seigo <aseigo@kde.org>
|
|
|
|
* Copyright 2009 Marco Martin <notmart@gmail.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Library General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PLASMA_FRAMESVG_P_H
|
|
|
|
#define PLASMA_FRAMESVG_P_H
|
|
|
|
|
|
|
|
#include <QHash>
|
2010-09-27 19:19:06 +02:00
|
|
|
#include <QStringBuilder>
|
|
|
|
|
2010-09-27 20:16:27 +02:00
|
|
|
#include <kdebug.h>
|
2009-01-13 22:46:07 +01:00
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
class FrameData
|
|
|
|
{
|
|
|
|
public:
|
2010-09-27 19:19:06 +02:00
|
|
|
FrameData(FrameSvg *svg)
|
2009-01-13 22:46:07 +01:00
|
|
|
: enabledBorders(FrameSvg::AllBorders),
|
2009-05-31 07:38:42 +02:00
|
|
|
frameSize(-1,-1),
|
|
|
|
topHeight(0),
|
|
|
|
leftWidth(0),
|
|
|
|
rightWidth(0),
|
|
|
|
bottomHeight(0),
|
|
|
|
topMargin(0),
|
|
|
|
leftMargin(0),
|
|
|
|
rightMargin(0),
|
|
|
|
bottomMargin(0),
|
|
|
|
noBorderPadding(false),
|
|
|
|
stretchBorders(false),
|
|
|
|
tileCenter(false)
|
2009-01-13 22:46:07 +01:00
|
|
|
{
|
2010-09-27 19:19:06 +02:00
|
|
|
ref(svg);
|
2009-01-13 22:46:07 +01:00
|
|
|
}
|
|
|
|
|
2010-09-27 19:19:06 +02:00
|
|
|
FrameData(const FrameData &other, FrameSvg *svg)
|
2009-01-13 22:46:07 +01:00
|
|
|
: enabledBorders(other.enabledBorders),
|
2009-05-31 07:38:42 +02:00
|
|
|
frameSize(other.frameSize),
|
|
|
|
topHeight(0),
|
|
|
|
leftWidth(0),
|
|
|
|
rightWidth(0),
|
|
|
|
bottomHeight(0),
|
|
|
|
topMargin(0),
|
|
|
|
leftMargin(0),
|
|
|
|
rightMargin(0),
|
|
|
|
bottomMargin(0),
|
|
|
|
noBorderPadding(false),
|
|
|
|
stretchBorders(false),
|
2010-05-06 16:16:03 +02:00
|
|
|
tileCenter(false),
|
|
|
|
composeOverBorder(false)
|
2009-01-13 22:46:07 +01:00
|
|
|
{
|
2010-09-27 19:19:06 +02:00
|
|
|
ref(svg);
|
2009-01-13 22:46:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
~FrameData()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-09-27 19:19:06 +02:00
|
|
|
void ref(FrameSvg *svg);
|
|
|
|
bool deref(FrameSvg *svg);
|
|
|
|
bool removeRefs(FrameSvg *svg);
|
|
|
|
bool isUsed() const;
|
|
|
|
int refcount() const;
|
|
|
|
|
2009-01-13 22:46:07 +01:00
|
|
|
FrameSvg::EnabledBorders enabledBorders;
|
|
|
|
QPixmap cachedBackground;
|
2010-08-05 23:15:18 +02:00
|
|
|
QHash<QString, QRegion> cachedMasks;
|
|
|
|
static const int MAX_CACHED_MASKS = 10;
|
|
|
|
|
2009-02-07 21:44:08 +01:00
|
|
|
QSize frameSize;
|
2009-01-13 22:46:07 +01:00
|
|
|
|
|
|
|
//measures
|
|
|
|
int topHeight;
|
|
|
|
int leftWidth;
|
|
|
|
int rightWidth;
|
|
|
|
int bottomHeight;
|
|
|
|
|
|
|
|
//margins, are equal to the measures by default
|
|
|
|
int topMargin;
|
|
|
|
int leftMargin;
|
|
|
|
int rightMargin;
|
|
|
|
int bottomMargin;
|
|
|
|
|
|
|
|
//size of the svg where the size of the "center"
|
|
|
|
//element is contentWidth x contentHeight
|
|
|
|
bool noBorderPadding : 1;
|
|
|
|
bool stretchBorders : 1;
|
|
|
|
bool tileCenter : 1;
|
2010-05-06 16:16:03 +02:00
|
|
|
bool composeOverBorder : 1;
|
2010-09-27 19:19:06 +02:00
|
|
|
|
|
|
|
QHash<FrameSvg *, int> references;
|
2009-01-13 22:46:07 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class FrameSvgPrivate
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FrameSvgPrivate(FrameSvg *psvg)
|
|
|
|
: q(psvg),
|
|
|
|
cacheAll(false),
|
|
|
|
overlayPos(0,0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-09-27 19:19:06 +02:00
|
|
|
~FrameSvgPrivate();
|
2009-01-13 22:46:07 +01:00
|
|
|
|
2010-03-05 23:37:44 +01:00
|
|
|
QPixmap alphaMask();
|
2010-09-27 19:19:06 +02:00
|
|
|
|
2009-01-13 22:46:07 +01:00
|
|
|
void generateBackground(FrameData *frame);
|
2009-09-28 23:54:00 +02:00
|
|
|
void generateFrameBackground(FrameData *frame);
|
|
|
|
QString cacheId(FrameData *frame, const QString &prefixToUse) const;
|
2009-09-28 23:02:24 +02:00
|
|
|
void cacheFrame(const QString &prefixToSave, const QPixmap &background, const QPixmap &overlay);
|
2009-09-28 23:54:00 +02:00
|
|
|
void updateSizes() const;
|
2009-01-13 22:46:07 +01:00
|
|
|
void updateNeeded();
|
|
|
|
void updateAndSignalSizes();
|
2009-09-28 23:54:00 +02:00
|
|
|
QSizeF frameSize(FrameData *frame) const;
|
2009-01-13 22:46:07 +01:00
|
|
|
|
|
|
|
Location location;
|
|
|
|
QString prefix;
|
|
|
|
|
|
|
|
FrameSvg *q;
|
|
|
|
|
|
|
|
bool cacheAll : 1;
|
|
|
|
QPoint overlayPos;
|
|
|
|
|
|
|
|
QHash<QString, FrameData*> frames;
|
2010-09-27 19:19:06 +02:00
|
|
|
|
|
|
|
static QHash<QString, FrameData *> s_sharedFrames;
|
2009-01-13 22:46:07 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|