mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Borderless UI: Use TitlePane.background only (#IDEA-211054)
GitOrigin-RevId: 08229036f709ae654bfa681da19d4ed9fb6831b4
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9a66695bdc
commit
9bc6627789
+36
@@ -0,0 +1,36 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.openapi.wm.impl.customFrameDecorations.header
|
||||
|
||||
import com.intellij.ide.DataManager
|
||||
import com.intellij.openapi.actionSystem.ActionGroup
|
||||
import com.intellij.openapi.actionSystem.ex.ActionManagerEx
|
||||
import com.intellij.openapi.actionSystem.impl.ActionMenu
|
||||
import com.intellij.openapi.wm.impl.IdeMenuBar
|
||||
import com.intellij.util.ui.JBUI
|
||||
import java.awt.Graphics
|
||||
import javax.swing.border.Border
|
||||
|
||||
class CustomHeaderMenuBar : IdeMenuBar(ActionManagerEx.getInstanceEx(), DataManager.getInstance()) {
|
||||
override fun getBorder(): Border? {
|
||||
return JBUI.Borders.empty()
|
||||
}
|
||||
|
||||
override fun paintBackground(g: Graphics?) {
|
||||
|
||||
}
|
||||
|
||||
override fun createActionMenu(enableMnemonics: Boolean, isDarkMenu: Boolean, action: ActionGroup?): ActionMenu {
|
||||
val actionMenu = super.createActionMenu(enableMnemonics, isDarkMenu, action)
|
||||
actionMenu.isOpaque = false
|
||||
|
||||
return actionMenu
|
||||
}
|
||||
|
||||
init {
|
||||
isOpaque = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
+1
-24
@@ -1,29 +1,22 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.openapi.wm.impl.customFrameDecorations.header
|
||||
|
||||
import com.intellij.ide.DataManager
|
||||
import com.intellij.ide.ui.UISettings
|
||||
import com.intellij.ide.ui.UISettingsListener
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.actionSystem.ActionGroup
|
||||
import com.intellij.openapi.actionSystem.ex.ActionManagerEx
|
||||
import com.intellij.openapi.actionSystem.impl.ActionMenu
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.openapi.wm.impl.IdeMenuBar
|
||||
import com.intellij.openapi.wm.impl.customFrameDecorations.header.titleLabel.CustomDecorationPath
|
||||
import com.intellij.ui.awt.RelativeRectangle
|
||||
import com.intellij.util.ui.JBUI
|
||||
import net.miginfocom.swing.MigLayout
|
||||
import java.awt.Frame
|
||||
import java.awt.Graphics
|
||||
import java.awt.Rectangle
|
||||
import java.util.*
|
||||
import javax.swing.JFrame
|
||||
import javax.swing.JPanel
|
||||
import javax.swing.SwingUtilities
|
||||
import javax.swing.border.Border
|
||||
import javax.swing.event.ChangeListener
|
||||
|
||||
class MainFrameHeader(frame: JFrame) : FrameHeader(frame){
|
||||
@@ -39,23 +32,7 @@ class MainFrameHeader(frame: JFrame) : FrameHeader(frame){
|
||||
layout = MigLayout("novisualpadding, fillx, ins 0, gap 0, top", "$H_GAP[pref!]$H_GAP[][pref!]")
|
||||
add(productIcon)
|
||||
|
||||
myIdeMenu = object : IdeMenuBar(ActionManagerEx.getInstanceEx(), DataManager.getInstance()) {
|
||||
override fun getBorder(): Border? {
|
||||
return JBUI.Borders.empty()
|
||||
}
|
||||
|
||||
override fun paintBackground(g: Graphics?) {
|
||||
|
||||
}
|
||||
|
||||
override fun createActionMenu(enableMnemonics: Boolean, isDarkMenu: Boolean, action: ActionGroup?): ActionMenu {
|
||||
val actionMenu = super.createActionMenu(enableMnemonics, isDarkMenu, action)
|
||||
|
||||
return actionMenu
|
||||
}
|
||||
}.apply {
|
||||
isOpaque = false
|
||||
}
|
||||
myIdeMenu = CustomHeaderMenuBar()
|
||||
|
||||
mainMenuUpdater = UISettingsListener {
|
||||
myIdeMenu.isVisible = UISettings.instance.showMainMenu
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.intellij.ui.plaf.beg;
|
||||
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.wm.impl.IdeFrameDecorator;
|
||||
import com.intellij.ui.scale.JBUIScale;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
@@ -98,24 +99,11 @@ public class IdeaMenuUI extends BasicMenuUI{
|
||||
jMenu.getText() != null ? defaultTextIconGap : 0,
|
||||
defaultTextIconGap
|
||||
);
|
||||
Color color2 = g.getColor();
|
||||
Color mainColor = g.getColor();
|
||||
if (comp.isOpaque()){
|
||||
g.setColor(jMenu.getBackground());
|
||||
g.fillRect(0, 0, jMenu.getWidth(), jMenu.getHeight());
|
||||
if (buttonmodel.isArmed() || buttonmodel.isSelected()){
|
||||
if (UIUtil.isUnderAquaLookAndFeel()) {
|
||||
myAquaSelectedBackgroundPainter.paintBorder(comp, g, 0, 0, jMenu.getWidth(), jMenu.getHeight());
|
||||
} else {
|
||||
g.setColor(selectionBackground);
|
||||
if (allowedIcon != null && !(UIUtil.isUnderIntelliJLaF() || UIUtil.isUnderDarcula())) {
|
||||
g.fillRect(k, 0, jMenu.getWidth() - k, jMenu.getHeight());
|
||||
}
|
||||
else {
|
||||
g.fillRect(0, 0, jMenu.getWidth(), jMenu.getHeight());
|
||||
}
|
||||
}
|
||||
}
|
||||
g.setColor(color2);
|
||||
fillOpaque(g, comp, jMenu, buttonmodel, allowedIcon, mainColor);
|
||||
} else {
|
||||
fillOpaqueFalse(g, comp, jMenu, buttonmodel, allowedIcon, mainColor);
|
||||
}
|
||||
if (allowedIcon != null){
|
||||
if (buttonmodel.isArmed() || buttonmodel.isSelected()){
|
||||
@@ -127,7 +115,7 @@ public class IdeaMenuUI extends BasicMenuUI{
|
||||
if (useCheckAndArrow()){
|
||||
allowedIcon.paintIcon(comp, g, ourCheckIconRect.x, ourCheckIconRect.y);
|
||||
}
|
||||
g.setColor(color2);
|
||||
g.setColor(mainColor);
|
||||
if (menuItem.isArmed()){
|
||||
drawIconBorder(g);
|
||||
}
|
||||
@@ -193,10 +181,42 @@ public class IdeaMenuUI extends BasicMenuUI{
|
||||
}
|
||||
}
|
||||
}
|
||||
g.setColor(color2);
|
||||
g.setColor(mainColor);
|
||||
g.setFont(font);
|
||||
}
|
||||
|
||||
protected void fillOpaque(Graphics g, JComponent comp, JMenu jMenu, ButtonModel buttonmodel, Icon allowedIcon, Color mainColor) {
|
||||
g.setColor(jMenu.getBackground());
|
||||
g.fillRect(0, 0, jMenu.getWidth(), jMenu.getHeight());
|
||||
if (buttonmodel.isArmed() || buttonmodel.isSelected()){
|
||||
paintHover(g, comp, jMenu, allowedIcon);
|
||||
}
|
||||
g.setColor(mainColor);
|
||||
}
|
||||
|
||||
protected void fillOpaqueFalse(Graphics g, JComponent comp, JMenu jMenu, ButtonModel buttonmodel, Icon allowedIcon, Color mainColor) {
|
||||
if(IdeFrameDecorator.isCustomDecorationActive()) {
|
||||
if (buttonmodel.isArmed() || buttonmodel.isSelected()) {
|
||||
paintHover(g, comp, jMenu, allowedIcon);
|
||||
}
|
||||
g.setColor(mainColor);
|
||||
}
|
||||
}
|
||||
|
||||
protected final void paintHover(Graphics g, JComponent comp, JMenu jMenu, Icon allowedIcon) {
|
||||
if (UIUtil.isUnderAquaLookAndFeel()) {
|
||||
myAquaSelectedBackgroundPainter.paintBorder(comp, g, 0, 0, jMenu.getWidth(), jMenu.getHeight());
|
||||
} else {
|
||||
g.setColor(selectionBackground);
|
||||
if (allowedIcon != null && !(UIUtil.isUnderIntelliJLaF() || UIUtil.isUnderDarcula())) {
|
||||
g.fillRect(k, 0, jMenu.getWidth() - k, jMenu.getHeight());
|
||||
}
|
||||
else {
|
||||
g.fillRect(0, 0, jMenu.getWidth(), jMenu.getHeight());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean useCheckAndArrow() {
|
||||
return !((JMenu)menuItem).isTopLevelMenu();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user