-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Implement "manual" update mechanism for all VFXContainers
📝 Addressed some TODOs 📝 Add some more TODOs (:sigh: will this ever end) Signed-off-by: palexdev <[email protected]>
- Loading branch information
Showing
17 changed files
with
523 additions
and
132 deletions.
There are no files selected for viewing
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
45 changes: 45 additions & 0 deletions
45
src/main/java/io/github/palexdev/virtualizedfx/events/VFXContainerEvent.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,45 @@ | ||
package io.github.palexdev.virtualizedfx.events; | ||
|
||
import io.github.palexdev.virtualizedfx.base.VFXContainer; | ||
import io.github.palexdev.virtualizedfx.cells.Cell; | ||
import javafx.event.Event; | ||
import javafx.event.EventTarget; | ||
import javafx.event.EventType; | ||
import javafx.scene.Node; | ||
|
||
/** | ||
* Custom event implementation to be used with {@link VFXContainer}s. Event-based systems are very useful for loose coupling, | ||
* because it allows components to communicate with each other without needing to know the specifics of their implementations. | ||
* <p> | ||
* This mechanism should be used only when there are no other reasonable ways as the performance implications of this system | ||
* are not very clear. | ||
*/ | ||
public class VFXContainerEvent extends Event { | ||
//================================================================================ | ||
// Event Types | ||
//================================================================================ | ||
|
||
/** | ||
* This event type can be used to tell cells to forcefully update. Especially useful when the model's data does not | ||
* use JavaFX's properties. | ||
* | ||
* @see VFXContainer#update(int...) | ||
*/ | ||
public static final EventType<VFXContainerEvent> UPDATE = new EventType<>("UPDATE"); | ||
|
||
//================================================================================ | ||
// Constructors | ||
//================================================================================ | ||
public VFXContainerEvent(Object source, EventTarget target, EventType<? extends Event> eventType) { | ||
super(source, target, eventType); | ||
} | ||
|
||
//================================================================================ | ||
// Static Methods | ||
//================================================================================ | ||
public static <T> void update(Cell<T> cell) { | ||
if (cell == null) return; // Avoid null targets | ||
Node node = cell.toNode(); | ||
fireEvent(node, new VFXContainerEvent(null, node, UPDATE)); | ||
} | ||
} |
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
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
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
Oops, something went wrong.