Issue #720 resolved

New items should be vertically aligned with same font

Dave Jarvis
created an issue

Consider the following examples.

Adding Plain Text

StatusBar sb = new StatusBar();
sb.getRightItems().add( new Text( "OK" ) );

Produces: statusbar-01.png

Adding Text in a VBox

StatusBar sb = new StatusBar();
VBox box = new VBox();
box.setAlignment( Pos.CENTER );
box.getChildren().add( new Text( "OK" ) );
sb.getRightItems().add( box );

Produces: statusbar-02.png

Baseline to Center

    final VBox box = new VBox();
    box.setAlignment( Pos.BASELINE_CENTER );
    box.getChildren().add( new Text( "OK" ) );
    sb.getRightItems().add( box );

Produces nearly the correct result: statusbar-03.png

The font weight is inconsistent.

Expected Behaviour

The developer should not have to modify CSS to get the expected default behaviour, which is that items added to the status bar will have the same alignment. Also, the first example above should produce the results from the last example to avoid violating the principle of least astonishment.

Alternative

Another way to resolve this issue is by documenting an example that shows how to add items on the status bar that are vertically aligned and in the same font.

Comments (9)

  1. Samir Hadzic

    Hi,

    I think the best solution is indeed to add in the StatusBarSkin a default alignement on Center. Then, the added text will be well aligned :

     leftBox = new HBox();
            leftBox.setAlignment(Pos.CENTER);
            leftBox.getStyleClass().add("left-items"); //$NON-NLS-1$
    
            rightBox = new HBox();
            rightBox.setAlignment(Pos.CENTER);
            rightBox.getStyleClass().add("right-items"); //$NON-NLS-1$
    

    Regarding the Font issue, well if you use a standard Label, it will be the same. Actually, the Text object is a bit special. So I don't think we can do anything, it's up to you to modify the font of your Text object.

    Are you willing to provide a pull request or should I?

  2. Log in to comment