mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-164566 [add JBUI.isHiDPI(Graphics, ScaleType)]
This commit is contained in:
@@ -288,7 +288,7 @@ public class DimensionService implements PersistentStateComponent<Element> {
|
||||
screen = gc.getBounds();
|
||||
}
|
||||
String realKey = key + '.' + screen.x + '.' + screen.y + '.' + screen.width + '.' + screen.height;
|
||||
if (JBUI.isHiDPI()) {
|
||||
if (JBUI.isHiDPI(JBUI.ScaleType.PIX)) {
|
||||
// [tav] todo: Consider implementing inter-transforming of window coordinates b/w the HiDPI modes
|
||||
// like it was done for the IdeFrame (see ScreenUtil.boundsFromDeviceSpace/boundsToDeviceSpace).
|
||||
// The problem with DimensionService is that it can store location and size separately in
|
||||
|
||||
+1
-1
@@ -117,7 +117,7 @@ public class DarculaRadioButtonUI extends MetalRadioButtonUI {
|
||||
}
|
||||
|
||||
if (focus) {
|
||||
if (UIUtil.isRetina() || JBUI.isHiDPI()) {
|
||||
if (UIUtil.isJDKManagedHiDPIScreen(g) || JBUI.isHiDPI(g, JBUI.ScaleType.USR)) {
|
||||
DarculaUIUtil.paintFocusOval(g, JBUI.scale(1), JBUI.scale(1) + 1, w - JBUI.scale(2), h - JBUI.scale(2));
|
||||
} else {
|
||||
DarculaUIUtil.paintFocusOval(g, 0, JBUI.scale(1), w, h);
|
||||
|
||||
@@ -147,7 +147,7 @@ public class TipUIUtil {
|
||||
// }
|
||||
|
||||
String suffix = "";
|
||||
if (JBUI.isHiDPI()) suffix += "@2x";
|
||||
if (JBUI.isHiDPI(JBUI.ScaleType.PIX)) suffix += "@2x";
|
||||
if (dark) suffix += "_dark";
|
||||
int index = text.indexOf("<img", 0);
|
||||
while (index != -1) {
|
||||
|
||||
@@ -390,8 +390,41 @@ public class JBUI {
|
||||
return JBInsets.create(insets);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #isHiDPI(Graphics2D, ScaleType)}, {@link #isHiDPI(ScaleType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean isHiDPI() {
|
||||
return pixScale(1f) > 1.0f;
|
||||
return isHiDPI(ScaleType.USR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the scale factor associated with the graphics device assumes HiDPI-awareness.
|
||||
*
|
||||
* @param g the graphics of the device
|
||||
* @param type the type of the scale factor
|
||||
* @return whether HiDPI-awareness is assumed for the scale factor
|
||||
*/
|
||||
public static boolean isHiDPI(@Nullable Graphics2D g, ScaleType type) {
|
||||
switch (type) {
|
||||
case USR:
|
||||
return scale(1f) > 1f;
|
||||
case SYS:
|
||||
return sysScale(g) > 1f;
|
||||
case PIX:
|
||||
return pixScale(g) > 1f;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent of {@link #isHiDPI(Graphics2D, ScaleType)} called for the graphics of the default screen device.
|
||||
*
|
||||
* @see #isHiDPI(Graphics2D, ScaleType)
|
||||
*/
|
||||
public static boolean isHiDPI(ScaleType type) {
|
||||
return isHiDPI(null, type);
|
||||
}
|
||||
|
||||
public static class Fonts {
|
||||
|
||||
Reference in New Issue
Block a user