-
Notifications
You must be signed in to change notification settings - Fork 39
Feature/finished/jpro 105 adjust default window height to content #369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
carldea
merged 12 commits into
ikmdev:main
from
Sandec:feature/finished/jpro-105-adjust-default-window-height-to-content
Apr 14, 2025
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
edd2783
Update version to start feature: jpro-105-adjust-default-window-heigh…
indritbeqiri 57962cb
Rework concept window layout to properly compute height while adherin…
indritbeqiri 174c578
Remove preferred heights from LIDR and Pattern windows to enable heig…
indritbeqiri ff3065d
Remove default height setting when adding new windows to the workspac…
indritbeqiri fd3cc3f
Fix typo in default concept window width value
indritbeqiri ed49b86
Update version to finish feature: jpro-105-adjust-default-window-heig…
indritbeqiri 9206147
Remove background color of the split pane in the axiom section
indritbeqiri 80aa854
Fix typo in background color name
indritbeqiri dbea3ee
Merge branch 'main' into feature/finished/jpro-105-adjust-default-win…
indritbeqiri d7582f2
Merge branch 'main' into feature/finished/jpro-105-adjust-default-win…
indritbeqiri 79b5239
Merge branch 'main' into feature/finished/jpro-105-adjust-default-win…
indritbeqiri 8d1673f
Merge branch 'main' into feature/finished/jpro-105-adjust-default-win…
indritbeqiri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
100 changes: 100 additions & 0 deletions
100
kview/src/main/java/dev/ikm/komet/kview/controls/ResponsiveTextFlow.java
This file contains hidden or 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,100 @@ | ||
| package dev.ikm.komet.kview.controls; | ||
|
|
||
| import javafx.application.Platform; | ||
| import javafx.geometry.Insets; | ||
| import javafx.scene.Parent; | ||
| import javafx.scene.layout.Region; | ||
| import javafx.scene.text.TextFlow; | ||
|
|
||
| /** | ||
| * A responsive extension of JavaFX's TextFlow component that properly handles | ||
| * text wrapping and layout recalculation based on parent container dimensions. | ||
| * <p> | ||
| * This component improves upon the standard TextFlow by: | ||
| * <ul> | ||
| * <li>Calculating preferred height based on parent width for proper text wrapping</li> | ||
| * <li>Deferring layout requests to the next JavaFX pulse cycle</li> | ||
| * <li>Ensuring text properly wraps and reflows when container dimensions change</li> | ||
| * </ul> | ||
| * <p> | ||
| * Use this component when you need text that automatically adjusts to its container | ||
| * while maintaining proper text wrapping behavior. | ||
| * | ||
| * @see TextFlow | ||
| * @see Region | ||
| */ | ||
| public class ResponsiveTextFlow extends TextFlow { | ||
|
|
||
| /** | ||
| * Constructs a new responsive text flow component with deferred layout behavior. | ||
| */ | ||
| public ResponsiveTextFlow() { | ||
| super(); | ||
| } | ||
|
|
||
| /** | ||
| * Requests a layout pass on this component with deferred scheduling. | ||
| * <p> | ||
| * This implementation improves upon the standard TextFlow layout behavior by | ||
| * deferring layout requests to the next pulse via Platform.runLater(). | ||
| * <p> | ||
| * The deferred processing allows text wrapping calculations to complete before | ||
| * final layout positioning occurs, ensuring that the component's size properly | ||
| * accounts for text that needs to wrap based on the parent container's dimensions. | ||
| */ | ||
| @Override | ||
| public void requestLayout() { | ||
| Platform.runLater(super::requestLayout); | ||
| } | ||
|
|
||
| /** | ||
| * Computes the preferred height of this text flow component based on the | ||
| * given width. | ||
| * <p> | ||
| * This implementation uses the parent container's width (accounting for insets) | ||
| * rather than the provided width parameter, which allows for accurate text wrapping | ||
| * and height calculations even before the component is fully laid out. | ||
| * | ||
| * @param width The width available for layout (not used directly in this implementation) | ||
| * @return The preferred height for this component based on parent width | ||
| */ | ||
| @Override | ||
| protected double computePrefHeight(double width) { | ||
| return super.computePrefHeight(getParentWidth()); | ||
| } | ||
|
|
||
| /** | ||
| * Determines the effective width of the parent container, accounting for | ||
| * insets when applicable. | ||
| * <p> | ||
| * This method handles different parent types: | ||
| * <ul> | ||
| * <li>For Region parents, uses width minus insets</li> | ||
| * <li>For other parent types, uses the layout bounds width</li> | ||
| * </ul> | ||
| * <p> | ||
| * If no parent exists or the parent width is not positive, returns | ||
| * {@link Region#USE_COMPUTED_SIZE} to indicate that a computed size should be used. | ||
| * | ||
| * @return The effective width of the parent container, or {@link Region#USE_COMPUTED_SIZE} | ||
| * if the parent width cannot be determined | ||
| */ | ||
| private double getParentWidth() { | ||
| final Parent parent = getParent(); | ||
| double parentWidth; | ||
| if (parent != null) { | ||
| if (parent instanceof Region region) { | ||
| parentWidth = region.getWidth(); | ||
| Insets insets = region.getInsets(); | ||
| if (insets != null) { | ||
| parentWidth -= insets.getLeft() + insets.getRight(); | ||
| } | ||
| } else { | ||
| parentWidth = parent.getLayoutBounds().getWidth(); | ||
| } | ||
|
|
||
| return parentWidth > 0 ? parentWidth : Region.USE_COMPUTED_SIZE; | ||
| } | ||
| return Region.USE_COMPUTED_SIZE; | ||
| } | ||
| } | ||
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.