Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
179f1fe1
Commit
179f1fe1
authored
Nov 09, 2010
by
Max-Wilhelm Bruker
Browse files
added yellow border to cards being moused over
parent
55e7feee
Changes
2
Show whitespace changes
Inline
Side-by-side
cockatrice/src/abstractcarditem.cpp
View file @
179f1fe1
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
#include
<QTimer>
#include
<QTimer>
AbstractCardItem
::
AbstractCardItem
(
const
QString
&
_name
,
Player
*
_owner
,
QGraphicsItem
*
parent
)
AbstractCardItem
::
AbstractCardItem
(
const
QString
&
_name
,
Player
*
_owner
,
QGraphicsItem
*
parent
)
:
ArrowTarget
(
_owner
,
parent
),
info
(
db
->
getCard
(
_name
)),
infoWidget
(
0
),
name
(
_name
),
tapped
(
false
),
tapAngle
(
0
)
:
ArrowTarget
(
_owner
,
parent
),
info
(
db
->
getCard
(
_name
)),
infoWidget
(
0
),
name
(
_name
),
tapped
(
false
),
tapAngle
(
0
)
,
isHovered
(
false
)
{
{
setCursor
(
Qt
::
OpenHandCursor
);
setCursor
(
Qt
::
OpenHandCursor
);
setFlag
(
ItemIsSelectable
);
setFlag
(
ItemIsSelectable
);
...
@@ -132,6 +132,9 @@ void AbstractCardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *
...
@@ -132,6 +132,9 @@ void AbstractCardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *
if
(
isSelected
())
{
if
(
isSelected
())
{
painter
->
setPen
(
Qt
::
red
);
painter
->
setPen
(
Qt
::
red
);
painter
->
drawRect
(
QRectF
(
0.5
,
0.5
,
CARD_WIDTH
-
1
,
CARD_HEIGHT
-
1
));
painter
->
drawRect
(
QRectF
(
0.5
,
0.5
,
CARD_WIDTH
-
1
,
CARD_HEIGHT
-
1
));
}
else
if
(
isHovered
)
{
painter
->
setPen
(
Qt
::
yellow
);
painter
->
drawRect
(
QRectF
(
0.5
,
0.5
,
CARD_WIDTH
-
1
,
CARD_HEIGHT
-
1
));
}
}
painter
->
restore
();
painter
->
restore
();
...
@@ -209,9 +212,16 @@ void AbstractCardItem::processHoverEvent()
...
@@ -209,9 +212,16 @@ void AbstractCardItem::processHoverEvent()
void
AbstractCardItem
::
hoverEnterEvent
(
QGraphicsSceneHoverEvent
*
event
)
void
AbstractCardItem
::
hoverEnterEvent
(
QGraphicsSceneHoverEvent
*
event
)
{
{
processHoverEvent
();
processHoverEvent
();
isHovered
=
true
;
QGraphicsItem
::
hoverEnterEvent
(
event
);
QGraphicsItem
::
hoverEnterEvent
(
event
);
}
}
void
AbstractCardItem
::
hoverLeaveEvent
(
QGraphicsSceneHoverEvent
*
event
)
{
isHovered
=
false
;
QGraphicsItem
::
hoverLeaveEvent
(
event
);
}
QVariant
AbstractCardItem
::
itemChange
(
QGraphicsItem
::
GraphicsItemChange
change
,
const
QVariant
&
value
)
QVariant
AbstractCardItem
::
itemChange
(
QGraphicsItem
::
GraphicsItemChange
change
,
const
QVariant
&
value
)
{
{
if
(
change
==
ItemSelectedHasChanged
)
{
if
(
change
==
ItemSelectedHasChanged
)
{
...
...
cockatrice/src/abstractcarditem.h
View file @
179f1fe1
...
@@ -22,6 +22,7 @@ protected:
...
@@ -22,6 +22,7 @@ protected:
QString
color
;
QString
color
;
private:
private:
QTimer
*
animationTimer
;
QTimer
*
animationTimer
;
bool
isHovered
;
private
slots
:
private
slots
:
void
animationEvent
();
void
animationEvent
();
void
pixmapUpdated
();
void
pixmapUpdated
();
...
@@ -51,6 +52,7 @@ protected:
...
@@ -51,6 +52,7 @@ protected:
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
void
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
);
void
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
);
void
hoverEnterEvent
(
QGraphicsSceneHoverEvent
*
event
);
void
hoverEnterEvent
(
QGraphicsSceneHoverEvent
*
event
);
void
hoverLeaveEvent
(
QGraphicsSceneHoverEvent
*
event
);
QVariant
itemChange
(
QGraphicsItem
::
GraphicsItemChange
change
,
const
QVariant
&
value
);
QVariant
itemChange
(
QGraphicsItem
::
GraphicsItemChange
change
,
const
QVariant
&
value
);
};
};
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment