Ticket #22346: 22346.patch

File 22346.patch, 4.9 KB (added by taylor.smock, 4 years ago)

Needs work (UI doesn't work properly when 2 components are maximized, UI does not work properly when multiple dialogs are not collapsed)

  • src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java b/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
    a b  
    384384        layerManager.removeActiveLayerChangeListener(activateLayerAction);
    385385    }
    386386
     387    @Override
     388    protected int getPanelMaximumHeight() {
     389        return this.layerList.getHeight() + this.layerList.getRowHeight();
     390    }
     391
     392    @Override
     393    protected int getPanelMinimumHeight() {
     394        return Math.min(4 * this.layerList.getRowHeight(), getPanelMaximumHeight());
     395    }
     396
    387397    /**
    388398     * Returns the layer list model.
    389399     * @return the layer list model
  • src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java b/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
    a b  
    909909        return new Dimension(dialogsPanel.getWidth(), preferredHeight);
    910910    }
    911911
     912    /**
     913     * Return the maximum height for the dialog given the current contents
     914     * @return The maximum height
     915     * @since xxx
     916     */
     917    protected int getPanelMaximumHeight() {
     918        return Integer.MIN_VALUE;
     919    }
     920
     921    /**
     922     * Return the minimum height for the dialog given the current contents
     923     * @return The minimum height
     924     * @since xxx
     925     */
     926    protected int getPanelMinimumHeight() {
     927        return Integer.MIN_VALUE;
     928    }
     929
     930    @Override
     931    public Dimension getMaximumSize() {
     932        if (!this.isCollapsed) {
     933            int maxHeight = this.getPanelMaximumHeight();
     934            if (maxHeight >= preferredHeight) {
     935                // Use preferred, since maximum is not bounded for all intents and purposes.
     936                Dimension buttons = this.buttonsPanel.getPreferredSize();
     937                Dimension title = this.titleBar.getPreferredSize();
     938                return new Dimension(this.dialogsPanel.getWidth(), title.height + maxHeight + buttons.height);
     939            }
     940        }
     941        return super.getMaximumSize();
     942    }
     943
     944    @Override
     945    public Dimension getMinimumSize() {
     946        if (!this.isCollapsed) {
     947            int minimumHeight = this.getPanelMinimumHeight();
     948            if (minimumHeight > 0) {
     949                Dimension buttons = this.buttonsPanel.getMinimumSize();
     950                Dimension title = this.titleBar.getMinimumSize();
     951                return new Dimension(Math.max(buttons.width, title.width), title.height + minimumHeight + buttons.height);
     952            }
     953        }
     954        return super.getMaximumSize();
     955    }
     956
    912957    /**
    913958     * Do something when the toggleButton is pressed.
    914959     */
  • src/org/openstreetmap/josm/gui/widgets/ScrollableTable.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/org/openstreetmap/josm/gui/widgets/ScrollableTable.java b/src/org/openstreetmap/josm/gui/widgets/ScrollableTable.java
    a b  
    22package org.openstreetmap.josm.gui.widgets;
    33
    44import java.awt.Container;
     5import java.awt.Dimension;
    56import java.awt.Point;
    67import java.awt.Rectangle;
    78
     
    4344            viewport.scrollRectToVisible(rect);
    4445        }
    4546    }
     47
     48    @Override
     49    public Dimension getPreferredSize() {
     50        if (super.isPreferredSizeSet()) {
     51            return super.getPreferredSize();
     52        }
     53        Dimension pref = super.getPreferredSize();
     54        return new Dimension(pref.width, this.getRowHeight() * this.getRowCount());
     55    }
     56
     57    @Override
     58    public Dimension getMaximumSize() {
     59        if (isMaximumSizeSet()) {
     60            return super.getMaximumSize();
     61        }
     62        Dimension max = super.getMaximumSize();
     63        return new Dimension(max.width, this.getRowHeight() * (this.getRowCount() + 1));
     64    }
     65
     66    @Override
     67    public Dimension getMinimumSize() {
     68        if (this.isMinimumSizeSet()) {
     69            return super.getMinimumSize();
     70        }
     71        Dimension min = super.getMinimumSize();
     72        return new Dimension(min.width, this.getRowHeight());
     73    }
    4674}