Hint on setting opaque font on transparent TextEditor


#1

I am experimenting with Juce and not very proficient …
This is very close to what I am looking for:
editor = new TextEditor();
effect = new ReduceOpacityEffect;
editor->setOpaque( false );
effect->setOpacity( (float)0.7 );
editor->setComponentEffect( pEffect );

But what I really want is for the characters to be solid and only the font’s background to be transparent.

Any hint much appreciated,
Conrad


#2

You can just set the colour of the TextEditor’s background with textEditor->setColour (TextEditor::backgroundColourId, Colours::transparentBlack);

As colours in Juce are 32 bit ARGB you can just specify them using hex such as “Colour(0x00ffffff)” or the Colours class as above which is a bit easier to read.

Almost all colours are set using the look and feel this way to find the class in the API and look for the required colour ID, no need to mess around with the ReduceOpacityEffect as this for for applying to images.


#3

[quote=“dave96”]You can just set the colour of the TextEditor’s background with textEditor->setColour (TextEditor::backgroundColourId, Colours::transparentBlack);

[/quote]

Thank you Dave. I tried this. I can see now that I am attempting something different. Juce seems to give me “overlay” capabilities with very nice looking resizing. A transparent background in the text control works as long as the pixels under the characters are light or of a very different colour. My background is dynamic, so I think I am going to have to use a custom filter and analyze pixels. Alternatively, use your advise and expect the underlying picture to be “kind”. Ehm…
/conrad


#4

Do you mean you want to change the text colour depending on the background?

Or you just want to ‘fade’ your background slightly I would overlay it with a semi opaque white as the text editor background. Something like:

textEditor->setColour (TextEditor::backgroundColourId, (Colours::white).withAlpha(0.5f));

Is that what you mean or could you provide a screen shot of your specific problem.


#5

[quote=“dave96”]Or you just want to ‘fade’ your background slightly I would overlay it with a semi opaque white as the text editor background. Something like:
textEditor->setColour (TextEditor::backgroundColourId, (Colours::white).withAlpha(0.5f));
[/quote]

I think this can get me close, perhaps even “good enough” - at least much better than I have been able to achieve with other frameworks.
Essentially, a View (panel) with many Text controls can have any picture overlay (or “underlay”). It’s either the picture’s responsibility to make sure that characters in the text controls are clearly readable, yet sufficiently blending in or the text control’s responsibility too fade out the picture background where needed.
And, it should look good during a resizing.
I am trying to figure out how little work I can get away with :slight_smile:
Thanks for the input here!
Conrad.


#6

You can easily experiment with this kind of thing in the Jucer - all the texteditor’s colours are editable there.