mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
Improved "Recently Used" toolbox, doesn't jump as you click
This commit is contained in:
+19
-4
@@ -39,6 +39,8 @@ class ComponentTabbedPane extends JTabbedPane {
|
||||
public static int SCROLL_STEP = Presenter.ICON_SIZE + ComponentButton.MARGIN * 2 + 2;
|
||||
|
||||
private final IPlugInPort plugInPort;
|
||||
private Container recentToolbar;
|
||||
private List<String> pendingRecentComponents = null;
|
||||
|
||||
public ComponentTabbedPane(IPlugInPort plugInPort) {
|
||||
super();
|
||||
@@ -56,6 +58,12 @@ class ComponentTabbedPane extends JTabbedPane {
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
ComponentTabbedPane.this.plugInPort.setNewComponentTypeSlot(null);
|
||||
// Refresh recent components if needed
|
||||
if (pendingRecentComponents != null) {
|
||||
refreshRecentComponentsToolbar(getRecentToolbar(), pendingRecentComponents);
|
||||
getRecentToolbar().invalidate();
|
||||
pendingRecentComponents = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -113,6 +121,14 @@ class ComponentTabbedPane extends JTabbedPane {
|
||||
// return scrollPane;
|
||||
// }
|
||||
|
||||
public Container getRecentToolbar() {
|
||||
if (recentToolbar == null) {
|
||||
recentToolbar = new Container();
|
||||
recentToolbar.setLayout(new BoxLayout(recentToolbar, BoxLayout.X_AXIS));
|
||||
}
|
||||
return recentToolbar;
|
||||
}
|
||||
|
||||
private Component createComponentPanel(List<ComponentType> componentTypes) {
|
||||
Container toolbar = new Container();
|
||||
Collections.sort(componentTypes, ComparatorFactory.getInstance()
|
||||
@@ -130,8 +146,7 @@ class ComponentTabbedPane extends JTabbedPane {
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.setOpaque(false);
|
||||
|
||||
final Container toolbar = new Container();
|
||||
toolbar.setLayout(new BoxLayout(toolbar, BoxLayout.X_AXIS));
|
||||
final Container toolbar = getRecentToolbar();
|
||||
refreshRecentComponentsToolbar(toolbar, (List<String>) ConfigurationManager.getInstance()
|
||||
.readObject(IPlugInPort.RECENT_COMPONENTS_KEY, new ArrayList<String>()));
|
||||
ConfigurationManager.getInstance().addConfigListener(IPlugInPort.RECENT_COMPONENTS_KEY,
|
||||
@@ -139,8 +154,8 @@ class ComponentTabbedPane extends JTabbedPane {
|
||||
|
||||
@Override
|
||||
public void valueChanged(String key, Object value) {
|
||||
refreshRecentComponentsToolbar(toolbar, (List<String>) value);
|
||||
toolbar.invalidate();
|
||||
// Cache the new list, we'll refresh when there's a chance
|
||||
pendingRecentComponents = (List<String>) value;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -650,6 +650,10 @@
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Remove junk from BOM (eyelets, wires, traces)</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Improved "Recently Used" toolbox, doesn't jump as you click</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>http://code.google.com/p/diy-layout-creator/downloads/list</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
|
||||
Reference in New Issue
Block a user