25 26 txd 28 1 lao 1 1/10/13 9:16 am page 25 tech brief · system.actions) shared with the vcl. the...

2
The same is true for the action objects (here listed from base to derived class), declared in the following units: TBasicAction in System.Classes TContainedAction in System.Actions TCustomAction and TAction in FMX.ActnList In terms of features, actions in FireMonkey are almost identical to their VCL counterpart, offering predefined actions, direct hooks to visual controls, and much more. Notice, though, that I’m referring to the plain ActionList component, not the more sophisticated ActionManager, which is not available in FireMonkey. In Figure 1 there is a snapshot of one of the official demos, showing the actions list editor and the set of standard actions in FireMonkey (captured on a beta version, so the final content might change). I really like the overall ActionList architecture a lot, so I’m quite happy to see it available in FireMonkey. Notice that this architecture is also the foundation of other building blocks of the VCL, like gestures, which in fact are tied to Actions also in FireMonkey. TOUCH AND GESTURES In the VCL, actions have been a foundation for gestures management, and the lack of actions (and possibly also the lack of time) prevented this key feature to be available in the first version of FireMonkey. Needless to say, the focus on modern architectures and on phones and devices makes it compulsory to have a good support for gestures, movements of the finger (or mouse) over a portion of the form of the application. As you certainly know if you looked into gestures in the VCL, a gesture is a movement of the finder or mouse, which is compared against a set of predefined ones or custom ones defined by the user. This is done either using a native Windows gesture engine or a custom one available in Delphi. It seems this engine has been fine-tuned differently from the TECHXTEND.COM 800.445.7899 25 TECH BRIEF VCL Features In FireMonkey 2 by Marco Cantù, Senior Product Manager, Embarcadero When the FireMonkey library made its debut in Delphi XE2 and RAD Studio XE2, many developers were excited about its potential but some were wary of adopting a new framework. Some of the concerns might have been due to a lack of understanding of the architecture of the new library, or being unsure how to get by without some classic VCL features that they were accustomed to. Delphi XE3 and RAD Studio XE3 change all that and give Delphi and RAD Studio users new reasons to look at multi-device and multi-platform development. Now with the release of the second version of FireMonkey in Delphi XE3, a number of the limitations of the first release have been overcome. The architecture hasn’t change much, but has been fine tuned and improved in a few areas, and many missing pieces have been introduced matching a lot of features found in the VCL. Embarcadero choose to name the new version of the library “FireMonkey FM2” to underline the fact this is now a more robust and complete library. In this article I’ll provide an overview of the changes and extensions of FM2, focusing exclusively on features that were traditionally available in the VCL and have been moved over to the new user interface library. Other new features, from Video support to Pixel- Perfect styles, and from Sensors to Metropolis UI, will be worth another article. ACTIONS AND ACTIONLIST I think that the most relevant features of the VCL that has been asked for since FireMonkey was released and that is now available is the use of Actions connected with user interface elements. In FM2 there is now a TActionList non-visual component, which works very similarly to its VCL counterpart (but they are technically different components).To be more precise, the FireMonkey TActionList class inherits from the base class TCustomActionList, both declared in the FMX.ActnList unit and specific to the library. The base class of TCustomActionList, however, is called TContainedActionList. This class is part of the RTL (specifically System.Actions) shared with the VCL.The VCL TActionList component, in fact, also inherits from this base class. Figure 1 - FireMonkey now has an ActionList component, with its editor and a set of standard actions.

Upload: others

Post on 16-Oct-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 25 26 TXD 28 1 Lao 1 1/10/13 9:16 AM Page 25 TECH BRIEF · System.Actions) shared with the VCL. The VCL TA L component, in fact, also inherits from this base class. Figure 1 - FireMonkey

The same is true for the action objects (here listed from base to derivedclass), declared in the following units:

• TBasicAction in System.Classes• TContainedAction in System.Actions• TCustomAction and TAction in FMX.ActnList

In terms of features, actions in FireMonkey are almost identical to theirVCL counterpart, offering predefined actions, direct hooks to visualcontrols, and much more. Notice, though, that I’m referring to the plainActionList component, not the more sophisticated ActionManager,which is not available in FireMonkey.

In Figure 1 there is a snapshot of one of the official demos, showingthe actions list editor and the set of standard actions in FireMonkey(captured on a beta version, so the final content might change).

I really like the overall ActionList architecture a lot, so I’m quite happyto see it available in FireMonkey. Notice that this architecture is also the

foundation of other building blocks of the VCL, like gestures, which infact are tied to Actions also in FireMonkey.

TOUCH AND GESTURESIn the VCL, actions have been a foundation for gestures management, andthe lack of actions (and possibly also the lack of time) prevented this keyfeature to be available in the first version of FireMonkey. Needless to say,the focus on modern architectures and on phones and devices makes itcompulsory to have a good support for gestures, movements of thefinger (or mouse) over a portion of the form of the application.

As you certainly know if you looked into gestures in the VCL, a gestureis a movement of the finder or mouse, which is compared against a setof predefined ones or custom ones defined by the user. This is doneeither using a native Windows gesture engine or a custom one availablein Delphi. It seems this engine has been fine-tuned differently from the

TECHXTEND.COM 800.445.7899 25

TECH BRIEF

VCL Features In FireMonkey 2by Marco Cantù, Senior Product Manager, Embarcadero

When the FireMonkey library made its debutin Delphi XE2 and RAD Studio XE2, manydevelopers were excited about its potentialbut some were wary of adopting a newframework. Some of the concerns mighthave been due to a lack of understanding ofthe architecture of the new library, or beingunsure how to get by without some classicVCL features that they were accustomed to.Delphi XE3 and RAD Studio XE3 change allthat and give Delphi and RAD Studio usersnew reasons to look at multi-device andmulti-platform development.

