Align ribbon zoom label to zoom combobox
This commit is contained in:
parent
ac57e0851d
commit
0ff3c739e2
@ -295,7 +295,7 @@ public class FreeformFinSetConfig extends FinSetConfig {
|
||||
panel.add(new StyledLabel(trans.get("FreeformFinSetConfig.lbl.ctrlClick"), -2), "spanx 3, wrap");
|
||||
|
||||
// row of controls at the bottom of the tab:
|
||||
panel.add(selector, "aligny bottom, gap unrel");
|
||||
panel.add(selector.getAsPanel(), "aligny bottom, gap unrel");
|
||||
panel.add(scaleButton, "");
|
||||
panel.add(importButton, "");
|
||||
panel.add(exportCsvButton, "");
|
||||
|
@ -325,14 +325,19 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
||||
|
||||
// Zoom level selector
|
||||
scaleSelector = new ScaleSelector(scrollPane);
|
||||
ribbon.add(new JLabel(trans.get("RocketPanel.lbl.Zoom")), "cell 1 0, center");
|
||||
ribbon.add(scaleSelector, "gapleft para, cell 1 1");
|
||||
JButton zoomOutButton = scaleSelector.getZoomOutButton();
|
||||
JComboBox<String> scaleSelectorCombo = scaleSelector.getScaleSelectorCombo();
|
||||
JButton zoomInButton = scaleSelector.getZoomInButton();
|
||||
ribbon.add(zoomOutButton, "gapleft para, cell 1 1");
|
||||
ribbon.add(new JLabel(trans.get("RocketPanel.lbl.Zoom")), "cell 2 0, spanx 2");
|
||||
ribbon.add(scaleSelectorCombo, "cell 2 1");
|
||||
ribbon.add(zoomInButton, "cell 3 1");
|
||||
|
||||
// Show CG/CP
|
||||
JCheckBox showCGCP = new JCheckBox();
|
||||
showCGCP.setText(trans.get("RocketPanel.checkbox.ShowCGCP"));
|
||||
showCGCP.setSelected(true);
|
||||
ribbon.add(showCGCP, "cell 2 1, gapleft para");
|
||||
ribbon.add(showCGCP, "cell 4 1, gapleft para");
|
||||
|
||||
showCGCP.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
@ -352,21 +357,21 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
||||
Dimension d_sep = sep.getPreferredSize();
|
||||
d_sep.height = (int) (0.7 * ribbon.getPreferredSize().height);
|
||||
sep.setPreferredSize(d_sep);
|
||||
ribbon.add(sep, "cell 3 0, spany 2, gapleft para, gapright para");
|
||||
ribbon.add(sep, "cell 5 0, spany 2, gapleft para, gapright para");
|
||||
|
||||
// Stage selector
|
||||
StageSelector stageSelector = new StageSelector( rkt );
|
||||
rkt.addChangeListener(stageSelector);
|
||||
ribbon.add(new JLabel(trans.get("RocketPanel.lbl.Stages")), "cell 4 0, pushx");
|
||||
ribbon.add(stageSelector, "cell 4 1, pushx");
|
||||
ribbon.add(new JLabel(trans.get("RocketPanel.lbl.Stages")), "cell 6 0, pushx");
|
||||
ribbon.add(stageSelector, "cell 6 1, pushx");
|
||||
|
||||
// Flight configuration selector
|
||||
//// Flight configuration:
|
||||
JLabel label = new JLabel(trans.get("RocketPanel.lbl.Flightcfg"));
|
||||
ribbon.add(label, "cell 5 0");
|
||||
ribbon.add(label, "cell 7 0");
|
||||
|
||||
final ConfigurationComboBox configComboBox = new ConfigurationComboBox(rkt);
|
||||
ribbon.add(configComboBox, "cell 5 1, width 16%, wmin 100");
|
||||
ribbon.add(configComboBox, "cell 7 1, width 16%, wmin 100");
|
||||
|
||||
add(ribbon, "growx, span, wrap");
|
||||
|
||||
|
@ -17,7 +17,7 @@ import net.sf.openrocket.gui.widgets.SelectColorButton;
|
||||
import net.sf.openrocket.util.StateChangeListener;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class ScaleSelector extends JPanel {
|
||||
public class ScaleSelector {
|
||||
|
||||
public static final double MINIMUM_ZOOM = 0.01; // == 1 %
|
||||
public static final double MAXIMUM_ZOOM = 1000.00; // == 10,000 %
|
||||
@ -36,16 +36,16 @@ public class ScaleSelector extends JPanel {
|
||||
}
|
||||
|
||||
private final ScaleScrollPane scrollPane;
|
||||
private final JComboBox<String> scaleSelector;
|
||||
private final JComboBox<String> scaleSelectorCombo;
|
||||
private final JButton zoomOutButton;
|
||||
private final JButton zoomInButton;
|
||||
|
||||
public ScaleSelector(ScaleScrollPane scroll) {
|
||||
super(new MigLayout("insets 0"));
|
||||
|
||||
this.scrollPane = scroll;
|
||||
|
||||
// Zoom out button
|
||||
JButton button = new SelectColorButton(Icons.ZOOM_OUT);
|
||||
button.addActionListener(new ActionListener() {
|
||||
zoomOutButton = new SelectColorButton(Icons.ZOOM_OUT);
|
||||
zoomOutButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
final double oldScale = scrollPane.getUserScale();
|
||||
@ -54,17 +54,16 @@ public class ScaleSelector extends JPanel {
|
||||
setZoomText();
|
||||
}
|
||||
});
|
||||
add(button);
|
||||
|
||||
// Zoom level selector
|
||||
scaleSelector = new JComboBox<>(SCALE_LABELS);
|
||||
scaleSelector.setEditable(true);
|
||||
scaleSelectorCombo = new JComboBox<>(SCALE_LABELS);
|
||||
scaleSelectorCombo.setEditable(true);
|
||||
setZoomText();
|
||||
scaleSelector.addActionListener(new ActionListener() {
|
||||
scaleSelectorCombo.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
String text = (String) scaleSelector.getSelectedItem();
|
||||
String text = (String) scaleSelectorCombo.getSelectedItem();
|
||||
if (text == null) return;
|
||||
text = text.replaceAll("%", "").trim();
|
||||
|
||||
@ -93,11 +92,10 @@ public class ScaleSelector extends JPanel {
|
||||
update();
|
||||
}
|
||||
});
|
||||
add(scaleSelector);
|
||||
|
||||
// Zoom in button
|
||||
button = new SelectColorButton(Icons.ZOOM_IN);
|
||||
button.addActionListener(new ActionListener() {
|
||||
zoomInButton = new SelectColorButton(Icons.ZOOM_IN);
|
||||
zoomInButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
double scale = scrollPane.getUserScale();
|
||||
@ -106,8 +104,27 @@ public class ScaleSelector extends JPanel {
|
||||
update();
|
||||
}
|
||||
});
|
||||
add(button);
|
||||
}
|
||||
|
||||
public JPanel getAsPanel() {
|
||||
JPanel panel = new JPanel(new MigLayout("insets 0"));
|
||||
panel.add(zoomOutButton);
|
||||
panel.add(scaleSelectorCombo);
|
||||
panel.add(zoomInButton);
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
public JComboBox<String> getScaleSelectorCombo() {
|
||||
return scaleSelectorCombo;
|
||||
}
|
||||
|
||||
public JButton getZoomOutButton() {
|
||||
return zoomOutButton;
|
||||
}
|
||||
|
||||
public JButton getZoomInButton() {
|
||||
return zoomInButton;
|
||||
}
|
||||
|
||||
private void setZoomText() {
|
||||
@ -116,8 +133,8 @@ public class ScaleSelector extends JPanel {
|
||||
if (scrollPane.isFitting()) {
|
||||
text = "Fit (" + text + ")";
|
||||
}
|
||||
if (!text.equals(scaleSelector.getSelectedItem()))
|
||||
scaleSelector.setSelectedItem(text);
|
||||
if (!text.equals(scaleSelectorCombo.getSelectedItem()))
|
||||
scaleSelectorCombo.setSelectedItem(text);
|
||||
}
|
||||
|
||||
private static double getNextLargerScale(final double currentScale) {
|
||||
@ -148,12 +165,10 @@ public class ScaleSelector extends JPanel {
|
||||
return currentScale * 1.5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean b){
|
||||
for ( Component c : getComponents() ){
|
||||
c.setEnabled(b);
|
||||
}
|
||||
super.setEnabled(b);
|
||||
zoomInButton.setEnabled(b);
|
||||
scaleSelectorCombo.setEnabled(b);
|
||||
zoomOutButton.setEnabled(b);
|
||||
}
|
||||
|
||||
public void update(){
|
||||
|
Loading…
x
Reference in New Issue
Block a user