1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-17 22:23:10 +03:00

Centering the first Editor to the middle of the main monitor. Fixes #1629

This commit is contained in:
Federico Fissore
2013-10-17 16:42:48 +02:00
parent 143c91f0b5
commit 1877703920

View File

@ -581,11 +581,11 @@ public class Base {
protected int[] nextEditorLocation() { protected int[] nextEditorLocation() {
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
int defaultWidth = Preferences.getInteger("editor.window.width.default"); int defaultWidth = Preferences.getInteger("editor.window.width.default");
int defaultHeight = Preferences.getInteger("editor.window.height.default"); int defaultHeight = Preferences.getInteger("editor.window.height.default");
if (activeEditor == null) { if (activeEditor == null) {
Rectangle screen = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration().getBounds();
// If no current active editor, use default placement // If no current active editor, use default placement
return new int[] { return new int[] {
(screen.width - defaultWidth) / 2, (screen.width - defaultWidth) / 2,
@ -594,13 +594,15 @@ public class Base {
}; };
} else { } else {
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
// With a currently active editor, open the new window // With a currently active editor, open the new window
// using the same dimensions, but offset slightly. // using the same dimensions, but offset slightly.
synchronized (editors) { synchronized (editors) {
final int OVER = 50; final int OVER = 50;
// In release 0160, don't // In release 0160, don't
//location = activeEditor.getPlacement(); //location = activeEditor.getPlacement();
Editor lastOpened = editors.get(editors.size() - 1); Editor lastOpened = activeEditor;
int[] location = lastOpened.getPlacement(); int[] location = lastOpened.getPlacement();
// Just in case the bounds for that window are bad // Just in case the bounds for that window are bad
location[0] += OVER; location[0] += OVER;