-
Notifications
You must be signed in to change notification settings - Fork 116
CSSTUDIO-3524 Fix equal spacing of widgets in Display Builder #3614
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -620,7 +620,7 @@ public void run(final DisplayEditor editor, final boolean selected) | |
| .mapToInt(w -> w.propHeight().getValue()) | ||
| .sum(); | ||
|
|
||
| final int offset = ( max - min - totalHeight ) / ( N - 1 ); | ||
| final double offset = ( (double) max - (double) min - (double) totalHeight ) / ( (double) N - 1.0 ); | ||
| final List<Widget> sortedWidgets = widgets.stream() | ||
| .sorted(( w1, w2 ) -> | ||
| { | ||
|
|
@@ -680,14 +680,14 @@ else if ( w1y >= w2y && w1y + w1h >= w2y + w2h ) | |
| // Equal gap distribution... | ||
| // ------------------------------------------------------------ | ||
| Widget widget = sortedWidgets.get(0); | ||
| int location = widget.propY().getValue(); | ||
| double location = widget.propY().getValue(); | ||
| int height = widget.propHeight().getValue(); | ||
|
|
||
| for ( int i = 1; i < N - 1; i++ ) | ||
| { | ||
| widget = sortedWidgets.get(i); | ||
| location += height + offset; | ||
| undo.execute(new SetWidgetPropertyAction<>(widget.propY(), location)); | ||
| undo.execute(new SetWidgetPropertyAction<>(widget.propY(), (int) Math.round(location))); | ||
| height = widget.propHeight().getValue(); | ||
| } | ||
| } | ||
|
|
@@ -703,19 +703,19 @@ else if ( offset < 0 ) | |
| int location = widget.propY().getValue(); | ||
| int height = widget.propHeight().getValue(); | ||
|
|
||
| final int bottomCenter = location + height / 2; | ||
| final double bottomCenter = (double) location + (double) height / 2.0; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cast to double should not be necessary.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not do
the intent is clear |
||
|
|
||
| widget = sortedWidgets.get(0); | ||
| location = widget.propY().getValue(); | ||
| height = widget.propHeight().getValue(); | ||
|
|
||
| final int topCenter = location + height / 2; | ||
| final int coffset = ( bottomCenter - topCenter ) / ( N - 1 ); | ||
| final double topCenter = (double) location + (double) height / 2.0; | ||
| final double coffset = ( bottomCenter - topCenter ) / ( (double) N - 1.0 ); | ||
|
||
| for ( int i = 1; i < N - 1; i++ ) | ||
| { | ||
| widget = sortedWidgets.get(i); | ||
| height = widget.propHeight().getValue(); | ||
| undo.execute(new SetWidgetPropertyAction<>(widget.propY(), ( topCenter + i * coffset ) - height / 2)); | ||
| undo.execute(new SetWidgetPropertyAction<>(widget.propY(), (int) Math.round(( topCenter + (double) i * coffset ) - (double) height / 2.0))); | ||
|
||
| } | ||
| } | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.