Properly set preferredSize of navContainer
- New CardLayout requires also preferredSize in addition to maximum and minimum sizes to expand/contract properly without leaving artifacts + also requires revalidation. - Remove entire container repaint to prevent unnecessary slowdown for no reason Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
@@ -383,7 +383,9 @@ public class ClientUI
|
|||||||
navContainer = new JPanel();
|
navContainer = new JPanel();
|
||||||
navContainer.setLayout(cardLayout);
|
navContainer.setLayout(cardLayout);
|
||||||
navContainer.setMinimumSize(new Dimension(0, 0));
|
navContainer.setMinimumSize(new Dimension(0, 0));
|
||||||
navContainer.setMaximumSize(new Dimension(0, Integer.MAX_VALUE));
|
navContainer.setMaximumSize(new Dimension(0, 0));
|
||||||
|
navContainer.setPreferredSize(new Dimension(0, 0));
|
||||||
|
|
||||||
// To reduce substance's colorization (tinting)
|
// To reduce substance's colorization (tinting)
|
||||||
navContainer.putClientProperty(SubstanceSynapse.COLORIZATION_FACTOR, 1.0);
|
navContainer.putClientProperty(SubstanceSynapse.COLORIZATION_FACTOR, 1.0);
|
||||||
container.add(navContainer);
|
container.add(navContainer);
|
||||||
@@ -656,7 +658,6 @@ public class ClientUI
|
|||||||
|
|
||||||
// Revalidate sizes of affected Swing components
|
// Revalidate sizes of affected Swing components
|
||||||
container.revalidate();
|
container.revalidate();
|
||||||
container.repaint();
|
|
||||||
giveClientFocus();
|
giveClientFocus();
|
||||||
|
|
||||||
if (sidebarOpen)
|
if (sidebarOpen)
|
||||||
@@ -688,18 +689,15 @@ public class ClientUI
|
|||||||
toggleSidebar();
|
toggleSidebar();
|
||||||
}
|
}
|
||||||
|
|
||||||
int expandBy = panel.getWrappedPanel().getPreferredSize().width;
|
int width = panel.getWrappedPanel().getPreferredSize().width;
|
||||||
|
int expandBy = pluginPanel != null ? pluginPanel.getWrappedPanel().getPreferredSize().width - width : width;
|
||||||
if (pluginPanel != null)
|
|
||||||
{
|
|
||||||
expandBy = pluginPanel.getWrappedPanel().getPreferredSize().width - expandBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
pluginPanel = panel;
|
pluginPanel = panel;
|
||||||
navContainer.setMinimumSize(new Dimension(pluginPanel.getWrappedPanel().getPreferredSize().width, 0));
|
|
||||||
navContainer.setMaximumSize(new Dimension(pluginPanel.getWrappedPanel().getPreferredSize().width, Integer.MAX_VALUE));
|
|
||||||
|
|
||||||
final JPanel wrappedPanel = panel.getWrappedPanel();
|
// Expand sidebar
|
||||||
|
navContainer.setMinimumSize(new Dimension(width, 0));
|
||||||
|
navContainer.setMaximumSize(new Dimension(width, Integer.MAX_VALUE));
|
||||||
|
navContainer.setPreferredSize(new Dimension(width, 0));
|
||||||
|
navContainer.revalidate();
|
||||||
cardLayout.show(navContainer, button.getTooltip());
|
cardLayout.show(navContainer, button.getTooltip());
|
||||||
|
|
||||||
// panel.onActivate has to go after giveClientFocus so it can get focus if it needs.
|
// panel.onActivate has to go after giveClientFocus so it can get focus if it needs.
|
||||||
@@ -727,6 +725,8 @@ public class ClientUI
|
|||||||
pluginPanel.onDeactivate();
|
pluginPanel.onDeactivate();
|
||||||
navContainer.setMinimumSize(new Dimension(0, 0));
|
navContainer.setMinimumSize(new Dimension(0, 0));
|
||||||
navContainer.setMaximumSize(new Dimension(0, 0));
|
navContainer.setMaximumSize(new Dimension(0, 0));
|
||||||
|
navContainer.setPreferredSize(new Dimension(0, 0));
|
||||||
|
navContainer.revalidate();
|
||||||
giveClientFocus();
|
giveClientFocus();
|
||||||
frame.contractBy(pluginPanel.getWrappedPanel().getPreferredSize().width);
|
frame.contractBy(pluginPanel.getWrappedPanel().getPreferredSize().width);
|
||||||
pluginPanel = null;
|
pluginPanel = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user