mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 22:10:54 +03:00
IntelliJ Themes: added hover and pressed feedback to Button, CheckBox, RadioButton and ToggleButton (issue #176)
This commit is contained in:
@@ -14,6 +14,8 @@ FlatLaf Change Log
|
|||||||
`FlatUIDefaultsInspector.createInspectorPanel()`.
|
`FlatUIDefaultsInspector.createInspectorPanel()`.
|
||||||
- Copy selected keys and values into clipboard via context menu.
|
- Copy selected keys and values into clipboard via context menu.
|
||||||
- IntelliJ Themes:
|
- IntelliJ Themes:
|
||||||
|
- Added hover and pressed feedback to Button, CheckBox, RadioButton and
|
||||||
|
ToggleButton. (issue #176)
|
||||||
- Added "Material Theme UI Lite / Moonlight" theme.
|
- Added "Material Theme UI Lite / Moonlight" theme.
|
||||||
- Updated "Dracula", "Gradianto" and "Material Theme UI Lite" themes.
|
- Updated "Dracula", "Gradianto" and "Material Theme UI Lite" themes.
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.formdev.flatlaf;
|
package com.formdev.flatlaf;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
@@ -156,6 +157,11 @@ public class IntelliJTheme
|
|||||||
defaults.put( "Button.disabledBackground", panelBackground );
|
defaults.put( "Button.disabledBackground", panelBackground );
|
||||||
defaults.put( "ToggleButton.disabledBackground", panelBackground );
|
defaults.put( "ToggleButton.disabledBackground", panelBackground );
|
||||||
|
|
||||||
|
// fix Button borders
|
||||||
|
copyIfNotSet( defaults, "Button.focusedBorderColor", "Component.focusedBorderColor", uiKeys );
|
||||||
|
defaults.put( "Button.hoverBorderColor", defaults.get( "Button.focusedBorderColor" ) );
|
||||||
|
defaults.put( "HelpButton.hoverBorderColor", defaults.get( "Button.focusedBorderColor" ) );
|
||||||
|
|
||||||
// IDEA uses a SVG icon for the help button, but paints the background with Button.startBackground and Button.endBackground
|
// IDEA uses a SVG icon for the help button, but paints the background with Button.startBackground and Button.endBackground
|
||||||
Object helpButtonBackground = defaults.get( "Button.startBackground" );
|
Object helpButtonBackground = defaults.get( "Button.startBackground" );
|
||||||
Object helpButtonBorderColor = defaults.get( "Button.startBorderColor" );
|
Object helpButtonBorderColor = defaults.get( "Button.startBorderColor" );
|
||||||
@@ -381,7 +387,7 @@ public class IntelliJTheme
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Because IDEA uses SVGs for check boxes and radio buttons the colors for
|
* Because IDEA uses SVGs for check boxes and radio buttons, the colors for
|
||||||
* this two components are specified in "icons > ColorPalette".
|
* this two components are specified in "icons > ColorPalette".
|
||||||
* FlatLaf uses vector icons and expects colors for the two components in UI defaults.
|
* FlatLaf uses vector icons and expects colors for the two components in UI defaults.
|
||||||
*/
|
*/
|
||||||
@@ -453,28 +459,44 @@ public class IntelliJTheme
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove hover and pressed colors
|
// update hover, pressed and focused colors
|
||||||
if( checkboxModified ) {
|
if( checkboxModified ) {
|
||||||
|
// for non-filled checkbox/radiobutton used in dark themes
|
||||||
defaults.remove( "CheckBox.icon.focusWidth" );
|
defaults.remove( "CheckBox.icon.focusWidth" );
|
||||||
defaults.remove( "CheckBox.icon.hoverBorderColor" );
|
defaults.put( "CheckBox.icon.hoverBorderColor", defaults.get( "CheckBox.icon.focusedBorderColor" ) );
|
||||||
defaults.remove( "CheckBox.icon.focusedBackground" );
|
|
||||||
defaults.remove( "CheckBox.icon.hoverBackground" );
|
|
||||||
defaults.remove( "CheckBox.icon.pressedBackground" );
|
|
||||||
defaults.remove( "CheckBox.icon.selectedFocusedBackground" );
|
|
||||||
defaults.remove( "CheckBox.icon.selectedHoverBackground" );
|
|
||||||
defaults.remove( "CheckBox.icon.selectedPressedBackground" );
|
|
||||||
|
|
||||||
|
// for filled checkbox/radiobutton used in light themes
|
||||||
defaults.remove( "CheckBox.icon[filled].focusWidth" );
|
defaults.remove( "CheckBox.icon[filled].focusWidth" );
|
||||||
defaults.remove( "CheckBox.icon[filled].hoverBorderColor" );
|
defaults.put( "CheckBox.icon[filled].hoverBorderColor", defaults.get( "CheckBox.icon[filled].focusedBorderColor" ) );
|
||||||
defaults.remove( "CheckBox.icon[filled].focusedBackground" );
|
defaults.put( "CheckBox.icon[filled].selectedFocusedBackground", defaults.get( "CheckBox.icon[filled].selectedBackground" ) );
|
||||||
defaults.remove( "CheckBox.icon[filled].hoverBackground" );
|
|
||||||
defaults.remove( "CheckBox.icon[filled].pressedBackground" );
|
if( dark ) {
|
||||||
defaults.remove( "CheckBox.icon[filled].selectedFocusedBackground" );
|
// IDEA Darcula checkBoxFocused.svg, checkBoxSelectedFocused.svg,
|
||||||
defaults.remove( "CheckBox.icon[filled].selectedHoverBackground" );
|
// radioFocused.svg and radioSelectedFocused.svg
|
||||||
defaults.remove( "CheckBox.icon[filled].selectedPressedBackground" );
|
// use opacity=".65" for the border
|
||||||
|
// --> add alpha to focused border colors
|
||||||
|
String[] focusedBorderColorKeys = new String[] {
|
||||||
|
"CheckBox.icon.focusedBorderColor",
|
||||||
|
"CheckBox.icon.selectedFocusedBorderColor",
|
||||||
|
"CheckBox.icon[filled].focusedBorderColor",
|
||||||
|
"CheckBox.icon[filled].selectedFocusedBorderColor",
|
||||||
|
};
|
||||||
|
for( String key : focusedBorderColorKeys ) {
|
||||||
|
Color color = defaults.getColor( key );
|
||||||
|
if( color != null ) {
|
||||||
|
defaults.put( key, new ColorUIResource( new Color(
|
||||||
|
(color.getRGB() & 0xffffff) | 0xa6000000, true ) ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void copyIfNotSet( UIDefaults defaults, String destKey, String srcKey, Set<String> uiKeys ) {
|
||||||
|
if( !uiKeys.contains( destKey ) )
|
||||||
|
defaults.put( destKey, defaults.get( srcKey ) );
|
||||||
|
}
|
||||||
|
|
||||||
/** Rename UI default keys (key --> value). */
|
/** Rename UI default keys (key --> value). */
|
||||||
private static Map<String, String> uiKeyMapping = new HashMap<>();
|
private static Map<String, String> uiKeyMapping = new HashMap<>();
|
||||||
/** Copy UI default keys (value --> key). */
|
/** Copy UI default keys (value --> key). */
|
||||||
|
|||||||
Reference in New Issue
Block a user