Advertisement
Guest User

animation

a guest
Feb 6th, 2020
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.17 KB | None | 0 0
  1. import QtQuick 2.0
  2. import QtQuick.Layouts 1.3
  3.  
  4. Item {
  5. id: global
  6. state: "SomeText2"
  7.  
  8. QtObject {
  9. id: __data
  10.  
  11. readonly property real normalFontSize: 12
  12. readonly property real bigFontSize: 18
  13. readonly property int animationDuration: 200
  14. }
  15.  
  16. ColumnLayout {
  17.  
  18. RowLayout {
  19. spacing: 5
  20. id: modes
  21. Text {
  22. id: firstText
  23. text: "fst"
  24. font.pointSize: __data.normalFontSize
  25. }
  26.  
  27. Text {
  28. id: secondText
  29. text: "snd"
  30. font.pointSize: __data.normalFontSize
  31. }
  32.  
  33. Text {
  34. id: thirdText
  35. text: "third"
  36. font.pointSize: __data.normalFontSize
  37. }
  38. }
  39.  
  40. Rectangle {
  41. color: "green"
  42. width: 50
  43. height: 50
  44.  
  45.  
  46. MouseArea {
  47. anchors.fill: parent
  48.  
  49. onPressed: {
  50. global.state = "SomeText1"
  51. }
  52. }
  53. }
  54.  
  55. Rectangle {
  56. color: "red"
  57. width: 50
  58. height: 50
  59.  
  60.  
  61. MouseArea {
  62. anchors.fill: parent
  63.  
  64. onPressed: {
  65. global.state = "SomeText2"
  66. }
  67. }
  68. }
  69.  
  70. Rectangle {
  71. color: "yellow"
  72. width: 50
  73. height: 50
  74.  
  75.  
  76. MouseArea {
  77. anchors.fill: parent
  78.  
  79. onPressed: {
  80. global.state = "SomeText3"
  81. }
  82. }
  83. }
  84. }
  85.  
  86. states: [
  87. State {
  88. name: "SomeText2"
  89. PropertyChanges {
  90. target: firstText
  91. font.pointSize: __data.bigFontSize
  92. }
  93. },
  94. State {
  95. name: "SomeText1"
  96. PropertyChanges {
  97. target: secondText
  98. font.pointSize: __data.bigFontSize
  99.  
  100. }
  101. },
  102. State {
  103. name: "SomeText3"
  104. PropertyChanges {
  105. target: thirdText
  106. font.pointSize: __data.bigFontSize
  107. }
  108. }
  109. ]
  110.  
  111. transitions: [
  112. Transition {
  113. from: "SomeText2"
  114. to: "SomeText1"
  115. SequentialAnimation {
  116. PropertyAnimation {
  117. target: firstText
  118. property: "font.pointSize"
  119. to: __data.normalFontSize
  120. }
  121. }
  122. },
  123. Transition {
  124. from: "SomeText1"
  125. to: "SomeText2"
  126. SequentialAnimation {
  127. PropertyAnimation {
  128. target: secondText
  129. property: "font.pointSize"
  130. to: __data.normalFontSize
  131. duration: 1000
  132. }
  133. NumberAnimation {
  134. target: secondText
  135. duration: 1000
  136. }
  137. }
  138. },
  139. Transition {
  140. from: "SomeText1"
  141. to: "SomeText3"
  142. SequentialAnimation {
  143. PropertyAnimation {
  144. target: secondText
  145. property: "font.pointSize"
  146. to: __data.normalFontSize
  147. }
  148. }
  149. },
  150. Transition {
  151. from: "SomeText3"
  152. to: "SomeText1"
  153. SequentialAnimation {
  154. PropertyAnimation {
  155. target: thirdText
  156. property: "font.pointSize"
  157. to: __data.normalFontSize
  158. }
  159. }
  160. },
  161. Transition {
  162. from: "SomeText3"
  163. to: "SomeText2"
  164. SequentialAnimation {
  165. PropertyAnimation {
  166. target: thirdText
  167. property: "font.pointSize"
  168. to: __data.normalFontSize
  169. }
  170.  
  171. }
  172. },
  173. Transition {
  174. from: "SomeText2"
  175. to: "SomeText3"
  176. SequentialAnimation {
  177. PropertyAnimation {
  178. target: firstText
  179. property: "font.pointSize"
  180. to: __data.normalFontSize
  181. }
  182. }
  183. }
  184. ]
  185. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement