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
04a3d311
Commit
04a3d311
authored
Jun 16, 2009
by
Max-Wilhelm Bruker
Browse files
improved gameview resizing
parent
0f272a2f
Changes
2
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/gameview.cpp
View file @
04a3d311
...
@@ -10,25 +10,8 @@ GameView::GameView(QGraphicsScene *scene, QWidget *parent)
...
@@ -10,25 +10,8 @@ GameView::GameView(QGraphicsScene *scene, QWidget *parent)
// setViewportUpdateMode(FullViewportUpdate);
// setViewportUpdateMode(FullViewportUpdate);
}
}
void
GameView
::
scaleToScene
()
{
// This function ensures that the bounding rectangles of card pictures
// have integer sizes. This is achieved by using a scale factor of n / 6.
QRectF
sr
=
scene
()
->
sceneRect
();
QRectF
vr
=
QRectF
(
viewport
()
->
rect
().
adjusted
(
2
,
2
,
-
2
,
-
2
));
qreal
scale_h
=
vr
.
width
()
/
sr
.
width
();
qreal
scale_v
=
vr
.
height
()
/
sr
.
height
();
qreal
scale_total
=
qMin
(
scale_h
,
scale_v
);
qreal
scale_corr
=
(
qreal
)
((
int
)
(
scale_total
*
6
))
/
6
;
qDebug
(
QString
(
"scale_corr = %1 / 6"
).
arg
(
scale_corr
*
6
).
toLatin1
());
setTransform
(
QTransform
().
scale
(
scale_corr
,
scale_corr
));
}
void
GameView
::
resizeEvent
(
QResizeEvent
*
event
)
void
GameView
::
resizeEvent
(
QResizeEvent
*
event
)
{
{
qDebug
(
"GameView: resizeEvent"
);
QGraphicsView
::
resizeEvent
(
event
);
QGraphicsView
::
resizeEvent
(
event
);
scaleToScene
(
);
fitInView
(
scene
()
->
sceneRect
(),
Qt
::
KeepAspectRatio
);
}
}
cockatrice/src/window_main.cpp
View file @
04a3d311
...
@@ -131,7 +131,7 @@ void MainWindow::updateSceneSize()
...
@@ -131,7 +131,7 @@ void MainWindow::updateSceneSize()
QSizeF
zoneSize
=
zoneLayout
->
size
();
QSizeF
zoneSize
=
zoneLayout
->
size
();
qDebug
(
QString
(
"updateSceneSize: width=%1"
).
arg
(
952
+
zoneSize
.
width
()).
toLatin1
());
qDebug
(
QString
(
"updateSceneSize: width=%1"
).
arg
(
952
+
zoneSize
.
width
()).
toLatin1
());
scene
->
setSceneRect
(
sr
.
x
(),
sr
.
y
(),
952
+
zoneSize
.
width
(),
sr
.
height
());
scene
->
setSceneRect
(
sr
.
x
(),
sr
.
y
(),
952
+
zoneSize
.
width
(),
sr
.
height
());
view
->
scaleToScene
(
);
view
->
fitInView
(
scene
->
sceneRect
(),
Qt
::
KeepAspectRatio
);
}
}
void
MainWindow
::
textChanged
(
const
QString
&
text
)
void
MainWindow
::
textChanged
(
const
QString
&
text
)
...
...
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