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"/>
Screen shots for above configuration:
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 Index

QVariantbackground [read-only]
QVariantplain [read-only]
QVariantplainBase [read-only]
QVariantprimary [read-only]
QVariantprimaryBase [read-only]
QVariantprimarySoft [read-only]
QVarianttext [read-only]
QVarianttextOnPlain [read-only]
QVarianttextOnPrimary [read-only]
QVarianttextPrimary [read-only]

Public Functions Index

Colorbackground () const
Colorplain () const
ColorplainBase () const
Colorprimary () const
ColorprimaryBase () const
ColorprimarySoft () const
Colortext () const
ColortextOnPlain () const
ColortextOnPrimary () const
ColortextPrimary () const

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 primarySoft[read-only]

Specifies the primary soft Color of the UIPalette.

Since:

BlackBerry 10.3.0

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 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 primarySoft ()

Retrieves the primary soft color.

Return:

The primary soft Color in the ui palette.

Since:

BlackBerry 10.3.0

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 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-06-24



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

comments powered by Disqus