mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-06 06:21:16 +07:00
[welcome screen] Fix tooltip problem with custom tree UI (IDEA-296134)
GitOrigin-RevId: 9c102b02e5da18c930f8a315f4d7385623739104
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f44c14f3df
commit
d90a554ea6
+37
-1
@@ -10,7 +10,6 @@ import com.intellij.ide.RecentProjectsManagerBase
|
||||
import com.intellij.ide.ui.laf.darcula.ui.DarculaProgressBarUI
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.actionSystem.*
|
||||
import com.intellij.openapi.project.ProjectManager
|
||||
import com.intellij.openapi.ui.Messages
|
||||
import com.intellij.openapi.ui.addKeyboardAction
|
||||
import com.intellij.openapi.util.Condition
|
||||
@@ -29,6 +28,7 @@ import com.intellij.ui.render.RenderingUtil
|
||||
import com.intellij.ui.scale.JBUIScale
|
||||
import com.intellij.ui.speedSearch.SpeedSearchSupply
|
||||
import com.intellij.ui.tree.ui.Control
|
||||
import com.intellij.ui.tree.ui.DefaultTreeUI
|
||||
import com.intellij.ui.treeStructure.Tree
|
||||
import com.intellij.util.IconUtil
|
||||
import com.intellij.util.PathUtil
|
||||
@@ -88,6 +88,7 @@ class RecentProjectFilteringTree(
|
||||
background = WelcomeScreenUIManager.getProjectsBackground()
|
||||
toggleClickCount = 0
|
||||
|
||||
setUI(FullRendererComponentTreeUI())
|
||||
setExpandableItemsEnabled(false)
|
||||
UIUtil.setCursor(this, Cursor.getPredefinedCursor(Cursor.HAND_CURSOR))
|
||||
}
|
||||
@@ -576,6 +577,41 @@ class RecentProjectFilteringTree(
|
||||
}
|
||||
}
|
||||
|
||||
private class FullRendererComponentTreeUI : DefaultTreeUI() {
|
||||
override fun getPathBounds(tree: JTree, path: TreePath?): Rectangle? {
|
||||
val bounds = super.getPathBounds(tree, path)
|
||||
if (bounds != null) {
|
||||
bounds.width = bounds.width.coerceAtLeast(tree.width - bounds.x)
|
||||
}
|
||||
|
||||
return bounds
|
||||
}
|
||||
|
||||
override fun paintRow(g: Graphics, clipBounds: Rectangle,
|
||||
insets: Insets, bounds: Rectangle,
|
||||
path: TreePath, row: Int,
|
||||
isExpanded: Boolean, hasBeenExpanded: Boolean, isLeaf: Boolean) {
|
||||
if (tree != null) {
|
||||
bounds.width = tree.width
|
||||
val viewport = ComponentUtil.getViewport(tree)
|
||||
if (viewport != null) {
|
||||
bounds.width = viewport.width - viewport.viewPosition.x - insets.right / 2
|
||||
}
|
||||
bounds.width -= bounds.x
|
||||
}
|
||||
|
||||
super.paintRow(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf)
|
||||
}
|
||||
|
||||
override fun getRowX(row: Int, depth: Int): Int {
|
||||
return JBUIScale.scale(getLeftMargin(depth - 1))
|
||||
}
|
||||
|
||||
private fun getLeftMargin(level: Int): Int {
|
||||
return 3 + level * (11 + 5)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private fun createActionEvent(tree: Tree, inputEvent: InputEvent? = null): AnActionEvent {
|
||||
val dataContext = DataManager.getInstance().getDataContext(tree)
|
||||
|
||||
@@ -46,7 +46,7 @@ import static com.intellij.util.ReflectionUtil.getMethod;
|
||||
import static com.intellij.util.containers.ContainerUtil.createWeakSet;
|
||||
|
||||
@DirtyUI
|
||||
public final class DefaultTreeUI extends BasicTreeUI {
|
||||
public class DefaultTreeUI extends BasicTreeUI {
|
||||
@ApiStatus.Internal
|
||||
public static final Key<Boolean> LARGE_MODEL_ALLOWED = Key.create("allows to use large model (only for synchronous tree models)");
|
||||
@ApiStatus.Internal
|
||||
|
||||
Reference in New Issue
Block a user