Skip to content

Commit

Permalink
🔖 Version 11.15.0
Browse files Browse the repository at this point in the history
Beans Package
:recycle: SizeBean: override toString() method

Controls Package
:boom: Implement an API for controls that can be styled (almost all MFX controls). This API also allows SceneBuilder support for the new styling system introduced by version 11.14.0

Utils Package
:sparkles: Improved When, OnChanged and OnInvalidated constructs by importing them from the latest version of MFXCore
:sparkles: Added utility to detect SceneBuilder at runtime

Signed-off-by: palexdev <[email protected]>
  • Loading branch information
palexdev committed Mar 17, 2023
1 parent 3c71c2f commit b590762
Show file tree
Hide file tree
Showing 54 changed files with 1,212 additions and 96 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

[//]: ##[Unreleased]

## [11.15.0] - 17-03-2023

## Changed

- SizeBean: override toString() methods
- Improved When, OnChanged and OnInvalidated constructs by importing them from the latest version of MFXCore

## Added

- Implemented API for MaterialFX styleable controls and SceneBuilder support
- Added utility to detect SceneBuilder at runtime

## [11.14.0] - 16-03-2023

## Changed
Expand Down
27 changes: 17 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,6 @@ To run the main demo, execute the following command:

**NOTE**: MaterialFX requires **Java 11** and above.

**NOTE**: Starting from version 11.14.0 (next major version), MaterialFX will transition to
Java 17 and bump version to 17.x.x. What will happen to version 11 is still to be decided

### Usage

###### Gradle
Expand All @@ -226,7 +223,7 @@ repositories {
}
dependencies {
implementation 'io.github.palexdev:materialfx:11.14.0'
implementation 'io.github.palexdev:materialfx:11.15.0'
}
```

Expand All @@ -237,7 +234,7 @@ dependencies {
<dependency>
<groupId>io.github.palexdev</groupId>
<artifactId>materialfx</artifactId>
<version>11.14.0</version>
<version>11.15.0</version>
</dependency>
```

Expand Down Expand Up @@ -330,7 +327,7 @@ There are two implementations of this interface:
`MFXThemeManager` is a utility class that will help the user add/set themes and stylesheets (which implement `Theme`) on
nodes or scenes.

**Pros and Cons**
**Pros**

- The biggest pro is to have a more reliable styling system. With this users shouldn't hava any issue anymore while
styling
Expand All @@ -341,6 +338,7 @@ nodes or scenes.
- This change should have also impacted on memory usage in a good way as now controls do not store the "url" to their
stylesheet anymore

**Cons**

- One con is that now themes must be managed by the user. Since controls are not styled by default, the user must
use the aforementioned manager or enumerators to load/add the themes on the App.
Expand All @@ -361,10 +359,19 @@ nodes or scenes.
**You have to add the Themes on every separate scene**.
To simplify things, MaterialFX automatically applies the Themes on its dialogs and popups, but since now they
are added to the `getStylesheets()` list it's easy to remove them and define your own
- The last con I can think of is SceneBuilder. As of now there is no support for it, I have some ideas on how to style
controls inside of it though. The issue is that even if I figure out a way, I doubt the system will be flexible.
What I mean is, I can probably set the default themes on the SceneBuilder' scene, but it's very unlikely there will
be a way to choose which themes/stylesheets will be applied
- ~~The last con I can think of is SceneBuilder. As of now there is no support for it, I have some ideas on how to style
controls inside of it though. The issue is that even if I figure out a way,~~ I doubt the system will be flexible
enough.
~~What I mean is, I can probably set the default themes on the SceneBuilder' scene,~~ but it's very unlikely there
will
be a way to choose which themes/stylesheets will be applied.
Since version 11.15.0, MaterialFX controls are capable of detecting if they are being used in SceneBuilder and can
automatically
style themselves. From my little testings, it seems that this doesn't break the styling system in any way, I was able
to style a button
by adding a custom stylesheet on itself or on its parent. There's also an emergency system to completely shut down the
SceneBuilder integration, more info
here: [Themable](https://github.com/palexdev/MaterialFX/blob/main/materialfx/src/main/java/io/github/palexdev/materialfx/controls/base/Themable.java)

<!-- CONTRIBUTING -->

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#--------------------------------------#
jdk=11
testJdk=17
materialfx=11.14.0
materialfx=11.15.0

# Plugins
jfxPlugin=0.0.13
Expand Down
2 changes: 1 addition & 1 deletion materialfx/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GROUP=io.github.palexdev
POM_ARTIFACT_ID=materialfx
VERSION_NAME=11.14.0
VERSION_NAME=11.15.0

POM_NAME=materialfx
POM_DESCRIPTION=Material Desgin components for JavaFX
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,16 @@ public DoubleProperty heightProperty() {
public void setHeight(double height) {
this.height.set(height);
}

//================================================================================
// Overridden Methods
//================================================================================

@Override
public String toString() {
return "SizeBean{" +
"width=" + width +
", height=" + height +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
package io.github.palexdev.materialfx.controls;

import io.github.palexdev.materialfx.beans.PositionBean;
import io.github.palexdev.materialfx.controls.base.Themable;
import io.github.palexdev.materialfx.css.themes.Stylesheets;
import io.github.palexdev.materialfx.css.themes.Theme;
import io.github.palexdev.materialfx.effects.DepthLevel;
import io.github.palexdev.materialfx.effects.ripple.MFXCircleRippleGenerator;
import io.github.palexdev.materialfx.enums.ButtonType;
Expand All @@ -28,6 +31,7 @@
import javafx.css.*;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.control.Button;
import javafx.scene.control.Skin;
import javafx.scene.paint.Color;
Expand All @@ -41,7 +45,7 @@
* Extends {@code Button}, redefines the style class to "mfx-button" for usage in CSS and
* includes a {@code RippleGenerator} to generate ripple effects on click.
*/
public class MFXButton extends Button {
public class MFXButton extends Button implements Themable {
//================================================================================
// Properties
//================================================================================
Expand Down Expand Up @@ -80,6 +84,7 @@ private void initialize() {
getStyleClass().add(STYLE_CLASS);
setAlignment(Pos.CENTER);
setupRippleGenerator();
sceneBuilderIntegration();
}

public MFXCircleRippleGenerator getRippleGenerator() {
Expand Down Expand Up @@ -344,6 +349,25 @@ private static class StyleableProperties {
//================================================================================
// Override Methods
//================================================================================
@Override
public Parent toParent() {
return this;
}

@Override
public Theme getTheme() {
return Stylesheets.BUTTON;
}

@Override
public boolean sceneBuilderIntegration() {
if (Themable.super.sceneBuilderIntegration()) {
setText("Button");
return true;
}
return false;
}

@Override
protected Skin<?> createDefaultSkin() {
return new MFXButtonSkin(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import io.github.palexdev.materialfx.controls.base.AbstractMFXListView;
import io.github.palexdev.materialfx.controls.cell.MFXCheckListCell;
import io.github.palexdev.materialfx.css.themes.Stylesheets;
import io.github.palexdev.materialfx.css.themes.Theme;
import io.github.palexdev.materialfx.skins.MFXListViewSkin;
import io.github.palexdev.materialfx.utils.ListChangeProcessor;
import io.github.palexdev.virtualizedfx.beans.NumberRange;
Expand Down Expand Up @@ -213,6 +215,10 @@ public SimpleVirtualFlow<T, MFXCheckListCell<T>>.Features features() {
//================================================================================
// Override Methods
//================================================================================
@Override
public Theme getTheme() {
return Stylesheets.CHECK_LIST_VIEW;
}

/**
* Sets the default factory for the cells.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import io.github.palexdev.materialfx.controls.base.AbstractMFXTreeCell;
import io.github.palexdev.materialfx.controls.base.AbstractMFXTreeItem;
import io.github.palexdev.materialfx.controls.cell.MFXCheckTreeCell;
import io.github.palexdev.materialfx.css.themes.Stylesheets;
import io.github.palexdev.materialfx.css.themes.Theme;
import io.github.palexdev.materialfx.selection.TreeCheckModel;
import io.github.palexdev.materialfx.selection.base.ITreeCheckModel;
import io.github.palexdev.materialfx.skins.MFXCheckTreeItemSkin;
Expand Down Expand Up @@ -113,6 +115,11 @@ public void setIndeterminate(boolean indeterminate) {
// Override Methods
//================================================================================

@Override
public Theme getTheme() {
return Stylesheets.TREE_ITEM;
}

/**
* Overridden to return the ITreeCheckModel instance of the MFXCheckTreeView.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@
package io.github.palexdev.materialfx.controls;

import io.github.palexdev.materialfx.controls.base.MFXLabeled;
import io.github.palexdev.materialfx.controls.base.Themable;
import io.github.palexdev.materialfx.css.themes.Stylesheets;
import io.github.palexdev.materialfx.css.themes.Theme;
import io.github.palexdev.materialfx.skins.MFXCheckboxSkin;
import io.github.palexdev.materialfx.utils.StyleablePropertiesUtils;
import javafx.css.*;
import javafx.scene.Parent;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ContentDisplay;
import javafx.scene.control.Skin;
Expand All @@ -39,7 +43,7 @@
* <p> - {@link #gapProperty()}: to control the gap between the checkbox and the text
* <p> - {@link #textExpandProperty()}: to control the text size and the checkbox layout (see documentation)
*/
public class MFXCheckbox extends CheckBox implements MFXLabeled {
public class MFXCheckbox extends CheckBox implements MFXLabeled, Themable {
//================================================================================
// Properties
//================================================================================
Expand All @@ -63,6 +67,7 @@ public MFXCheckbox(String text) {
//================================================================================
private void initialize() {
getStyleClass().add(STYLE_CLASS);
sceneBuilderIntegration();
}

//================================================================================
Expand Down Expand Up @@ -173,6 +178,24 @@ private static class StyleableProperties {
//================================================================================
// Override Methods
//================================================================================
@Override
public Parent toParent() {
return this;
}

@Override
public Theme getTheme() {
return Stylesheets.CHECKBOX;
}

@Override
public boolean sceneBuilderIntegration() {
if (Themable.super.sceneBuilderIntegration()) {
setText("Checkbox");
return true;
}
return false;
}

@Override
protected Skin<?> createDefaultSkin() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
package io.github.palexdev.materialfx.controls;

import io.github.palexdev.materialfx.controls.base.AbstractMFXToggleNode;
import io.github.palexdev.materialfx.css.themes.Stylesheets;
import io.github.palexdev.materialfx.css.themes.Theme;
import io.github.palexdev.materialfx.enums.TextPosition;
import io.github.palexdev.materialfx.skins.MFXCircleToggleNodeSkin;
import io.github.palexdev.materialfx.utils.StyleablePropertiesUtils;
Expand Down Expand Up @@ -185,6 +187,12 @@ private static class StyleableProperties {
//================================================================================
// Override Methods
//================================================================================

@Override
public Theme getTheme() {
return Stylesheets.CIRCLE_TOGGLE_NODE;
}

@Override
protected Skin<?> createDefaultSkin() {
return new MFXCircleToggleNodeSkin(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import io.github.palexdev.materialfx.beans.properties.styleable.StyleableIntegerProperty;
import io.github.palexdev.materialfx.controls.base.MFXCombo;
import io.github.palexdev.materialfx.controls.cell.MFXComboBoxCell;
import io.github.palexdev.materialfx.css.themes.Stylesheets;
import io.github.palexdev.materialfx.css.themes.Theme;
import io.github.palexdev.materialfx.font.MFXFontIcon;
import io.github.palexdev.materialfx.i18n.I18N;
import io.github.palexdev.materialfx.selection.ComboBoxSelectionModel;
Expand Down Expand Up @@ -279,6 +281,12 @@ protected void itemsChanged(ListChangeListener.Change<? extends T> change) {
//================================================================================
// Overridden Methods
//================================================================================

@Override
public Theme getTheme() {
return Stylesheets.COMBO_BOX;
}

@Override
protected Skin<?> createDefaultSkin() {
return new MFXComboBoxSkin<>(this, boundField);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@

import io.github.palexdev.materialfx.beans.properties.EventHandlerProperty;
import io.github.palexdev.materialfx.beans.properties.functional.SupplierProperty;
import io.github.palexdev.materialfx.controls.base.Themable;
import io.github.palexdev.materialfx.css.themes.Stylesheets;
import io.github.palexdev.materialfx.css.themes.Theme;
import io.github.palexdev.materialfx.skins.MFXContextMenuItemSkin;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.control.Labeled;
import javafx.scene.control.Skin;
import javafx.scene.control.Tooltip;
Expand All @@ -52,7 +56,7 @@
* <p></p>
* A {@link Builder} class is offered to easily build items with fluent api.
*/
public class MFXContextMenuItem extends Labeled {
public class MFXContextMenuItem extends Labeled implements Themable {
//================================================================================
// Properties
//================================================================================
Expand Down Expand Up @@ -93,6 +97,17 @@ private void initialize() {
//================================================================================
// Overridden Methods
//================================================================================

@Override
public Parent toParent() {
return this;
}

@Override
public Theme getTheme() {
return Stylesheets.CONTEXT_MENU_ITEM;
}

@Override
protected Skin<?> createDefaultSkin() {
return new MFXContextMenuItemSkin(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import io.github.palexdev.materialfx.beans.properties.functional.FunctionProperty;
import io.github.palexdev.materialfx.beans.properties.functional.SupplierProperty;
import io.github.palexdev.materialfx.controls.cell.MFXDateCell;
import io.github.palexdev.materialfx.css.themes.Stylesheets;
import io.github.palexdev.materialfx.css.themes.Theme;
import io.github.palexdev.materialfx.enums.FloatMode;
import io.github.palexdev.materialfx.font.MFXFontIcon;
import io.github.palexdev.materialfx.skins.MFXDatePickerSkin;
Expand Down Expand Up @@ -281,6 +283,12 @@ public void stopCurrentDayUpdater() {
//================================================================================
// Overridden Methods
//================================================================================

@Override
public Theme getTheme() {
return Stylesheets.DATE_PICKER;
}

@Override
protected Skin<?> createDefaultSkin() {
return new MFXDatePickerSkin(this, boundField);
Expand Down
Loading

0 comments on commit b590762

Please sign in to comment.