native application (c/c++) on blackberry 10
DESCRIPTION
TRANSCRIPT
Native Application (C/C++) development on BlackBerry 10
Aaron Ardiri
Principal Developer Evangelist
[email protected]: @ARDIRI
BlackBerry 10SDKs
C++/Qt
CascadesActionScript
Adobe® AIR®HTML5 BlackBerry®
WebWorks™
C/C++
Native SDKJava
Android™
Runtime
Native SDKOSS & Developer Experience
#include <stdio.h>#include <stdlib.h>
int main(int argc, char **argv){ fprintf(stdout, “Hello World!\n”); return EXIT_SUCCESS;}
Native SDKHello World
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
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 }}
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
NATIVE SDK:“HARDCORE” DEVELOPMENT
VI, BASH & SSH DEBUGGING
Native SDKOpen Industry Standards
Native SDKOpen Source Support
CASCADES SDK
Cascades SDKOSS & Developer Experience
Mature C++ application framework
Good APIs
Signals and Slots
Many help classes
QML
QtGui Cascades
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)
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
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
import bb.cascades 1.0
Page { content: Label { text: "Hello World" }}
Cascades SDKHello World
Page* root = new Page;Label* label = Label::create() .text("Hello World");root->setContent(label);Application::instance()->setScene(root);
Cascades SDKHello World
60 FPS!
App logic
Photos by rumpleteaser and whologwy Flickr
Cascades
UI in separate thread28°
Scene Graph
RootContainer
Text: “Hello World”
Container
Hello World
RotationZScaleOpacity
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
In QML
Container { opacity: 0.5 scaleX: 1.5; scaleY: 1.5 rotationZ: 45 ImageView { … } Label { … }}
C++
Container *bubble= new Container();bubble->setOpacity(0.5f);bubble->setScale(1.5f);bubble->setRotationZ(45);bubble->add(ImageView::create() ... );bubble->add(Label::create() ... );…
Events
Qt uses signals & slots paradigm
Cascades events are mapped to Qt signals
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; } } …}
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); } } }
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
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, …
Core Controls
Custom controls
Custom Controls
ContainerDockLayout
SpeedGauge
RotationZ (-0) RotationZ (-40)
TranslationY (30)
TranslationY(30)
Standard List Items
Custom list items
Data Binding
SQL
XML
JSON
Anything
StackLayout & DockLayout
Pages, Panes and Navigation
CASCADES SDK:“PLEASING” DEVELOPMENT
IDE, GUI, REAL-TIME UPDATES
For More Information…
developer.blackberry.com/cascades