Skip to content

Commit

Permalink
ENH: Fixed aspect ratio
Browse files Browse the repository at this point in the history
  • Loading branch information
Debilski committed May 19, 2023
1 parent ced9054 commit b0e5f1c
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions pelita/ui/qt/qt_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
QSocketNotifier, pyqtSignal, pyqtSlot)
from PyQt6.QtGui import QKeySequence, QShortcut
from PyQt6.QtWidgets import (QApplication, QGraphicsView, QGridLayout,
QHBoxLayout, QMainWindow, QPushButton, QWidget)
QHBoxLayout, QVBoxLayout, QMainWindow, QPushButton, QWidget)

from .qt_items import EndTextOverlay
from .qt_scene import PelitaScene, blue_col, red_col
Expand Down Expand Up @@ -175,6 +175,11 @@ def setupUi(self):
self.view = GameView(self.scene)
self.view.setCacheMode(QGraphicsView.CacheModeFlag.CacheBackground)

game_layout_w = QWidget(self)
game_layout = QVBoxLayout(game_layout_w)
game_layout.addWidget(self.view)
game_layout.addStretch()

bottom_info = QWidget(self)
bottom_info_layout = QHBoxLayout(bottom_info)

Expand All @@ -189,7 +194,7 @@ def setupUi(self):
grid_layout.addWidget(self.stats_blue, 1, 0)
grid_layout.addWidget(self.stats_red, 1, 1)

grid_layout.addWidget(self.view, 2, 0, 1, 2)
grid_layout.addWidget(game_layout_w, 2, 0, 1, 2)
grid_layout.addWidget(bottom_info, 3, 0, 1, 2)
grid_layout.addWidget(self.button, 4, 0, 1, 2)

Expand Down Expand Up @@ -340,6 +345,15 @@ class GameView(QGraphicsView):
def __init__(self, scene, parent=None):
super().__init__(scene, parent)

def minimumHeight(self) -> int:
return super().minimumHeight()

def hasHeightForWidth(self) -> bool:
return True

def heightForWidth(self, a0: int) -> int:
return a0 // 2

def resizeEvent(self, event) -> None:
if self.scene().shape:
x, y = self.scene().shape
Expand Down

0 comments on commit b0e5f1c

Please sign in to comment.