[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdegames/kolf
From:       Stefan Majewsky <majewsky () gmx ! net>
Date:       2010-10-31 22:15:46
Message-ID: 20101031221546.83846AC8EA () svn ! kde ! org
[Download RAW message or body]

SVN commit 1191689 by majewsky:

Change signature of CanvasItem::setSize from (double, double) to (QSizeF).

 M  +1 -1      canvasitem.h  
 M  +0 -1      floater.cpp  
 M  +35 -33    game.cpp  
 M  +8 -9      game.h  
 M  +6 -6      slope.cpp  
 M  +1 -1      slope.h  


--- trunk/KDE/kdegames/kolf/canvasitem.h #1191688:1191689
@@ -109,7 +109,7 @@
 
 	QString name() const { return m_name; }
 	void setName(const QString &newname) { m_name = newname; }
-	virtual void setSize(double /*width*/, double /*height*/) {}
+	virtual void setSize(const QSizeF&) {}
 
 	///custom animation code
 	bool isAnimated() const { return m_animated; }
--- trunk/KDE/kdegames/kolf/floater.cpp #1191688:1191689
@@ -83,7 +83,6 @@
 	setLeftWallVisible(false);
 	setRightWallVisible(false);
 
-	setSize(width(), height());
 	moveBy(0, 0);
 	setSpeed(0);
 
--- trunk/KDE/kdegames/kolf/game.cpp #1191688:1191689
@@ -81,7 +81,7 @@
 : QGraphicsEllipseItem(parent)
 {
 	setZValue(9999);
-	setSize(10, 10);
+	setSize(QSizeF(10, 10));
 	this->rect = rect;
 	setBrush(QBrush(color));
 	setSizeFactor(1.0);
@@ -102,12 +102,12 @@
 	if (!qitem)
 		return;
 
-	int nw = ( int )( m_sizeFactor * fabs(x() - qitem->x()) );
-	int nh = ( int )( m_sizeFactor * fabs(y() - qitem->y()) );
+	int nw = ( int )( m_sizeFactor * qAbs(x() - qitem->x()) );
+	int nh = ( int )( m_sizeFactor * qAbs(y() - qitem->y()) );
 	if (nw <= 0 || nh <= 0)
 		return;
 
-	rect->setSize(nw, nh);
+	rect->setSize(QSizeF(nw, nh));
 }
 
 Config *RectPoint::config(QWidget *parent)
@@ -119,9 +119,9 @@
 		return CanvasItem::config(parent);
 }
 
-void RectPoint::setSize(double width, double height)
+void RectPoint::setSize(const QSizeF& size)
 {
-	setRect(x(), y(), width, height);
+	setRect(QRectF(pos(), size));
 }
 
 /////////////////////////
@@ -291,8 +291,8 @@
 	point = new RectPoint(color, this, parent);
 	editModeChanged(false);
 
-	setSize(defaultSize.width(), defaultSize.height());
-	setSize(width(), height());
+	setSize(defaultSize);
+	setSize(Tagaro::SpriteObjectItem::size());
 }
 
 bool Bridge::collision(Ball *ball, long int /*id*/)
@@ -375,7 +375,7 @@
 
 void Bridge::doLoad(KConfigGroup *cfgGroup)
 {
-	setSize(cfgGroup->readEntry("width", width()), cfgGroup->readEntry("height", \
height())); +	setSize(QSizeF(cfgGroup->readEntry("width", width()), \
cfgGroup->readEntry("height", height())));  \
setTopWallVisible(cfgGroup->readEntry("topWallVisible", topWallVisible()));  \
setBotWallVisible(cfgGroup->readEntry("botWallVisible", botWallVisible()));  \
setLeftWallVisible(cfgGroup->readEntry("leftWallVisible", leftWallVisible())); @@ \
-404,10 +404,11 @@  return ret;
 }
 
-void Bridge::setSize(double width, double height)
+void Bridge::setSize(const QSizeF& size)
 {
-	Tagaro::SpriteObjectItem::setSize(width, height);
+	Tagaro::SpriteObjectItem::setSize(size);
 
+	const qreal width = size.width(), height = size.height();
 	topWall->setPoints(0, 0, width, 0);
 	botWall->setPoints(0, height, width, height);
 	leftWall->setPoints(0, 0, 0, height);
@@ -498,7 +499,7 @@
 	setLeftWallVisible(true);
 	setRightWallVisible(true);
 
-	setSize(width(), height());
+	setSize(Tagaro::SpriteObjectItem::size());
 	moveBy(0, 0);
 }
 
@@ -568,13 +569,14 @@
 void Windmill::setBottom(bool yes)
 {
 	m_bottom = yes;
-	setSize(width(), height());
+	setSize(Tagaro::SpriteObjectItem::size());
 }
 
