Skip to content

Commit 64dd274

Browse files
committed
carousel stumper
1 parent 9d7ef41 commit 64dd274

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1136
-0
lines changed

stumpers/bbjamcarousel/.cproject

Lines changed: 210 additions & 0 deletions
Large diffs are not rendered by default.

stumpers/bbjamcarousel/.project

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>carousel</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
10+
<arguments>
11+
<dictionary>
12+
<key>?name?</key>
13+
<value></value>
14+
</dictionary>
15+
<dictionary>
16+
<key>org.eclipse.cdt.make.core.append_environment</key>
17+
<value>true</value>
18+
</dictionary>
19+
<dictionary>
20+
<key>org.eclipse.cdt.make.core.autoBuildTarget</key>
21+
<value>Device-Debug</value>
22+
</dictionary>
23+
<dictionary>
24+
<key>org.eclipse.cdt.make.core.buildArguments</key>
25+
<value></value>
26+
</dictionary>
27+
<dictionary>
28+
<key>org.eclipse.cdt.make.core.buildCommand</key>
29+
<value>make</value>
30+
</dictionary>
31+
<dictionary>
32+
<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
33+
<value>clean</value>
34+
</dictionary>
35+
<dictionary>
36+
<key>org.eclipse.cdt.make.core.contents</key>
37+
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
38+
</dictionary>
39+
<dictionary>
40+
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
41+
<value>true</value>
42+
</dictionary>
43+
<dictionary>
44+
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
45+
<value>true</value>
46+
</dictionary>
47+
<dictionary>
48+
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
49+
<value>true</value>
50+
</dictionary>
51+
<dictionary>
52+
<key>org.eclipse.cdt.make.core.fullBuildTarget</key>
53+
<value>Device-Debug</value>
54+
</dictionary>
55+
<dictionary>
56+
<key>org.eclipse.cdt.make.core.stopOnError</key>
57+
<value>true</value>
58+
</dictionary>
59+
<dictionary>
60+
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
61+
<value>true</value>
62+
</dictionary>
63+
</arguments>
64+
</buildCommand>
65+
<buildCommand>
66+
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
67+
<triggers>full,incremental,</triggers>
68+
<arguments>
69+
</arguments>
70+
</buildCommand>
71+
<buildCommand>
72+
<name>com.rim.tad.tools.qml.core.qmlFileBuilder</name>
73+
<arguments>
74+
</arguments>
75+
</buildCommand>
76+
<buildCommand>
77+
<name>com.qnx.tools.bbt.xml.core.bbtXMLValidationBuilder</name>
78+
<arguments>
79+
</arguments>
80+
</buildCommand>
81+
</buildSpec>
82+
<natures>
83+
<nature>com.rim.tad.tools.wst.jsdt.core.jsNature</nature>
84+
<nature>org.eclipse.cdt.core.cnature</nature>
85+
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
86+
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
87+
<nature>com.qnx.tools.ide.bbt.core.bbtnature</nature>
88+
<nature>org.eclipse.cdt.core.ccnature</nature>
89+
<nature>com.rim.tad.tools.qml.core.qmlNature</nature>
90+
</natures>
91+
</projectDescription>

stumpers/bbjamcarousel/Makefile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
QMAKE_TARGET = carousel
2+
QMAKE = $(QNX_HOST)/usr/bin/qmake
3+
TARGET = $(QMAKE_TARGET)
4+
5+
6+
all: Makefile $(QMAKE_TARGET)
7+
8+
clean:
9+
$(MAKE) -C ./arm -f Makefile sureclean
10+
$(MAKE) -C ./x86 -f Makefile sureclean
11+
12+
13+
Makefile: FORCE
14+
$(QMAKE) -spec unsupported/blackberry-armv7le-qcc -o arm/Makefile $(QMAKE_TARGET).pro CONFIG+=device
15+
$(QMAKE) -spec unsupported/blackberry-x86-qcc -o x86/Makefile $(QMAKE_TARGET).pro CONFIG+=simulator
16+
$(MAKE) -C ./translations -f Makefile update release
17+
18+
FORCE:
19+
20+
$(QMAKE_TARGET): device simulator
21+
22+
device:
23+
$(MAKE) -C ./arm -f Makefile all
24+
25+
Device-Debug: Makefile
26+
$(MAKE) -C ./arm -f Makefile debug
27+
28+
Device-Release: Makefile
29+
$(MAKE) -C ./arm -f Makefile release
30+
31+
simulator:
32+
$(MAKE) -C ./x86 -f Makefile all
33+
34+
Simulator-Debug: Makefile
35+
$(MAKE) -C ./x86 -f Makefile debug

stumpers/bbjamcarousel/Notice

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Hello Cascades
2+
Copyright (c) 2011 Research In Motion Limited (http://www.rim.com/)
3+
4+
This product includes software developed at
5+
Research In Motion Limited (http://www.rim.com/).
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Empty target directory for building.
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
/* Copyright (c) 2012 Research In Motion Limited.
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
import bb.cascades 1.0
17+
18+
Container {
19+
id: root
20+
property int angle: 0
21+
property int baseAngle: 0
22+
property double offsetValue: 0
23+
property variant centeredControl: 0
24+
property double releaseSpeed: 0
25+
property double momentumSpeed: 0
26+
layout: DockLayout {
27+
}
28+
horizontalAlignment: HorizontalAlignment.Fill
29+
verticalAlignment: VerticalAlignment.Fill
30+
Container {
31+
horizontalAlignment: HorizontalAlignment.Fill
32+
verticalAlignment: VerticalAlignment.Fill
33+
id: carouselContainer
34+
layout: AbsoluteLayout {
35+
}
36+
CarouselItem {
37+
centered: true
38+
angle: root.angle + root.baseAngle
39+
imgFileName: "images/bg1.png"
40+
// use one item to trigger sort
41+
onDepthChanged: {
42+
root.sort()
43+
}
44+
}
45+
CarouselItem {
46+
angle: root.angle + root.baseAngle
47+
imgFileName: "images/bg2.png"
48+
}
49+
CarouselItem {
50+
angle: root.angle + root.baseAngle
51+
imgFileName: "images/johan.png"
52+
}
53+
CarouselItem {
54+
angle: root.angle + root.baseAngle
55+
imgFileName: "images/bg4.png"
56+
}
57+
CarouselItem {
58+
angle: root.angle + root.baseAngle
59+
imgFileName: "images/bg5.png"
60+
}
61+
}
62+
onCreationCompleted: {
63+
root.offsetValue = 360 / (carouselContainer.controls.length)
64+
var currentOffset = 0
65+
for (var i = 0; i < carouselContainer.controls.length; i ++) {
66+
carouselContainer.controls[i].angleOffset = currentOffset
67+
currentOffset += root.offsetValue;
68+
}
69+
root.centeredControl = carouselContainer.controls[0]
70+
sort();
71+
}
72+
function sort() {
73+
//Bubblesort the carousel items
74+
var n = carouselContainer.controls.length
75+
var swopped
76+
do {
77+
swopped = false
78+
for (var i = 0; i < n - 1; ++ i) {
79+
// 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.
80+
if (carouselContainer.controls[i].depth > carouselContainer.controls[i + 1].depth) {
81+
carouselContainer.swap(i, i + 1)
82+
swopped = true
83+
}
84+
}
85+
} while (swopped)
86+
}
87+
onAngleChanged: {
88+
sort();
89+
root.centeredControl.centered = false;
90+
}
91+
onBaseAngleChanged: {
92+
sort();
93+
}
94+
function snapToItem() {
95+
if (root.baseAngle % root.offsetValue != 0) {
96+
snapToItemAnimation.startValue = root.baseAngle
97+
snapToItemAnimation.duration = 300
98+
99+
// snap in the directon the user is scrolling to avoid unsmooth snapping
100+
if (root.releaseSpeed < 0) {
101+
snapToItemAnimation.endValue = Math.floor(root.baseAngle / root.offsetValue) * root.offsetValue
102+
} else if (root.releaseSpeed > 0) {
103+
snapToItemAnimation.endValue = Math.ceil(root.baseAngle / root.offsetValue) * root.offsetValue
104+
} else {
105+
snapToItemAnimation.endValue = Math.round(root.baseAngle / root.offsetValue) * root.offsetValue
106+
}
107+
108+
// Calculate the duration of the snap if we are snapping from a momentum scroll
109+
if (root.momentumSpeed != 0) {
110+
var dist = Math.abs(snapToItemAnimation.endValue - snapToItemAnimation.startValue)
111+
snapToItemAnimation.duration = Math.abs(dist / root.momentumSpeed)
112+
}
113+
snapToItemAnimation.start()
114+
115+
// Set the new centered object
116+
for (var i = 0; i < carouselContainer.controls.length; i ++) {
117+
//if (carouselContainer.controls[i].angleOffset == Math.abs(360 - (snapToItemAnimation.endValue)) % 360) {
118+
if (carouselContainer.controls[i].angleOffset == Math.abs(360 - snapToItemAnimation.endValue) % 360) {
119+
root.centeredControl.centered = false;
120+
root.centeredControl = carouselContainer.controls[i];
121+
root.centeredControl.centered = true;
122+
}
123+
}
124+
}
125+
}
126+
attachedObjects: [
127+
// QPropertyAnimation should be used with care since it is a client side animation that will
128+
// spam the server with messages for every update.
129+
QPropertyAnimation {
130+
id: snapToItemAnimation
131+
startValue: 0
132+
endValue: 360
133+
duration: 300
134+
easingCurve: app.getEase() // TODO:: expose this correctly
135+
targetObject: root
136+
propertyName: app.getBytes("baseAngle") // TODO:: workaround since we need the QByteArray of the property name
137+
onFinished: {
138+
root.baseAngle = root.baseAngle % 360
139+
}
140+
}
141+
]
142+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/* Copyright (c) 2012 Research In Motion Limited.
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
import bb.cascades 1.0
17+
18+
Container {
19+
id: itemRoot
20+
property int angle: 0
21+
property int angleOffset: 0
22+
property bool centered: false
23+
property alias image: theImage.imageSource
24+
property string imgFileName: ""
25+
onImgFileNameChanged: {
26+
theImage.image = app.createMirrorImage(imgFileName)
27+
}
28+
preferredWidth: 426
29+
preferredHeight: 280 + 280 * 0.25 + 2
30+
translationX: 427 + 410 * Math.cos((itemRoot.angle + itemRoot.angleOffset + 90) * (Math.PI / 180))
31+
translationY: 130 + 220 * Math.sin((itemRoot.angle + itemRoot.angleOffset + 90) * (Math.PI / 180))
32+
attachedObjects: [
33+
ImplicitAnimationController {
34+
propertyName: "translationX"
35+
enabled: false
36+
},
37+
ImplicitAnimationController {
38+
propertyName: "translationY"
39+
enabled: false
40+
},
41+
ImplicitAnimationController {
42+
propertyName: "scaleX"
43+
enabled: false
44+
},
45+
ImplicitAnimationController {
46+
propertyName: "scaleY"
47+
enabled: false
48+
}
49+
]
50+
property double scaleFactor: 1 - 0.55 * Math.sin((itemRoot.angle + itemRoot.angleOffset + 180 + 90) * (Math.PI / 180))
51+
// value pening between 0.0 (background) and 2.0 (foreground)
52+
property double depth: 1 + Math.cos((itemRoot.angle + itemRoot.angleOffset) * (Math.PI / 180))
53+
scaleX: scaleFactor
54+
scaleY: scaleFactor
55+
layout: DockLayout {
56+
}
57+
ImageView {
58+
id: theImage
59+
horizontalAlignment: HorizontalAlignment.Fill
60+
verticalAlignment: VerticalAlignment.Fill
61+
scalingMethod: ScalingMethod.AspectFill
62+
opacity: (itemRoot.depth * 0.375) + 0.25
63+
attachedObjects: [
64+
ImplicitAnimationController {
65+
propertyName: "opacity"
66+
enabled: false
67+
}
68+
]
69+
}
70+
}

0 commit comments

Comments
 (0)