Skip to content

Commit

Permalink
Bugfixes related to disabled icons
Browse files Browse the repository at this point in the history
- Bugfix: disabled icon of DockActions was converted to gray twice,
making them hard to read and also overriding the (not gray) icon that
might be set by the client. Thanks Thomas for finding this bug.
- Bugfix: disabled icon of DockActions was not painted in
drop-down-menus
  • Loading branch information
Benoker committed Jul 31, 2017
1 parent f78688c commit 4ee19ea
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 21 deletions.
2 changes: 1 addition & 1 deletion docking-frames-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.dockingframes</groupId>
<artifactId>docking-frames-base</artifactId>
<version>1.1.2-P19b</version>
<version>1.1.2-P19c</version>
</parent>

<artifactId>docking-frames-common</artifactId>
Expand Down
7 changes: 6 additions & 1 deletion docking-frames-core/changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1118,4 +1118,9 @@
- Feature (provided by Nicolas Roduit): new and better translations for various languages

[v1.1.2p19b]
- Bugfix: memory leak fixed, that was caused by a listener created by the "AbstractTabLayoutManagerPane". The listener was never removed properly. Thanks mattbru2 for finding the bug!
- Bugfix: memory leak fixed, that was caused by a listener created by the "AbstractTabLayoutManagerPane". The listener was never removed properly. Thanks mattbru2 for finding the bug!

[v1.1.2p19c]
- Bugfix: disabled icon of DockActions was converted to gray twice, making them hard to read and also overriding the (not gray) icon that might be set by the client. Thanks Thomas for finding this bug.
- Bugfix: disabled icon of DockActions was not painted in drop-down-menus

2 changes: 1 addition & 1 deletion docking-frames-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.dockingframes</groupId>
<artifactId>docking-frames-base</artifactId>
<version>1.1.2-P19b</version>
<version>1.1.2-P19c</version>
</parent>

