Skip to content

Commit

Permalink
Fixed some propriety for JToolBar and add a couple of check
Browse files Browse the repository at this point in the history
  • Loading branch information
vincenzopalazzo committed Jul 20, 2020
1 parent 5447eae commit 484cafc
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 15 deletions.
9 changes: 5 additions & 4 deletions src/main/java/mdlaf/MaterialLookAndFeel.java
Original file line number Diff line number Diff line change
Expand Up @@ -509,13 +509,14 @@ protected void initComponentDefaults(UIDefaults table) {

table.put("ToolBar.font", theme.getFontRegular());
table.put("ToolBar.background", theme.getBackgroundPrimary());
table.put("ToolBar.dockingForeground", theme.getBackgroundPrimary());
table.put("ToolBar.foreground", theme.getTextColor());
table.put("ToolBar.border", theme.getBorderToolBar());
table.put("ToolBar.rolloverBorder", new BorderUIResource(BorderFactory.createEmptyBorder(5,5,5,5)));
table.put("ToolBar.dockingBackground", theme.getDockingBackgroundToolBar());
table.put("ToolBar.floatingBackground", theme.getFloatingBackgroundToolBar());
table.put("ToolBar[button].mouseHover", theme.getMouseHoverButtonEnable());
table.put("ToolBar.dockingBackground", theme.getBackgroundPrimary());
table.put("ToolBar.floatingBackground", theme.getBackgroundPrimary());
table.put("ToolBar.dockingForeground", theme.getTextColor());
table.put("ToolBar.floatingForeground", theme.getTextColor());
table.put("ToolBar[button].mouseHover", false);

table.put("Tree.font", theme.getFontRegular());
table.put("Tree.selectionForeground", theme.getHighlightBackgroundPrimary());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public void update(Graphics g, JComponent c) {
@Override
protected void paintButtonPressed(Graphics g, AbstractButton b) {
//if the mouse hover is enabled I can set the mouse hover color when the button is pressed
if (mouseHoverEnabled) {
if (mouseHoverEnabled && b.getModel().isPressed()) {
if (b.isEnabled()) {
if (this.isDefaultButton()) {
g.setColor(colorMouseHoverDefaultButton);
Expand Down
26 changes: 25 additions & 1 deletion src/main/java/mdlaf/components/toolbar/MaterialToolBarUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicToolBarUI;
import java.awt.*;
import java.awt.event.ContainerEvent;
import java.awt.event.ContainerListener;

/**
* @author https://github.com/vincenzopalazzo
Expand Down Expand Up @@ -55,6 +57,29 @@ public void uninstallUI(JComponent c) {
super.uninstallUI(c);
}

@Override
protected ContainerListener createToolBarContListener() {
return new ToolBarContListener() {
@Override
public void componentAdded( ContainerEvent e ) {
super.componentAdded( e );

Component c = e.getChild();
if( c instanceof AbstractButton )
c.setFocusable( false );
}

@Override
public void componentRemoved( ContainerEvent e ) {
super.componentRemoved( e );

Component c = e.getChild();
if( c instanceof AbstractButton )
c.setFocusable( true );
}
};
}

@Override
protected void setBorderToRollover( Component c ) {}

Expand All @@ -78,5 +103,4 @@ protected void installNormalBorders( JComponent c ) {}

@Override
protected Border createNonRolloverBorder() { return null; }

}
3 changes: 3 additions & 0 deletions src/main/java/mdlaf/themes/AbstractMaterialTheme.java
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,9 @@ protected void installDefaultColor(){
this.foregroundToolTip = textColor;

this.disabledColorSlider = buttonDisabledBackground;

this.dockingBackgroundToolBar = this.backgroundPrimary;
this.floatingBackgroundToolBar = this.textColor;
}

protected void installFonts() {
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/mdlaf/themes/JMarsDarkTheme.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@ protected void installColor() {
this.gridColorTable = new ColorUIResource(151,151,151);
this.alternateRowBackgroundTable = new ColorUIResource(59, 62, 69);

this.dockingBackgroundToolBar = MaterialColors.LIGHT_GREEN_A100;
this.floatingBackgroundToolBar = MaterialColors.GRAY_200;

this.backgroundTextField = new ColorUIResource(81, 86, 101);
this.inactiveForegroundTextField = MaterialColors.WHITE;
this.inactiveBackgroundTextField = new ColorUIResource(81, 86, 101);
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/mdlaf/themes/MaterialLiteTheme.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ protected void installColor() {
this.gridColorTable = MaterialColors.GRAY_200;
this.alternateRowBackgroundTable = MaterialColors.GRAY_300;

this.dockingBackgroundToolBar = MaterialColors.LIGHT_GREEN_A100;
this.floatingBackgroundToolBar = MaterialColors.GRAY_200;

this.backgroundTextField = MaterialColors.GRAY_200;
this.inactiveForegroundTextField = MaterialColors.GRAY_800;
this.inactiveBackgroundTextField = MaterialColors.GRAY_200;
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/mdlaf/themes/MaterialOceanicTheme.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,6 @@ protected void installColor() {
this.gridColorTable = MaterialColors.COSMO_BLACK;
this.alternateRowBackgroundTable = MaterialColors.DARKLY_STRONG_BLUE;

this.dockingBackgroundToolBar = MaterialColors.LIGHT_GREEN_A100;
this.floatingBackgroundToolBar = MaterialColors.GRAY_200;

this.backgroundTextField = MaterialColors.DARKLY_BLUE;
this.inactiveForegroundTextField = MaterialColors.WHITE;
this.inactiveBackgroundTextField = MaterialColors.DARKLY_BLUE;
Expand Down

0 comments on commit 484cafc

Please sign in to comment.