mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 11:50:54 +07:00
fix toolbar layout issues when wrapped in a panel
IDEA-297728 Tool window header buttons are shifted up IDEA-297485 Tool window header is redrawn incorrectly after docking a floating tool window GitOrigin-RevId: 87406a9c877537d15b6ef583848c099c059c433e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
bc88579b96
commit
a60724d3b1
@@ -1286,7 +1286,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
if (forced || canUpdateActions(newVisibleActions)) {
|
||||
myForcedUpdateRequested = false;
|
||||
myCachedImage = null;
|
||||
boolean shouldRebuildUI = newVisibleActions.isEmpty() || myVisibleActions.isEmpty();
|
||||
boolean fullReset = newVisibleActions.isEmpty() || myVisibleActions.isEmpty();
|
||||
myVisibleActions = newVisibleActions;
|
||||
|
||||
boolean skipSizeAdjustments = mySkipWindowAdjustments;
|
||||
@@ -1302,30 +1302,20 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
if (!skipSizeAdjustments) {
|
||||
Dimension availSize = compForSize.getSize();
|
||||
Dimension newSize = compForSize.getPreferredSize();
|
||||
adjustContainerWindowSize(shouldRebuildUI, availSize, oldSize, newSize);
|
||||
}
|
||||
|
||||
if (shouldRebuildUI) {
|
||||
revalidate();
|
||||
}
|
||||
else {
|
||||
Container parent = getParent();
|
||||
if (parent != null) {
|
||||
parent.invalidate();
|
||||
parent.validate();
|
||||
}
|
||||
adjustContainerWindowSize(fullReset, availSize, oldSize, newSize);
|
||||
}
|
||||
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
private void adjustContainerWindowSize(boolean shouldRebuildUI,
|
||||
private void adjustContainerWindowSize(boolean fullReset,
|
||||
@NotNull Dimension availSize,
|
||||
@NotNull Dimension oldSize,
|
||||
@NotNull Dimension newSize) {
|
||||
Dimension delta = new Dimension(newSize.width - oldSize.width, newSize.height - oldSize.height);
|
||||
if (!shouldRebuildUI) {
|
||||
if (!fullReset) {
|
||||
if (myOrientation == SwingConstants.HORIZONTAL) delta.width = 0;
|
||||
if (myOrientation == SwingConstants.VERTICAL) delta.height = 0;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.openapi.wm.impl.DockToolWindowAction
|
||||
import com.intellij.openapi.wm.impl.ToolWindowImpl
|
||||
import com.intellij.openapi.wm.impl.content.ToolWindowContentUi
|
||||
import com.intellij.ui.*
|
||||
import com.intellij.ui.components.panels.HorizontalLayout
|
||||
import com.intellij.ui.layout.migLayout.*
|
||||
import com.intellij.ui.layout.migLayout.patched.*
|
||||
import com.intellij.ui.popup.PopupState
|
||||
@@ -38,6 +39,7 @@ import java.beans.PropertyChangeListener
|
||||
import java.util.function.Supplier
|
||||
import javax.swing.JComponent
|
||||
import javax.swing.JPanel
|
||||
import javax.swing.SwingConstants
|
||||
import javax.swing.SwingUtilities
|
||||
import javax.swing.event.PopupMenuEvent
|
||||
import javax.swing.event.PopupMenuListener
|
||||
@@ -117,14 +119,19 @@ abstract class ToolWindowHeader internal constructor(
|
||||
toolbar.targetComponent = toolbar.component
|
||||
toolbar.layoutPolicy = ActionToolbar.NOWRAP_LAYOUT_POLICY
|
||||
toolbar.setReservePlaceAutoPopupIcon(false)
|
||||
toolbar.component.border = JBUI.Borders.empty(2, 0)
|
||||
toolbar.component.isOpaque = false
|
||||
val component = toolbar.component
|
||||
component.border = JBUI.Borders.empty(2, 0)
|
||||
if (toolWindow.toolWindowManager.isNewUi) {
|
||||
toolbar.component.border = JBUI.Borders.empty(JBUI.CurrentTheme.ToolWindow.headerToolbarLeftRightInsets())
|
||||
component.border = JBUI.Borders.empty(JBUI.CurrentTheme.ToolWindow.headerToolbarLeftRightInsets())
|
||||
}
|
||||
@Suppress("LeakingThis")
|
||||
add(toolbar.component, BorderLayout.EAST)
|
||||
component.isOpaque = false
|
||||
|
||||
val toolbarPanel = JPanel(HorizontalLayout(0, SwingConstants.CENTER))
|
||||
toolbarPanel.isOpaque = false
|
||||
toolbarPanel.add(component)
|
||||
|
||||
@Suppress("LeakingThis")
|
||||
add(toolbarPanel, BorderLayout.EAST)
|
||||
westPanel.addMouseListener(
|
||||
object : MouseAdapter() {
|
||||
override fun mouseClicked(e: MouseEvent) {
|
||||
|
||||
Reference in New Issue
Block a user