mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-16 11:21:18 +03:00
Resynced with Processing/Wiring IDE code: improved auto-format, better performance for EditorConsole, etc...
This commit is contained in:
@ -41,9 +41,11 @@ public class EditorButtons extends JComponent implements MouseInputListener {
|
||||
};
|
||||
|
||||
static final int BUTTON_COUNT = title.length;
|
||||
static final int BUTTON_WIDTH = 27; //Preferences.GRID_SIZE;
|
||||
static final int BUTTON_HEIGHT = 32; //Preferences.GRID_SIZE;
|
||||
static final int BUTTON_GAP = 15; //BUTTON_WIDTH / 2;
|
||||
/// height, width of the toolbar buttons
|
||||
static final int BUTTON_WIDTH = 27;
|
||||
static final int BUTTON_HEIGHT = 32;
|
||||
/// amount of space between groups of buttons on the toolbar
|
||||
static final int BUTTON_GAP = 15;
|
||||
|
||||
static final int RUN = 0;
|
||||
static final int STOP = 1;
|
||||
@ -59,7 +61,7 @@ public class EditorButtons extends JComponent implements MouseInputListener {
|
||||
static final int ACTIVE = 2;
|
||||
|
||||
Editor editor;
|
||||
boolean disableRun;
|
||||
//boolean disableRun;
|
||||
//Label status;
|
||||
|
||||
Image offscreen;
|
||||
@ -72,7 +74,7 @@ public class EditorButtons extends JComponent implements MouseInputListener {
|
||||
Image rollover[];
|
||||
Image active[];
|
||||
int currentRollover;
|
||||
int currentSelection;
|
||||
//int currentSelection;
|
||||
|
||||
JPopupMenu popup;
|
||||
|
||||
@ -112,7 +114,7 @@ public class EditorButtons extends JComponent implements MouseInputListener {
|
||||
// see EditorStatus.java for details.
|
||||
//bgcolor = Preferences.getColor("buttons.bgcolor");
|
||||
bgcolor = new Color(0x04, 0x4F, 0x6F);
|
||||
|
||||
|
||||
status = "";
|
||||
|
||||
statusFont = Preferences.getFont("buttons.status.font");
|
||||
@ -234,10 +236,10 @@ public class EditorButtons extends JComponent implements MouseInputListener {
|
||||
if (sel == -1) return;
|
||||
|
||||
if (state[sel] != ACTIVE) {
|
||||
if (!(disableRun && ((sel == RUN) || (sel == STOP)))) {
|
||||
setState(sel, ROLLOVER, true);
|
||||
currentRollover = sel;
|
||||
}
|
||||
//if (!(disableRun && ((sel == RUN) || (sel == STOP)))) {
|
||||
setState(sel, ROLLOVER, true);
|
||||
currentRollover = sel;
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@ -284,6 +286,10 @@ public class EditorButtons extends JComponent implements MouseInputListener {
|
||||
|
||||
|
||||
public void mouseExited(MouseEvent e) {
|
||||
// if the popup menu for is visible, don't register this,
|
||||
// because the popup being set visible will fire a mouseExited() event
|
||||
if ((popup != null) && popup.isVisible()) return;
|
||||
|
||||
if (state[OPEN] != INACTIVE) {
|
||||
setState(OPEN, INACTIVE, true);
|
||||
}
|
||||
@ -295,27 +301,78 @@ public class EditorButtons extends JComponent implements MouseInputListener {
|
||||
|
||||
|
||||
public void mousePressed(MouseEvent e) {
|
||||
int x = e.getX();
|
||||
int y = e.getY();
|
||||
final int x = e.getX();
|
||||
final int y = e.getY();
|
||||
|
||||
int sel = findSelection(x, y);
|
||||
///if (sel == -1) return false;
|
||||
if (sel == -1) return;
|
||||
currentRollover = -1;
|
||||
currentSelection = sel;
|
||||
if (!(disableRun && ((sel == RUN) || (sel == STOP)))) {
|
||||
setState(sel, ACTIVE, true);
|
||||
}
|
||||
//int currentSelection = sel;
|
||||
//if (!(disableRun && ((sel == RUN) || (sel == STOP)))) {
|
||||
// moving the handling of this over into the editor
|
||||
//setState(sel, ACTIVE, true);
|
||||
//}
|
||||
|
||||
if (currentSelection == OPEN) {
|
||||
//if (currentSelection == OPEN) {
|
||||
//switch (currentSelection) {
|
||||
switch (sel) {
|
||||
case RUN:
|
||||
//if (!disableRun) {
|
||||
editor.handleRun(e.isShiftDown());
|
||||
//}
|
||||
break;
|
||||
|
||||
case STOP:
|
||||
//if (!disableRun) {
|
||||
//setState(RUN, INACTIVE, true);
|
||||
//setInactive();
|
||||
editor.handleStop();
|
||||
//}
|
||||
break;
|
||||
|
||||
case OPEN:
|
||||
if (popup == null) {
|
||||
//popup = new JPopupMenu();
|
||||
popup = editor.sketchbook.getPopupMenu();
|
||||
// no events properly being fired, so nevermind
|
||||
/*
|
||||
popup.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
System.out.println("action " + e);
|
||||
}
|
||||
});
|
||||
popup.addComponentListener(new ComponentAdapter() {
|
||||
public void componentHidden(ComponentEvent e) {
|
||||
System.out.println("hidden " + e);
|
||||
}
|
||||
});
|
||||
*/
|
||||
add(popup);
|
||||
}
|
||||
//editor.sketchbook.rebuildPopup(popup);
|
||||
popup.show(this, x, y);
|
||||
}
|
||||
//activate(OPEN);
|
||||
//SwingUtilities.invokeLater(new Runnable() {
|
||||
//public void run() {
|
||||
popup.show(EditorButtons.this, x, y);
|
||||
//}});
|
||||
break;
|
||||
|
||||
case NEW:
|
||||
editor.handleNew(e.isShiftDown());
|
||||
break;
|
||||
|
||||
case SAVE:
|
||||
editor.handleSave(false);
|
||||
break;
|
||||
|
||||
case EXPORT:
|
||||
editor.handleExport();
|
||||
break;
|
||||
|
||||
case SERIAL:
|
||||
editor.handleSerial();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -323,6 +380,7 @@ public class EditorButtons extends JComponent implements MouseInputListener {
|
||||
|
||||
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
/*
|
||||
switch (currentSelection) {
|
||||
case RUN:
|
||||
if (!disableRun) {
|
||||
@ -344,14 +402,47 @@ public class EditorButtons extends JComponent implements MouseInputListener {
|
||||
case SERIAL: editor.handleSerial(); break;
|
||||
}
|
||||
currentSelection = -1;
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
public void disableRun(boolean what) {
|
||||
disableRun = what;
|
||||
//public void disableRun(boolean what) {
|
||||
//disableRun = what;
|
||||
//}
|
||||
|
||||
|
||||
/*
|
||||
public void run() {
|
||||
if (inactive == null) return;
|
||||
clear();
|
||||
setState(RUN, ACTIVE, true);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
public void running(boolean yesno) {
|
||||
setState(RUN, yesno ? ACTIVE : INACTIVE, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set a particular button to be active.
|
||||
*/
|
||||
public void activate(int what) {
|
||||
if (inactive == null) return;
|
||||
setState(what, ACTIVE, true);
|
||||
}
|
||||
|
||||
|
||||
//public void clearRun() {
|
||||
//if (inactive == null) return;
|
||||
//setState(RUN, INACTIVE, true);
|
||||
//}
|
||||
|
||||
|
||||
/**
|
||||
* Clear all the state of all buttons.
|
||||
*/
|
||||
public void clear() { // (int button) {
|
||||
if (inactive == null) return;
|
||||
|
||||
@ -363,24 +454,6 @@ public class EditorButtons extends JComponent implements MouseInputListener {
|
||||
}
|
||||
|
||||
|
||||
public void run() {
|
||||
if (inactive == null) return;
|
||||
clear();
|
||||
setState(RUN, ACTIVE, true);
|
||||
}
|
||||
|
||||
|
||||
public void running(boolean yesno) {
|
||||
setState(RUN, yesno ? ACTIVE : INACTIVE, true);
|
||||
}
|
||||
|
||||
|
||||
public void clearRun() {
|
||||
if (inactive == null) return;
|
||||
setState(RUN, INACTIVE, true);
|
||||
}
|
||||
|
||||
|
||||
public void message(String msg) {
|
||||
//status.setText(msg + " "); // don't mind the hack
|
||||
status = msg;
|
||||
|
Reference in New Issue
Block a user