<artifactId>docking-frames-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ public void updateUI(){

label.setIconOffset( 0 );
label.setIconTextDistance( 2 );

// we already build our own disabled version of the icon
label.setPaintDisabledIcon( false );
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import bibliothek.gui.dock.action.DockAction;
import bibliothek.gui.dock.action.StandardDockAction;
import bibliothek.gui.dock.event.StandardDockActionListener;
import bibliothek.gui.dock.util.DockUtilities;

/**
* A handler that connects a {@link JMenuItem} with a {@link DockAction}.
Expand Down Expand Up @@ -110,7 +111,7 @@ public void bind(){
if( item != null ){
item.setEnabled( action.isEnabled( dockable ));
item.setIcon( getIcon( ActionContentModifier.NONE_HORIZONTAL ) );
item.setDisabledIcon( action.getIcon( dockable, ActionContentModifier.DISABLED ) );
updateDisabledIcon();
item.setText( action.getText( dockable ));
item.setToolTipText( action.getTooltipText( dockable ));
}
Expand All @@ -120,23 +121,44 @@ public void bind(){
}
}

private Icon getIcon( ActionContentModifier modifier ){
private void updateDisabledIcon(){
Icon icon = getIcon( ActionContentModifier.DISABLED_HORIZONTAL, ActionContentModifier.NONE_HORIZONTAL, ActionContentModifier.NONE );
if( icon == null ){
icon = getIcon( ActionContentModifier.NONE_HORIZONTAL );
icon = DockUtilities.disabledIcon( getItem(), icon );
}

item.setDisabledIcon( icon );
}

private Icon getIcon( ActionContentModifier modifier, ActionContentModifier... limits ){
List<ActionContentModifier> modifiers = new LinkedList<ActionContentModifier>();
modifiers.add( modifier );

while( !modifiers.isEmpty() ){
modifier = modifiers.remove( 0 );
Icon icon = action.getIcon( dockable, modifier );
if( icon != null ){
return icon;
}
for( ActionContentModifier backup : modifier.getBackup() ){
modifiers.add( backup );
if( !isLimited( modifier, limits )){
Icon icon = action.getIcon( dockable, modifier );
if( icon != null ){
return icon;
}
for( ActionContentModifier backup : modifier.getBackup() ){
modifiers.add( backup );
}
}
}
return null;
}

private boolean isLimited( ActionContentModifier modifier, ActionContentModifier... limits ){
for( ActionContentModifier limit : limits ){
if( limit.equals( modifier )){
return true;
}
}
return false;
}

/**
* Disconnects this handler from its action
*/
Expand Down Expand Up @@ -172,8 +194,8 @@ public void actionIconChanged( StandardDockAction action, ActionContentModifier
else if( modifier == null || modifier == ActionContentModifier.NONE ){
item.setIcon( getIcon( ActionContentModifier.NONE_HORIZONTAL ) );
}
if( modifier == null || modifier == ActionContentModifier.DISABLED ){
item.setDisabledIcon( action.getIcon( dockable, ActionContentModifier.DISABLED ) );
if( modifier == null || modifier == ActionContentModifier.DISABLED || modifier == ActionContentModifier.DISABLED_HORIZONTAL ){
updateDisabledIcon();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public class OrientedLabel extends ConfiguredBackgroundPanel{
/** icon painted when this label is disabled */
private Icon disabledIcon;

/** whether to paint a special disabled version of {@link #icon} if disabled */
private boolean paintDisabledIcon = true;

/** distance between icon and border */
private int iconOffset = 2;

Expand Down Expand Up @@ -79,6 +82,23 @@ public Icon getIcon(){
return icon;
}

/**
* Whether to build and paint a special disabled version of {@link #getIcon()} if this label is disabled.
* @param paintDisabledIcon whether to paint the special icon
*/
public void setPaintDisabledIcon( boolean paintDisabledIcon ) {
this.paintDisabledIcon = paintDisabledIcon;
revalidate();
repaint();
}
/**
* Whether a special disabled version of {@link #getIcon()} is painted if this label is disabled.
* @return <code>true</code> if an artificial icon is created
*/
public boolean isPaintDisabledIcon() {
return paintDisabledIcon;
}

/**
* Sets the distance between icon and the three adjacent borders.
* @param iconOffset the distance
Expand Down Expand Up @@ -350,7 +370,7 @@ public void paintForeground( Graphics g ){
}
else{
Icon icon = this.icon;
if( !isEnabled() ){
if( !isEnabled() && paintDisabledIcon ){
if( disabledIcon == null ){
disabledIcon = DockUtilities.disabledIcon( this, icon );
}
Expand Down
2 changes: 1 addition & 1 deletion docking-frames-core/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.2-P19b
1.1.2-P19c
2 changes: 1 addition & 1 deletion docking-frames-demo-tutorial/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.dockingframes</groupId>
<artifactId>docking-frames-base</artifactId>
<version>1.1.2-P19b</version>
<version>1.1.2-P19c</version>
</parent>

<artifactId>tutorial</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion docking-frames-ext-glass/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.dockingframes</groupId>
<artifactId>docking-frames-base</artifactId>
<version>1.1.2-P19b</version>
<version>1.1.2-P19c</version>
</parent>

<artifactId>docking-frames-ext-glass</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion docking-frames-ext-toolbar-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.dockingframes</groupId>
<artifactId>docking-frames-base</artifactId>
<version>1.1.2-P19b</version>
<version>1.1.2-P19c</version>
</parent>

<artifactId>docking-frames-ext-toolbar-common</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion docking-frames-ext-toolbar-tutorial/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.dockingframes</groupId>
<artifactId>docking-frames-base</artifactId>
<version>1.1.2-P19b</version>
<version>1.1.2-P19c</version>
</parent>

<artifactId>tutorial-toolbar</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion docking-frames-ext-toolbar/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.dockingframes</groupId>
<artifactId>docking-frames-base</artifactId>
<version>1.1.2-P19b</version>
<version>1.1.2-P19c</version>
</parent>

<artifactId>docking-frames-ext-toolbar</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>org.dockingframes</groupId>
<artifactId>docking-frames-base</artifactId>
<version>1.1.2-P19b</version>
<version>1.1.2-P19c</version>
<packaging>pom</packaging>

<modules>
Expand Down

0 comments on commit 4ee19ea

Please sign in to comment.