[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/games/palapeli/src
From: Stefan Majewsky <majewsky () gmx ! net>
Date: 2009-09-30 22:04:40
Message-ID: 1254348280.069215.25381.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1029852 by majewsky:
Implement drop shadows everywhere, but only optional because of the bad performance.
M +16 -1 engine/part.cpp
M +2 -0 engine/part.h
M +0 -3 engine/scene.cpp
M +2 -2 engine/shadowitem.cpp
M +1 -1 engine/shadowitem.h
M +9 -3 palapeli.kcfg
M +28 -2 settings.ui
--- trunk/playground/games/palapeli/src/engine/part.cpp #1029851:1029852
@@ -19,6 +19,7 @@
#include "part.h"
#include "piece.h"
#include "settings.h"
+#include "shadowitem.h"
#include <QGraphicsScene>
#include <QGraphicsSceneMouseEvent>
@@ -30,7 +31,16 @@
piece->setParentItem(this);
setFlag(QGraphicsItem::ItemIsMovable);
setHandlesChildEvents(true);
- piece->setFlag(QGraphicsItem::ItemStacksBehindParent); //DEBUG
+ //add shadow to piece
+ if (Settings::pieceShadows())
+ {
+ const QSize pixmapSize = piece->pixmap().size();
+ const int radius = 0.05 * (pixmapSize.width() + pixmapSize.height());
+ Palapeli::ShadowItem* shadowItem = new Palapeli::ShadowItem(piece->pixmap(), radius, piece->offset());
+ m_shadows << shadowItem;
+ shadowItem->setParentItem(this);
+ shadowItem->setZValue(-10);
+ }
}
Palapeli::Part::~Part()
@@ -89,6 +99,11 @@
piece->setParentItem(this);
m_pieces << piece;
}
+ foreach (Palapeli::ShadowItem* shadowItem, part->m_shadows)
+ {
+ shadowItem->setParentItem(this);
+ m_shadows << shadowItem;
+ }
delete part;
}
//update internal neighbor lists in the pieces
--- trunk/playground/games/palapeli/src/engine/part.h #1029851:1029852
@@ -25,6 +25,7 @@
namespace Palapeli
{
class Piece;
+ class ShadowItem;
class Part : public QObject, public QGraphicsItem
{
@@ -51,6 +52,7 @@
void validatePosition();
private:
QList<Palapeli::Piece*> m_pieces;
+ QList<Palapeli::ShadowItem*> m_shadows;
};
}
--- trunk/playground/games/palapeli/src/engine/scene.cpp #1029851:1029852
@@ -21,7 +21,6 @@
#include "piece.h"
#include "../file-io/puzzle.h"
#include "settings.h"
-#include "shadowitem.h"
#include <QFile>
#include <KConfig>
@@ -62,8 +61,6 @@
connect(part, SIGNAL(destroyed(QObject*)), this, SLOT(partDestroyed(QObject*)));
connect(part, SIGNAL(partMoved()), this, SLOT(partMoved()));
m_parts << part;
- if (pieceID == 0)
- addItem(new Palapeli::ShadowItem(contents->pieces[0], contents->pieces[0].width() / 10));
}
//add piece relations
foreach (DoubleIntPair relation, contents->relations)
--- trunk/playground/games/palapeli/src/engine/shadowitem.cpp #1029851:1029852
@@ -19,8 +19,8 @@
#include "shadowitem.h"
#include "shadowhelper.h"
-Palapeli::ShadowItem::ShadowItem(const QPixmap& pixmap, int radius)
+Palapeli::ShadowItem::ShadowItem(const QPixmap& pixmap, int radius, const QPointF& offset)
: QGraphicsPixmapItem(Palapeli::createShadow(pixmap, radius))
{
- setOffset(-radius, -radius);
+ setOffset(offset + QPointF(-radius, -radius));
}
--- trunk/playground/games/palapeli/src/engine/shadowitem.h #1029851:1029852
@@ -26,7 +26,7 @@
class ShadowItem : public QGraphicsPixmapItem
{
public:
- ShadowItem(const QPixmap& pixmap, int radius);
+ ShadowItem(const QPixmap& pixmap, int radius, const QPointF& offset);
};
}
--- trunk/playground/games/palapeli/src/palapeli.kcfg #1029851:1029852
@@ -6,13 +6,19 @@
<label>Scene size (in multiples of the image size).</label>
<default>2.0</default>
</entry>
+ <entry name="SnappingPrecision" type="Int">
+ <label>Precision of snapping (in percent of piece size).</label>
+ <default>20</default>
+ </entry>
+ </group>
+ <group name="Appearance">
<entry name="ViewBackground" type="String">
<label>The background image to use for the View.</label>
<default>background.svg</default>
</entry>
- <entry name="SnappingPrecision" type="Int">
- <label>Precision of snapping (in percent of piece size).</label>
- <default>20</default>
+ <entry name="PieceShadows" type="Bool">
+ <label></label>
+ <default>false</default>
</entry>
</group>
</kcfg>
--- trunk/playground/games/palapeli/src/settings.ui #1029851:1029852
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>400</width>
- <height>300</height>
+ <width>483</width>
+ <height>327</height>
</rect>
</property>
<property name="windowTitle">
@@ -114,6 +114,32 @@
</widget>
</item>
<item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>Miscellaneous options</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QCheckBox" name="kcfg_PieceShadows">
+ <property name="text">
+ <string>Pieces drop shadows</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Changes to this option will not take effect until you load a new puzzle.</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic