Multiple different text colours/formats in one text box?
-
@cynthasiser What is a text box in this context?
-
@d-healey The text property of a label.
-
@cynthasiser use LAF
-
@Lindon Do labels have laf?
-
@d-healey said in Multiple different text colours/formats in one text box?:
@Lindon Do labels have laf?
if he cant get it done in a label - then he might have to use a panel-or a button...??
-
@Lindon yeah I think a panel is a good choice
-
@cynthasiser Thanks for the reply, but could you be more specific? I thought look and feel was for setting a global aesthetic for the plugin.
My goal is to have a big list of frequencies on screen (the frequencies of every held note and a given number of their harmonics), for example:
C: 262___523___785___1047__1308...
E: 330___659___989___1317__1648...
G: 392 ___784__1176__1568__1960...This information is stored in an array of arrays; an array for each note, which each contains the note's harmonics. I want to highlight any frequencies that are beating - we can see the third harmonic of C and the second harmonic of G are 1Hz apart for example. Let's say my criteria is any frequency within 20Hz of any other frequency in the list.
From what I can tell, if I used a panel, I'd need to set a paint routine and use g.drawText. I'd do a bunch of for loops to get the indexes of all values that i wanted to format and then do something like:
for (i = 0; i = noOfNotes.length; i++) { for (j = 0; j = noOfHarmonics.length; j++) { local area = this.getLocalBounds(j * 20, i * 20); //I'm not clear on how to set the area! Is this right? if ( noteNeedsFormatting == true) {g.setFont(highlightFont); g.drawText(exampleNote, area); } else {g.setFont(normalFont); g.drawText(exampleNote, area); } } }
And i could use set colour or set opacity where I've put set font, but is this generally right? I'd need to set the exact position of every frequency I wanted to display and then switch back and forth between my chosen formatting?
And finally, would this work in real time, reacting as I held and released notes?
Thanks again!
-
@cynthasiser said in Multiple different text colours/formats in one text box?:
And finally, would this work in real time, reacting as I held and released notes?
The GUI is not real-time, but it's close enough for the human eye.
Start with something simpler to get a feel for paint routines.
You can't use
local
in paint routines, you need to usevar
.The formatting of your if statements is not so readable. Do it like this:
if (thing) { do stuff } else { do other stuff }
I'm not clear on how to set the area! Is this right?
If a function has "get" in the name, such as
getLocalBounds
then it's returning a value not setting a value.I have a video about this specific function:
-
@d-healey Thanks for the quick response and the advice, I'll have a play around with paint routines. I was just being lazy with the if statements! And thank you so much for your videos generally, they're an incredible resource, and I wouldn't have gotten anywhere without them!
-
Another way is to use a MarkdownRenderer and a panel, but it's not highly customisable.
So a simple panel with a neat paintRoutine is still a good choice