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)
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)
@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.