1 of 29

Day 3 Building Effective

User Interfaces

with FireMonkey

Daniele Teti

d.teti@bittime.it

@danieleteti

Jim McKeeth

jim.mckeeth@embarcadero.com

@JimMcKeeth

© 2016 Embarcadero Technologies, Inc. All rights reserved.

2 of 29

Agenda

  • User Interface Considerations
  • Layouts & Paradigms
  • Using Animations
  • Using Effects
  • Using Transitions
  • Screen resolution
  • Customizing Styles and Appearance
  • Planning for Mobile and other platform
  • Mastering FireMonkey controls, shapes, and effects

© 2016 Embarcadero Technologies, Inc. All rights reserved.

3 of 29

Daniele Teti

CEO @ bit Time Professionals

High-Level Consultancy,

Trainings and Development

Book Author

Open Source

DelphiMVCFramework

DelphiRedisClient

DelphiSTOMPClient

LoggerPro for Delphi

Others…

blog: www.danieleteti.it

company: www.bittimeprofessionals.it

email: d.teti@bittime.it

© 2016 Embarcadero Technologies, Inc. All rights reserved.

4 of 29

Jim McKeeth

  • Lead World Wide Developer Evangelist & Engineer
  • Long time software developer
  • Invented and patented pattern and swipe to unlock
    • US Patent # 8352745 & 6766456, etc.
  • Built thought controlled drone with Google Glass
  • Host of Podcast at Delphi.org
  • Lives near Boise, Idaho, USA with his family & dogs
  • Improvisational comedy performer with CSz Boise

blog: delphi.org

twitter: @JimMcKeeth

email: jim.mckeeth@embarcadero.com

© 2016 Embarcadero Technologies, Inc. All rights reserved.

5 of 29

User Interface Considerations

  • Layouts
  • Anchors
  • Alignments
  • Padding
  • Spacing
  • Tab Control
  • List View vs. List Box
  • Scollables
  • Frames
  • MultiView

FMX Layout Strategies http://embt.co/fmxlayouts

© 2016 Embarcadero Technologies, Inc. All rights reserved.

6 of 29

FireMonkey (FMX) Basics

  • Anything can be nested
    • See ClipChildren
  • Most numeric properties are a single & animatable
    • Position, RotationCenter, Scale, Size (Height & Width), Opacity, & RotationAngle
  • Use MakeScreenshot method to get Bitmap of layout

© 2016 Embarcadero Technologies, Inc. All rights reserved.

7 of 29

Anchors

  • Position relative to one or more edge(s) of parent:
    • Top
    • Bottom
    • Left
    • Right
  • Default is Top, Left
  • Moves with parent resize
  • Each control has 0 to 4 anchors

  • DocWiki: http://embt.co/fmxanchors

© 2016 Embarcadero Technologies, Inc. All rights reserved.

8 of 29

Alignment

  • Aligns control within parent, setting anchors, size and position. Default is None.
  • Anchor and fill along edge
    • Top, Bottom, Left, Right
  • Fill parent, but preserve aspect ratio
    • Fit, FitLeft, FitRight
  • Fill along one side of the parent
    • MostBottom, MostTop, MostLeft, MostRight
  • Resize only on one axis (width or height)
    • Vertical, VertCenter, Horizontal, HorzCenter
  • Miscellaneous
    • Client, Center, Contents, Scale
  • DocWiki: http://embt.co/fmxalignlayout

© 2016 Embarcadero Technologies, Inc. All rights reserved.

9 of 29

Spacing – Margins and Padding

  • Margins
    • Spacing for siblings �(and parent edges)
    • http://embt.co/fmxmargins
  • Padding
    • Spacing for children
    • http://embt.co/fmxpadding

© 2016 Embarcadero Technologies, Inc. All rights reserved.

10 of 29

TFlowLayout

  • Arrange child controls like words in a paragraph
  • Controls arranged in order added to layout
  • Use TFlowLayoutBreak for forced line break
  • DocWiki: http://embt.co/tflowlayout

© 2016 Embarcadero Technologies, Inc. All rights reserved.

11 of 29

TGridLayout

  • Arranges child controls in a grid of equal sizes
  • Controls flow through grid as parent resizes
  • Use ItemWidth and ItemHeight properties
  • Customize margins of individual controls

  • DocWiki : http://embt.co/tgridlayout

© 2016 Embarcadero Technologies, Inc. All rights reserved.

12 of 29

TGridPanelLayout

  • Creates a grid of specified rows and columns
  • Does not change the anchor or size of child
  • Each cell can contain 1 child control
  • You set the Height, Width, Align, and Anchors of children
  • Controls can span multiple cells

  • DocWiki : http://embt.co/tgridpanellayout

© 2016 Embarcadero Technologies, Inc. All rights reserved.

13 of 29

TScaledLayout

  • Stretches child controls as it is resized at runtime
  • Doesn’t respect aspect ratios of controls
  • Set the Align of the TScaledLayout to Fit to maintain aspect ratio
  • DocWiki: http://embt.co/tscaledlayout

© 2016 Embarcadero Technologies, Inc. All rights reserved.

14 of 29

TScrollBox

  • Allows children to take up more space than parent
  • Usually anchored to Client
  • Only anchor children to Top & Left (default)
    • Do not align children to client!
  • Scroll to see additional children
  • See also:
    • TVertScrollBox, THorzScrollBox, TFramedScrollBox and TFramedVertScrollBox
    • DocWiki: http://embt.co/tscrollbox

© 2016 Embarcadero Technologies, Inc. All rights reserved.

15 of 29

