Skip to content

Commit

Permalink
Merge pull request #433 from leanity/master-11
Browse files Browse the repository at this point in the history
Distance between groups now handled via top margins instead of bottom margins to fix #432
  • Loading branch information
dlemmermann committed Sep 9, 2022
2 parents 4de933f + 28ca8e5 commit 726fe92
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 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
Original file line number Diff line number Diff line change
Expand Up @@ -779,15 +779,20 @@ public Setting customKey(String key) {
* @param additionalVisibilityCondition define the visibility condition to be added (ANDed) to the current (if any)
*/
public Setting applyVisibility(VisibilityProperty visibilityProperty, boolean additionalVisibilityCondition) {
SimpleControl renderer = (SimpleControl) ((Field) getElement()).getRenderer();
if (element instanceof Field) {
SimpleControl renderer = (SimpleControl) ((Field) getElement()).getRenderer();

if (additionalVisibilityCondition) {
VisibilityProperty existingVP = renderer.getVisibilityProperty();
if (existingVP != null) {
visibilityProperty = VisibilityProperty.of(existingVP.get().and(visibilityProperty.get()));
if (additionalVisibilityCondition) {
VisibilityProperty existingVP = renderer.getVisibilityProperty();
if (existingVP != null) {
visibilityProperty = VisibilityProperty.of(existingVP.get().and(visibilityProperty.get()));
}
}
renderer.setVisibilityProperty(visibilityProperty);
}
if (element instanceof NodeElement) {
((NodeElement) element).getNode().visibleProperty().bind(visibilityProperty.get());
}
renderer.setVisibilityProperty(visibilityProperty);
return this;
}

Expand Down

0 comments on commit 726fe92

Please sign in to comment.