jMonkeyEngine-Contributions / Lemur

Lemur is a jMonkeyEngine-based UI toolkit.
http://jmonkeyengine-contributions.github.io/Lemur/
BSD 3-Clause "New" or "Revised" License
116 stars 33 forks source link

Repaired an Bug in Styling #103

Closed Aufricer closed 2 years ago

Aufricer commented 2 years ago

During creation of lemur elements, while calling styles.applyStyles(this, ElementId , style); the function public void initializeStyles(Class c, String style) { is called. That function is first of all initialisating the styles by checking for an function annotated with @Styledefault in the lemur element class
"@StyleDefaults(ELEMENT_ID) public static void initializeDefaultStyles( Styles styles, Attributes attrs ) {"

Before the changes Attributes in variable attrs always belonged to style „null“ so setting any style in that function like would only apply to the default style or „root“ style in the end

attrs.set("scrollOnHover",true,false); To set and apply any options in an element that is not of the current standard style a workaround and passing around variables would have been of need. e.g. styles.getSelector(ElemenmtID, Style .set("scrollOnHover", true, false); The applied changes are minimal and I feel the Style.class as well as the Lemur concept is thought to work that way → thus it was just a BUG

Aufricer commented 2 years ago

Read your comment at https://hub.jmonkeyengine.org/t/bug-in-styling-class/44994/2. If someone is using more then 1 style in a application and lets say he want to set a preferredwidth witdh in all textfields it would be usefull to use the attributes in the textfield.class. If you use styling somewhere you would need to write it several times (for each style). On the other side this functionality is (only?) used in the class of the lemur element. A user of lemur libraries wont have access to the class (only via a *jar). It would help in adjusting the lemur library by tweaking known elements or in the creation of custom lemur elements.

Of course setting styles for elements can always be done outside the element.class but while I wrote my own lemur element it took me hours to figure out why the attributes never matched the expected outcome and why some setting was never applied.
On the other side I am not sure if anyone ever will go that deep in using the library and styling again. I have not tested if the root style inherits all other styles but my feeling was, that the setting was not applied.