Permalink
Browse files

carousel stumper

  • Loading branch information...
1 parent 9d7ef41 commit 64dd274fb3de8aff8b45b647750555020555cf4f @jlarsby jlarsby committed Oct 2, 2012
Showing with 1,136 additions and 0 deletions.
  1. +210 −0 stumpers/bbjamcarousel/.cproject
  2. +91 −0 stumpers/bbjamcarousel/.project
  3. +35 −0 stumpers/bbjamcarousel/Makefile
  4. +5 −0 stumpers/bbjamcarousel/Notice
  5. +1 −0 stumpers/bbjamcarousel/arm/README.txt
  6. +142 −0 stumpers/bbjamcarousel/assets/Carousel.qml
  7. +70 −0 stumpers/bbjamcarousel/assets/CarouselItem.qml
  8. +85 −0 stumpers/bbjamcarousel/assets/SwipeHandler.qml
  9. BIN stumpers/bbjamcarousel/assets/images/bg.png
  10. BIN stumpers/bbjamcarousel/assets/images/bg1.jpg
  11. BIN stumpers/bbjamcarousel/assets/images/bg1.png
  12. BIN stumpers/bbjamcarousel/assets/images/bg2.jpg
  13. BIN stumpers/bbjamcarousel/assets/images/bg2.png
  14. BIN stumpers/bbjamcarousel/assets/images/bg3.jpg
  15. BIN stumpers/bbjamcarousel/assets/images/bg3.png
  16. BIN stumpers/bbjamcarousel/assets/images/bg4.jpg
  17. BIN stumpers/bbjamcarousel/assets/images/bg4.png
  18. BIN stumpers/bbjamcarousel/assets/images/bg5.jpg
  19. BIN stumpers/bbjamcarousel/assets/images/bg5.png
  20. BIN stumpers/bbjamcarousel/assets/images/hl.png
  21. BIN stumpers/bbjamcarousel/assets/images/johan.png
  22. BIN stumpers/bbjamcarousel/assets/images/originals/bg1.jpg
  23. BIN stumpers/bbjamcarousel/assets/images/originals/bg10.jpg
  24. BIN stumpers/bbjamcarousel/assets/images/originals/bg11.jpg
  25. BIN stumpers/bbjamcarousel/assets/images/originals/bg2.jpg
  26. BIN stumpers/bbjamcarousel/assets/images/originals/bg3.jpg
  27. BIN stumpers/bbjamcarousel/assets/images/originals/bg4.jpg
  28. BIN stumpers/bbjamcarousel/assets/images/originals/bg5.jpg
  29. BIN stumpers/bbjamcarousel/assets/images/originals/bg6.jpg
  30. BIN stumpers/bbjamcarousel/assets/images/originals/bg7.jpg
  31. BIN stumpers/bbjamcarousel/assets/images/originals/bg8.jpg
  32. BIN stumpers/bbjamcarousel/assets/images/originals/bg9.jpg
  33. +64 −0 stumpers/bbjamcarousel/assets/main.qml
  34. +105 −0 stumpers/bbjamcarousel/bar-descriptor.xml
  35. +50 −0 stumpers/bbjamcarousel/carousel.pro
  36. +4 −0 stumpers/bbjamcarousel/device-assets.xml
  37. BIN stumpers/bbjamcarousel/icon.png
  38. +150 −0 stumpers/bbjamcarousel/src/Carousel.cpp
  39. +44 −0 stumpers/bbjamcarousel/src/Carousel.hpp
  40. +61 −0 stumpers/bbjamcarousel/src/main.cpp
  41. +12 −0 stumpers/bbjamcarousel/translations/Makefile
  42. +1 −0 stumpers/bbjamcarousel/translations/carousel.pro
  43. +1 −0 stumpers/bbjamcarousel/translations/carousel.qm
  44. +4 −0 stumpers/bbjamcarousel/translations/carousel.ts
  45. +1 −0 stumpers/bbjamcarousel/x86/README.txt

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>carousel</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+ <arguments>
+ <dictionary>
+ <key>?name?</key>
+ <value></value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.append_environment</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.autoBuildTarget</key>
+ <value>Device-Debug</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.buildArguments</key>
+ <value></value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.buildCommand</key>
+ <value>make</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
+ <value>clean</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.contents</key>
+ <value>org.eclipse.cdt.make.core.activeConfigSettings</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableAutoBuild</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableCleanBuild</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableFullBuild</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.fullBuildTarget</key>
+ <value>Device-Debug</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.stopOnError</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
+ <value>true</value>
+ </dictionary>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+ <triggers>full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.rim.tad.tools.qml.core.qmlFileBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.qnx.tools.bbt.xml.core.bbtXMLValidationBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.rim.tad.tools.wst.jsdt.core.jsNature</nature>
+ <nature>org.eclipse.cdt.core.cnature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+ <nature>com.qnx.tools.ide.bbt.core.bbtnature</nature>
+ <nature>org.eclipse.cdt.core.ccnature</nature>
+ <nature>com.rim.tad.tools.qml.core.qmlNature</nature>
+ </natures>
+</projectDescription>
@@ -0,0 +1,35 @@
+QMAKE_TARGET = carousel
+QMAKE = $(QNX_HOST)/usr/bin/qmake
+TARGET = $(QMAKE_TARGET)
+
+
+all: Makefile $(QMAKE_TARGET)
+
+clean:
+ $(MAKE) -C ./arm -f Makefile sureclean
+ $(MAKE) -C ./x86 -f Makefile sureclean
+
+
+Makefile: FORCE
+ $(QMAKE) -spec unsupported/blackberry-armv7le-qcc -o arm/Makefile $(QMAKE_TARGET).pro CONFIG+=device
+ $(QMAKE) -spec unsupported/blackberry-x86-qcc -o x86/Makefile $(QMAKE_TARGET).pro CONFIG+=simulator
+ $(MAKE) -C ./translations -f Makefile update release
+
+FORCE:
+
+$(QMAKE_TARGET): device simulator
+
+device:
+ $(MAKE) -C ./arm -f Makefile all
+
+Device-Debug: Makefile
+ $(MAKE) -C ./arm -f Makefile debug
+
+Device-Release: Makefile
+ $(MAKE) -C ./arm -f Makefile release
+
+simulator:
+ $(MAKE) -C ./x86 -f Makefile all
+
+Simulator-Debug: Makefile
+ $(MAKE) -C ./x86 -f Makefile debug
@@ -0,0 +1,5 @@
+Hello Cascades
+Copyright (c) 2011 Research In Motion Limited (http://www.rim.com/)
+
+This product includes software developed at
+Research In Motion Limited (http://www.rim.com/).
@@ -0,0 +1 @@
+Empty target directory for building.
@@ -0,0 +1,142 @@
+/* Copyright (c) 2012 Research In Motion Limited.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import bb.cascades 1.0
+
+Container {
+ id: root
+ property int angle: 0
+ property int baseAngle: 0
+ property double offsetValue: 0
+ property variant centeredControl: 0
+ property double releaseSpeed: 0
+ property double momentumSpeed: 0
+ layout: DockLayout {
+ }
+ horizontalAlignment: HorizontalAlignment.Fill
+ verticalAlignment: VerticalAlignment.Fill
+ Container {
+ horizontalAlignment: HorizontalAlignment.Fill
+ verticalAlignment: VerticalAlignment.Fill
+ id: carouselContainer
+ layout: AbsoluteLayout {
+ }
+ CarouselItem {
+ centered: true
+ angle: root.angle + root.baseAngle
+ imgFileName: "images/bg1.png"
+ // use one item to trigger sort
+ onDepthChanged: {
+ root.sort()
+ }
+ }
+ CarouselItem {
+ angle: root.angle + root.baseAngle
+ imgFileName: "images/bg2.png"
+ }
+ CarouselItem {
+ angle: root.angle + root.baseAngle
+ imgFileName: "images/johan.png"
+ }
+ CarouselItem {
+ angle: root.angle + root.baseAngle
+ imgFileName: "images/bg4.png"
+ }
+ CarouselItem {
+ angle: root.angle + root.baseAngle
+ imgFileName: "images/bg5.png"
+ }
+ }
+ onCreationCompleted: {
+ root.offsetValue = 360 / (carouselContainer.controls.length)
+ var currentOffset = 0
+ for (var i = 0; i < carouselContainer.controls.length; i ++) {
+ carouselContainer.controls[i].angleOffset = currentOffset
+ currentOffset += root.offsetValue;
+ }
+ root.centeredControl = carouselContainer.controls[0]
+ sort();
+ }
+ function sort() {
+ //Bubblesort the carousel items
+ var n = carouselContainer.controls.length
+ var swopped
+ do {
+ swopped = false
+ for (var i = 0; i < n - 1; ++ i) {
+ // a larger depth value means the pic should be on top, i.e. move towards the end of the list of items in the container.
+ if (carouselContainer.controls[i].depth > carouselContainer.controls[i + 1].depth) {
+ carouselContainer.swap(i, i + 1)
+ swopped = true
+ }
+ }
+ } while (swopped)
+ }
+ onAngleChanged: {
+ sort();
+ root.centeredControl.centered = false;
+ }
+ onBaseAngleChanged: {
+ sort();
+ }
+ function snapToItem() {
+ if (root.baseAngle % root.offsetValue != 0) {
+ snapToItemAnimation.startValue = root.baseAngle
+ snapToItemAnimation.duration = 300
+
+ // snap in the directon the user is scrolling to avoid unsmooth snapping
+ if (root.releaseSpeed < 0) {
+ snapToItemAnimation.endValue = Math.floor(root.baseAngle / root.offsetValue) * root.offsetValue
+ } else if (root.releaseSpeed > 0) {
+ snapToItemAnimation.endValue = Math.ceil(root.baseAngle / root.offsetValue) * root.offsetValue
+ } else {
+ snapToItemAnimation.endValue = Math.round(root.baseAngle / root.offsetValue) * root.offsetValue
+ }
+
+ // Calculate the duration of the snap if we are snapping from a momentum scroll
+ if (root.momentumSpeed != 0) {
+ var dist = Math.abs(snapToItemAnimation.endValue - snapToItemAnimation.startValue)
+ snapToItemAnimation.duration = Math.abs(dist / root.momentumSpeed)
+ }
+ snapToItemAnimation.start()
+
+ // Set the new centered object
+ for (var i = 0; i < carouselContainer.controls.length; i ++) {
+ //if (carouselContainer.controls[i].angleOffset == Math.abs(360 - (snapToItemAnimation.endValue)) % 360) {
+ if (carouselContainer.controls[i].angleOffset == Math.abs(360 - snapToItemAnimation.endValue) % 360) {
+ root.centeredControl.centered = false;
+ root.centeredControl = carouselContainer.controls[i];
+ root.centeredControl.centered = true;
+ }
+ }
+ }
+ }
+ attachedObjects: [
+ // QPropertyAnimation should be used with care since it is a client side animation that will
+ // spam the server with messages for every update.
+ QPropertyAnimation {
+ id: snapToItemAnimation
+ startValue: 0
+ endValue: 360
+ duration: 300
+ easingCurve: app.getEase() // TODO:: expose this correctly
+ targetObject: root
+ propertyName: app.getBytes("baseAngle") // TODO:: workaround since we need the QByteArray of the property name
+ onFinished: {
+ root.baseAngle = root.baseAngle % 360
+ }
+ }
+ ]
+}
@@ -0,0 +1,70 @@
+/* Copyright (c) 2012 Research In Motion Limited.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import bb.cascades 1.0
+
+Container {
+ id: itemRoot
+ property int angle: 0
+ property int angleOffset: 0
+ property bool centered: false
+ property alias image: theImage.imageSource
+ property string imgFileName: ""
+ onImgFileNameChanged: {
+ theImage.image = app.createMirrorImage(imgFileName)
+ }
+ preferredWidth: 426
+ preferredHeight: 280 + 280 * 0.25 + 2
+ translationX: 427 + 410 * Math.cos((itemRoot.angle + itemRoot.angleOffset + 90) * (Math.PI / 180))
+ translationY: 130 + 220 * Math.sin((itemRoot.angle + itemRoot.angleOffset + 90) * (Math.PI / 180))
+ attachedObjects: [
+ ImplicitAnimationController {
+ propertyName: "translationX"
+ enabled: false
+ },
+ ImplicitAnimationController {
+ propertyName: "translationY"
+ enabled: false
+ },
+ ImplicitAnimationController {
+ propertyName: "scaleX"
+ enabled: false
+ },
+ ImplicitAnimationController {
+ propertyName: "scaleY"
+ enabled: false
+ }
+ ]
+ property double scaleFactor: 1 - 0.55 * Math.sin((itemRoot.angle + itemRoot.angleOffset + 180 + 90) * (Math.PI / 180))
+ // value pening between 0.0 (background) and 2.0 (foreground)
+ property double depth: 1 + Math.cos((itemRoot.angle + itemRoot.angleOffset) * (Math.PI / 180))
+ scaleX: scaleFactor
+ scaleY: scaleFactor
+ layout: DockLayout {
+ }
+ ImageView {
+ id: theImage
+ horizontalAlignment: HorizontalAlignment.Fill
+ verticalAlignment: VerticalAlignment.Fill
+ scalingMethod: ScalingMethod.AspectFill
+ opacity: (itemRoot.depth * 0.375) + 0.25
+ attachedObjects: [
+ ImplicitAnimationController {
+ propertyName: "opacity"
+ enabled: false
+ }
+ ]
+ }
+}
Oops, something went wrong.

0 comments on commit 64dd274

Please sign in to comment.