mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-07 06:20:53 +03:00
MenuBar.underlineSelectionColor
This commit is contained in:
@@ -246,7 +246,7 @@ public class FlatMenuItemRenderer
|
|||||||
g.setColor( Color.orange ); g.drawRect( arrowRect.x, arrowRect.y, arrowRect.width - 1, arrowRect.height - 1 );
|
g.setColor( Color.orange ); g.drawRect( arrowRect.x, arrowRect.y, arrowRect.width - 1, arrowRect.height - 1 );
|
||||||
debug*/
|
debug*/
|
||||||
|
|
||||||
paintBackground( g, selectionBackground );
|
paintBackground( g, selectionBackground, underlineSelectionColor );
|
||||||
paintIcon( g, iconRect, getIconForPainting() );
|
paintIcon( g, iconRect, getIconForPainting() );
|
||||||
paintText( g, textRect, menuItem.getText(), selectionForeground, disabledForeground );
|
paintText( g, textRect, menuItem.getText(), selectionForeground, disabledForeground );
|
||||||
paintAccelerator( g, accelRect, getAcceleratorText(), acceleratorForeground, acceleratorSelectionForeground, disabledForeground );
|
paintAccelerator( g, accelRect, getAcceleratorText(), acceleratorForeground, acceleratorSelectionForeground, disabledForeground );
|
||||||
@@ -254,7 +254,7 @@ debug*/
|
|||||||
paintArrowIcon( g, arrowRect, arrowIcon );
|
paintArrowIcon( g, arrowRect, arrowIcon );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void paintBackground( Graphics g, Color selectionBackground ) {
|
protected void paintBackground( Graphics g, Color selectionBackground, Color underlineSelectionColor ) {
|
||||||
boolean armedOrSelected = isArmedOrSelected( menuItem );
|
boolean armedOrSelected = isArmedOrSelected( menuItem );
|
||||||
if( menuItem.isOpaque() || armedOrSelected ) {
|
if( menuItem.isOpaque() || armedOrSelected ) {
|
||||||
int width = menuItem.getWidth();
|
int width = menuItem.getWidth();
|
||||||
|
|||||||
@@ -60,13 +60,16 @@ import javax.swing.plaf.basic.BasicMenuUI;
|
|||||||
* <!-- FlatMenuUI -->
|
* <!-- FlatMenuUI -->
|
||||||
*
|
*
|
||||||
* @uiDefault MenuItem.iconTextGap int
|
* @uiDefault MenuItem.iconTextGap int
|
||||||
* @uiDefault MenuBar.hoverBackground Color
|
* @uiDefault MenuBar.hoverBackground
|
||||||
|
* @uiDefault MenuBar.underlineSelectionColor Color
|
||||||
*
|
*
|
||||||
* @author Karl Tauber
|
* @author Karl Tauber
|
||||||
*/
|
*/
|
||||||
public class FlatMenuUI
|
public class FlatMenuUI
|
||||||
extends BasicMenuUI
|
extends BasicMenuUI
|
||||||
{
|
{
|
||||||
|
protected final Color menuBarUnderlineSelectionColor = UIManager.getColor( "MenuBar.underlineSelectionColor" );
|
||||||
|
|
||||||
private Color hoverBackground;
|
private Color hoverBackground;
|
||||||
private FlatMenuItemRenderer renderer;
|
private FlatMenuItemRenderer renderer;
|
||||||
|
|
||||||
@@ -154,7 +157,7 @@ public class FlatMenuUI
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintBackground( Graphics g, Color selectionBackground ) {
|
protected void paintBackground( Graphics g, Color selectionBackground, Color menuItemUnderlineSelectionColor ) {
|
||||||
ButtonModel model = menuItem.getModel();
|
ButtonModel model = menuItem.getModel();
|
||||||
if( model.isRollover() && !model.isArmed() && !model.isSelected() &&
|
if( model.isRollover() && !model.isArmed() && !model.isSelected() &&
|
||||||
model.isEnabled() && ((JMenu)menuItem).isTopLevelMenu() )
|
model.isEnabled() && ((JMenu)menuItem).isTopLevelMenu() )
|
||||||
@@ -162,7 +165,7 @@ public class FlatMenuUI
|
|||||||
g.setColor( deriveBackground( hoverBackground ) );
|
g.setColor( deriveBackground( hoverBackground ) );
|
||||||
g.fillRect( 0, 0, menuItem.getWidth(), menuItem.getHeight() );
|
g.fillRect( 0, 0, menuItem.getWidth(), menuItem.getHeight() );
|
||||||
} else
|
} else
|
||||||
super.paintBackground( g, selectionBackground );
|
super.paintBackground( g, selectionBackground, ((JMenu)menuItem).isTopLevelMenu() ? menuBarUnderlineSelectionColor : menuItemUnderlineSelectionColor );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -337,6 +337,7 @@ MenuBar.border=com.formdev.flatlaf.ui.FlatMenuBarBorder
|
|||||||
MenuBar.background=@menuBackground
|
MenuBar.background=@menuBackground
|
||||||
MenuBar.hoverBackground=@menuHoverBackground
|
MenuBar.hoverBackground=@menuHoverBackground
|
||||||
MenuBar.itemMargins=3,8,3,8
|
MenuBar.itemMargins=3,8,3,8
|
||||||
|
MenuBar.underlineSelectionColor=$TabbedPane.underlineColor
|
||||||
|
|
||||||
|
|
||||||
#---- MenuItem ----
|
#---- MenuItem ----
|
||||||
|
|||||||
Reference in New Issue
Block a user