Skip to content

Commit 4b86d0b

Browse files
committed
moving step buttons into the main toolbar
1 parent 956f90d commit 4b86d0b

7 files changed

Lines changed: 203 additions & 78 deletions

File tree

app/src/processing/app/Editor.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,11 @@ public EditorConsole getConsole() {
596596
abstract public EditorToolbar createToolbar();
597597

598598

599+
public void rebuildToolbar() {
600+
toolbar.rebuild();
601+
}
602+
603+
599604
abstract public Formatter createFormatter();
600605

601606

app/src/processing/app/EditorButton.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ abstract public class EditorButton extends JComponent
3434
protected String title;
3535
/** Description of alternate behavior when shift is down. */
3636
protected String titleShift;
37+
/** Description of alternate behavior when alt is down. */
38+
protected String titleAlt;
3739

3840
protected boolean pressed;
3941
protected boolean selected;
@@ -53,14 +55,22 @@ abstract public class EditorButton extends JComponent
5355

5456

5557
public EditorButton(Mode mode, String name, String title) {
56-
this(mode, name, title, title);
58+
this(mode, name, title, title, title);
5759
}
5860

5961

60-
public EditorButton(Mode mode, String name, String title, String titleShift) {
62+
public EditorButton(Mode mode, String name,
63+
String title, String titleShift) {
64+
this(mode, name, title, titleShift, title);
65+
}
66+
67+
68+
public EditorButton(Mode mode, String name,
69+
String title, String titleShift, String titleAlt) {
6170
this.mode = mode;
6271
this.title = title;
6372
this.titleShift = titleShift;
73+
this.titleAlt = titleAlt;
6474

6575
final int res = Toolkit.highResDisplay() ? 2 : 1;
6676
disabledImage = mode.loadImage(name + "-disabled-" + res + "x.png");
@@ -185,7 +195,13 @@ public void setSelected(boolean selected) {
185195
public void mouseEntered(MouseEvent e) {
186196
rollover = true;
187197
if (rolloverLabel != null) {
188-
rolloverLabel.setText(e.isShiftDown() ? titleShift : title);
198+
if (e.isShiftDown()) {
199+
rolloverLabel.setText(titleShift);
200+
} else if (e.isAltDown()) {
201+
rolloverLabel.setText(titleAlt);
202+
} else {
203+
rolloverLabel.setText(title);
204+
}
189205
}
190206
repaint();
191207
}

app/src/processing/app/EditorToolbar.java

Lines changed: 46 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,17 @@
2323

2424
package processing.app;
2525

26-
import java.awt.*;
26+
import java.awt.BorderLayout;
27+
import java.awt.Color;
28+
import java.awt.Dimension;
29+
import java.awt.Font;
30+
import java.awt.FontMetrics;
31+
import java.awt.Graphics;
32+
import java.awt.Image;
2733
import java.awt.event.*;
34+
import java.util.ArrayList;
35+
import java.util.Arrays;
36+
import java.util.List;
2837

2938
import javax.swing.Box;
3039
import javax.swing.JLabel;
@@ -42,7 +51,7 @@ abstract public class EditorToolbar extends JPanel {
4251
// horizontal gap between buttons
4352
static final int GAP = 9;
4453
// gap from the run button to the sketch label
45-
static final int LABEL_GAP = GAP;
54+
// static final int LABEL_GAP = GAP;
4655

4756
protected Editor editor;
4857
protected Base base;
@@ -66,42 +75,28 @@ public EditorToolbar(Editor editor) {
6675
base = editor.getBase();
6776
mode = editor.getMode();
6877

69-
//setOpaque(false);
70-
//gradient = createGradient();
71-
//System.out.println(gradient);
72-
7378
gradient = mode.getGradient("toolbar", 400, HIGH);
7479
// reverseGradient = mode.getGradient("reversed", 100, EditorButton.DIM);
7580

76-
runButton = new EditorButton(mode,
77-
"/lib/toolbar/run",
78-
Language.text("toolbar.run"),
79-
Language.text("toolbar.present")) {
80-
81-
@Override
82-
public void actionPerformed(ActionEvent e) {
83-
handleRun(e.getModifiers());
84-
}
85-
};
81+
rebuild();
82+
}
8683

87-
stopButton = new EditorButton(mode,
88-
"/lib/toolbar/stop",
89-
Language.text("toolbar.stop")) {
9084

91-
@Override
92-
public void actionPerformed(ActionEvent e) {
93-
handleStop();
94-
}
95-
};
85+
public void rebuild() {
86+
removeAll(); // remove previous components, if any
87+
List<EditorButton> buttons = createButtons();
9688

9789
box = Box.createHorizontalBox();
9890
box.add(Box.createHorizontalStrut(Editor.LEFT_GUTTER));
9991

100-
box.add(runButton);
101-
box.add(Box.createHorizontalStrut(GAP));
102-
box.add(stopButton);
92+
for (EditorButton button : buttons) {
93+
box.add(button);
94+
box.add(Box.createHorizontalStrut(GAP));
95+
}
96+
// // remove the last gap
97+
// box.remove(box.getComponentCount() - 1);
10398

104-
box.add(Box.createHorizontalStrut(LABEL_GAP));
99+
// box.add(Box.createHorizontalStrut(LABEL_GAP));
105100
label = new JLabel();
106101
label.setFont(mode.getFont("toolbar.rollover.font"));
107102
label.setForeground(mode.getColor("toolbar.rollover.color"));
@@ -144,6 +139,29 @@ public void paintComponent(Graphics g) {
144139
}
145140

146141

142+
public List<EditorButton> createButtons() {
143+
runButton = new EditorButton(mode,
144+
"/lib/toolbar/run",
145+
Language.text("toolbar.run"),
146+
Language.text("toolbar.present")) {
147+
@Override
148+
public void actionPerformed(ActionEvent e) {
149+
handleRun(e.getModifiers());
150+
}
151+
};
152+
153+
stopButton = new EditorButton(mode,
154+
"/lib/toolbar/stop",
155+
Language.text("toolbar.stop")) {
156+
@Override
157+
public void actionPerformed(ActionEvent e) {
158+
handleStop();
159+
}
160+
};
161+
return new ArrayList<>(Arrays.asList(runButton, stopButton));
162+
}
163+
164+
147165
public void addModeButtons(Box box) {
148166
}
149167

build/shared/lib/languages/PDE.properties

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,27 +67,28 @@ menu.sketch.add_file = Add File...
6767
# | Debug |
6868
menu.debug = Debug
6969
menu.debug.enable = Enable Debugger
70-
menu.debug.show_debug_toolbar = Show Debug Toolbar
70+
#menu.debug.show_debug_toolbar = Show Debug Toolbar
7171
menu.debug.debug = Debug
72-
menu.debug.continue = Continue
7372
menu.debug.stop = Stop
7473
# ---
7574
menu.debug.toggle_breakpoint = Toggle Breakpoint
76-
menu.debug.list_breakpoints = List breakpoints
75+
#menu.debug.list_breakpoints = List breakpoints
7776
# ---
77+
# used for both menus and toolbars
7878
menu.debug.step = Step
7979
menu.debug.step_into = Step Into
8080
menu.debug.step_out = Step Out
81+
menu.debug.continue = Continue
8182
# ---
82-
menu.debug.print_stack_trace = Print Stack Trace
83-
menu.debug.print_locals = Print Locals
84-
menu.debug.print_fields = Print Fields
85-
menu.debug.print_source_location = Print Source Location
86-
menu.debug.print_threads = Print Threads
83+
#menu.debug.print_stack_trace = Print Stack Trace
84+
#menu.debug.print_locals = Print Locals
85+
#menu.debug.print_fields = Print Fields
86+
#menu.debug.print_source_location = Print Source Location
87+
#menu.debug.print_threads = Print Threads
8788
# ---
88-
menu.debug.toggle_variable_inspector = Toggle Variable Inspector
89-
menu.debug.show_sketch_outline = Show Sketch Outline
90-
menu.debug.show_tabs_list = Show Tabs List
89+
menu.debug.variable_inspector = Variable Inspector
90+
#menu.debug.show_sketch_outline = Show Sketch Outline
91+
#menu.debug.show_tabs_list = Show Tabs List
9192

9293
# | File | Edit | Sketch | Debug | Tools | Help |
9394
# | Tools |
@@ -281,11 +282,11 @@ toolbar.export_application = Export Application
281282
toolbar.add_mode = Add mode...
282283

283284
# [Debug] [Continue] [Step] [Stop] [Toggle Breakpoints] [Variable Inspector]
284-
toolbar.debug.continue = Continue
285-
toolbar.debug.step = Step
286-
toolbar.debug.step_into = Step Into
287-
toolbar.debug.stop = Stop
288-
toolbar.debug.toggle_breakpoints = Toggle Breakpoint
285+
#toolbar.debug.continue = Continue
286+
#toolbar.debug.step = Step
287+
#toolbar.debug.step_into = Step Into
288+
#toolbar.debug.stop = Stop
289+
#toolbar.debug.toggle_breakpoints = Toggle Breakpoint
289290
#toolbar.debug.variable_inspector = Variable Inspector
290291

291292

core/todo.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
0236 (3.0a9)
22

3+
andres
4+
X Offscreen rendering broken in OpenGL renderers
5+
X https://github.com/processing/processing/issues/3292
6+
37

48
high priority
59
_ instead of all these sketchXxxx() methods, should we have sketchSetting()

0 commit comments

Comments
 (0)