Text Styles Classes

Hello everyone :)
I would like to choose from pre-set Text Paragraph Styles for the texts of an interface programmed with gamma. Something like the web classes H1, H2, body, ecc to have an easy way to manage the coherence and changes of text styles.
I’ve program it using classes, but I’m quite new with Object-oriented programming, so I would like to ask your opinion: is a correct approch?

Now I can change the style of the text (H1, H2, ecc) writing a string, the best option is to have a static enumeration, to select from a list, but I don’t know how to create it.

I have seen from this post that there is no way to manage kerning (text spacing)… :(

I have attached the patch in order to let you check what I’ve done
fontstyle.vl (92.2 KB)

Thanks a lot!

Hi, there are many ways to approach this which would depends mostly on how your system will be.

For now you could do it like this :
fontstyle.vl (89.9 KB)

You use a Dictionary to register your StyleParagraph and get them by name / Key.

Have a look here too : Community Coding : Design Patterns
And by the way, be careful not to put the Create on update because your StyleParagraph class would be recreated every frame constantly. In a small situation like this it doesn’t affect anything but in a bigger project it would lead to serious disasters.

Another step would be to create a Repository and with an Input PinGroup. Now you can add as many as you want with CTRL+
fontstyle2.vl (92.9 KB)

@Martina1 Maybe take a look at VL.RichTextKit

@lecloneur Any reason the styles are constantly re-added to the dictionary on update in fonststyle?
And in fontstyle2 the dictionary is also recreated every frame.

Indeed that’s because I forgot to put those on Create… my bad.
fontstyle.vl (89.4 KB)
fontstyle2.vl (92.4 KB)

Maybe converting a spread to a dictionary isn’t too costly :
fontstyle3.vl (91.2 KB)

Wow thanks a lot guys!

@bjoern I will! Thanks :)

@lecloneur thanks for the suggestions and the explanations!
I will have a look to Design patterns discourse! Looks very interesting :)
I have a question, about the Create operation: how have you create the node StyleParagraph, where you can assign the values to the class?

I have to go deeply in the FromSequence operation of the fontstyle3 patch.


In Gamma a class can be used in the “Traditional” way which is using a “Create” and then you use the different operation defined in it such as Split in our case. But a Class can also be a Process node and will look like a normal node on the UI.



Now if you have such class then in the node browser you will see two choices :

First one has some sort of a folder icon gives access to the processes defined in your class :

Second will add the class as a Process Node :

Think of it as different patching style that could be adopted based on your taste or a specific technical situation.

Sequence is a base type in Gamma. Spreads, MutableObservableCollections, SpreadBuilders are all sequences so they have common functionality such as “Count”, “Add” etc. Sometimes you can use things that exist in the Sequence category to manipulate spread or all those kind of “List” like types.

1 Like

Wow @lecloneur,
thank you very much!
I’ve used vvvv in a very easy patching mode, but I’m trying to improve and your exhaustive answer is very usefull :D

Thanks a lot!!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.