Ignore:
Timestamp:
2011-12-20T21:33:34+01:00 (12 years ago)
Author:
stoecker
Message:

fix #6963 - patch by akks - fixes for left hand buttons

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/IconToggleButton.java

    r4666 r4669  
    2525    public boolean groupbutton;
    2626    private ShowHideButtonListener listener;
     27    private boolean hideIfDisabled=false;
    2728
    2829    /**
     
    6667    }
    6768   
     69    String getPreferenceKey() {
     70        String s = (String) getSafeActionValue("toolbar");
     71        if (s==null) {
     72            if (getAction()!=null) s=getAction().getClass().getName();
     73        }
     74        return "sidetoolbar.hidden."+s;
     75       
     76    }
     77   
    6878    @Override
    6979    public void applyButtonHiddenPreferences() {
    70         String actionName = (String) getSafeActionValue(AbstractAction.NAME);
    71         boolean hiddenFlag = Main.pref.getBoolean(actionName + ".itbutton_hidden", false);
    72         setVisible(!hiddenFlag);   
     80        boolean alwaysHideDisabled = Main.pref.getBoolean("sidetoolbar.hideDisabledButtons", false);
     81        boolean hiddenFlag = Main.pref.getBoolean(getPreferenceKey(), false);
     82        if (!isEnabled() && (hideIfDisabled || alwaysHideDisabled))
     83                setVisible(false);  // hide because of disabled button
     84            else
     85                setVisible( !hiddenFlag ); // show or hide, do what preferences say 
    7386    }
    7487
    7588    @Override
    7689    public void setButtonHidden(boolean b) {
    77         String actionName = (String) getSafeActionValue(AbstractAction.NAME);
    7890        setVisible(!b);
    7991        if (listener!=null) { // if someone wants to know about changes of visibility
    8092            if (!b) listener.buttonShown(); else listener.buttonHidden();
    8193        }
    82         Main.pref.put(actionName + ".itbutton_hidden", b);
     94        Main.pref.put(getPreferenceKey(), b);
     95    }
     96   
     97    /*
     98     * This fuction should be called for plugins that want to enable auto-hiding
     99     * custom buttons when they are disabled (because of incorrect layer, for example)
     100     */
     101    public void setAutoHideDisabledButton(boolean b) {
     102        hideIfDisabled=b;
     103        if (b && !isEnabled()) setVisible(false);
    83104    }
    84105   
Note: See TracChangeset for help on using the changeset viewer.