kordamp / ikonli

Icon packs for Java applications
http://kordamp.org/ikonli/
Apache License 2.0
500 stars 50 forks source link

Resizing ikons dynamically #156

Open parszab opened 1 year ago

parszab commented 1 year ago

What would be the preferred was to resize the icons dynamically? E.g. when I have a zoom-in/out button that can change the default font-size with something like this:

applicationPreferences.getFontSizeProperty().addListener((c, o, n) -> {
    borderPane.setStyle(String.format("-fx-font-size: %d; ", n));
});

I would like to also resize the icons with it. The only way I found was to bind the font-size in code:

fontIon.iconSizeProperty().bind(ApplicationPreferences.getInstance().getFontSizeProperty().add(4));

But this creates a lot of error messages:

SEVERE: Could not reset [-fx-icon-size] on [IntegerProperty [bean: fth-printer:19:0xeceff4ff, name: iconSize, bound, value: 19]] due to FontIcon.iconSize : A bound value cannot be set.

Not sure why the iconSize is a property if it cannot be cleanly bound.

I also tried this, which breaks the icons:

applicationPreferences.getFontSizeProperty().addListener((c, o, n) -> {
    fontIcon.setStyle(String.format("-fx-icon-size: %d; ", applicationPreferences.getFontSizeProperty().get()));
});
aalmiray commented 1 year ago

Related to https://github.com/kordamp/ikonli/issues/150