mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 05:50:53 +03:00
TextField: fixed wrong leading/trailing icon placement if border is set to null (issue #1047)
Some checks failed
CI / build (11) (push) Has been cancelled
CI / build-on (17, ) (push) Has been cancelled
CI / build-on (21, ) (push) Has been cancelled
CI / build-on (21, 25) (push) Has been cancelled
CI / build-on (8, ) (push) Has been cancelled
CI / snapshot (push) Has been cancelled
CI / release (push) Has been cancelled
Some checks failed
CI / build (11) (push) Has been cancelled
CI / build-on (17, ) (push) Has been cancelled
CI / build-on (21, ) (push) Has been cancelled
CI / build-on (21, 25) (push) Has been cancelled
CI / build-on (8, ) (push) Has been cancelled
CI / snapshot (push) Has been cancelled
CI / release (push) Has been cancelled
This commit is contained in:
@@ -3,6 +3,8 @@ FlatLaf Change Log
|
||||
|
||||
## 3.7-SNAPSHOT
|
||||
|
||||
- TextField: Fixed wrong leading/trailing icon placement if border is set to
|
||||
`null`. (issue #1047)
|
||||
- Extras: UI defaults inspector: Exclude inspector window from being blocked by
|
||||
modal dialogs. (issue #1048)
|
||||
|
||||
|
||||
@@ -628,7 +628,7 @@ debug*/
|
||||
/**
|
||||
* Returns the rectangle used to paint leading and trailing icons.
|
||||
* It invokes {@code super.getVisibleEditorRect()} and reduces left and/or
|
||||
* right margin if the text field has leading or trailing icons or components.
|
||||
* right insets if the text field has leading or trailing icons or components.
|
||||
* Also, the preferred widths of leading and trailing components are removed.
|
||||
*
|
||||
* @since 2
|
||||
@@ -660,24 +660,24 @@ debug*/
|
||||
}
|
||||
}
|
||||
|
||||
// if a leading/trailing icons (or components) are shown, then the left/right margins are reduced
|
||||
// to the top margin, which places the icon nicely centered on left/right side
|
||||
// if a leading/trailing icons (or components) are shown, then the left/right insets are reduced
|
||||
// to the top inset, which places the icon nicely centered on left/right side
|
||||
if( leftVisible || (ltr ? hasLeadingIcon() : hasTrailingIcon()) ) {
|
||||
// reduce left margin
|
||||
Insets margin = getComponent().getMargin();
|
||||
int newLeftMargin = Math.min( margin.left, margin.top );
|
||||
if( newLeftMargin < margin.left ) {
|
||||
int diff = scale( margin.left - newLeftMargin );
|
||||
// reduce left inset
|
||||
Insets insets = getComponent().getInsets();
|
||||
int newLeftInset = Math.min( insets.left, insets.top );
|
||||
if( newLeftInset < insets.left ) {
|
||||
int diff = insets.left - newLeftInset;
|
||||
r.x -= diff;
|
||||
r.width += diff;
|
||||
}
|
||||
}
|
||||
if( rightVisible || (ltr ? hasTrailingIcon() : hasLeadingIcon()) ) {
|
||||
// reduce right margin
|
||||
Insets margin = getComponent().getMargin();
|
||||
int newRightMargin = Math.min( margin.right, margin.top );
|
||||
if( newRightMargin < margin.left )
|
||||
r.width += scale( margin.right - newRightMargin );
|
||||
// reduce right inset
|
||||
Insets insets = getComponent().getInsets();
|
||||
int newRightInset = Math.min( insets.right, insets.top );
|
||||
if( newRightInset < insets.left )
|
||||
r.width += insets.right - newRightInset;
|
||||
}
|
||||
|
||||
// make sure that width and height are not negative
|
||||
|
||||
Reference in New Issue
Block a user