Now with the release of the second versionof FireMonkey in Delphi XE3, a number of the limitations of the first release havebeen overcome. The architecture hasn’tchange much, but has been fine tuned andimproved in a few areas, and many missingpieces have been introduced matching a lotof features found in the VCL. Embarcaderochoose to name the new version of thelibrary “FireMonkey FM2” to underline thefact this is now a more robust and completelibrary.

In this article I’ll provide an overview of thechanges and extensions of FM2, focusingexclusively on features that were traditionallyavailable in the VCL and have been movedover to the new user interface library. Othernew features, from Video support to Pixel-Perfect styles, and from Sensors to MetropolisUI, will be worth another article.

ACTIONS AND ACTIONLISTI think that the most relevant features of theVCL that has been asked for since FireMonkeywas released and that is now available is theuse of Actions connected with user interfaceelements. In FM2 there is now a TActionListnon-visual component, which works verysimilarly to its VCL counterpart (but they aretechnically different components).To be moreprecise, the FireMonkey TActionList classinherits from the base classTCustomActionList, both declared in theFMX.ActnList unit and specific to the library.The base class of TCustomActionList,however, is called TContainedActionList.This class is part of the RTL (specificallySystem.Actions) shared with the VCL. The VCLTActionList component, in fact, also inheritsfrom this base class.

Figure 1 - FireMonkey now has an ActionList component,with its editor and a set of standard actions.

25_26_TXD 28_1_Layout 1 1/10/13 9:16 AM Page 25

Page 2: 25 26 TXD 28 1 Lao 1 1/10/13 9:16 AM Page 25 TECH BRIEF · System.Actions) shared with the VCL. The VCL TA L component, in fact, also inherits from this base class. Figure 1 - FireMonkey

26 800.445.7899 TECHXTEND.COM

TECH BRIEF

Another feature related to controls positioning is theavailability of a new set of layouts. These are controlscontainers in which the position of the contained controls isnot an absolute position (X and Y), but depends on theposition of other elements. The basic flow control is like inan HTML page, where elements just follow each other (withoptional spacing).

The new version of FireMonkey introduces several layouts: a TFlowLayout, a TFlowLayoutBreak (which lets youcustomize the breaks between rows), and a TGridLayout(which doesn’t look as complete as the VCL counterpart). As an example of a FlowLayout you can see Figure 3.

The FlowLayout control has a few specific properties, like thefollowing (taken from the demo used to capture Figure 3):

Justify = fjLeft

JustifyLastLine = fjLeft

FlowDirection = fdLeftToRight

HorizontalGap = 3.000000000000000000

VerticalGap = 3.000000000000000000

CONCLUSIONNow that we have FireMonkey FM2, we can start to assess thelibrary and its role much better than for the first version. Sowe can now ask ourselves if this is a worthwhile alternativeto VCL for new applications or maybe also to move existingones over. Of course this mainly depends on your needs, onthe importance of supporting the Mac OS X operating systemfor your applications, on the number of complex third partycomponents you are currently using in the VCL, on anyWindows API calls you are currently making, and much more.

What is quite obvious from looking at FM2 features is thatEmbarcadero is investing heavily in FireMonkey as a user-interface library, for desktop and (soon) for mobile platforms.And it is the mobile platform where FireMonkey will reallyshine, opening up many new possibilities. Having a singlelibrary (and in many cases a single source code) you can usefor native Windows, Mac OS X, iOS, and Android apps could bea dream come true for Delphi (and C++Builder) developers.

past to recognize more imprecise gestures made withfingers (“fat-fingers” recognition).

As you drop in a GestureManager component in aFireMonkey form, you can use the form Touch property,hook in the GestureManager sub-property, and thenpick one or more gestures connecting them to actionsin an ActionList component. You can see a very roughsample in Figure 2.

You can also handle gestures at a lower level, with theOnGesture event. In this case you’ll notice somedifferences from the past, as the TGestureEventInfostructure passed as parameter has new information, like the inertia vector and the tap location:

TGestureEventInfo = record

GestureID: TGestureID;

Location: TPointF;

Flags: TInteractiveGestureFlags;

Angle: Double;

InertiaVector: TPointF;

Distance: Integer;

TapLocation: TPointF;

end;

There is also support for multi-touch gestures (calledinteractive gestures, like in the VCL), which require amulti-touch screen or touch pad. Again, gesture supportis very relevant for phones and tables, while few PCshave a touch screen these days. However, kioskapplications really need gesture management, and touchmonitors might as well become much more commonwith Windows 8.

CONTROLS POSITIONINGIn the second version of FireMonkey, there are also a fewfeatures related with controls positioning and sizing thatcome from the VCL. One of them is the use of Anchors,which let you keep the position of a control tied to theright side of the hosting form, rather than the left one (or the bottom side rather than the top one). You canalso select both left and right anchors to make thecontrol resize along with the hosting control or form.

If you used this feature in the VCL, you’ll find it verysimilar in FireMonkey.Very appreciated, I think, as anchorsgive a lot of flexibility in building the user interface.

Figure 2 - FireMonkey has gesture support, much likethe VCL, which lets you connect gestures to actions.

Figure 3 - A FireMonkey form with a FlowLayoutcontrol hosting a few check boxes.

See all Embarcadero products & pricing attechxtend.com/embarcadero

25_26_TXD 28_1_Layout 1 1/10/13 9:17 AM Page 26