-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a new TabIndicator component to inform the user about changes (#1866
- Loading branch information
Showing
4 changed files
with
132 additions
and
1 deletion.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
...cis-javafx/src/main/java/org/phoenicis/javafx/components/common/control/TabIndicator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.phoenicis.javafx.components.common.control; | ||
|
||
import javafx.beans.property.SimpleStringProperty; | ||
import javafx.beans.property.StringProperty; | ||
import javafx.scene.control.Tab; | ||
import org.phoenicis.javafx.components.common.skin.TabIndicatorSkin; | ||
|
||
/** | ||
* An indicator symbol shown inside the header of a {@link Tab} object. | ||
* A {@link TabIndicator} can be used to inform the user about changes that occurred since the user visited the tab the | ||
* last time | ||
*/ | ||
public class TabIndicator extends ControlBase<TabIndicator, TabIndicatorSkin> { | ||
/** | ||
* The text shown inside the tab indicator | ||
*/ | ||
private final StringProperty text; | ||
|
||
/** | ||
* Constructor | ||
*/ | ||
public TabIndicator() { | ||
super(); | ||
|
||
this.text = new SimpleStringProperty(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public TabIndicatorSkin createSkin() { | ||
return new TabIndicatorSkin(this); | ||
} | ||
|
||
public String getText() { | ||
return this.text.get(); | ||
} | ||
|
||
public StringProperty textProperty() { | ||
return this.text; | ||
} | ||
|
||
public void setText(String text) { | ||
this.text.set(text); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...is-javafx/src/main/java/org/phoenicis/javafx/components/common/skin/TabIndicatorSkin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.phoenicis.javafx.components.common.skin; | ||
|
||
import javafx.scene.layout.Region; | ||
import javafx.scene.layout.StackPane; | ||
import javafx.scene.text.Text; | ||
import org.phoenicis.javafx.components.common.control.TabIndicator; | ||
|
||
/** | ||
* A skin implementation for the {@link TabIndicator} component | ||
*/ | ||
public class TabIndicatorSkin extends SkinBase<TabIndicator, TabIndicatorSkin> { | ||
/** | ||
* Constructor | ||
* | ||
* @param control The control belonging to the skin | ||
*/ | ||
public TabIndicatorSkin(TabIndicator control) { | ||
super(control); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public void initialise() { | ||
final Region circle = new Region(); | ||
circle.getStyleClass().add("indicator-circle"); | ||
|
||
final Text text = new Text(); | ||
text.getStyleClass().add("indicator-information"); | ||
text.textProperty().bind(getControl().textProperty()); | ||
|
||
final StackPane container = new StackPane(circle, text); | ||
container.getStyleClass().add("indicator-container"); | ||
|
||
final StackPane tabIndicator = new StackPane(container); | ||
tabIndicator.getStyleClass().add("tab-indicator"); | ||
|
||
getChildren().add(tabIndicator); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters