RAD in Action: Revolutionary UI Development with FireUI
Build One UI for 4 Form Factors
Slide deck for the Webinar by David I.
January 28, 2015
http://forms.embarcadero.com/RADInActionFireUI
UI development has changed significantly over the years with new devices and form factors being introduced every day. From phones, desktops, tablets, mini-tablets, wearables, Google Glass and more, developers are faced with creating unique UIs that fit each form factor and native device style.
The revolutionary FireUI designer allows you to create custom and unique UI and UX for each device platform and form factor in a single codebase. FireUI allows you to share one master form and device view across multiple UIs. The webinar shows you how to change the design paradigm in today’s multi-device world.
You’ll learn about:
The New FireUI designer in XE7
Style Designer for FMX
MultiView Smart Menu Component
Behavior Services
And more!
5. EMBARCADERO TECHNOLOGIES
FireUI
• Embarcadero’s collection
of technologies to create
a shared User Interface
across all devices and
form factors
– UI Form Designer
– MultiView Components
– Behavior Services
6. EMBARCADERO TECHNOLOGIES
Multi-Device Designer
• MasterForm Design
• Create specific views if needed
– MasterForm uses
StreamInheritance to manage
deltas
• One project and one form
across all devices
– Shared UI code and event
handling
7. EMBARCADERO TECHNOLOGIES
Delta Streams: The Power Behind FireUI
• Based on form inheritance streaming
• Toggle visibility, position, size between views
• Device detection picks the best delta from the
master view
• One form object holds all controls for all views
7
8. EMBARCADERO TECHNOLOGIES
TMultiView: A Super Component
• It’s a drawer, popup, panel
• A container for other controls
• Presentation abstracted to a
separate object
• Set the presentation or let it be
selected at runtime
8
10. EMBARCADERO TECHNOLOGIES
Behavior Services - “Every Platform is Different”
• “Behind the scenes”
• API provides platform
appropriate design time and
runtime behavior
• Adds PlatformDefault size,
position and behavior for
some controls.
10
11. EMBARCADERO TECHNOLOGIES
Platform Default Behaviors
• PlatformDefault Component Size
– New Size property
– PlatformDefault is enabled on new components
– Automatically disables when a component is resized.
• Tab position
– New PlatformDefault setting
– Maps to Bottom for iOS, Top for all others
11
12. EMBARCADERO TECHNOLOGIES
Behavior Services at Design Time
• Examples:
• TTabControl.TabPosition
• Bottom on iOS, top otherwise
• Font.Size & Font.Family
• Many controls have Size.PlatformDefault = True
• TMultiView mode
12
13. EMBARCADERO TECHNOLOGIES
Behavior Services at Runtime
• TBehaviorServices class in FMX.BehaviorManager.pas
• IDeviceBehavior defines
• GetDeviceClass: TDeviceInfo.TDeviceClass;
• GetOSPlatform: TOSPlatform; // Windows, OSX, iOS, Android
• GetDisplayMetrics: TDeviceDisplayMetrics;
• IFontBehavior defines
• GetDefaultFontFamily & GetDefaultFontSize
13
OP
14. EMBARCADERO TECHNOLOGIES
Behavior Services - OS Specific
var
DeviceBehavior: IDeviceBehavior;
begin
if TBehaviorServices.Current.SupportsBehaviorService(
IDeviceBehavior, DeviceBehavior, Self) and
(DeviceBehavior.GetOSPlatform = TOSPlatform.iOS) then
// behavior specific to iOS
end;
14
OP
15. EMBARCADERO TECHNOLOGIES
Behavior Services - Display Metrics
var
DisplayMetrics: TDeviceDisplayMetrics;
begin // self is a form in this case
DisplayMetrics := DeviceBehavior.GetDisplayMetrics(Self);
if DisplayMetrics.AspectRatio > x then
// AspectRatio specific behavior
end;
15
OP
16. EMBARCADERO TECHNOLOGIES
Behavior Services - Display Metrics
type
TDeviceDisplayMetrics = record
PhysicalScreenSize: TSize;
LogicalScreenSize: TSize;
AspectRatio: Single;
PixelsPerInch: Integer;
ScreenScale: Single;
FontScale: Single;
end;
16
OP
17. EMBARCADERO TECHNOLOGIES
Behavior Services at Runtime
• TBehaviorServices class in FMX.BehaviorManager.hpp
• IDeviceBehavior defines
• GetDeviceClass: TDeviceInfo.TDeviceClass;
• GetOSPlatform: TOSPlatform; // Windows, OSX, iOS, Android
• GetDisplayMetrics: TDeviceDisplayMetrics;
• IFontBehavior defines
• GetDefaultFontFamily & GetDefaultFontSize
17
C++
18. EMBARCADERO TECHNOLOGIES
Behavior Services - OS Specific
_di_IDeviceBehavior DeviceBehavior;
if (TBehaviorServices::Current->SupportsBehaviorService(
__uuidof(IDeviceBehavior), DeviceBehavior, this) &&
(DeviceBehavior->GetOSPlatform() == TOSPlatform::iOS)) {
// iOS specific code
}
18
C++
19. EMBARCADERO TECHNOLOGIES
Behavior Services - Display Metrics
_di_IDeviceBehavior DeviceBehavior;
if (TBehaviorServices::Current->SupportsBehaviorService(
__uuidof(IDeviceBehavior), DeviceBehavior, this))
{
TDeviceDisplayMetrics DisplayMetrics;
DisplayMetrics = DeviceBehavior->GetDisplayMetrics(this);
if (DisplayMetrics.AspectRatio > x) {
// AspectRatio specific behavior
}
}
19
C++
23. EMBARCADERO TECHNOLOGIES
Multi-Device Designer - Introduction
• Create a Master View
• Customize views as
necessary for different
platforms.
• StreamInheritance only
stores difference
between platform views
23
24. EMBARCADERO TECHNOLOGIES
Multi-Device Designer - Details
• There is only one form class for all platforms
• Based on streaming differences (StreamInheritance)
• One FMX file for master, one FMX file per view
• Compiler will selectively include only current
platform resources
24
25. EMBARCADERO TECHNOLOGIES
Multi-Device Designer - Custom Views
• Install package with unit that calls TDeviceinfo.AddDevice
defining device at initialization, and
TDeviceinfo.RemoveDevice at finalization.
• This unit is used at runtime to take advantage of custom view.
• Defines device type, physical screen pixels, logical screen size
and aspect ratio.
• Add matching entry to
%AppData%RoamingEmbarcaderoBDS15.0MobileDevic
es.xml
25
28. EMBARCADERO TECHNOLOGIES
TMultiView Component
• 4 presentations in one
• A sort of “Super Panel”
• Presentation depends on
device kind and
orientation
• Automatically adapts to
different form factors and
orientations, and platforms.
• Custom presentation
available
28
29. EMBARCADERO TECHNOLOGIES
TMultiView Parts
29
TMultiView
MasterButton
TargetControl
Not always visible depending on mode,
should not be on TMultiView.
Usually TLayout or TTabControl
containing other controls. This is
the main content area.
Usually contains other
controls. Only
occasionally visible.
(Useful for settings,
menu, navigation, etc.)
31. EMBARCADERO TECHNOLOGIES
TMultiView at Runtime
• Open and close drawer (or equivalent)
• MultiView1.HideMaster / MultiView1.ShowMaster
• For custom view
• Implement TMultiViewPresentation
• Set it for the MultiView1.CustomPresentationClass
• HasPresenter & MultiView1.Presenter.State
• Set of (Installed, Opened, Moving)
31
34. EMBARCADERO TECHNOLOGIES
Native and Custom Styles
34
Native iOS 8 style Custom iOS style
• Built-in Native Styles
for iOS, Android,
Windows and Mac
• Premium custom
themes for all 4
supported platforms
36. EMBARCADERO TECHNOLOGIES
Bitmap Style Designer
• Create style files – IDE Tools menu and Bin folder
• You can distribute to graphic designers & customers
• The Bitmap Style Designer enables you to:
– Create, edit, and test FireMonkey styles (.style files)
– Create, edit, and test VCL styles (.vsf files)
– Convert a VCL style (.vsf file) into a FireMonkey style by saving the
VCL style as a FireMonkey style (.style file)
36
37. EMBARCADERO TECHNOLOGIES
Using a Custom/Premium Style – Android-L
0. Download the Android-L Style Pack
1. Place a TStyleBook onto your Master view
2. Set TStyleBook.Name = "AndroidLStyleBook"
3. Load AndroidLLight.fsf, AndroidLDarkBlue.fsf or AndroidLDark.fsf to AndroidLStyleBook
4. Use the TForm.OnCreate event and add this code:
Object Pascal:
{$IFDEF ANDROID}
if TOSVersion.Major = 5 then
Form1.StyleBook := AndroidLStyleBook;
{$ENDIF}
C++:
#if defined(__ANDROID__)
if (System::Sysutils::TOSVersion::Check(5)) {
Form1->StyleBook = AndroidLStyleBook;
}
#endif
37 http://cc.embarcadero.com/item/30118
38. EMBARCADERO TECHNOLOGIES
Native iOS Controls
• TEdit family of controls
• Same control, different presentation
• Model/View architecture
• Best of both worlds:
– High performance
– Platform-independent code
38
41. EMBARCADERO TECHNOLOGIES
Multi-Touch
• New FMX.MultiTouch unit: TMultiTouchManager
• Choose ONE of the following to use with FMX
– OnGesture
– OnTap
– OnTouch
• DocWiki
– http://docwiki.embarcadero.com/Libraries/XE7/en/FMX.MultiTouch
– http://docwiki.embarcadero.com/RADStudio/XE7/en/Gestures_in_FireM
onkey
42. EMBARCADERO TECHNOLOGIES
Multi-Touch – OnTap, OnTouch
• OnTap
– Single tap on a UI component
– C++: FormTap(TObject *Sender, const TPointF &Point)
– OP: FormTap(Sender: TObject; const Point: TPointF)
• OnTouch
– Multi-Touch gestures that are truly gestures
• TTouchAction
• Down - Occurs when a finger or other touch device touches the screen
• Up - Occurs when a finger or other touch device is removed or lifted from the screen
• Move - Occurs when a finger or other touch device moves but is not performing a Down or an Up action
• None - A default value; should never occur in reality.
• Cancel - Cancels the gesture.
– C++: FormTouch(TObject *Sender, const TTouches Touches, const TTouchAction Action
• if (Action == TTouchAction::Down)
• Touches[i].Location.X
• Touches[i].Location.Y
– OP: FormTouch(Sender: TObject; const Touches: TTouches; const Action: TTouchAction)
• if Action=TTouchAction.Down then
• Touches[i].Location.X
• Touches[i].Location.Y
43. EMBARCADERO TECHNOLOGIES
Multi-Touch - OnGesture
• Standard Gestures:
– The standard gestures (Up, Down, Triangle, and so on) are equivalent to Application Gestures
on Windows, and to Multi-Touch Sequences on Mac OS X and iOS. Standard gestures are made
with one finger on Windows, and with two fingers on Mac OS X.
– After the gesture finishes (the user lifts the finger), the OnGesture event is fired (if a standard
gesture was recognized).
• Interactive Gestures:
– The interactive gestures are multi-touch gestures (Zoom, Rotate, and so on) that are
equivalent to System Gestures on Windows, and to Gestures on Mac OS X, iOS, and Android.
Every time the fingers move on the touch surface, an OnGesture event is fired.
– FireMonkey uses the four standard gestures Up, Down, Left, and Right as equivalent to the
interactive Swipe gesture (on Mac OS X, iOS, Android, and Windows 8).
43
46. EMBARCADERO TECHNOLOGIES
Summary
• FireUI allows you to build one UI for all form factors
and platforms
• The multi-device designer allows you to create
custom and unique UI and user experience
• TMultiView component adapts to each device form
factor and orientation
46
49. EMBARCADERO TECHNOLOGIES
More Information
• CodeRage 9 sessions for FireUI
– Object Pascal
• FireUI and the Multi-Device Designer - https://www.youtube.com/watch?v=cj_geQ3Vz9E
• Designing Multi-Device Applications with FireUI and TMultiView -
https://www.youtube.com/watch?v=Qkf3n8Cw7_E
• What's New in FireMonkey - https://www.youtube.com/watch?v=PScvVpEO-Rs
• Touch Management with Object Pascal on all Platforms -
https://www.youtube.com/watch?v=lRYT3ToaMK8
– C++
• FireUI and the Multi-Device Designer - https://www.youtube.com/watch?v=zuE1ufYksAg
• Designing Multi-Device Applications with FireUI and TMultiView -
https://www.youtube.com/watch?v=i3M5T0oWmFU
• What's New in FireMonkey - https://www.youtube.com/watch?v=yjm0PxoxHnI
49
51. EMBARCADERO TECHNOLOGIES
Special offers and bonuses
• Enterprise purchases or upgrade from Pro to Enterprise
– Receive a 10-user deployment license for Enterprise Mobility Services
– January 21 to March 31, 2015
• XE2 and earlier versions registered users
– Upgrade from any previous version
– Get the upgrade price on RAD Studio XE7, Delphi XE7 or C++Builder XE7 when you purchase
the upgrade with 1 year Support and Maintenance
– January 12 to March 31, 2015
• Get Free Bonuses until March 31, 2015
– New Object Pascal Handbook by Marco Cantu
– Castalia for Delphi 2014.11
– VCL and FireMonkey Premium Styles
– Mida Converter Basic
51
Find all the details at http://www.embarcadero.com/radoffer