mirror of
https://github.com/processing/processing4.git
synced 2026-02-03 21:59:20 +01:00
debug button works on toolbar
This commit is contained in:
@@ -31,25 +31,25 @@ implements MouseListener, MouseMotionListener, ActionListener {
|
||||
static public final int DIM = 46;
|
||||
|
||||
/** Button's description. */
|
||||
String title;
|
||||
protected String title;
|
||||
/** Description of alternate behavior when shift is down. */
|
||||
String titleShift;
|
||||
protected String titleShift;
|
||||
|
||||
boolean pressed;
|
||||
boolean selected;
|
||||
boolean rollover;
|
||||
JLabel rolloverLabel;
|
||||
boolean shift;
|
||||
protected boolean pressed;
|
||||
protected boolean selected;
|
||||
protected boolean rollover;
|
||||
protected JLabel rolloverLabel;
|
||||
protected boolean shift;
|
||||
|
||||
// boolean enabled;
|
||||
// State state;
|
||||
// Map<State, Image> imageMap = new HashMap<>();
|
||||
protected Image enabledImage;
|
||||
protected Image disabledImage;
|
||||
protected Image selectedImage;
|
||||
protected Image rolloverImage;
|
||||
protected Image pressedImage;
|
||||
|
||||
Image enabledImage;
|
||||
Image disabledImage;
|
||||
Image selectedImage;
|
||||
Image rolloverImage;
|
||||
Image pressedImage;
|
||||
protected Image gradient;
|
||||
|
||||
protected Mode mode;
|
||||
|
||||
|
||||
public EditorButton(Mode mode, String name, String title) {
|
||||
@@ -58,6 +58,7 @@ implements MouseListener, MouseMotionListener, ActionListener {
|
||||
|
||||
|
||||
public EditorButton(Mode mode, String name, String title, String titleShift) {
|
||||
this.mode = mode;
|
||||
this.title = title;
|
||||
this.titleShift = titleShift;
|
||||
|
||||
@@ -97,6 +98,9 @@ implements MouseListener, MouseMotionListener, ActionListener {
|
||||
} else if (rollover) {
|
||||
image = rolloverImage;
|
||||
}
|
||||
if (gradient != null) {
|
||||
g.drawImage(gradient, 0, 0, DIM, DIM, this);
|
||||
}
|
||||
g.drawImage(image, 0, 0, DIM, DIM, this);
|
||||
}
|
||||
|
||||
@@ -122,6 +126,16 @@ implements MouseListener, MouseMotionListener, ActionListener {
|
||||
// }
|
||||
|
||||
|
||||
public void setReverse() {
|
||||
gradient = mode.getGradient("reversed", DIM, DIM);
|
||||
}
|
||||
|
||||
|
||||
// public void setGradient(Image gradient) {
|
||||
// this.gradient = gradient;
|
||||
// }
|
||||
|
||||
|
||||
public void setRolloverLabel(JLabel label) {
|
||||
rolloverLabel = label;
|
||||
}
|
||||
|
||||
@@ -98,10 +98,11 @@ abstract public class EditorToolbar extends JPanel {
|
||||
currentButton = runButton;
|
||||
|
||||
box.add(Box.createHorizontalGlue());
|
||||
Component items = createModeButtons();
|
||||
if (items != null) {
|
||||
box.add(items);
|
||||
}
|
||||
addModeButtons(box);
|
||||
// Component items = createModeButtons();
|
||||
// if (items != null) {
|
||||
// box.add(items);
|
||||
// }
|
||||
ModeSelector ms = new ModeSelector();
|
||||
box.add(ms);
|
||||
|
||||
@@ -110,6 +111,11 @@ abstract public class EditorToolbar extends JPanel {
|
||||
}
|
||||
|
||||
|
||||
// public void setReverse(EditorButton button) {
|
||||
// button.setGradient(reverseGradient);
|
||||
// }
|
||||
|
||||
|
||||
public void paintComponent(Graphics g) {
|
||||
// super.paintComponent(g);
|
||||
Dimension size = getSize();
|
||||
@@ -117,8 +123,7 @@ abstract public class EditorToolbar extends JPanel {
|
||||
}
|
||||
|
||||
|
||||
public Component createModeButtons() {
|
||||
return null;
|
||||
public void addModeButtons(Box box) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -257,6 +257,7 @@ archive_sketch = Archive sketch as...
|
||||
toolbar.run = Run
|
||||
toolbar.present = Present
|
||||
toolbar.stop = Stop
|
||||
toolbar.debug = Debug
|
||||
# ---
|
||||
toolbar.new = New
|
||||
toolbar.open = Open
|
||||
@@ -265,13 +266,12 @@ toolbar.export_application = Export Application
|
||||
toolbar.add_mode = Add mode...
|
||||
|
||||
# [Debug] [Continue] [Step] [Stop] [Toggle Breakpoints] [Variable Inspector]
|
||||
toolbar.debug.debug = Debug
|
||||
toolbar.debug.continue = Continue
|
||||
toolbar.debug.step = Step
|
||||
toolbar.debug.step_into = Step Into
|
||||
toolbar.debug.stop = Stop
|
||||
toolbar.debug.toggle_breakpoints = Toggle Breakpoints
|
||||
toolbar.debug.variable_inspector = Variable Inspector
|
||||
toolbar.debug.toggle_breakpoints = Toggle Breakpoint
|
||||
#toolbar.debug.variable_inspector = Variable Inspector
|
||||
|
||||
|
||||
# ---------------------------------------
|
||||
|
||||
@@ -2005,6 +2005,12 @@ public class JavaEditor extends Editor {
|
||||
}
|
||||
|
||||
|
||||
public void toggleDebug() {
|
||||
enableDebug.setSelected(!enableDebug.isSelected());
|
||||
updateDebugToggle();
|
||||
}
|
||||
|
||||
|
||||
public void updateDebugToggle() {
|
||||
final boolean enabled = enableDebug.isSelected();
|
||||
if (enabled) {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2010-11 Ben Fry and Casey Reas
|
||||
Copyright (c) 2013-15 The Processing Foundation
|
||||
Copyright (c) 2010-13 Ben Fry and Casey Reas
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License version 2
|
||||
@@ -19,10 +20,15 @@
|
||||
|
||||
package processing.mode.java;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.InputEvent;
|
||||
|
||||
import javax.swing.Box;
|
||||
|
||||
import processing.app.Editor;
|
||||
import processing.app.EditorButton;
|
||||
import processing.app.EditorToolbar;
|
||||
import processing.app.Language;
|
||||
|
||||
|
||||
public class JavaToolbar extends EditorToolbar {
|
||||
@@ -33,6 +39,20 @@ public class JavaToolbar extends EditorToolbar {
|
||||
super(editor);
|
||||
jeditor = (JavaEditor) editor;
|
||||
}
|
||||
|
||||
|
||||
public void addModeButtons(Box box) {
|
||||
EditorButton debugButton = new EditorButton(mode, "/lib/toolbar/debug",
|
||||
Language.text("toolbar.debug")) {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
jeditor.toggleDebug();
|
||||
}
|
||||
};
|
||||
debugButton.setReverse();
|
||||
box.add(debugButton);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user