solitare/qml/FoundationPiles.qml
ItsDrike 57958ed853
Dynamically scale the cards & everything else
Currently, most things were scaled based on the card dimensions,
though some things were hard-coded. This commit moves away from all
hard-coded sizes in favor of everything relying on card heights.

Additionally, it makes the card height itself no longer hard-coded,
passing it as a property to most custom structures.

The card height itself is now calculated from Main.qml to make sure
everything fits within the screen and scales as the window is resized.
2024-12-08 13:09:15 +01:00

56 lines
1.3 KiB
QML

import QtQuick
import Solitare
Row {
id: foundationRow
required property real cardWidth
required property real cardHeight
spacing: cardWidth * 0.2
Repeater {
model: 4 // Each of the 4 suits
Item {
id: foundationPile
width: foundationRow.cardWidth
height: foundationRow.cardHeight
required property int index // passed from repeater
CardModel {
id: foundationCard
anchors.fill: parent
visible: GameState.foundation[parent.index].length > 0
card: GameState.foundation[parent.index].length > 0 ? GameState.foundation[parent.index][0] : null
isFaceDown: false
}
Rectangle {
id: emptyPileRect
anchors.fill: parent
visible: GameState.foundation[parent.index].length === 0
color: "gray"
border.color: "white"
border.width: width * 0.03
opacity: 0.4
radius: width * 0.125
Text {
text: "A"
color: "white"
font.pixelSize: parent.width * 0.5
font.bold: true
anchors.centerIn: parent
}
}
}
}
}