Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 188
Registered: ‎07-19-2012
My Device: Z10 LE
My Carrier: Three
Accepted Solution

Get hex values of current theme

I'm currently working on an application where I require a notification container to be hidden behind a titlebar container. An example of my QML would be:

 

Container {
    layout: DockLayout{}

    Container {
        // Notification stuff goes here
    }

    Container {
        // Title bar that hides notification
        background: Color.White } }

 

The title bar container needs to have a background colour defined, else the notification would be visible at all times. This notification slides down into view via an animation when needed. This works fine and well for the Z10, but for the Q10 this presents a problem.

 

As the Dev Alpha C (and Q10) uses an OLED screen, the bright theme uses a light grey shade as its background colour instead of white. This means that the title bar stands out as it's explicitly set to have a white background and is thus brighter than the rest of the page. This'll also cause a problem if I wish to give the user the option of changing theme in the future.

 

Is there a way of finding the hex value of the current theme's background colour, or any other component? And if not, is there any way of future-proofing against any future visual changes?



Did this post help you? If so, please make sure to "like" it!
Developer
Posts: 16,838
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Get hex values of current theme

maybe you take a screenshot, get the picture data and check for the color on some predefined spot? quite a dirty hack, but without an API its all there is.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 188
Registered: ‎07-19-2012
My Device: Z10 LE
My Carrier: Three

Re: Get hex values of current theme

[ Edited ]

Just compared screenshots of the app running on the devices. The problem is there's a very subtle difference in background colour between the two devices running the same build of the same app. On my Red Z10 it's #FEFEFE, while on the Dev Alpha C it's #F1F1F1. Both devices are running 10.1.0.1485.

 

It's only a small difference in colour between the two devices, but it's big enough to notice a difference if I hard-coded a colour value in. Saying that, I remember seeing in the documentation somewhere that there is an if OLED selector available somewhere in 10.1, might be worth picking a value based on that.



Did this post help you? If so, please make sure to "like" it!
Developer
Posts: 188
Registered: ‎07-19-2012
My Device: Z10 LE
My Carrier: Three

Re: Get hex values of current theme

And lo and behold, I've found it. I can find the screen type in DisplayInfo and pick the approriate colour value from there. It's not a pretty workaround, but it'll do in this case.



Did this post help you? If so, please make sure to "like" it!
Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: Get hex values of current theme

You can also fetch the background color using this class (assignable, but not the RGB values though):

http://developer.blackberry.com/cascades/reference/bb__cascades__systemdefaults__paints.html

 


Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 188
Registered: ‎07-19-2012
My Device: Z10 LE
My Carrier: Three

Re: Get hex values of current theme


Zmey wrote:

You can also fetch the background color using this class (assignable, but not the RGB values though):

http://developer.blackberry.com/cascades/reference/bb__cascades__systemdefaults__paints.html

 


For some reason that didn't work for me. Just gave me a transparent Paint.

 

This is the solution I used in the end:

        //
	// Set title bar colour based on display technology
	Container* titleBar = mRoot->findChild<Container*>("containerTitle");
	unsigned int ledColour = 0xfffefefe;
	unsigned int oledColour = 0xfff1f1f1;

	bb::device::DisplayInfo display;
	switch(display.displayTechnology()) {
	case bb::device::DisplayTechnology::Oled:
		titleBar->setBackground(Color::fromARGB(oledColour));
		break;

	default:
		titleBar->setBackground(Color::fromARGB(ledColour));
		break;
	}

 Once Blackberry get SystemDefaults:Smiley Tongueaints working though, I'll be able to get this down to a two line solution!



Did this post help you? If so, please make sure to "like" it!