mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
Deprecate JBUI.scale(icon)
Replaced with JBUIScale.scaleIcon(icon) GitOrigin-RevId: a1b6e3bca3d331d34d6d474310ca2723fbeee0d3
This commit is contained in:
committed by
intellij-monorepo-bot
parent
22a4c90043
commit
cdd2426b79
@@ -19,13 +19,12 @@ import java.awt.geom.RoundRectangle2D;
|
||||
import java.beans.PropertyChangeListener;
|
||||
|
||||
import static com.intellij.ide.ui.laf.darcula.DarculaUIUtil.isMultiLineHTML;
|
||||
import static com.intellij.util.ui.JBUI.scale;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class DarculaCheckBoxUI extends MetalCheckBoxUI {
|
||||
private static final Icon DEFAULT_ICON = scale(EmptyIcon.create(18)).asUIResource();
|
||||
private static final Icon DEFAULT_ICON = JBUIScale.scaleIcon(EmptyIcon.create(18)).asUIResource();
|
||||
|
||||
private final PropertyChangeListener textChangedListener = e -> updateTextPosition((AbstractButton)e.getSource());
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.intellij.util.LazyInitializer.MutableNotNullValue;
|
||||
import com.intellij.util.LazyInitializer.NullableValue;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import com.intellij.util.ui.DetectRetinaKit;
|
||||
import com.intellij.util.ui.JBScalableIcon;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -294,6 +295,17 @@ public final class JBUIScale {
|
||||
return Math.round(userScaleFactor.get() * i);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scales the passed {@code icon} according to the user scale factor.
|
||||
*
|
||||
* @see ScaleType#USR_SCALE
|
||||
*/
|
||||
@NotNull
|
||||
public static <T extends JBScalableIcon> T scaleIcon(@NotNull T icon) {
|
||||
//noinspection unchecked
|
||||
return (T)icon.withIconPreScaled(false);
|
||||
}
|
||||
|
||||
public static int scaleFontSize(float fontSize) {
|
||||
if (userScaleFactor.get() == 1.25f) return (int)(fontSize * 1.34f);
|
||||
if (userScaleFactor.get() == 1.75f) return (int)(fontSize * 1.67f);
|
||||
|
||||
@@ -43,7 +43,7 @@ import static com.intellij.ui.scale.DerivedScaleType.PIX_SCALE;
|
||||
/**
|
||||
* Creates an icon of the provided size.
|
||||
*
|
||||
* Use {@link JBUI#scale(JBScalableIcon)} to meet HiDPI.
|
||||
* Use {@link JBUIScale#scaleIcon(JBScalableIcon)} (JBScalableIcon)} to meet HiDPI.
|
||||
*/
|
||||
@NotNull
|
||||
public static EmptyIcon create(int size) {
|
||||
@@ -53,7 +53,7 @@ import static com.intellij.ui.scale.DerivedScaleType.PIX_SCALE;
|
||||
/**
|
||||
* Creates an icon of the provided size.
|
||||
*
|
||||
* Use {@link JBUI#scale(JBScalableIcon)} to meet HiDPI.
|
||||
* Use {@link JBUIScale#scaleIcon(JBScalableIcon)} (JBScalableIcon)} to meet HiDPI.
|
||||
*/
|
||||
@NotNull
|
||||
public static EmptyIcon create(int width, int height) {
|
||||
|
||||
@@ -64,7 +64,7 @@ public abstract class JBScalableIcon extends UserScaleContextSupport implements
|
||||
*
|
||||
* @param preScaled whether the icon is pre-scaled
|
||||
* @return the icon in the provided pre-scaled state
|
||||
* @see JBUI#scale(JBScalableIcon)
|
||||
* @see JBUIScale#scaleIcon(JBScalableIcon) (JBScalableIcon)
|
||||
*/
|
||||
@NotNull
|
||||
public JBScalableIcon withIconPreScaled(boolean preScaled) {
|
||||
|
||||
@@ -186,16 +186,21 @@ public class JBUI {
|
||||
return new JBInsets(0, 0, 0, r);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link JBUIScale#scaleIcon(JBScalableIcon)}.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval
|
||||
@NotNull
|
||||
public static <T extends JBScalableIcon> T scale(@NotNull T icon) {
|
||||
//noinspection unchecked
|
||||
return (T)icon.withIconPreScaled(false);
|
||||
return JBUIScale.scaleIcon(icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #scale(JBScalableIcon)}.
|
||||
* @deprecated Use {@link JBUIScale#scaleIcon(JBScalableIcon)}.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval
|
||||
@NotNull
|
||||
public static <T extends JBIcon> T scale(@NotNull T icon) {
|
||||
//noinspection unchecked
|
||||
|
||||
@@ -18,7 +18,7 @@ import java.awt.geom.RoundRectangle2D;
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class MacIntelliJCheckBoxUI extends DarculaCheckBoxUI {
|
||||
public static final Icon DEFAULT_ICON = JBUI.scale(EmptyIcon.create(22));
|
||||
public static final Icon DEFAULT_ICON = JBUIScale.scaleIcon(EmptyIcon.create(22));
|
||||
|
||||
public MacIntelliJCheckBoxUI(JCheckBox c) {
|
||||
c.setOpaque(false);
|
||||
|
||||
@@ -16,7 +16,7 @@ import java.awt.geom.Rectangle2D;
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class WinIntelliJCheckBoxUI extends DarculaCheckBoxUI {
|
||||
private static final Icon DEFAULT_ICON = JBUI.scale(EmptyIcon.create(13)).asUIResource();
|
||||
private static final Icon DEFAULT_ICON = JBUIScale.scaleIcon(EmptyIcon.create(13)).asUIResource();
|
||||
|
||||
@SuppressWarnings({"MethodOverridesStaticMethodOfSuperclass", "UnusedDeclaration"})
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
|
||||
Reference in New Issue
Block a user