mirror of
https://github.com/processing/processing4.git
synced 2026-02-19 05:15:34 +01:00
ui rework in progress
This commit is contained in:
@@ -51,8 +51,10 @@ public abstract class Editor extends JFrame implements RunnerListener {
|
||||
protected EditorState state;
|
||||
protected Mode mode;
|
||||
|
||||
static final int LEFT_GUTTER = 60;
|
||||
static final int RIGHT_GUTTER = 26;
|
||||
static public final int LEFT_GUTTER = 44;
|
||||
static public final int RIGHT_GUTTER = 20;
|
||||
static public final int GUTTER_MARGIN = 3;
|
||||
|
||||
|
||||
// Otherwise, if the window is resized with the message label
|
||||
// set to blank, its preferredSize() will be fuckered
|
||||
|
||||
@@ -28,7 +28,7 @@ import javax.swing.*;
|
||||
|
||||
abstract public class EditorButton extends JComponent
|
||||
implements MouseListener, MouseMotionListener, ActionListener {
|
||||
static public final int DIM = 46;
|
||||
static public final int DIM = 35;
|
||||
|
||||
/** Button's description. */
|
||||
protected String title;
|
||||
|
||||
@@ -37,7 +37,7 @@ import javax.swing.*;
|
||||
*/
|
||||
public class EditorHeader extends JComponent {
|
||||
// height of this tab bar
|
||||
static final int HIGH = 36;
|
||||
static final int HIGH = 30;
|
||||
// standard UI sizing (OS-specific, but generally consistent)
|
||||
// static final int SCROLLBAR_WIDTH = 16;
|
||||
// amount of space on the left edge before the tabs start
|
||||
|
||||
@@ -38,11 +38,11 @@ import javax.swing.JPopupMenu;
|
||||
abstract public class EditorToolbar extends JPanel {
|
||||
// haven't decided how to handle this/how to make public/consistency
|
||||
// for components/does it live in theme.txt
|
||||
static final int HIGH = 80;
|
||||
// gap between buttons
|
||||
static final int GAP = 8;
|
||||
static final int HIGH = 53;
|
||||
// horizontal gap between buttons
|
||||
static final int GAP = 9;
|
||||
// gap from the run button to the sketch label
|
||||
static final int LABEL_GAP = 18;
|
||||
static final int LABEL_GAP = GAP;
|
||||
|
||||
protected Editor editor;
|
||||
protected Base base;
|
||||
|
||||
@@ -37,7 +37,6 @@ import processing.mode.java.debug.LineID;
|
||||
import processing.mode.java.pdex.ErrorCheckerService;
|
||||
import processing.mode.java.pdex.ErrorMarker;
|
||||
import processing.mode.java.pdex.ErrorMessageSimplifier;
|
||||
import processing.mode.java.pdex.ImportStatement;
|
||||
import processing.mode.java.pdex.JavaTextArea;
|
||||
import processing.mode.java.pdex.Problem;
|
||||
import processing.mode.java.pdex.XQConsoleToggle;
|
||||
|
||||
@@ -36,6 +36,7 @@ import javax.swing.DefaultListModel;
|
||||
import javax.swing.SwingWorker;
|
||||
|
||||
import processing.app.Base;
|
||||
import processing.app.Editor;
|
||||
import processing.app.Mode;
|
||||
import processing.app.syntax.JEditTextArea;
|
||||
import processing.app.syntax.PdeTextAreaDefaults;
|
||||
@@ -46,9 +47,9 @@ public class JavaTextArea extends JEditTextArea {
|
||||
protected PdeTextAreaDefaults defaults;
|
||||
protected JavaEditor editor;
|
||||
|
||||
static final int LEFT_GUTTER = 59;
|
||||
static final int RIGHT_GUTTER = 27;
|
||||
static final int GUTTER_MARGIN = 3;
|
||||
// static final int LEFT_GUTTER = Editor.LEFT_GUTTER;
|
||||
// static final int RIGHT_GUTTER = Editor.RIGHT_GUTTER;
|
||||
// static final int GUTTER_MARGIN = 3;
|
||||
|
||||
protected MouseListener[] mouseListeners; // cached mouselisteners, these are wrapped by MouseHandler
|
||||
|
||||
@@ -669,7 +670,7 @@ public class JavaTextArea extends JEditTextArea {
|
||||
*/
|
||||
@Override
|
||||
public int _offsetToX(int line, int offset) {
|
||||
return super._offsetToX(line, offset) + LEFT_GUTTER;
|
||||
return super._offsetToX(line, offset) + Editor.LEFT_GUTTER;
|
||||
}
|
||||
|
||||
|
||||
@@ -685,7 +686,7 @@ public class JavaTextArea extends JEditTextArea {
|
||||
*/
|
||||
@Override
|
||||
public int xToOffset(int line, int x) {
|
||||
return super.xToOffset(line, x - LEFT_GUTTER);
|
||||
return super.xToOffset(line, x - Editor.LEFT_GUTTER);
|
||||
}
|
||||
|
||||
|
||||
@@ -709,7 +710,7 @@ public class JavaTextArea extends JEditTextArea {
|
||||
@Override
|
||||
public void mousePressed(MouseEvent me) {
|
||||
// check if this happened in the gutter area
|
||||
if (me.getX() < LEFT_GUTTER) {
|
||||
if (me.getX() < Editor.LEFT_GUTTER) {
|
||||
if (me.getButton() == MouseEvent.BUTTON1 && me.getClickCount() == 2) {
|
||||
int line = me.getY() / painter.getFontMetrics().getHeight()
|
||||
+ firstLine;
|
||||
@@ -766,12 +767,12 @@ public class JavaTextArea extends JEditTextArea {
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent me) {
|
||||
// No need to forward since the standard MouseMotionListeners are called anyway
|
||||
if (me.getX() < LEFT_GUTTER) {
|
||||
if (lastX >= LEFT_GUTTER) {
|
||||
if (me.getX() < Editor.LEFT_GUTTER) {
|
||||
if (lastX >= Editor.LEFT_GUTTER) {
|
||||
painter.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
} else {
|
||||
if (lastX < LEFT_GUTTER) {
|
||||
if (lastX < Editor.LEFT_GUTTER) {
|
||||
painter.setCursor(new Cursor(Cursor.TEXT_CURSOR));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,11 +43,13 @@ import java.util.List;
|
||||
|
||||
|
||||
|
||||
|
||||
import javax.swing.text.BadLocationException;
|
||||
import javax.swing.text.Segment;
|
||||
import javax.swing.text.Utilities;
|
||||
|
||||
import processing.app.Base;
|
||||
import processing.app.Editor;
|
||||
import processing.app.SketchCode;
|
||||
import processing.app.syntax.SyntaxDocument;
|
||||
import processing.app.syntax.TextAreaDefaults;
|
||||
@@ -182,7 +184,7 @@ public class JavaTextAreaPainter extends TextAreaPainter
|
||||
try {
|
||||
// TODO This line is causing NPEs randomly ever since I added the
|
||||
// toggle for Java Mode/Debugger toolbar. [Manindra]
|
||||
super.paintLine(gfx, line, x + JavaTextArea.LEFT_GUTTER, tokenMarker);
|
||||
super.paintLine(gfx, line, x + Editor.LEFT_GUTTER, tokenMarker);
|
||||
|
||||
} catch (Exception e) {
|
||||
Base.log(e.getMessage());
|
||||
@@ -210,7 +212,7 @@ public class JavaTextAreaPainter extends TextAreaPainter
|
||||
protected void paintGutterBg(Graphics gfx, int line, int x) {
|
||||
gfx.setColor(getTextArea().gutterBgColor);
|
||||
int y = textArea.lineToY(line) + fm.getLeading() + fm.getMaxDescent();
|
||||
gfx.fillRect(0, y, JavaTextArea.LEFT_GUTTER, fm.getHeight());
|
||||
gfx.fillRect(0, y, Editor.LEFT_GUTTER, fm.getHeight());
|
||||
}
|
||||
|
||||
|
||||
@@ -227,8 +229,8 @@ public class JavaTextAreaPainter extends TextAreaPainter
|
||||
protected void paintGutterLine(Graphics gfx, int line, int x) {
|
||||
int y = textArea.lineToY(line) + fm.getLeading() + fm.getMaxDescent();
|
||||
gfx.setColor(getTextArea().gutterLineColor);
|
||||
gfx.drawLine(JavaTextArea.LEFT_GUTTER, y,
|
||||
JavaTextArea.LEFT_GUTTER, y + fm.getHeight());
|
||||
gfx.drawLine(Editor.LEFT_GUTTER, y,
|
||||
Editor.LEFT_GUTTER, y + fm.getHeight());
|
||||
}
|
||||
|
||||
|
||||
@@ -260,13 +262,13 @@ public class JavaTextAreaPainter extends TextAreaPainter
|
||||
// draw 4 times to make it appear bold, displaced 1px to the right, to the bottom and bottom right.
|
||||
//int len = text.length() > ta.gutterChars ? ta.gutterChars : text.length();
|
||||
Utilities.drawTabbedText(new Segment(text.toCharArray(), 0, text.length()),
|
||||
JavaTextArea.GUTTER_MARGIN, y, gfx, this, 0);
|
||||
Editor.GUTTER_MARGIN, y, gfx, this, 0);
|
||||
Utilities.drawTabbedText(new Segment(text.toCharArray(), 0, text.length()),
|
||||
JavaTextArea.GUTTER_MARGIN + 1, y, gfx, this, 0);
|
||||
Editor.GUTTER_MARGIN + 1, y, gfx, this, 0);
|
||||
Utilities.drawTabbedText(new Segment(text.toCharArray(), 0, text.length()),
|
||||
JavaTextArea.GUTTER_MARGIN, y + 1, gfx, this, 0);
|
||||
Editor.GUTTER_MARGIN, y + 1, gfx, this, 0);
|
||||
Utilities.drawTabbedText(new Segment(text.toCharArray(), 0, text.length()),
|
||||
JavaTextArea.GUTTER_MARGIN + 1, y + 1, gfx, this, 0);
|
||||
Editor.GUTTER_MARGIN + 1, y + 1, gfx, this, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -373,8 +375,8 @@ public class JavaTextAreaPainter extends TextAreaPainter
|
||||
int x1 = fm.stringWidth(goodCode) + (aw - rw), y1 = y + fm.getHeight()
|
||||
- 2, x2 = x1 + rw;
|
||||
// Adding offsets for the gutter
|
||||
x1 += JavaTextArea.LEFT_GUTTER;
|
||||
x2 += JavaTextArea.LEFT_GUTTER;
|
||||
x1 += Editor.LEFT_GUTTER;
|
||||
x2 += Editor.LEFT_GUTTER;
|
||||
|
||||
// gfx.fillRect(x1, y, rw, height);
|
||||
|
||||
|
||||
4
todo.txt
4
todo.txt
@@ -16,6 +16,10 @@ _ don't return here, allow contrib types to fail:
|
||||
_ https://github.com/processing/processing/blob/master/app/src/processing/app/contrib/ContributionListing.java#L509
|
||||
_ trying to add a second tab with the same name causes an error
|
||||
|
||||
_ implement line numbers in the editor
|
||||
_ 5px between line number (right-aligned) and the right edge of the gutter
|
||||
_ ie textAlign(RIGHT) / text(lineNum, LEFT_GUTTER - 5, y)
|
||||
|
||||
_ run button w/ debugger shouldn't require "continue" before actually starting
|
||||
_ https://github.com/processing/processing/issues/3096
|
||||
_ large window places the debugger window offscreen
|
||||
|
||||
Reference in New Issue
Block a user