Qt wiki will be updated on October 12th 2023 starting at 11:30 AM (EEST) and the maintenance will last around 2-3 hours. During the maintenance the site will be unavailable.

QtComplexGeometryTool: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
(Marked as outdated)
 
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
=Qt-Complex Geometry tool=
{{Outdated|reason=Qt Quick 1}}


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


For a complete documentation on the Geometry tool go to the project wiki [https://projects.developer.nokia.com/Qt_Complex/wiki/GeometryNotes Geometry Notes] ''[projects.developer.nokia.com]''
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 <span class="caps">QML</span> 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.


As the Qt-Complex release supporting Harmattan Meego 1.2 devices (formerly N9 and N950) was possible when it was released the Qt <span class="caps">SDK</span> 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] ''[labs.qt.nokia.com]'')<br /> 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 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 [https://projects.developer.nokia.com/Qt_Complex/wiki/GeometryNotes Geometry] ''[projects.developer.nokia.com]'' 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
* Device category as classified by Qt Quick components (but also by Meego operating system and Android): Small, Normal, Large, ExtraLarge.
* 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.
* Proportional customizable sizes for the components i.e. button height, field spacing, object separator and so on.


===Geometry methods===
=== Geometry methods ===


====getDeviceWidth ()====
==== getDeviceWidth () ====


Return the physical width of the device running the application.
Return the physical width of the device running the application.


====getDeviceHeight ()====
==== getDeviceHeight () ====


Return the physical height of the device running the application.
Return the physical height of the device running the application.


====getObjectHeight (constrains, subobjects)====
==== getObjectHeight (constrains, subobjects) ====


Get the height of a object based on the screen size
Get the height of a object based on the screen size


====getObjectWidth (constrains, subobjects)====
==== getObjectWidth (constrains, subobjects) ====


Get the width of a object based on the screen size
Get the width of a object based on the screen size


====getButtonSpacing ()====
==== getButtonSpacing () ====


Spacing between buttons when grouped of aligned.
Spacing between buttons when grouped of aligned.


====getFormBorder ()====
==== getFormBorder () ====


Get the form border size.
Get the form border size.


====getFieldSpacing ()====
==== getFieldSpacing () ====


Spacing between fields when grouped or aligned.
Spacing between fields when grouped or aligned.


====getFieldHeight ()====
==== getFieldHeight () ====


Get the field height in pixels.
Get the field height in pixels.


====getButtonHeight ()====
==== getButtonHeight () ====


Get the button height in pixels.
Get the button height in pixels.


====getBigButtonHeight ()====
==== getBigButtonHeight () ====


Get the Big Button component height in pixels.
Get the Big Button component height in pixels.


====getRadius ()====
==== getRadius () ====


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


====getFontPoints ()====
==== getFontPoints () ====


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


====getSeparator ()====
==== getSeparator () ====


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


===Behind the scene: stylish your interface===
=== Behind the scene: stylish your interface ===


A typical Geometry function returning a numeric value sounds like the following example:
A typical Geometry function returning a numeric value sounds like the following example:
<code>
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;
}
}
</code>


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.
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 <span class="caps">QML</span> documents==
== Using Geometry in your QML documents ==


A typical <span class="caps">QML</span> source implementing the framework with the Geometry tool is shown in the following scriptlet
A typical QML source implementing the framework with the Geometry tool is shown in the following scriptlet


At this point the Geometry functions can be managed by your <span class="caps">QML</span> code.
<code>
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
</code>


===Importing the correct Qt Quick components for your target platform===
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
If you are developing for symbian platforms you should use the statement
<code>import com.nokia.symbian 1.0</code>


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


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

Latest revision as of 11:37, 24 March 2016

IMPORTANT: The content of this page is outdated. Reason: Qt Quick 1
If you have checked or updated this page and found the content to be suitable, please remove this notice.

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.