MCPcopy Create free account
hub / github.com/XMuli/ChineseChess / boardTransform

Method boardTransform

ChessBoard.cpp:209–229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207}
208
209bool ChessBoard::boardTransform(QPointF& origin, qreal& side) const
210{
211 if (!ui || !ui->label)
212 return false;
213
214 const QPoint topLeft = ui->label->mapTo(this, QPoint(0, 0));
215 const QSize boardSize = ui->label->size();
216 if (boardSize.isEmpty())
217 return false;
218
219 const qreal width = boardSize.width();
220 const qreal height = boardSize.height();
221 side = qMin(width, height);
222 if (side <= 0.0)
223 return false;
224
225 origin = QPointF(topLeft);
226 origin.rx() += (width - side) / 2.0;
227 origin.ry() += (height - side) / 2.0;
228 return true;
229}
230
231void ChessBoard::paintEvent(QPaintEvent *event)
232{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected