mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-08-06 13:44:23 -04:00
use stackpane for currency icons
This commit is contained in:
parent
55032f94e7
commit
ed25756ae8
1 changed files with 27 additions and 23 deletions
|
@ -350,11 +350,10 @@ public class GUIUtil {
|
||||||
default:
|
default:
|
||||||
|
|
||||||
// use icon if available
|
// use icon if available
|
||||||
ImageView currencyIcon = getCurrencyIcon(code);
|
StackPane currencyIcon = getCurrencyIcon(code);
|
||||||
if (currencyIcon != null) {
|
if (currencyIcon != null) {
|
||||||
label1.setText("");
|
label1.setText("");
|
||||||
StackPane iconWrapper = new StackPane(currencyIcon); // TODO: icon must be wrapped in StackPane for reliable rendering on linux
|
label1.setGraphic(currencyIcon);
|
||||||
label1.setGraphic(iconWrapper);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preferences.isSortMarketCurrenciesNumerically() && item.numTrades > 0) {
|
if (preferences.isSortMarketCurrenciesNumerically() && item.numTrades > 0) {
|
||||||
|
@ -461,11 +460,10 @@ public class GUIUtil {
|
||||||
default:
|
default:
|
||||||
|
|
||||||
// use icon if available
|
// use icon if available
|
||||||
ImageView currencyIcon = getCurrencyIcon(code);
|
StackPane currencyIcon = getCurrencyIcon(code);
|
||||||
if (currencyIcon != null) {
|
if (currencyIcon != null) {
|
||||||
label1.setText("");
|
label1.setText("");
|
||||||
StackPane iconWrapper = new StackPane(currencyIcon); // TODO: icon must be wrapped in StackPane for reliable rendering on linux
|
label1.setGraphic(currencyIcon);
|
||||||
label1.setGraphic(iconWrapper);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isCrypto = CurrencyUtil.isCryptoCurrency(code);
|
boolean isCrypto = CurrencyUtil.isCryptoCurrency(code);
|
||||||
|
@ -506,11 +504,10 @@ public class GUIUtil {
|
||||||
label2.getStyleClass().add("currency-label");
|
label2.getStyleClass().add("currency-label");
|
||||||
|
|
||||||
// use icon if available
|
// use icon if available
|
||||||
ImageView currencyIcon = getCurrencyIcon(item.getCode());
|
StackPane currencyIcon = getCurrencyIcon(item.getCode());
|
||||||
if (currencyIcon != null) {
|
if (currencyIcon != null) {
|
||||||
label1.setText("");
|
label1.setText("");
|
||||||
StackPane iconWrapper = new StackPane(currencyIcon); // TODO: icon must be wrapped in StackPane for reliable rendering on linux
|
label1.setGraphic(currencyIcon);
|
||||||
label1.setGraphic(iconWrapper);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
box.getChildren().addAll(label1, label2);
|
box.getChildren().addAll(label1, label2);
|
||||||
|
@ -1283,21 +1280,31 @@ public class GUIUtil {
|
||||||
return contentColumns;
|
return contentColumns;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ImageView getCurrencyIcon(String currencyCode) {
|
private static ImageView getCurrencyImageView(String currencyCode) {
|
||||||
return getCurrencyIcon(currencyCode, 24);
|
return getCurrencyImageView(currencyCode, 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ImageView getCurrencyIcon(String currencyCode, double size) {
|
private static ImageView getCurrencyImageView(String currencyCode, double size) {
|
||||||
if (currencyCode == null) return null;
|
if (currencyCode == null) return null;
|
||||||
String imageId = getImageId(currencyCode);
|
String imageId = getImageId(currencyCode);
|
||||||
if (imageId == null) return null;
|
if (imageId == null) return null;
|
||||||
ImageView iconView = new ImageView();
|
ImageView icon = new ImageView();
|
||||||
iconView.setFitWidth(size);
|
icon.setFitWidth(size);
|
||||||
iconView.setPreserveRatio(true);
|
icon.setPreserveRatio(true);
|
||||||
iconView.setSmooth(true);
|
icon.setSmooth(true);
|
||||||
iconView.setCache(true);
|
icon.setCache(true);
|
||||||
iconView.setId(imageId);
|
icon.setId(imageId);
|
||||||
return iconView;
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static StackPane getCurrencyIcon(String currencyCode) {
|
||||||
|
ImageView icon = getCurrencyImageView(currencyCode);
|
||||||
|
return icon == null ? null : new StackPane(icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static StackPane getCurrencyIcon(String currencyCode, double size) {
|
||||||
|
ImageView icon = getCurrencyImageView(currencyCode, size);
|
||||||
|
return icon == null ? null : new StackPane(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StackPane getCurrencyIconWithBorder(String currencyCode) {
|
public static StackPane getCurrencyIconWithBorder(String currencyCode) {
|
||||||
|
@ -1307,12 +1314,9 @@ public class GUIUtil {
|
||||||
public static StackPane getCurrencyIconWithBorder(String currencyCode, double size, double borderWidth) {
|
public static StackPane getCurrencyIconWithBorder(String currencyCode, double size, double borderWidth) {
|
||||||
if (currencyCode == null) return null;
|
if (currencyCode == null) return null;
|
||||||
|
|
||||||
ImageView icon = getCurrencyIcon(currencyCode, size);
|
ImageView icon = getCurrencyImageView(currencyCode, size);
|
||||||
icon.setFitWidth(size - 2 * borderWidth);
|
icon.setFitWidth(size - 2 * borderWidth);
|
||||||
icon.setFitHeight(size - 2 * borderWidth);
|
icon.setFitHeight(size - 2 * borderWidth);
|
||||||
icon.setPreserveRatio(true);
|
|
||||||
icon.setSmooth(true);
|
|
||||||
icon.setCache(true);
|
|
||||||
|
|
||||||
StackPane circleWrapper = new StackPane(icon);
|
StackPane circleWrapper = new StackPane(icon);
|
||||||
circleWrapper.setPrefSize(size, size);
|
circleWrapper.setPrefSize(size, size);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue