QtComplexGeometryTool: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
(Remove non-functioning "toc" command)
(clean-up)
Line 1: Line 1:
{{Cleanup | reason=Auto-imported from ExpressionEngine.}}
{{Cleanup | reason=Auto-imported from ExpressionEngine.}}


= Qt-Complex Geometry tool =
= Qt-Complex Geometry tool =
(return to the main [http://developer.qt.nokia.com/wiki/category:Tools::QtComplex Qt-Complex wiki page] or go to the [https://projects.developer.nokia.com/Qt_Complex main project page])
For a complete documentation on the Geometry tool go to the project wiki [https://projects.developer.nokia.com/Qt_Complex/wiki/GeometryNotes Geometry Notes]


One of the primary goals of the Qt-Complex project was to find some good methods to design Qt Quick UI basd on QML in a device-independent way. The first steps in this direction was concerning the parametrization of the custom UI components together with the intensive application of the loader methods as created in the Qt-Complex 1.0 beta release. The obtained result was almost good expecially the feature to manage the device screen orientation: rotating the device the sizes changes and usually inverts. This first approach evidentiated a limit difficult to workaround: the physical screen size of the device itself. Regardless of the screen dimension (physical units, i.e. mm) the same parameters that are working for a certain screen category should be modified and adapted to work on devices with different screen size (pixel ratio).
One of the primary goals of the Qt-Complex project was to find some good methods to design Qt Quick UI basd on QML in a device-independent way. The first steps in this direction was concerning the parametrization of the custom UI components together with the intensive application of the loader methods as created in the Qt-Complex 1.0 beta release. The obtained result was almost good expecially the feature to manage the device screen orientation: rotating the device the sizes changes and usually inverts. This first approach evidentiated a limit difficult to workaround: the physical screen size of the device itself. Regardless of the screen dimension (physical units, i.e. mm) the same parameters that are working for a certain screen category should be modified and adapted to work on devices with different screen size (pixel ratio).


As the Qt-Complex release supporting Harmattan Meego 1.2 devices (formerly N9 and N950) was possible when it was released the Qt SDK 4.7.3 as adopting the last version of the '''Qt Quick components''' it was possible a more efficient approach to the screen geometry with Qt-Complex (for details and installation read the Nokia Labs article [http://labs.qt.nokia.com/2011/07/06/ready-made-ui-building-blocks-at-your-service-qt-quick-components-for-symbian-and-meego-1-2-harmattan/ Qt Quick components for Symbian and MeeGo 1.2 Harmattan])
As the Qt-Complex release supporting Harmattan Meego 1.2 devices (formerly N9 and N950) was possible when it was released the Qt SDK 4.7.3 as adopting the last version of the '''Qt Quick components''' it was possible a more efficient approach to the screen geometry with Qt-Complex. Using the Screen Qt Quick component Qt-Geometry includes a set of functions that support in a best way the screen orientation (including rotation angle where disposable), information on display size and geomtry, the native device sizes etc.
Using the Screen Qt Quick component Qt-Geometry includes a set of functions that support in a best way the screen orientation (including rotation angle where disposable), information on display size and geomtry, the native device sizes etc.


== Geometry.js ==
== Geometry.js ==


As a matter of fact the [https://projects.developer.nokia.com/Qt_Complex/wiki/GeometryNotes Geometry] tool is a javascript set of methods that can be used to obtain the framework component sizes depending by the following parameters:
As a matter of fact the Geometry tool is a javascript set of methods that can be used to obtain the framework component sizes depending by the following parameters:


* Physical orientation where the ancle '0' i the device oriented in the native position
* Physical orientation where the ancle '0' i the device oriented in the native position
Line 118: Line 112:
If you are developing for symbian platforms you should use the statement
If you are developing for symbian platforms you should use the statement


<code>import com.nokia.symbian 1.0<code>
<code>import com.nokia.symbian 1.0</code>


instead of
instead of


</code>import com.meego 1.0</code>
<code>import com.meego 1.0</code>


that should be used for Harmattan platforms.
that should be used for Harmattan platforms.

Revision as of 11:36, 24 March 2016

This article may require cleanup to meet the Qt Wiki's quality standards. Reason: Auto-imported from ExpressionEngine.
Please improve this article if you can. Remove the {{cleanup}} tag and add this page to Updated pages list after it's clean.

Qt-Complex Geometry tool

One of the primary goals of the Qt-Complex project was to find some good methods to design Qt Quick UI basd on QML in a device-independent way. The first steps in this direction was concerning the parametrization of the custom UI components together with the intensive application of the loader methods as created in the Qt-Complex 1.0 beta release. The obtained result was almost good expecially the feature to manage the device screen orientation: rotating the device the sizes changes and usually inverts. This first approach evidentiated a limit difficult to workaround: the physical screen size of the device itself. Regardless of the screen dimension (physical units, i.e. mm) the same parameters that are working for a certain screen category should be modified and adapted to work on devices with different screen size (pixel ratio).

As the Qt-Complex release supporting Harmattan Meego 1.2 devices (formerly N9 and N950) was possible when it was released the Qt SDK 4.7.3 as adopting the last version of the Qt Quick components it was possible a more efficient approach to the screen geometry with Qt-Complex. Using the Screen Qt Quick component Qt-Geometry includes a set of functions that support in a best way the screen orientation (including rotation angle where disposable), information on display size and geomtry, the native device sizes etc.

Geometry.js

As a matter of fact the Geometry tool is a javascript set of methods that can be used to obtain the framework component sizes depending by the following parameters:

  • Physical orientation where the ancle '0' i the device oriented in the native position
  • Device category as classified by Qt Quick components (but also by Meego operating system and Android): Small, Normal, Large, ExtraLarge.
  • Proportional customizable sizes for the components i.e. button height, field spacing, object separator and so on.

Geometry methods

getDeviceWidth ()

Return the physical width of the device running the application.

getDeviceHeight ()

Return the physical height of the device running the application.

getObjectHeight (constrains, subobjects)

Get the height of a object based on the screen size

getObjectWidth (constrains, subobjects)

Get the width of a object based on the screen size

getButtonSpacing ()

Spacing between buttons when grouped of aligned.

getFormBorder ()

Get the form border size.

getFieldSpacing ()

Spacing between fields when grouped or aligned.

getFieldHeight ()

Get the field height in pixels.

getButtonHeight ()

Get the button height in pixels.

getBigButtonHeight ()

Get the Big Button component height in pixels.

getRadius ()

Get a reasonable radius for rounded corners objects based on the device category

getFontPoints ()

Get the base font size in points for a certain object. The title font size is obtained wit getFontPoints() + 1

getSeparator ()

Get the separator space (in pixels) between two objects, groups of components etc.

Behind the scene: stylish your interface

A typical Geometry function returning a numeric value sounds like the following example:

function getSeparator() {
 switch(qtComplex.screenCategory) {
 case device_screen_Small:
 return 14;
 break;
 case device_screen_Normal:
 return 20;
 break;
 case device_screen_Large:
 return 35;
 break;
 case device_screen_ExtraLarge:
 return 40;
 break;
 }
}

This means that depending by the screen category (or in other function by the screen size etc.) the function returns a choice of a predefined value. This means that you can personalize the style of the Geometry behavior changing these parameters accordingly with the geometry values creating the UI aspect that you prefer. Calibrating correctly the parameters the Geometry tool can manage the same UI aspect on a wide range of different devices.

Using Geometry in your QML documents

A typical QML source implementing the framework with the Geometry tool is shown in the following scriptlet

import QtQuick 1.1
import com.meego 1.0
import "QtComplex" as Framework
import "QtComplex/Theme.js" as Theme
import "QtComplex/Geometry.js" as Geometry

At this point the Geometry functions can be managed by your QML code.

Importing the correct Qt Quick components for your target platform

If you are developing for symbian platforms you should use the statement

import com.nokia.symbian 1.0

instead of

import com.meego 1.0

that should be used for Harmattan platforms.