-void Windmill::setSize(double width, double height)
+void Windmill::setSize(const QSizeF& size)
 {
-	Bridge::setSize(width, height);
+	Bridge::setSize(size);
 
+	const double width = size.width(), height = size.height();
 	const double indent = width / 4;
 
 	double indentY = m_bottom? height : 0;
@@ -785,10 +787,10 @@
 	return ret;
 }
 
-void KolfEllipse::setSize(double width, double height)
+void KolfEllipse::setSize(const QSizeF& size)
 {
-	setOffset(-0.5 * width, -0.5 * height);
-	Tagaro::SpriteObjectItem::setSize(width, height);
+	setOffset(-0.5 * size.width(), -0.5 * size.height());
+	Tagaro::SpriteObjectItem::setSize(size);
 }
 
 void KolfEllipse::moveBy(double dx, double dy)
@@ -827,7 +829,7 @@
 	double newWidth = width(), newHeight = height();
 	newWidth = cfgGroup->readEntry("width", newWidth);
 	newHeight = cfgGroup->readEntry("height", newHeight);
-	setSize(newWidth, newHeight);
+	setSize(QSizeF(newWidth, newHeight));
 	moveBy(0, 0); 
 } 
 
@@ -861,7 +863,7 @@
 : KolfEllipse(parent, "puddle")
 {
 	setData(0, Rtti_DontPlaceOn);
-	setSize(45, 30);
+	setSize(QSizeF(45, 30));
 	setZValue(-25);
 }
 
@@ -897,7 +899,7 @@
 Sand::Sand(QGraphicsItem * parent)
 : KolfEllipse(parent, "sand")
 {
-	setSize(45, 40);
+	setSize(QSizeF(45, 40));
 	setZValue(-26);
 }
 
@@ -1049,7 +1051,7 @@
 {
 	const int diameter = 20;
 	setOffset(-0.5 * diameter, -0.5 * diameter);
-	Tagaro::SpriteObjectItem::setSize(diameter, diameter);
+	Tagaro::SpriteObjectItem::setSize(QSizeF(diameter, diameter));
 	setZValue(-25);
 
 	count = 0;
@@ -1109,7 +1111,7 @@
 {
 	const int diameter = 16;
 	setOffset(-0.5 * diameter, -0.5 * diameter);
-	Tagaro::SpriteObjectItem::setSize(diameter, diameter);
+	Tagaro::SpriteObjectItem::setSize(QSizeF(diameter, diameter));
 
 	setZValue(998.1);
 }
@@ -1197,7 +1199,7 @@
 	exitItem->setPen(QPen(myColor, 6));
 	exitItem->setPos(300, 100);
 
-	setSize(baseWidth, baseHeight);
+	setSize(QSizeF(baseWidth, baseHeight));
 	pixmapInitialised=false;
 
 	moveBy(0, 0); 
@@ -1622,7 +1624,7 @@
 void WallPoint::clean()
 {
 	double oldWidth = width();
-	setSize(7, 7);
+	setSize(QSizeF(7, 7));
 
 	QList<QGraphicsItem *> l = collidingItems();
 	for (QList<QGraphicsItem *>::Iterator it = l.begin(); it != l.end(); ++it)
@@ -1634,7 +1636,7 @@
 		}
 	}
 
-	setSize(oldWidth, oldWidth);
+	setSize(QSizeF(oldWidth, oldWidth));
 }
 
 void WallPoint::moveBy(double dx, double dy)
@@ -2088,7 +2090,7 @@
 	ithickness = 8;
 	setZValue(10000);
 
-	setSize(80, 80);
+	setSize(QSizeF(80, 80));
 	setThickness(8);
 }
 
@@ -2116,12 +2118,12 @@
 	if (dvalue > dmax)
 		dvalue = dmax;
 }
