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
09595cc6
Commit
09595cc6
authored
Jan 10, 2011
by
Max-Wilhelm Bruker
Browse files
phase toolbar visual changes
parent
2c186221
Changes
2
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/phasestoolbar.cpp
View file @
09595cc6
...
@@ -2,20 +2,24 @@
...
@@ -2,20 +2,24 @@
#include
<QVBoxLayout>
#include
<QVBoxLayout>
#include
<QPainter>
#include
<QPainter>
#include
<QPen>
#include
<QPen>
#include
<QTimer>
#include
"phasestoolbar.h"
#include
"phasestoolbar.h"
#include
"protocol_items.h"
#include
"protocol_items.h"
PhaseButton
::
PhaseButton
(
const
QIcon
&
icon
,
QAction
*
_doubleClickAction
)
PhaseButton
::
PhaseButton
(
const
QIcon
&
icon
,
QAction
*
_doubleClickAction
)
:
QPushButton
(
icon
,
QString
()),
active
(
false
),
doubleClickAction
(
_doubleClickAction
),
activePixmap
(
50
,
50
),
inactiveP
ixmap
(
50
,
50
)
:
QPushButton
(
icon
,
QString
()),
active
(
false
),
activeAnimationCounter
(
0
),
doubleClickAction
(
_doubleClickAction
),
p
ixmap
(
50
,
50
)
{
{
setFocusPolicy
(
Qt
::
NoFocus
);
setFocusPolicy
(
Qt
::
NoFocus
);
setFixedSize
(
50
,
50
);
setFixedSize
(
50
,
50
);
updatePixmap
(
activePixmap
,
true
);
activeAnimationTimer
=
new
QTimer
(
this
);
updatePixmap
(
inactivePixmap
,
false
);
connect
(
activeAnimationTimer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
updateAnimation
()));
activeAnimationTimer
->
setSingleShot
(
false
);
updatePixmap
(
pixmap
);
}
}
void
PhaseButton
::
updatePixmap
(
QPixmap
&
pixmap
,
bool
active
)
void
PhaseButton
::
updatePixmap
(
QPixmap
&
pixmap
)
{
{
pixmap
.
fill
(
Qt
::
transparent
);
pixmap
.
fill
(
Qt
::
transparent
);
...
@@ -23,21 +27,44 @@ void PhaseButton::updatePixmap(QPixmap &pixmap, bool active)
...
@@ -23,21 +27,44 @@ void PhaseButton::updatePixmap(QPixmap &pixmap, bool active)
int
height
=
pixmap
.
height
();
int
height
=
pixmap
.
height
();
int
width
=
pixmap
.
width
();
int
width
=
pixmap
.
width
();
if
(
active
)
painter
.
setBrush
(
Qt
::
red
);
painter
.
setPen
(
Qt
::
gray
);
painter
.
drawRect
(
1
,
1
,
width
-
2
,
height
-
2
);
icon
().
paint
(
&
painter
,
5
,
5
,
width
-
10
,
height
-
10
);
icon
().
paint
(
&
painter
,
5
,
5
,
width
-
10
,
height
-
10
);
}
}
void
PhaseButton
::
paintEvent
(
QPaintEvent
*/
*
event
*/
)
void
PhaseButton
::
paintEvent
(
QPaintEvent
*/
*
event
*/
)
{
{
QPainter
painter
(
this
);
QPainter
painter
(
this
);
if
(
active
)
painter
.
drawPixmap
(
0
,
0
,
size
().
width
(),
size
().
height
(),
activePixmap
);
painter
.
setBrush
(
QColor
(
220
*
(
activeAnimationCounter
/
10.0
),
220
*
(
activeAnimationCounter
/
10.0
),
220
*
(
activeAnimationCounter
/
10.0
)));
else
painter
.
setPen
(
Qt
::
gray
);
painter
.
drawPixmap
(
0
,
0
,
size
().
width
(),
size
().
height
(),
inactivePixmap
);
painter
.
drawRect
(
1
,
1
,
pixmap
.
width
()
-
2
,
pixmap
.
height
()
-
2
);
painter
.
drawPixmap
(
0
,
0
,
size
().
width
(),
size
().
height
(),
pixmap
);
// painter.setBrush(QColor(220 * (activeAnimationCounter / 10.0), 220 * (activeAnimationCounter / 10.0), 220 * (activeAnimationCounter / 10.0), 255 * ((10 - activeAnimationCounter) / 15.0)));
painter
.
setBrush
(
QColor
(
0
,
0
,
0
,
255
*
((
10
-
activeAnimationCounter
)
/
15.0
)));
painter
.
setPen
(
Qt
::
gray
);
painter
.
drawRect
(
1
,
1
,
pixmap
.
width
()
-
2
,
pixmap
.
height
()
-
2
);
}
void
PhaseButton
::
setActive
(
bool
_active
)
{
if
(
active
==
_active
)
return
;
active
=
_active
;
activeAnimationTimer
->
start
(
50
);
}
void
PhaseButton
::
updateAnimation
()
{
if
(
active
)
{
if
(
++
activeAnimationCounter
>=
10
)
activeAnimationTimer
->
stop
();
}
else
{
if
(
--
activeAnimationCounter
<=
0
)
activeAnimationTimer
->
stop
();
}
update
();
}
}
void
PhaseButton
::
setPhaseText
(
const
QString
&
_phaseText
)
void
PhaseButton
::
setPhaseText
(
const
QString
&
_phaseText
)
...
@@ -60,6 +87,9 @@ void PhaseButton::triggerDoubleClickAction()
...
@@ -60,6 +87,9 @@ void PhaseButton::triggerDoubleClickAction()
PhasesToolbar
::
PhasesToolbar
(
QWidget
*
parent
)
PhasesToolbar
::
PhasesToolbar
(
QWidget
*
parent
)
:
QFrame
(
parent
)
:
QFrame
(
parent
)
{
{
setBackgroundRole
(
QPalette
::
Shadow
);
setAutoFillBackground
(
true
);
QAction
*
aUntapAll
=
new
QAction
(
this
);
QAction
*
aUntapAll
=
new
QAction
(
this
);
connect
(
aUntapAll
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
actUntapAll
()));
connect
(
aUntapAll
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
actUntapAll
()));
QAction
*
aDrawCard
=
new
QAction
(
this
);
QAction
*
aDrawCard
=
new
QAction
(
this
);
...
...
cockatrice/src/phasestoolbar.h
View file @
09595cc6
...
@@ -13,15 +13,19 @@ class PhaseButton : public QPushButton {
...
@@ -13,15 +13,19 @@ class PhaseButton : public QPushButton {
private:
private:
QString
phaseText
;
QString
phaseText
;
bool
active
;
bool
active
;
int
activeAnimationCounter
;
QTimer
*
activeAnimationTimer
;
QAction
*
doubleClickAction
;
QAction
*
doubleClickAction
;
QPixmap
activePixmap
,
inactiveP
ixmap
;
QPixmap
p
ixmap
;
void
updatePixmap
(
QPixmap
&
pixmap
,
bool
active
);
void
updatePixmap
(
QPixmap
&
pixmap
);
private
slots
:
void
updateAnimation
();
public:
public:
PhaseButton
(
const
QIcon
&
icon
,
QAction
*
_doubleClickAction
=
0
);
PhaseButton
(
const
QIcon
&
icon
,
QAction
*
_doubleClickAction
=
0
);
void
setPhaseText
(
const
QString
&
_phaseText
);
void
setPhaseText
(
const
QString
&
_phaseText
);
QString
getPhaseText
()
const
{
return
phaseText
;
}
QString
getPhaseText
()
const
{
return
phaseText
;
}
void
setActive
(
bool
_active
)
{
active
=
_active
;
update
();
}
void
setActive
(
bool
_active
)
;
bool
getActive
()
const
{
return
active
;
}
bool
getActive
()
const
{
return
active
;
}
void
triggerDoubleClickAction
();
void
triggerDoubleClickAction
();
protected:
protected:
...
...
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