TTabControl

  • Control to group child controls into tabs
  • Tabs are in a stack with one visible at a time.
  • TabPosition := PlatformDefault to use platform default behavior.
  • TabPosition := None to hide navigation.
  • Use TTabChangeAction to animate transitions.
  • DocWiki: http://embt.co/usingttabcontrol

© 2016 Embarcadero Technologies, Inc. All rights reserved.

16 of 29

TMultiView

  • One super panel with multiple modes
  • Supported modes
    • PlatformDefault
    • Drawer
    • NavigationPane
    • Panel
    • Popover
    • Custom
  • Point to MasterPane, DetailPane and definable MasterButton
  • PlatformDefault adapts to platform and orientation (for mobile)
  • Custom supports user defined layout and behavior
  • DocWiki: http://embt.co/usingmultiview

© 2016 Embarcadero Technologies, Inc. All rights reserved.

17 of 29

Frames

  • Reusable pieces of User Interface
    • The layout and all the event handlers
    • All the code in the unit
  • Create 1 or more Frames in project, then reuse them in different layouts or in different places

  • DocWiki: �http://embt.co/workingwithframes

https://commons.wikimedia.org/wiki/File:Oil_painting_frame_Wellcome_L0067855.jpg

© 2016 Embarcadero Technologies, Inc. All rights reserved.

18 of 29

List View vs. List Box

  • TListBox is similar to the VCL TListBox
    • Contains an items TStrings list property
    • Ideal for lists of controls
    • DocWiki: http://embt.co/fmxlistbox
  • TListView is new for FireMonkey
    • Optimized for scrolling speed
    • Great design time customization
    • Ideal for lists of data
    • DocWiki: http://embt.co/fmxlistview

© 2016 Embarcadero Technologies, Inc. All rights reserved.

19 of 29

Animations

  • Modify property values over duration
  • Automatic or manual start
  • Optional delay, loop, inverse, etc.
  • Triggers (or True or False)
    • IsMouseOver, IsDragOver, IsFocused, IsVisible, IsPressed, IsChecked, IsSelected, IsExpanded
  • Events OnProcess & OnFinish
  • Note: Multiple animation instances are not necessarily synchronized (noticeable over time).

© 2016 Embarcadero Technologies, Inc. All rights reserved.

20 of 29

Interpolation

  • Determines how the rate of the value changes to the over time.
  • Linear is default and changes at a constant rate.
    • All options: Linear, Quadratic, Cubic, Quartic, Quintic, Sinusoidal, Exponential, Circular, Elastic, Back, & Bounce
  • AnimationType controls how Interpolation is applied (start vs. end)
    • In - The curve applies to the starting value of the property animated.
    • Out - The curve applies to the ending value of the property animated and proceeds backwards to the starting value.
    • InOut - The curve applies to the both the starting value and the ending value of the property animated and meets at the center point.

© 2016 Embarcadero Technologies, Inc. All rights reserved.

21 of 29

Effects

  • Over 40 GPU powered effects (not counting transition effects)
  • Built using shader filters
  • Progress property represents precentage of application (can be animated over time)
  • Supports optional trigger for automatic enable or disable
  • Apply to image or control

© 2016 Embarcadero Technologies, Inc. All rights reserved.

22 of 29

Transition Effects

  • Over 20 Transition Effects
  • A subset of regular Effects
  • Changes parent image (or control) into target image
  • Progress property represents percentage of application (can be animated over time)
  • For control transitions use MakeScreenshot to get Target image

© 2016 Embarcadero Technologies, Inc. All rights reserved.

23 of 29

Avoiding Freezes

  • Don’t run processes in the main UI thread
  • Use TTask & TFuture from the PPL
  • The PPL manages a thread pool
  • TTask is a unit of work
    • http://embt.co/UsingTTask
  • TFuture is a value needed later
    • http://embt.co/UsingIFuture
  • Use TThread.Queue to update UI
    • http://embt.co/TThreadQueue
  • More on PPL
    • http://embt.co/UsingPPL

© 2016 Embarcadero Technologies, Inc. All rights reserved.

24 of 29

Styles

  • Use TStyleBook to load style
  • Default style is platform default
  • Can override style
  • Optionally customize style
  • http://embt.co/fmxstyles

© 2016 Embarcadero Technologies, Inc. All rights reserved.

25 of 29

Daniele Teti

CEO @ bit Time Professionals

High-Level Consultancy,

Trainings and Development

Book Author

Open Source

DelphiMVCFramework

DelphiRedisClient

DelphiSTOMPClient

LoggerPro for Delphi

Others…

blog: www.danieleteti.it

company: www.bittimeprofessionals.it

email: d.teti@bittime.it

© 2016 Embarcadero Technologies, Inc. All rights reserved.

26 of 29

Delphi Cookbook 2nd Edition

Published in June 2016

More than 60 "recipes"

Best seller after 30 days

470 pages updated to Delphi 10.1 Berlin

More than ⅓ of brand new contents compared to the 1st edition

© 2016 Embarcadero Technologies, Inc. All rights reserved.

27 of 29

Reinventing your GUI also known as mastering Firemonkey controls, shapes, and effects

Let's talk about this specific recipe of the Delphi Cookbook 2nd Edition!

© 2016 Embarcadero Technologies, Inc. All rights reserved.

28 of 29

Reinventing your GUI also known as mastering Firemonkey controls, shapes, and effects

Where to buy the book?

PacktPub

Amazon

iTunes Book

O'REILLY

Others...

© 2016 Embarcadero Technologies, Inc. All rights reserved.

29 of 29

Thank You

Daniele Teti

CEO @ bit Time Professionals

www.danieleteti.it

www.bittimeprofessionals.it

d.teti@bittime.it

© 2016 Embarcadero Technologies, Inc. All rights reserved.