# HG changeset patch # User unc0rr # Date 1411678596 -14400 # Node ID 4cf23d4c762485cc189a3cafa567803dbc9e2ba6 # Parent 02c573d1922443993da910204f644c6a99da8c07 - Pages - Animations on buttons hovering diff -r 02c573d19224 -r 4cf23d4c7624 qmlFrontend/qml/qmlFrontend/First.qml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/qmlFrontend/qml/qmlFrontend/First.qml Fri Sep 26 00:56:36 2014 +0400 @@ -0,0 +1,29 @@ +import QtQuick 2.0 + +Rectangle { + HWButton { + id: btnLocalGame + x: 8 + y: 80 + width: 166 + height: 166 + + onClicked: pages.currentPage = "LocalGame" + } + + HWButton { + id: btnNetwork + x: 192 + y: 80 + width: 166 + height: 166 + } + + HWButton { + id: btnAbout + x: 100 + y: 16 + width: 200 + height: 50 + } +} diff -r 02c573d19224 -r 4cf23d4c7624 qmlFrontend/qml/qmlFrontend/GameConfig.qml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/qmlFrontend/qml/qmlFrontend/GameConfig.qml Fri Sep 26 00:56:36 2014 +0400 @@ -0,0 +1,30 @@ +import QtQuick 2.0 +import Hedgewars.Engine 1.0 + +Rectangle { + HWButton { + id: btnPreview + x: 50 + y: 66 + width: 150 + height: 150 + + onClicked: { + HWEngine.run() + } + + Connections { + target: HWEngine + onPreviewImageChanged: previewImage.source = "image://preview/1" + } + } + + Image { + id: previewImage + x: 210 + y: 70 + width: 256 + height: 128 + cache: false + } +} diff -r 02c573d19224 -r 4cf23d4c7624 qmlFrontend/qml/qmlFrontend/HWButton.qml --- a/qmlFrontend/qml/qmlFrontend/HWButton.qml Mon Sep 22 02:10:39 2014 +0400 +++ b/qmlFrontend/qml/qmlFrontend/HWButton.qml Fri Sep 26 00:56:36 2014 +0400 @@ -7,17 +7,36 @@ color: "#15193a" radius: 8 border.width: 4 - border.color: "#ea761d" opacity: 1 signal clicked() + Behavior on border.color { + ColorAnimation {} + } + MouseArea { id: mousearea anchors.fill: parent hoverEnabled: true - onEntered: parent.border.color = "#eaea00" - onExited: parent.border.color = "#ea761d" - onClicked: hwbutton.clicked() + onClicked: parent.clicked() } + + states: [ + State { + when: mousearea.containsMouse + + PropertyChanges { + target: hwbutton + border.color: "#eaea00" + } + } + , State { + when: !mousearea.containsMouse + + PropertyChanges { + target: hwbutton + border.color: "#ea761d" + } + }] } diff -r 02c573d19224 -r 4cf23d4c7624 qmlFrontend/qml/qmlFrontend/LocalGame.qml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/qmlFrontend/qml/qmlFrontend/LocalGame.qml Fri Sep 26 00:56:36 2014 +0400 @@ -0,0 +1,22 @@ +import QtQuick 2.0 +//import Hedgewars.Engine 1.0 + +Rectangle { + HWButton { + id: btnQuickGame + x: 8 + y: 66 + width: 150 + height: 150 + } + + HWButton { + id: btnMultiplayer + x: 192 + y: 66 + width: 150 + height: 150 + + onClicked: pages.currentPage = "GameConfig" + } +} diff -r 02c573d19224 -r 4cf23d4c7624 qmlFrontend/qml/qmlFrontend/main.qml --- a/qmlFrontend/qml/qmlFrontend/main.qml Mon Sep 22 02:10:39 2014 +0400 +++ b/qmlFrontend/qml/qmlFrontend/main.qml Fri Sep 26 00:56:36 2014 +0400 @@ -1,41 +1,35 @@ import QtQuick 2.0 -import Hedgewars.Engine 1.0 Rectangle { - width: 400 - height: 400 + id: pages + width: 800 + height: 600 + + property variant pagesList : [ + "First" + , "LocalGame" + , "GameConfig" + ]; + + property string currentPage : "First"; + + Repeater { + model: pagesList; - HWButton { - id: hwbutton1 - x: 8 - y: 66 - width: 166 - height: 158 + delegate: Loader { + active: false + asynchronous: true + anchors.fill: parent + visible: (currentPage === modelData) + source: "%1.qml".arg(modelData) + onVisibleChanged: loadIfNotLoaded(); + Component.onCompleted: loadIfNotLoaded(); - onClicked: { - HWEngine.run() - } - - Connections { - target: HWEngine - onPreviewImageChanged: previewImage.source = "image://preview/1" + function loadIfNotLoaded () + { + if (visible && !active) + active = true; + } } } - - HWButton { - id: hwbutton2 - x: 192 - y: 66 - width: 200 - height: 139 - } - - Image { - id: previewImage - x: 70 - y: 250 - width: 256 - height: 128 - cache: false - } } diff -r 02c573d19224 -r 4cf23d4c7624 qmlFrontend/qmlFrontend.pro --- a/qmlFrontend/qmlFrontend.pro Mon Sep 22 02:10:39 2014 +0400 +++ b/qmlFrontend/qmlFrontend.pro Fri Sep 26 00:56:36 2014 +0400 @@ -32,4 +32,7 @@ OTHER_FILES += \ qtquick2applicationviewer/qtquick2applicationviewer.pri \ qml/qmlFrontend/HWButton.qml \ - qml/qmlFrontend/main.qml + qml/qmlFrontend/main.qml \ + qml/qmlFrontend/LocalGame.qml \ + qml/qmlFrontend/GameConfig.qml \ + qml/qmlFrontend/First.qml