Browse Source

Shuffle around code structure

Change-Id: I357f65b4bc50428c56d90749170c5f5031044020
Donald Carr 9 năm trước cách đây
mục cha
commit
b3dd6e87a2

+ 0 - 5
qml/Ticker.qml

@@ -1,5 +0,0 @@
-import QtQuick 2.5
-
-Item {
-    anchors.fill: parent
-}

+ 6 - 9
qml/main.qml

@@ -2,6 +2,8 @@ import QtQuick 2.5
 import QtQuick.Window 2.2
 import Qt.labs.settings 1.0
 
+import "physics"
+
 Window {
     id: appWindow
 
@@ -9,15 +11,10 @@ Window {
     height: 768
 
     Settings {
-        id: settings
-        property int itemTravel: 0
+        id: generalSettings
         property int columnCount: 5
         property int interval: 5
-        property real pace: 1
         property bool viewItemCount: false
-        property bool globalWorld: false
-        // Very computationally heavy: 40% vs 20% for 0.1 vs 0
-        property real restitution: 0
         property string effect: ""
     }
 
@@ -27,7 +24,7 @@ Window {
         anchors.fill: parent
         Keys.forwardTo: [punk, toplevelhandler]
 
-        Gravity {
+        Physics {
             // TODO: generalize all this
             id: punk
         }
@@ -36,8 +33,8 @@ Window {
     Rectangle {
         id: toplevelhandler
         focus: true
-        Keys.onLeftPressed: settings.columnCount = Math.max(settings.columnCount-1,1)
-        Keys.onRightPressed: settings.columnCount++
+        Keys.onLeftPressed: generalSettings.columnCount = Math.max(generalSettings.columnCount-1,1)
+        Keys.onRightPressed: generalSettings.columnCount++
     }
 
     Rectangle {

+ 1 - 1
qml/ArtDelegate.qml → qml/physics/ArtDelegate.qml

@@ -14,7 +14,7 @@ ImageBoxBody {
 
     density: 1.0
     friction: 0
-    restitution: settings.restitution
+    restitution: physicsSettings.restitution
 
     fixedRotation: parent.fixedRotation
     bodyType: Body.Dynamic

+ 0 - 0
qml/HorizontalArtDelegate.qml → qml/physics/HorizontalArtDelegate.qml


+ 0 - 0
qml/ImageBoxBody.qml → qml/physics/ImageBoxBody.qml


+ 22 - 9
qml/Gravity.qml → qml/physics/Physics.qml

@@ -1,6 +1,8 @@
 import QtQuick 2.5
 import Box2D 2.0
-import "effects"
+import Qt.labs.settings 1.0
+
+import "../effects"
 
 Item {
     id: root
@@ -10,20 +12,31 @@ Item {
     signal next
 
     property var pictureDelegate: Qt.createComponent("HorizontalArtDelegate.qml")
-    property var effectDelegate: Qt.createComponent("VisualEffect.qml")
+    property var effectDelegate: Qt.createComponent("../VisualEffect.qml")
 
     anchors.fill: parent
 
+    Settings {
+        id: physicsSettings
+        category: "Physics"
+
+        property int itemTravel: 0
+        property real pace: 1
+        property bool globalWorld: false
+        // Very computationally heavy: 40% vs 20% for 0.1 vs 0
+        property real restitution: 0
+    }
+
     QtObject {
         id: d
-        property real pace: settings.pace/60.0
+        property real pace: physicsSettings.pace/60.0
         property int itemCount: 0
-        property int itemTravel: settings.itemTravel
+        property int itemTravel: physicsSettings.itemTravel
         property int primedColumns: 0
-        property int columnCount: settings.columnCount
+        property int columnCount: generalSettings.columnCount
         property bool running: primedColumns >= columnCount
-        property bool globalWorld: settings.globalWorld
-        property string effect: settings.effect
+        property bool globalWorld: physicsSettings.globalWorld
+        property string effect: generalSettings.effect
 
         function reset() {
             itemCount = 0
@@ -141,7 +154,7 @@ Item {
                 id: deathTimer
                 running: d.running
                 repeat: true
-                interval: 1000*(settings.interval > 60 ? 60*(settings.interval-60) : settings.interval)*(Math.random()+1)
+                interval: 1000*(generalSettings.interval > 60 ? 60*(generalSettings.interval-60) : generalSettings.interval)*(Math.random()+1)
                 onTriggered: shiftImageToLimbo()
             }
 
@@ -215,7 +228,7 @@ Item {
     }
 
     Rectangle {
-        visible: settings.viewItemCount
+        visible: generalSettings.viewItemCount
         z: 1
         color: "black"
         anchors { right: parent.right; top: parent.top }

+ 0 - 0
qml/RectangleBoxBody.qml → qml/physics/RectangleBoxBody.qml


+ 6 - 7
qml/qml.qrc

@@ -1,17 +1,16 @@
 <RCC>
     <qresource prefix="/">
         <file>main.qml</file>
-        <file>ArtDelegate.qml</file>
-        <file>ImageBoxBody.qml</file>
-        <file>RectangleBoxBody.qml</file>
-        <file>HorizontalArtDelegate.qml</file>
-        <file>Gravity.qml</file>
-        <file>Ticker.qml</file>
+        <file>VisualEffect.qml</file>
+        <file>physics/ArtDelegate.qml</file>
+        <file>physics/ImageBoxBody.qml</file>
+        <file>physics/RectangleBoxBody.qml</file>
+        <file>physics/HorizontalArtDelegate.qml</file>
+        <file>physics/Physics.qml</file>
         <file>effects/Effect.qml</file>
         <file>effects/Billboard.qml</file>
         <file>effects/Emboss.qml</file>
         <file>effects/GaussianBlur.qml</file>
-        <file>VisualEffect.qml</file>
         <file>effects/Effects.qml</file>
         <file>effects/qmldir</file>
     </qresource>