Skip to content

Commit

Permalink
Fixed issue when both Group and Setting have visibility defined. Grou…
Browse files Browse the repository at this point in the history
…p visibility used to overwrite setting visibility. Also prevent CategoryController from getting bigger and bigger when switching combobox content and PreferencesFxView is displayed as a node.
  • Loading branch information
reikjarloekl committed Aug 20, 2022
1 parent 0566950 commit 7d26674
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ private void init() {
breadCrumbPresenter = new BreadCrumbPresenter(preferencesFxModel, breadCrumbView);

categoryController = new CategoryController();
categoryController.setFitToWidth(true);
initializeCategoryViews();

// display initial category
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public void setVisibilityProperty(VisibilityProperty visibilityProperty) {
private void applyVisibilityForSettings() {
if (settings != null) {
for (Setting setting : settings) {
setting.applyVisibility(visibilityProperty);
setting.applyVisibility(visibilityProperty, true);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -776,10 +776,23 @@ public Setting customKey(String key) {
* Apply {@link VisibilityProperty} to renderer ({@link SimpleControl}.
*
* @param visibilityProperty source visibility condition
* @param additionalVisibilityCondition define the visibility condition to be added (ANDed) to the current (if any)
*/
public void applyVisibility(VisibilityProperty visibilityProperty) {
public Setting applyVisibility(VisibilityProperty visibilityProperty, boolean additionalVisibilityCondition) {
SimpleControl renderer = (SimpleControl) ((Field) getElement()).getRenderer();

if (additionalVisibilityCondition) {
VisibilityProperty existingVP = renderer.getVisibilityProperty();
if (existingVP != null) {
visibilityProperty = VisibilityProperty.of(existingVP.get().and(visibilityProperty.get()));
}
}
renderer.setVisibilityProperty(visibilityProperty);
return this;
}

public Setting applyVisibility(VisibilityProperty visibilityProperty) {
return applyVisibility(visibilityProperty, false);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.value.ObservableValue;

@FunctionalInterface
public interface VisibilityProperty {
Expand All @@ -21,7 +22,7 @@ public interface VisibilityProperty {
* @return
* @param <T>
*/
static <T> VisibilityProperty of(Property<T> property, Function<T, Boolean> visibilityFunc) {
static <T> VisibilityProperty of(ObservableValue<T> property, Function<T, Boolean> visibilityFunc) {
return () -> {
BooleanProperty visibilityProperty = new SimpleBooleanProperty(true);

Expand All @@ -43,7 +44,7 @@ static <T> VisibilityProperty of(Property<T> property, Function<T, Boolean> visi
* @return
* @param <T>
*/
static <T> VisibilityProperty of(Property<Boolean> property) {
static <T> VisibilityProperty of(ObservableValue<Boolean> property) {
return VisibilityProperty.of(property, (newValue) -> newValue);
}

Expand Down

0 comments on commit 7d26674

Please sign in to comment.