mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-13 15:52:01 +07:00
IJPL-161797 Introduce computeTextComponentMinimumSize overload
nCharactersToKeep is almost always 4. Even in DefaultCutStrategy it's effectively so, but since it's computed there from its own constant, let's just leave it explicit there. GitOrigin-RevId: f8b009aed84238e2dd9531311dbc2a15b8cd629e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
2aa9576a72
commit
60527dd48d
@@ -501,7 +501,7 @@ open class RedesignedRunConfigurationSelector : TogglePopupAction(), CustomCompo
|
||||
}
|
||||
|
||||
override fun getMinimumSize(): Dimension = preferredSize.apply {
|
||||
width = UIUtil.computeTextComponentMinimumSize(width, text, font?.let { getFontMetrics(it) }, 4)
|
||||
width = UIUtil.computeTextComponentMinimumSize(width, text, font?.let { getFontMetrics(it) })
|
||||
}
|
||||
}.also {
|
||||
it.foreground = JBUI.CurrentTheme.RunWidget.FOREGROUND
|
||||
|
||||
@@ -5055,6 +5055,7 @@ f:com.intellij.util.ui.UIUtil
|
||||
- s:canDisplayFocusedState(java.awt.Component):Z
|
||||
- s:changeBackGround(java.awt.Component,java.awt.Color):V
|
||||
- s:colorToHex(java.awt.Color):java.lang.String
|
||||
- s:computeTextComponentMinimumSize(I,java.lang.String,java.awt.FontMetrics):I
|
||||
- s:computeTextComponentMinimumSize(I,java.lang.String,java.awt.FontMetrics,I):I
|
||||
- s:configureNumericFormattedTextField(javax.swing.JFormattedTextField):V
|
||||
- s:convertToLabel(javax.swing.JEditorPane):V
|
||||
|
||||
@@ -560,6 +560,24 @@ public final class UIUtil {
|
||||
return ArrayUtilRt.toStringArray(lines);
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the minimum size the component must have to keep the given number of characters
|
||||
*
|
||||
* Same as {@code computeTextComponentMinimumSize(preferredSize, text, fontMetrics, 4)}.
|
||||
*
|
||||
* @param preferredSize the size of the component needed to keep everything, usually computed by {@link Component#getPreferredSize()}
|
||||
* @param text the currently set text
|
||||
* @param fontMetrics the current font metrics
|
||||
* @return the minimum size the component has to have to keep the given number of characters
|
||||
*/
|
||||
public static int computeTextComponentMinimumSize(
|
||||
int preferredSize,
|
||||
@Nullable String text,
|
||||
@Nullable FontMetrics fontMetrics
|
||||
) {
|
||||
return computeTextComponentMinimumSize(preferredSize, text, fontMetrics, 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the minimum size the component must have to keep the given number of characters
|
||||
* <p>
|
||||
|
||||
@@ -59,7 +59,7 @@ public class SwitchTaskAction extends ComboBoxAction implements DumbAware {
|
||||
var result = super.getMinimumSize();
|
||||
var font = getFont();
|
||||
if (font == null) return result;
|
||||
result.width = UIUtil.computeTextComponentMinimumSize(result.width, getText(), getFontMetrics(font), 4);
|
||||
result.width = UIUtil.computeTextComponentMinimumSize(result.width, getText(), getFontMetrics(font));
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user