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
4f4049fc
Commit
4f4049fc
authored
Jul 22, 2011
by
Max-Wilhelm Bruker
Browse files
ZoneViewZone fix
parent
60722e6e
Changes
6
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/gamescene.cpp
View file @
4f4049fc
...
...
@@ -160,6 +160,11 @@ QTransform GameScene::getViewTransform() const
return
views
().
at
(
0
)
->
transform
();
}
QTransform
GameScene
::
getViewportTransform
()
const
{
return
views
().
at
(
0
)
->
viewportTransform
();
}
void
GameScene
::
processViewSizeChange
(
const
QSize
&
newSize
)
{
viewSize
=
newSize
;
...
...
cockatrice/src/gamescene.h
View file @
4f4049fc
...
...
@@ -35,6 +35,7 @@ public:
void
retranslateUi
();
void
processViewSizeChange
(
const
QSize
&
newSize
);
QTransform
getViewTransform
()
const
;
QTransform
getViewportTransform
()
const
;
void
startRubberBand
(
const
QPointF
&
selectionOrigin
);
void
resizeRubberBand
(
const
QPointF
&
cursorPoint
);
...
...
cockatrice/src/gameview.cpp
View file @
4f4049fc
...
...
@@ -51,7 +51,7 @@ void GameView::startRubberBand(const QPointF &_selectionOrigin)
void
GameView
::
resizeRubberBand
(
const
QPointF
&
cursorPoint
)
{
if
(
rubberBand
)
rubberBand
->
setGeometry
(
QRect
(
mapFromScene
(
selectionOrigin
),
mapFromScene
(
cursorPoint
)).
normalized
());
rubberBand
->
setGeometry
(
QRect
(
mapFromScene
(
selectionOrigin
),
cursorPoint
.
toPoint
(
)).
normalized
());
}
void
GameView
::
stopRubberBand
()
...
...
cockatrice/src/selectzone.cpp
View file @
4f4049fc
#include
<QGraphicsSceneMouseEvent>
#include
"selectzone.h"
#include
"gamescene.h"
#include
<QDebug>
SelectZone
::
SelectZone
(
Player
*
_player
,
const
QString
&
_name
,
bool
_hasCardAttr
,
bool
_isShufflable
,
bool
_contentsKnown
,
QGraphicsItem
*
parent
,
bool
isView
)
:
CardZone
(
_player
,
_name
,
_hasCardAttr
,
_isShufflable
,
_contentsKnown
,
parent
,
isView
)
{
...
...
@@ -28,8 +28,7 @@ void SelectZone::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
continue
;
cards
[
i
]
->
setSelected
(
selectionRect
.
intersects
(
cards
[
i
]
->
mapRectToParent
(
cards
[
i
]
->
boundingRect
())));
}
static_cast
<
GameScene
*>
(
scene
())
->
resizeRubberBand
(
scenePos
()
+
pos
);
static_cast
<
GameScene
*>
(
scene
())
->
resizeRubberBand
(
deviceTransform
(
static_cast
<
GameScene
*>
(
scene
())
->
getViewportTransform
()).
map
(
pos
));
event
->
accept
();
}
}
...
...
cockatrice/src/zoneviewwidget.cpp
View file @
4f4049fc
...
...
@@ -36,7 +36,7 @@ QSizeF TitleLabel::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
if
(
which
==
Qt
::
MaximumSize
)
return
QSizeF
(
constraint
.
width
(),
fm
.
size
(
Qt
::
TextSingleLine
,
text
).
height
()
+
10
);
else
return
fm
.
size
(
Qt
::
TextSingleLine
,
text
);
return
fm
.
size
(
Qt
::
TextSingleLine
,
text
)
+
QSizeF
(
10
,
10
)
;
}
void
TitleLabel
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
...
...
@@ -105,10 +105,7 @@ ZoneViewWidget::ZoneViewWidget(Player *_player, CardZone *_origZone, int numberC
resize
(
150
,
150
);
zone
=
new
ZoneViewZone
(
player
,
_origZone
,
numberCards
,
_revealZone
,
this
);
connect
(
zone
,
SIGNAL
(
optimumRectChanged
()),
this
,
SLOT
(
resizeToZoneContents
()));
connect
(
zone
,
SIGNAL
(
beingDeleted
()),
this
,
SLOT
(
zoneDeleted
()));
vbox
->
addItem
(
zone
);
zone
->
initializeCards
(
cardList
);
if
(
sortByNameCheckBox
)
{
connect
(
sortByNameCheckBox
,
SIGNAL
(
stateChanged
(
int
)),
zone
,
SLOT
(
setSortByName
(
int
)));
...
...
@@ -117,8 +114,12 @@ ZoneViewWidget::ZoneViewWidget(Player *_player, CardZone *_origZone, int numberC
sortByTypeCheckBox
->
setChecked
(
settingsCache
->
getZoneViewSortByType
());
}
setLayout
(
vbox
);
retranslateUi
();
setLayout
(
vbox
);
connect
(
zone
,
SIGNAL
(
optimumRectChanged
()),
this
,
SLOT
(
resizeToZoneContents
()));
connect
(
zone
,
SIGNAL
(
beingDeleted
()),
this
,
SLOT
(
zoneDeleted
()));
zone
->
initializeCards
(
cardList
);
}
void
ZoneViewWidget
::
retranslateUi
()
...
...
@@ -140,7 +141,7 @@ void ZoneViewWidget::moveWidget(QPointF scenePos)
void
ZoneViewWidget
::
resizeToZoneContents
()
{
QRectF
zoneRect
=
zone
->
getOptimumRect
();
QSizeF
newSize
(
zoneRect
.
width
()
+
10
,
zoneRect
.
height
()
+
extraHeight
+
10
);
QSizeF
newSize
(
qMax
(
QGraphicsWidget
::
layout
()
->
effectiveSizeHint
(
Qt
::
MinimumSize
,
QSizeF
()).
width
(),
zoneRect
.
width
()
+
10
)
,
zoneRect
.
height
()
+
extraHeight
+
10
);
setMaximumSize
(
newSize
);
resize
(
newSize
);
if
(
layout
())
...
...
cockatrice/src/zoneviewzone.cpp
View file @
4f4049fc
...
...
@@ -96,11 +96,11 @@ void ZoneViewZone::reorganizeCards()
CardItem
*
c
=
cardsToDisplay
.
at
(
i
);
qreal
x
=
(
i
/
rows
)
*
CARD_WIDTH
;
qreal
y
=
(
i
%
rows
)
*
CARD_HEIGHT
/
3
;
c
->
setPos
(
x
,
y
);
c
->
setPos
(
x
+
5
,
y
+
5
);
c
->
setRealZValue
(
i
);
}
optimumRect
=
QRectF
(
0
,
0
,
cols
*
CARD_WIDTH
,
((
rows
-
1
)
*
CARD_HEIGHT
)
/
3
+
CARD_HEIGHT
);
optimumRect
=
QRectF
(
0
,
0
,
qMax
(
cols
,
3
)
*
CARD_WIDTH
+
10
,
((
rows
-
1
)
*
CARD_HEIGHT
)
/
3
+
CARD_HEIGHT
+
10
);
updateGeometry
();
emit
optimumRectChanged
();
}
...
...
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