Skip to content

Commit

Permalink
2013.11.20 (1.48h6)
Browse files Browse the repository at this point in the history
  • Loading branch information
rasband committed Nov 20, 2013
1 parent 4fae8c8 commit 837c896
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 20 deletions.
2 changes: 1 addition & 1 deletion ij/ImageJ.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public class ImageJ extends Frame implements ActionListener,

/** Plugins should call IJ.getVersion() or IJ.getFullVersion() to get the version string. */
public static final String VERSION = "1.48h";
public static final String BUILD = "4";
public static final String BUILD = "6";
public static Color backgroundColor = new Color(220,220,220); //224,226,235
/** SansSerif, 12-point, plain font. */
public static final Font SansSerif12 = new Font("SansSerif", Font.PLAIN, 12);
Expand Down
45 changes: 29 additions & 16 deletions ij/gui/Toolbar.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ public class Toolbar extends Canvas implements MouseListener, MouseMotionListene
private static final int NUM_TOOLS = 23;
private static final int NUM_BUTTONS = 21;
private static final int SIZE = 28;
private static final int GAP_SIZE = 9;
private static final int OFFSET = 6;
private static final String BRUSH_SIZE = "toolbar.brush.size";
public static final String CORNER_DIAMETER = "toolbar.arc.size";
public static String TOOL_KEY = "toolbar.tool";

private Dimension ps = new Dimension(SIZE*NUM_BUTTONS, SIZE);
private Dimension ps = new Dimension(SIZE*NUM_BUTTONS-(SIZE-GAP_SIZE), SIZE);
private boolean[] down;
private static int current;
private int previous;
Expand Down Expand Up @@ -234,13 +235,19 @@ private void drawButton(Graphics g, int tool) {
if (IJ.debugMode) IJ.log("drawButton: "+tool+" "+g);
if (g==null) return;
int index = toolIndex(tool);
fill3DRect(g, index * SIZE + 1, 1, SIZE, SIZE-1, !down[tool]);
int x = index * SIZE + 1;
if (tool>=SPARE2)
x -= SIZE-GAP_SIZE;
if (tool!=SPARE1)
fill3DRect(g, x, 1, SIZE, SIZE-1, !down[tool]);
g.setColor(toolColor);
int x = index * SIZE + OFFSET;
x = index * SIZE + OFFSET;
if (tool>=SPARE2)
x -= SIZE-GAP_SIZE;
int y = OFFSET;
if (down[tool]) { x++; y++;}
this.g = g;
if (tool>=SPARE1 && tool<=SPARE9 && icons[tool]!=null) {
if (tool>=SPARE2 && tool<=SPARE9 && icons[tool]!=null) {
drawIcon(g, tool, x, y);
return;
}
Expand Down Expand Up @@ -866,8 +873,11 @@ int toolIndex(int tool) {
}
}

// Returns the tool corresponding to the specified tool position index
int toolID(int index) {
// Returns the tool corresponding to the specified x coordinate
private int toolID(int x) {
if (x>SIZE*12+GAP_SIZE)
x -= GAP_SIZE;
int index = x/SIZE;
switch (index) {
case 0: return RECTANGLE;
case 1: return OVAL;
Expand All @@ -881,18 +891,19 @@ int toolID(int index) {
case 9: return MAGNIFIER;
case 10: return HAND;
case 11: return DROPPER;
case 12: return SPARE1;
default: return index + 2;
default: return index + 3;
}
}

private boolean inGap(int x) {
return x>=(SIZE*12) && x<(SIZE*12+GAP_SIZE);
}

public void mousePressed(MouseEvent e) {
int x = e.getX();
int newTool = 0;
for (int i=0; i<NUM_BUTTONS; i++) {
if (x>i*SIZE && x<i*SIZE+SIZE)
newTool = toolID(i);
}
if (inGap(x))
return;
int newTool = toolID(x);
if (newTool==SPARE9) {
showSwitchPopupMenu(e);
return;
Expand All @@ -908,7 +919,7 @@ public void mousePressed(MouseEvent e) {
mpPrevious = current;
if (isMacroTool(newTool)) {
String name = names[newTool];
if (name.contains("Unused Tool"))
if (newTool==SPARE1 || name.contains("Unused Tool"))
return;
if (name.indexOf("Action Tool")!=-1) {
if (e.isPopupTrigger()||e.isMetaDown()) {
Expand Down Expand Up @@ -1362,8 +1373,10 @@ public Dimension getMinimumSize(){

public void mouseMoved(MouseEvent e) {
int x = e.getX();
x=toolID(x/SIZE);
showMessage(x);
if (inGap(x))
IJ.showStatus("");
else
showMessage(toolID(x));
}

/** Adds a tool to the toolbar. The 'toolTip' string is displayed in the status bar
Expand Down
8 changes: 7 additions & 1 deletion ij/plugin/MacroInstaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,14 @@ else if (!name.endsWith("Tool Selected")) {
if (toolCount==1)
tb.addMacroTool((String)tools.get(0), this);
else {
int index = 0;
String firstTool = (String)tools.get(0);
if (!firstTool.startsWith("Unused") && tools.size()<=7) {
tb.addMacroTool("Unused Tool", this, 0);
index = 1;
}
for (int i=0; i<tools.size(); i++)
tb.addMacroTool((String)tools.get(i), this, i);
tb.addMacroTool((String)tools.get(i), this, index++);
}
if (toolCount>1 && Toolbar.getToolId()>=Toolbar.SPARE2)
tb.setTool(Toolbar.RECTANGLE);
Expand Down
5 changes: 3 additions & 2 deletions release-notes.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
</head>
<body>

<li> <u>1.48g 18 November 2013</u>
<li> <u>1.48g 20 November 2013</u>
<ul>
<li> Replaced the blank "Unused Tool" slot in the toolbar with a 9 pixel gap.
<li> Added "Insert", "Info" and "Close" buttons to the dialog opened by the
macro editor's <i>Macros&gt;Function Finder</i> command.
<li> Fixed a bug that caused toolbar icons to sometimes be drawn incorrectly.
<li> Thanks to Michael Schmid, fixed a bug in <i>Process&gt;Noise&gt;Salt and Pepper</i> that
caused it to omit the last column and row of the image.
<li> Thanks to Michael Schmid, fixed bugs in the macro interpreter that caused expressions in
the form s+"abc", where 's' is a string variable, to cause macros to abort when they are used
the form s+"abc", where 's' is a string variable, to cause macros to abort when used
as a function argument or used in a 'return' statement.
</ul>

Expand Down

1 comment on commit 837c896

@mutterer
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toolbar tectonics !

Please sign in to comment.