UIPalette

Since: BlackBerry 10.3.0

#include <bb/cascades/UIPalette>

A palette that provides access to color values that are being used within the current context.

A palette is comprised of a number of different colors that are dependent on the theme (bright or dark) and the primary colors (blue accent by default) that your app uses. Based on the theme and primary colors, the application creates a palette of complimentary colors and shades for all the different types of components (background, text, controls, and so on).

Like the visual style, primary and primary base colors can be customized in the bar-descriptor.xml file for your app. Here's an example of how you could set a custom primary and primary base color to go with a default theme (Depending on the device that your app runs on, either the bright theme or dark theme is applied to your UI controls).

 <env var="CASCADES_THEME" value="default?primaryColor=0xFF3333&amp;primaryBase=0xCC3333"/>
The following image shows where many of the UI palette colors occur in a typical UI, while using the configuration described above:
No caption available

At runtime, you can retrieve the palette by checking the UiObject::ui property of any component within the same context. Here's how to retrieve the palette colors from a Button, using C++:

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 ...
And here's how to retrieve the palette colors from a Page, using QML:
Page {
    property variant primary: ui.palette.primary;
    property variant base: ui.palette.primaryBase;

    onBaseChanged: {
        console.log("primary base color is changed -- " + Color.toHexString(base));
    }
    onPrimaryChanged: {
        console.log("primary color is changed -- " + Color.toHexString(primary));
    }
    content: Container {
        Container {
            background: base;
            Label {
                text: "primary base color : " + Color.toHexString(base)
            }
        }
        Container {
            background: primary;
            Label {
                text: "primary color : " +  Color.toHexString(primary)
            }
        }
    }
}


Overview

Properties

QVariant background[read-only]

Specifies the background Color of the UIPalette.

Since:

BlackBerry 10.3.0

QVariant plain[read-only]

Specifies the plain Color of the UIPalette.

Since:

BlackBerry 10.3.0

QVariant plainBase[read-only]

Specifies the plain base Color of the UIPalette.

Since:

BlackBerry 10.3.0

QVariant primary[read-only]

Specifies the primary Color of the UIPalette.

Since:

BlackBerry 10.3.0

QVariant primaryBase[read-only]

Specifies the primary base Color of the UIPalette.

Since:

BlackBerry 10.3.0

QVariant primaryDark[read-only]

Specifies the primary dark Color of the UIPalette.

Since:

BlackBerry 10.3.1

QVariant primarySoft[read-only]

Specifies the primary soft Color of the UIPalette.

Since:

BlackBerry 10.3.0

QVariant secondaryTextOnPlain[read-only]

Specifies the secondary text Color used with the plain color of the UIPalette.

Since:

BlackBerry 10.3.1

QVariant secondaryTextOnPrimary[read-only]

Specifies the secondary text Color used with the primary color of the UIPalette.

Since:

BlackBerry 10.3.1

QVariant secondaryTextOnPrimaryDark[read-only]

Specifies the secondary text Color used with the primaryDark color of the UIPalette.

Since:

BlackBerry 10.3.1

QVariant text[read-only]

Specifies the text Color of the UIPalette.

Since:

BlackBerry 10.3.0

QVariant textOnPlain[read-only]

Specifies the text Color on plain Color of the UIPalette.

Since:

BlackBerry 10.3.0

QVariant textOnPrimary[read-only]

Specifies the text Color on primry Color of the UIPalette.

Since:

BlackBerry 10.3.0

QVariant textOnPrimaryDark[read-only]

Specifies the text Color used with the primaryDark color of the UIPalette.

Since:

BlackBerry 10.3.1

QVariant textPrimary[read-only]

Specifies the primary accent text Color of the UIPalette.

Since:

BlackBerry 10.3.0

Public Functions

Color background ()

Retrieves the background color.

Return:

The background Color in the ui palette.

Since:

BlackBerry 10.3.0

Color plain ()

Retrieves the plain color.

Return:

The plain Color in the ui palette.

Since:

BlackBerry 10.3.0

Color plainBase ()

Retrieves the plain base color.

Return:

The plain base Color in the ui palette.

Since:

BlackBerry 10.3.0

Color primary ()

Retrieves the primary color.

Return:

The primary Color in the ui palette.

Since:

BlackBerry 10.3.0

Color primaryBase ()

Retrieves the primary base color.

Return:

The primary base Color in the ui palette.

Since:

BlackBerry 10.3.0

Color primaryDark ()

Retrieves the primary dark color.

Return:

The primary dark Color in the ui palette.

Since:

BlackBerry 10.3.1

Color primarySoft ()

Retrieves the primary soft color.

Return:

The primary soft Color in the ui palette.

Since:

BlackBerry 10.3.0

Color secondaryTextOnPlain ()

Retrieves the secondary text color for a plain color background.

Return:

The secondary text Color for a plain color background in the ui palette.

Since:

BlackBerry 10.3.1

Color secondaryTextOnPrimary ()

Retrieves the secondary text color for a primary color background.

Return:

The secondary text Color for a primary color background in the ui palette.

Since:

BlackBerry 10.3.1

Color secondaryTextOnPrimaryDark ()

Retrieves the secondary text color for a primary dark background.

Return:

The secondary text Color for a primary dark background in the ui palette.

Since:

BlackBerry 10.3.1

Color text ()

Retrieves the standard text color.

Return:

The standard text Color in the ui palette.

Since:

BlackBerry 10.3.0

Color textOnPlain ()

Retrieves the text color for a plain background.

Return:

The text Color for a plain background in the ui palette.

Since:

BlackBerry 10.3.0

Color textOnPrimary ()

Retrieves the text color for a primary background.

Return:

The text Color for a primary background in the ui palette.

Since:

BlackBerry 10.3.0

Color textOnPrimaryDark ()

Retrieves the text color for a primary dark background.

Return:

The text Color for a primary dark background in the ui palette.

Since:

BlackBerry 10.3.1

Color textPrimary ()

Retrieves the primary accent text color.

Return:

The primary accent text Color in the ui palette.

Since:

BlackBerry 10.3.0

Last modified: 2014-09-30



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

comments powered by Disqus