Skip to content

Commit

Permalink
Fixes #432. Distance between groups is now implemented through top ma…
Browse files Browse the repository at this point in the history
…rgins, not bottom margins of previous groups. As a result, distances are also correct when elements or groups are hidden.
  • Loading branch information
reikjarloekl committed Aug 26, 2022
1 parent bbeb2e4 commit 7862c50
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ public void layoutParts() {
grid.add(titleLabel, 0, nextRow++, 2, 1);
styleClass.append("-title");
titleLabel.getStyleClass().add("group-title");
// Set margin for all but first group titles to visually separate groups
if (nextRow > 1) {
GridPane.setMargin(titleLabel, new Insets(SPACING * 4, 0, 0, 0));
}
}

List<Element> elements = preferencesGroup.getElements().stream()
Expand All @@ -90,8 +94,8 @@ public void layoutParts() {
// add to GridPane
Element element = elements.get(i);
if (element instanceof Field) {
SimpleControl c = (SimpleControl) ((Field)element).getRenderer();
c.setField((Field)element);
SimpleControl c = (SimpleControl) ((Field) element).getRenderer();
c.setField((Field) element);
grid.add(c.getFieldLabel(), 0, i + rowAmount, 1, 1);
grid.add(c.getNode(), 1, i + rowAmount, 1, 1);

Expand All @@ -100,13 +104,14 @@ public void layoutParts() {
GridPane.setValignment(c.getNode(), VPos.CENTER);
GridPane.setValignment(c.getFieldLabel(), VPos.CENTER);

Insets margin;
Insets margin = new Insets(SPACING * 2, 0, 0, 0);
if (i == elements.size() - 1) {
// additional styling for the last setting
styleClass.append("-last");
margin = new Insets(SPACING * 2, 0, SPACING * 4, 0);
} else {
margin = new Insets(SPACING * 2, 0, 0, 0);
}
if ((preferencesGroup.getTitle() == null) && (i == 0) && (nextRow > 0)) {
// when there is no group title and this is the first element, add margin to top
margin = new Insets(SPACING * 6, 0, 0, 0);
}

GridPane.setMargin(c.getNode(), margin);
Expand Down

0 comments on commit 7862c50

Please sign in to comment.