What should I use instead of getCurrentColour?


#1

I was doing this in my paint routine:

[code] Colour curColor( g.getCurrentColour() );
Colour mutedColor( Colours::lightgrey );
mutedColor = mutedColor.withAlpha( 0.6f );

            // this slice is muted
            // set color for waveform
            g.setColour( curColor.overlaidWith( mutedColor ) );

[/code]

Since getCurrentColour is no longer supported, what should I be doing?


#2

I just checked the on-line documentation http://www.rawmaterialsoftware.com/juce/api/classGraphics.html

It still supports [quote]const Colour & getCurrentColour () const throw ()
Returns the colour that’s currently being used. [/quote]


#3

Thanks Vishvesh, but the docs are out of sync with the code… here is the checkin comment as well “* Removed methods Graphics::getCurrentFont and Graphics::getCurrentColour, because these methods will become impossible for future native drawing contexts.”


#4

I am sorry. I was using the released version of juce(juce 1.50). :oops:

Well Jules might have written some code as replacement. I will check out the latest code and give it a try.


#5

Yes, sorry. If your code snippet is the body of a function, I’d suggest just adding an explicit colour parameter to the function instead of relying on the current colour to pass that information.

Sorry if that’s a bit annoying, but the only way to keep getCurrentColour would be for me to maintain my own internal graphics state stack, mirroring the one that the native context uses - and considering how rarely getCurrentColour is used, that’d be horribly inefficient!


#6

Well in the end it’s efficiency that matters the most.