dlsc-software-consulting-gmbh / FormsFX

A framework for easily creating forms for a JavaFX UI.
Apache License 2.0
642 stars 94 forks source link

Configurable spacing/padding in multiple column layout #36

Open aalmiray opened 6 years ago

aalmiray commented 6 years ago

When a multiple column layout is used (by setting span() on Fields) the labels are placed too close to the previous value. This behavior is accentuated when short labels are used. The following screenshots show this behavior with a 2 and a 4 column layout.

formfx-spacing formsfx-spacing2

The code used for these examples is

import com.dlsc.formsfx.model.structure.Field;
import com.dlsc.formsfx.model.structure.Form;
import com.dlsc.formsfx.model.structure.Group;
import com.dlsc.formsfx.view.renderer.FormRenderer;
import com.dlsc.formsfx.view.util.ColSpan;
import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class Sample extends Application {
   @Override
   public void start(Stage stage) throws Exception {
      StringProperty p1 = new SimpleStringProperty("p1");
      StringProperty p2 = new SimpleStringProperty("p2");
      StringProperty p3 = new SimpleStringProperty("p3");
      StringProperty p4 = new SimpleStringProperty("p4");

      Form form = Form.of(
            Group.of(
                  Field.ofStringType(p1)
                        .label("P1")
                        .required(true).span(ColSpan.QUARTER),
                  Field.ofStringType(p2)
                        .label("P2")
                        .required(true).span(ColSpan.QUARTER),
                  Field.ofStringType(p3)
                        .label("P3")
                        .required(true).span(ColSpan.QUARTER),
                  Field.ofStringType(p4)
                        .label("P4")
                        .required(true).span(ColSpan.QUARTER)
            )
      );
      stage.setScene(new Scene(new FormRenderer(form)));
      stage.sizeToScene();
      stage.show();
   }
}

It would be great to have an option to specify padding/spacing without having to override the default renderers nor providing a custom renderer.

MarekKristof commented 6 years ago

Hello, can i take it ?