Skip to content

Commit

Permalink
Merge branch 'feature/layouts' into 'main'
Browse files Browse the repository at this point in the history
Feature/layouts

See merge request asxa86/aspire!22
  • Loading branch information
ASxa86 committed Nov 24, 2024
2 parents 5fbee70 + 8f03481 commit 4acb601
Show file tree
Hide file tree
Showing 11 changed files with 398 additions and 216 deletions.
2 changes: 2 additions & 0 deletions app/edh/Actions.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ QtObject {
signal updateTime(int index, int seconds)

signal select(int index)

signal setPlayerTotal(int total)
}
1 change: 1 addition & 0 deletions app/edh/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ qt_add_qml_module(${PROJECT_NAME}
VERSION 1.0
QML_FILES
Main.qml
MenuEDH.qml
MenuLife.qml
ModelPlayers.qml
Counter.qml
Expand Down
7 changes: 4 additions & 3 deletions app/edh/Counter.qml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ Item {
layer.enabled: true
layer.effect: MultiEffect {
blurEnabled: true
blur: 0.1
blur: 0.45
brightness: 0.5
}

radius: width / 16
color: "darkgoldenrod"
opacity: selected ? 1 : 0
scale: 0.99
scale: 0.96

TapHandler {
onLongPressed: {
Expand All @@ -51,9 +51,10 @@ Item {
maskEnabled: true
}

scale: 0.98
scale: 0.945

Rectangle {
id: counter
anchors.fill: parent

gradient: Gradient {
Expand Down
81 changes: 53 additions & 28 deletions app/edh/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ import app.edh

Window {
id: window
width: 1280
height: 720
width: 560
height: 996
visible: true
visibility: Qt.platform.os == "android" ? Window.FullScreen : Window.AutomaticVisibility
color: Style.color.cardback
color: Style.color.darkcardback
title: "EDH"

Component.onCompleted: {
Actions.setPlayerTotal(4);
}

ModelPlayers {
id: player
}
Expand All @@ -21,19 +25,56 @@ Window {
id: layout
anchors.fill: parent
columns: 2
rows: 2
columnSpacing: parent.width / 20
rowSpacing: 0
columnSpacing: 0

Repeater {
id: repeater

model: player

delegate: Counter {
delegate: Item {
id: root
Layout.fillHeight: true
Layout.fillWidth: true

rotation: index < layout.rows == 0 ? 0 : 180
Layout.columnSpan: (counter.rotation == 0 || counter.rotation == 180) ? 2 : 1

required property int index
required property color background
required property bool selected
required property int life
required property int time

function calcRotation() {
if(player.count == 1) {
return 0;
}
else if(player.count == 2 && root.index == 0) {
return 180;
}
else if(player.count == 2 || (player.count % 2 != 0 && root.index == player.count - 1)) {
return 0;
}
else if(root.index % 2 == 0) {
return 90;
}
else {
return 270;
}
}

Counter {
id: counter
width: (counter.rotation == 0 || counter.rotation == 180) ? parent.width : parent.height
height: (counter.rotation == 0 || counter.rotation == 180)? parent.height : parent.width
anchors.centerIn: parent
rotation: calcRotation()
index: root.index
background: root.background
selected: root.selected
life: root.life
time: root.time
}
}
}
}
Expand All @@ -42,7 +83,7 @@ Window {
Rectangle {
id: shade
anchors.fill: parent
visible: menuLife.active
visible: menu.state == "pressed"

Component.onCompleted: {
shade.color = Style.color.darkcardbackBG;
Expand All @@ -53,32 +94,16 @@ Window {
gesturePolicy: TapHandler.WithinBounds

onTapped: {
menuLife.active = false;
menu.state = "released"
}
}
}

// Menu Options
Column {
MenuEDH {
id: menu
anchors.centerIn: parent

property point center: Qt.point(width / 2, height / 2)
property int count: children.length
spacing: window.height / count

MenuLife {
id: menuLife
width: window.width / 24
height: width
}

ImageSVG {
source: Icons.home
color: "white"

width: window.width / 24
height: width
menuItemForest: MenuLife {
}
}

Expand Down
172 changes: 172 additions & 0 deletions app/edh/MenuEDH.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
import QtQuick

Rectangle {
id: root

width: Style.iconSize
height: Style.iconSize
radius: width / 2
color: Style.color.lightcardback
border.color: Style.color.lightcardbackBG
border.width: 2

property Component menuItemForest: Item {}
property Component menuItemPlains: Item {}
property Component menuItemMountain: Item {}
property Component menuItemIsland: Item {}
property Component menuItemSwamp: Item {}

state: stateReleased.name

states: [
State {
id: stateReleased
name: "released"

PropertyChanges {
target: path
radius: root.radius * 0.75 - 2
}
},
State {
id: statePressed
name: "pressed"

PropertyChanges {
target: path
radius: root.width * 2
}
}
]

transitions: Transition {
NumberAnimation {
property: "radius"
duration: 350
}
}

PathView {
id: path

anchors.centerIn: parent

property real radius: root.radius * 0.75 - 2
property real startAngle: -90


state: root.state
states: [
State {
name: statePressed.name

PropertyChanges {
target: path
startAngle: 270
}
}
]

transitions: Transition {
NumberAnimation {
property: "startAngle"
duration: 350
}
}

model: ListModel {
id: model

Component.onCompleted: {
model.append({
foreground: Style.color.plains,
component: root.menuItemPlains
});

model.append({
foreground: Style.color.island,
component: root.menuItemIsland
});

model.append({
foreground: Style.color.swamp,
component: root.menuItemSwamp
});

model.append({
foreground: Style.color.mountain,
component: root.menuItemMountain
});

model.append({
foreground: Style.color.forest,
component: root.menuItemForest
});
}
}

delegate: Rectangle {
id: rect
width: root.width / 5
height: width
radius: width / 2
color: foreground

state: root.state
states: [
State {
name: statePressed.name

PropertyChanges {
target: rect
width: Style.iconSize
}
},
State {
name: stateReleased.name

PropertyChanges {
target: rect
width: root.width / 5
}
}
]

transitions: Transition {
NumberAnimation {
property: "width"
duration: 350
}
}

Loader {
anchors.fill: parent
sourceComponent: component
}

TapHandler {
gesturePolicy: TapHandler.WithinBounds
}
}

path: Path {
PathAngleArc {
id: radial

radiusX: path.radius
radiusY: path.radius
startAngle: path.startAngle
sweepAngle: 360
}
}
}

TapHandler {
id: tapHandler
gesturePolicy: TapHandler.WithinBounds

onTapped: {
root.state = root.state == statePressed.name ? stateReleased.name : statePressed.name;
}
}
}
Loading

0 comments on commit 4acb601

Please sign in to comment.