UIConfig

Since: BlackBerry 10.3.0

#include <bb/cascades/UIConfig>

Provides UI configuration properties for a UiObject.

This class provides functions for converting design units into pixels and for exposing the ui palette used within the current context.

Design units are device-independent values that are converted into explicit pixel values optimized for the screen density and resolution of a particular device. Both the du() and sdu() methods convert a design unit into pixels, with the difference being that sdu() rounds the value off to the nearest whole number.


Overview

QML properties

compact: bool [read-only]
palette: bb::cascades::UIPalette [read-only]

Properties Index

boolcompact [read-only]
bb::cascades::UIPalettepalette [read-only]

Public Functions Index

Q_INVOKABLE floatdu (float duValue) const
boolisCompact () const
bb::cascades::UIPalette *palette () const
Q_INVOKABLE floatpx (float pxValue) const
Q_INVOKABLE floatsdu (float sduValue) const

Signals Index

voidcompactChanged (bool isCompact)
voidpaletteChanged (const bb::cascades::UIPalette *palette)

Properties

bool compact[read-only]

Should the UI use the Compact concept to define the appearance.

Since:

BlackBerry 10.3.0

bb::cascades::UIPalette palette[read-only]

Provides access to the palette used in a UIObject.

Since:

BlackBerry 10.3.0

Public Functions

Q_INVOKABLE float du (
  • floatduValue)

Converts a design unit value into a pixel value.

Parameters
duValue

The value to convert in design units.

Return:

The converted pixel value.

Since:

BlackBerry 10.3.0

bool isCompact ()

Returns the isCompact property of the UI context.

Return:

A bool stating whether the UI should be shown Compact or not.

Since:

BlackBerry 10.3.0

bb::cascades::UIPalette * palette ()

Retrieves the ui palette.

Return:

The UIPalette used by the UIObject.

Since:

BlackBerry 10.3.0

Q_INVOKABLE float px (
  • floatpxValue)

Converts a pixel value to a pixel value.

This method doesn't change the value of the measurement. It's simply used as a way to explicitly show that the value is a pixel value.

Note:

In future versions of Cascades, API changes may require that pixel values are specified explicitly by using this method. Using this API reduces the effort to adapt to those changes, and your code may be source compatible with future versions.

Parameters
pxValue

The value to convert in pixels.

Return:

The pixel value.

Since:

BlackBerry 10.3.0

Q_INVOKABLE float sdu (
  • floatsduValue)

Converts a design unit value into a pixel value, while rounding to the nearest whole pixel.

Parameters
sduValue

The value to convert in design units.

Return:

The converted pixel value, rounded to the nearest whole pixel.

Since:

BlackBerry 10.3.0

Signals

void compactChanged (
  • boolisCompact)

Emitted after the isCompact of the UI has changed.

Parameters
isCompact

The new mode for the UI.

Since:

BlackBerry 10.3.0

void paletteChanged (

Emitted when the UIPalette for this UIObject has changed.

Here's how to connect a slot to a button and listen for changes to its ui palette:

Button *button7 = new Button();
Color baseColor = button7->ui()->palette()->primaryBase();
// set primary base color as button color
button7->setColor(baseColor);

// listen to palette changed signal
QObject::connect(button7->ui(),
                 SIGNAL(paletteChanged(const bb::cascades::UIPalette*)),
                 this,
                SLOT(onPaletteChanged(const bb::cascades::UIPalette*)));
// update button color in onPrimaryPaletteChanged() slot ...
Parameters
palette

The new ui palette.

Since:

BlackBerry 10.3.0

Last modified: 2014-06-24



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus