Trivial.qml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import QtQuick 2.5
  2. import "../.."
  3. Item {
  4. id: root
  5. property var imageArray: []
  6. function animationStep() {
  7. var lastImage = d.headImageArray[0]
  8. if (lastImage === undefined || lastImage.y > 0) {
  9. globalUtil.itemCount++
  10. var newItem = d.pictureDelegate.createObject(root)
  11. newItem.y = !!d.headImageArray[0]
  12. ? d.headImageArray[0].y - newItem.height
  13. : - newItem.height
  14. imageArray.push(newItem)
  15. d.headImageArray[0] = newItem
  16. }
  17. imageArray.forEach(function(image) { image.advance() })
  18. }
  19. QtObject {
  20. id: d
  21. property real speed: 10
  22. property int startingPoint: 0
  23. property real t: 0
  24. property real columnRatio: globalSettings.useGoldenRatio ? globalVars.goldenRatio : globalSettings.lessGoldenRatio
  25. property var imageArray: []
  26. property var colWidthArray: []
  27. property var xposArray: []
  28. property var headImageArray: []
  29. property var pictureDelegate: Component {
  30. ArtImage {
  31. property int columnIndex: 0
  32. function advance() {
  33. if (y > root.height) {
  34. if (globalSettings.columnCount - columnIndex < 1) {
  35. imageArray.shift()
  36. visible = false
  37. destroy();
  38. d.speed = 1
  39. } else {
  40. columnIndex += 1
  41. y = !!d.headImageArray[columnIndex] ? d.headImageArray[columnIndex].y - height : - height
  42. d.headImageArray[columnIndex] = this
  43. }
  44. } else {
  45. y += d.speed
  46. }
  47. }
  48. width: d.colWidthArray[columnIndex]
  49. x: d.xposArray[columnIndex]
  50. onHeightChanged: {
  51. y = !!d.headImageArray[columnIndex] ? d.headImageArray[columnIndex].y - height : - height
  52. }
  53. }
  54. }
  55. NumberAnimation on t { from: 0; to: 1; duration: 1000; loops: -1 }
  56. onTChanged: { root.animationStep(); }
  57. Component.onCompleted: {
  58. var baseUnit = root.width*globalUtil.columnWidthRatio(d.columnRatio, globalSettings.columnCount)
  59. for(var i = 0; i < globalSettings.columnCount; i++) {
  60. if (i == (globalSettings.columnCount-1)) {
  61. var finalColWidth = root.width - colWidthArray.reduce(function(a,b){ return a+b; }, 0)
  62. colWidthArray.push(finalColWidth)
  63. globalVars.imageWidthOverride = finalColWidth
  64. } else {
  65. colWidthArray.push(Math.round(baseUnit*Math.pow(d.columnRatio, i)))
  66. }
  67. xposArray.push(i === 0 ? 0 : xposArray[i-1] + colWidthArray[i-1])
  68. }
  69. }
  70. }
  71. Connections {
  72. target: globalSettings
  73. onColumnCountChanged: console.log('Col count:' + globalSettings.columnCount)
  74. }
  75. }