mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
move combineIconTooltips to file level and make internal
GitOrigin-RevId: 3e3a2028fd1f0ed13bca9290e5065a201859510e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
4ffd77ac44
commit
d6a4423730
@@ -105,27 +105,6 @@ open class LayeredIcon : JBCachingScalableIcon<LayeredIcon>, DarkIconProvider, C
|
||||
layeredIcon.setIcon(foregroundIcon, 1)
|
||||
return layeredIcon
|
||||
}
|
||||
|
||||
fun combineIconTooltips(icons: Array<Icon?>): @NlsContexts.Tooltip String? {
|
||||
// If a layered icon contains only a single non-null layer and other layers are null, its tooltip is not composite.
|
||||
var singleIcon: Icon? = null
|
||||
for (icon in icons) {
|
||||
if (icon != null) {
|
||||
if (singleIcon != null) {
|
||||
val result: @NlsContexts.Tooltip StringBuilder = StringBuilder()
|
||||
val seenTooltips = HashSet<String>()
|
||||
buildCompositeTooltip(icons = icons, result = result, seenTooltips = seenTooltips)
|
||||
@Suppress("HardCodedStringLiteral")
|
||||
return result.toString()
|
||||
}
|
||||
singleIcon = icon
|
||||
}
|
||||
}
|
||||
if (singleIcon != null) {
|
||||
return if (singleIcon is IconWithToolTip) singleIcon.getToolTip(false) else null
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
private constructor(icon: LayeredIcon, replacer: IconReplacer?) : super(icon) {
|
||||
@@ -367,11 +346,32 @@ open class LayeredIcon : JBCachingScalableIcon<LayeredIcon>, DarkIconProvider, C
|
||||
return newIcon
|
||||
}
|
||||
|
||||
override fun toString() = "Layered icon ${getIconWidth()}x${getIconHeight()}. myIcons=$allLayers"
|
||||
override fun toString() = "LayeredIcon(w=$width, h=$height, icons=[${allLayers.joinToString(", ")}]"
|
||||
|
||||
override fun getToolTip(composite: Boolean) = combineIconTooltips(allLayers)
|
||||
}
|
||||
|
||||
internal fun combineIconTooltips(icons: Array<Icon?>): @NlsContexts.Tooltip String? {
|
||||
// If a layered icon contains only a single non-null layer and other layers are null, its tooltip is not composite.
|
||||
var singleIcon: Icon? = null
|
||||
for (icon in icons) {
|
||||
if (icon != null) {
|
||||
if (singleIcon != null) {
|
||||
val result: @NlsContexts.Tooltip StringBuilder = StringBuilder()
|
||||
val seenTooltips = HashSet<String>()
|
||||
buildCompositeTooltip(icons = icons, result = result, seenTooltips = seenTooltips)
|
||||
@Suppress("HardCodedStringLiteral")
|
||||
return result.toString()
|
||||
}
|
||||
singleIcon = icon
|
||||
}
|
||||
}
|
||||
if (singleIcon != null) {
|
||||
return if (singleIcon is IconWithToolTip) singleIcon.getToolTip(false) else null
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
private fun buildCompositeTooltip(icons: Array<Icon?>, result: StringBuilder, seenTooltips: MutableSet<String>) {
|
||||
for (i in icons.indices) {
|
||||
// the first layer is the actual object (noun), other layers are modifiers (adjectives), so put a first object in the last position
|
||||
|
||||
@@ -177,7 +177,7 @@ public class RowIcon extends JBCachingScalableIcon<RowIcon> implements com.intel
|
||||
@Override
|
||||
public @NotNull Icon getDarkIcon(boolean isDark) {
|
||||
RowIcon newIcon = copy();
|
||||
for (int i=0; i<newIcon.myIcons.length; i++) {
|
||||
for (int i = 0; i < newIcon.myIcons.length; i++) {
|
||||
newIcon.myIcons[i] = newIcon.myIcons[i] == null ? null : IconLoader.getDarkIcon(newIcon.myIcons[i], isDark);
|
||||
}
|
||||
return newIcon;
|
||||
@@ -190,6 +190,6 @@ public class RowIcon extends JBCachingScalableIcon<RowIcon> implements com.intel
|
||||
|
||||
@Override
|
||||
public String getToolTip(boolean composite) {
|
||||
return LayeredIcon.Companion.combineIconTooltips(myIcons);
|
||||
return LayeredIconKt.combineIconTooltips(myIcons);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user