improve tabs and transaction diagram tooltips with long labels

This commit is contained in:
Craig Raw 2025-04-03 14:10:02 +02:00
parent a8f7ce9e34
commit 2fa8e5fd70
2 changed files with 19 additions and 4 deletions

View file

@ -78,6 +78,7 @@ public class AppController implements Initializable {
private static final Logger log = LoggerFactory.getLogger(AppController.class); private static final Logger log = LoggerFactory.getLogger(AppController.class);
public static final String DRAG_OVER_CLASS = "drag-over"; public static final String DRAG_OVER_CLASS = "drag-over";
public static final int TAB_LABEL_MAX_WIDTH = 300;
public static final double TAB_LABEL_GRAPHIC_OPACITY_INACTIVE = 0.8; public static final double TAB_LABEL_GRAPHIC_OPACITY_INACTIVE = 0.8;
public static final double TAB_LABEL_GRAPHIC_OPACITY_ACTIVE = 0.95; public static final double TAB_LABEL_GRAPHIC_OPACITY_ACTIVE = 0.95;
public static final String LOADING_TRANSACTIONS_MESSAGE = "Loading wallet, select Transactions tab to view..."; public static final String LOADING_TRANSACTIONS_MESSAGE = "Loading wallet, select Transactions tab to view...";
@ -1990,8 +1991,15 @@ public class AppController implements Initializable {
glyph.setFontSize(10.0); glyph.setFontSize(10.0);
glyph.setOpacity(TAB_LABEL_GRAPHIC_OPACITY_ACTIVE); glyph.setOpacity(TAB_LABEL_GRAPHIC_OPACITY_ACTIVE);
Label tabLabel = new Label(tabName); Label tabLabel = new Label(tabName);
tabLabel.setMaxWidth(TAB_LABEL_MAX_WIDTH);
tabLabel.setGraphic(glyph); tabLabel.setGraphic(glyph);
tabLabel.setGraphicTextGap(5.0); tabLabel.setGraphicTextGap(5.0);
tabLabel.textTruncatedProperty().addListener((_, _, newValue) -> {
if(newValue && name != null && !name.isEmpty()) {
Tooltip tooltip = new Tooltip(name);
tabLabel.setTooltip(tooltip);
}
});
tab.setGraphic(tabLabel); tab.setGraphic(tabLabel);
tab.setContextMenu(getTabContextMenu(tab)); tab.setContextMenu(getTabContextMenu(tab));
tab.setClosable(true); tab.setClosable(true);

View file

@ -40,10 +40,7 @@ import javafx.scene.paint.Color;
import javafx.scene.shape.Circle; import javafx.scene.shape.Circle;
import javafx.scene.shape.CubicCurve; import javafx.scene.shape.CubicCurve;
import javafx.scene.shape.Line; import javafx.scene.shape.Line;
import javafx.stage.FileChooser; import javafx.stage.*;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.util.Duration; import javafx.util.Duration;
import org.controlsfx.glyphfont.Glyph; import org.controlsfx.glyphfont.Glyph;
@ -491,6 +488,11 @@ public class TransactionDiagram extends GridPane {
} }
tooltip.setShowDelay(new Duration(TOOLTIP_SHOW_DELAY)); tooltip.setShowDelay(new Duration(TOOLTIP_SHOW_DELAY));
tooltip.setShowDuration(Duration.INDEFINITE); tooltip.setShowDuration(Duration.INDEFINITE);
tooltip.setWrapText(true);
Window activeWindow = AppServices.getActiveWindow();
if(activeWindow != null) {
tooltip.setMaxWidth(activeWindow.getWidth());
}
if(!tooltip.getText().isEmpty()) { if(!tooltip.getText().isEmpty()) {
label.setTooltip(tooltip); label.setTooltip(tooltip);
} }
@ -688,6 +690,11 @@ public class TransactionDiagram extends GridPane {
recipientTooltip.getStyleClass().add("recipient-label"); recipientTooltip.getStyleClass().add("recipient-label");
recipientTooltip.setShowDelay(new Duration(TOOLTIP_SHOW_DELAY)); recipientTooltip.setShowDelay(new Duration(TOOLTIP_SHOW_DELAY));
recipientTooltip.setShowDuration(Duration.INDEFINITE); recipientTooltip.setShowDuration(Duration.INDEFINITE);
recipientTooltip.setWrapText(true);
Window activeWindow = AppServices.getActiveWindow();
if(activeWindow != null) {
recipientTooltip.setMaxWidth(activeWindow.getWidth());
}
recipientLabel.setTooltip(recipientTooltip); recipientLabel.setTooltip(recipientTooltip);
HBox paymentBox = new HBox(); HBox paymentBox = new HBox();
paymentBox.setAlignment(Pos.CENTER_LEFT); paymentBox.setAlignment(Pos.CENTER_LEFT);