Download - Native Application (C/C++) on BlackBerry 10
![Page 1: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/1.jpg)
Native Application (C/C++) development on BlackBerry 10
Aaron Ardiri
Principal Developer Evangelist
[email protected]: @ARDIRI
![Page 2: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/2.jpg)
BlackBerry 10SDKs
C++/Qt
CascadesActionScript
Adobe® AIR®HTML5 BlackBerry®
WebWorks™
C/C++
Native SDKJava
Android™
Runtime
![Page 3: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/3.jpg)
Native SDKOSS & Developer Experience
![Page 4: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/4.jpg)
#include <stdio.h>#include <stdlib.h>
int main(int argc, char **argv){ fprintf(stdout, “Hello World!\n”); return EXIT_SUCCESS;}
Native SDKHello World
![Page 5: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/5.jpg)
Native SDKBlackBerry Platform Servicesthe BlackBerry Platform Services (BPS) library provides an application with a single consistent interface to a number of different services during the execution of the application.
• universal event management• user interaction/navigator• input/output (sensors, audio, LED, screen, multimedia)• device information, locale and payment services• network status and geo-location
![Page 6: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/6.jpg)
Native SDKBlackBerry Platform Servicesbps_event_t *event_bps;
event_bps = NULL;bps_get_event(&event_bps, timeout); // -1, foreverif (event_bps != NULL){ event_domain = bps_event_get_domain(event_bps); if (event_domain == xxx) { // request event information within the domain }}
![Page 7: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/7.jpg)
Native SDKBlackBerry Platform Serviceshandling {service} events
{service}_request_events({param}); // request events
then capture the appropriate {service} events
event_domain = bps_event_get_domain(event_bps); if (event_domain == {service}_get_domain()) { // handle the {service} event
![Page 8: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/8.jpg)
NATIVE SDK:“HARDCORE” DEVELOPMENT
VI, BASH & SSH DEBUGGING
![Page 9: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/9.jpg)
Native SDKOpen Industry Standards
![Page 10: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/10.jpg)
Native SDKOpen Source Support
![Page 11: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/11.jpg)
CASCADES SDK
![Page 12: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/12.jpg)
Cascades SDKOSS & Developer Experience
![Page 13: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/13.jpg)
Mature C++ application framework
Good APIs
Signals and Slots
Many help classes
QML
QtGui Cascades
![Page 14: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/14.jpg)
Qt• Cross-platform application framework• Design GUI, Command line, Daemon Applications• More than a software development kit• Extends C++ (Meta Object Compiler)Cascades• Replacement for Qt UI Creation Kit (QtQuick)• Libraries to access device hardware• Provides development tools (Cascades Builder)
![Page 15: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/15.jpg)
Powerful toolkit with many components • Qt Network Module• Qt Media Module• Qt Core • C++ Extensions Qt Quick • Qt Modeling Language (QML)• JavaScript based declarative language• Used in design of User Interface Applications Qt Creator• Aids in QML development
![Page 16: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/16.jpg)
Replacement for Qt Quick• Cascades UI rendering is NOT on the main thread! Features • Provides BlackBerry Look and Feel • Provides advanced placement management of
components • Supports multiple resolutions • Supports orientation changes (Landscape vs
Portrait) Uses QML • Replaces Qt Creator
• QNX Momentics IDE Plugin – Cascades Builder
![Page 17: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/17.jpg)
import bb.cascades 1.0
Page { content: Label { text: "Hello World" }}
Cascades SDKHello World
![Page 18: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/18.jpg)
Page* root = new Page;Label* label = Label::create() .text("Hello World");root->setContent(label);Application::instance()->setScene(root);
Cascades SDKHello World
![Page 19: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/19.jpg)
60 FPS!
![Page 20: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/20.jpg)
App logic
Photos by rumpleteaser and whologwy Flickr
Cascades
UI in separate thread28°
![Page 21: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/21.jpg)
Scene Graph
RootContainer
Text: “Hello World”
Container
Hello World
RotationZScaleOpacity
![Page 22: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/22.jpg)
Scene GraphDesigning UI with QML• QML User Interfaces built on Object-Tree Model • Need a root node
Typical root nodes• Anything that subclasses AbstractPane• Page – individual screen within an application• NavigationPane• TabbedPane
Container – contains multiple UI objects • Used for custom components
![Page 23: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/23.jpg)
In QML
Container { opacity: 0.5 scaleX: 1.5; scaleY: 1.5 rotationZ: 45 ImageView { … } Label { … }}
![Page 24: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/24.jpg)
C++
Container *bubble= new Container();bubble->setOpacity(0.5f);bubble->setScale(1.5f);bubble->setRotationZ(45);bubble->add(ImageView::create() ... );bubble->add(Label::create() ... );…
![Page 25: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/25.jpg)
Events
Qt uses signals & slots paradigm
Cascades events are mapped to Qt signals
![Page 26: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/26.jpg)
Handling Touch Events in QML
Container{ onTouch: { if (event.isDown()) { scaleX = 2; scaleY = 2; rotationZ = 45; } else if (event.isUp()){ scaleX = 1; scaleY = 1; rotationZ = 0; } } …}
![Page 27: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/27.jpg)
Handling Touch Events in C++
QObject::connect(bubble,SIGNAL (touch(bb::cascades::TouchEvent*)) this,SLOT (touched(bb::cascades::TouchEvent*)));
touched(bb::cascades::TouchEvent *t){ if (t->isDown()) { bubble->setScale(2f); bubble->setRotation(45.0f); } else if (t->isUp()) { bubble->setScale(1f); bubble->setRotation(0.0f); } } }
![Page 28: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/28.jpg)
You can choose!
No difference between UI created in QML or C++
They can be combinedTypically, UI in QML and business logic in C++
QML supports JavaScript for signal handling
C++ QML
![Page 29: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/29.jpg)
Animations
Any Cascades UI element can be animated
Animations are “running” on the engine threadRemember the client server setup?
Explicit & Implicit animations:translation, rotation, scale, opacity, …
![Page 30: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/30.jpg)
Core Controls
![Page 31: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/31.jpg)
Custom controls
![Page 32: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/32.jpg)
Custom Controls
ContainerDockLayout
SpeedGauge
RotationZ (-0) RotationZ (-40)
TranslationY (30)
TranslationY(30)
![Page 33: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/33.jpg)
Standard List Items
![Page 34: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/34.jpg)
Custom list items
![Page 35: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/35.jpg)
Data Binding
SQL
XML
JSON
Anything
![Page 36: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/36.jpg)
StackLayout & DockLayout
![Page 37: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/37.jpg)
Pages, Panes and Navigation
![Page 38: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/38.jpg)
CASCADES SDK:“PLEASING” DEVELOPMENT
IDE, GUI, REAL-TIME UPDATES
![Page 39: Native Application (C/C++) on BlackBerry 10](https://reader034.vdocuments.net/reader034/viewer/2022042601/5469832eaf7959e3018b64c4/html5/thumbnails/39.jpg)
For More Information…
developer.blackberry.com/cascades