-void StrokeCircle::setSize(double w, double h)
+void StrokeCircle::setSize(const QSizeF& size)
 {
-	if (w > 0)
-		iwidth = w;
-	if (h > 0)
-		iheight = h;
+	if (size.width() > 0)
+		iwidth = size.width();
+	if (size.height() > 0)
+		iheight = size.height();
 }
 void StrokeCircle::setThickness(double t)
 {
@@ -3835,7 +3837,7 @@
 
 	newItem->setPos(width/2 - 18, height / 2 - 18);
 	sceneItem->moveBy(0, 0);
-	sceneItem->setSize(newItem->boundingRect().width(), \
newItem->boundingRect().height()); \
+	sceneItem->setSize(newItem->boundingRect().size());  
 	if (selectedItem)
 		sceneItem->selectedItem(selectedItem);
--- trunk/KDE/kdegames/kolf/game.h #1191688:1191689
@@ -165,7 +165,7 @@
 	virtual bool cornerResize() const { return true; }
 	virtual CanvasItem *itemToDelete() { return dynamic_cast<CanvasItem *>(rect); }
 	void setSizeFactor(double newFactor) { m_sizeFactor = newFactor; }
-	void setSize(double, double);
+	virtual void setSize(const QSizeF& size);
 
 protected:
 	Tagaro::SpriteObjectItem *rect;
@@ -192,7 +192,7 @@
 
 	virtual QList<QGraphicsItem *> moveableItems() const;
 
-	void setSize(double width, double height);
+	virtual void setSize(const QSizeF& size);
 
 	virtual void moveBy(double dx, double dy);
 
@@ -260,7 +260,7 @@
 public:
 	Inside(CanvasItem *item, QGraphicsItem *parent) : QGraphicsEllipseItem(parent) { \
this->item = item; }  virtual bool collision(Ball *ball, long int id) { return \
                item->collision(ball, id); }
-	void setSize(double width, double height) { setRect(rect().x(), rect().y(), width, \
height); } +	virtual void setSize(const QSizeF& size) { \
setRect(QRectF(rect().topLeft(), size)); }  
 protected:
 	CanvasItem *item;
@@ -397,8 +397,7 @@
 
 	virtual void moveBy(double dx, double dy);
 
-        void setSize(double width, double height) { setRect(rect().x(), rect().y
-(), width, height); }
+	virtual void setSize(const QSizeF& size) { setRect(QRectF(rect().topLeft(), size)); \
}  double width() { return rect().width(); }
         double height() { return rect().height(); }
 
@@ -489,7 +488,7 @@
 	void dontMove() { dontmove = true; }
 	void updateVisible();
 
-	void setSize(double width, double height) { setRect(rect().x(), rect().y(), width, \
height); } +	virtual void setSize(const QSizeF& size) { \
setRect(QRectF(rect().topLeft(), size)); }  double width() { return rect().width(); }
 	double height() { return rect().height(); }
 
@@ -585,7 +584,7 @@
 	void doSave(KConfigGroup *cfgGroup);
 	virtual void setGame(KolfGame *game);
 	virtual Config *config(QWidget *parent) { return new BridgeConfig(this, parent); }
-	void setSize(double width, double height);
+	virtual void setSize(const QSizeF& size);
 	virtual QList<QGraphicsItem *> moveableItems() const;
 
 	void setWallColor(const QColor &color);
@@ -684,7 +683,7 @@
 	virtual void setGame(KolfGame *game);
 	virtual Config *config(QWidget *parent) { return new WindmillConfig(this, parent); \
}  
-	void setSize(double width, double height);
+	virtual void setSize(const QSizeF& size);
 	virtual void moveBy(double dx, double dy);
 	void setSpeed(double news);
 	double curSpeed() const { return speed; }
@@ -760,7 +759,7 @@
 	void setValue(double v);
 	double value();
 	void setMaxValue(double m);
-	void setSize(double w, double h);
+	void setSize(const QSizeF& size);
 	void setThickness(double t);
 	double thickness() const;
 	double width() const;
--- trunk/KDE/kdegames/kolf/slope.cpp #1191688:1191689
@@ -129,12 +129,12 @@
 	}
 }
 
-void Slope::setSize(double width, double height)
+void Slope::setSize(const QSizeF& size)
 {
 	if (type == Elliptic)
 	{
-		const double size = qMin(width, height);
-		Tagaro::SpriteObjectItem::setSize(size, size);
+		const double extent = qMin(size.width(), size.height());
+		Tagaro::SpriteObjectItem::setSize(extent, extent);
 		// move point back to good spot
 		moveBy(0, 0);
 
@@ -143,7 +143,7 @@
 	}
 	else
 	{
-		Tagaro::SpriteObjectItem::setSize(width, height);
+		Tagaro::SpriteObjectItem::setSize(size);
 	}
 
 	updateZ();
@@ -238,7 +238,7 @@
 	reversed = cfgGroup->readEntry("reversed", reversed);
 
 	// bypass updatePixmap which setSize normally does
-	Tagaro::SpriteObjectItem::setSize(QSizeF(cfgGroup->readEntry("width", width()), \
cfgGroup->readEntry("height", height()))); \
+	Tagaro::SpriteObjectItem::setSize(cfgGroup->readEntry("width", width()), \
cfgGroup->readEntry("height", height()));  updateZ();
 
 	QString gradientType = cfgGroup->readEntry("gradient", gradientKeys[type]);
@@ -374,7 +374,7 @@
 	if (type == Elliptic)
 	{
 		//ensure quadratic shape
-		setSize(width(), height());
+		setSize(size());
 	}
 
 	updatePixmap();
--- trunk/KDE/kdegames/kolf/slope.h #1191688:1191689
@@ -55,7 +55,7 @@
 	virtual bool canBeMovedByOthers() const { return !stuckOnGround; }
 	virtual QList<QGraphicsItem *> moveableItems() const;
 	virtual Config *config(QWidget *parent) { return new SlopeConfig(this, parent); }
-	virtual void setSize(double width, double height);
+	virtual void setSize(const QSizeF& size);
 	virtual void moveBy(double dx, double dy);
 
 	virtual QPainterPath shape () const;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic