Proper window screen centering

Graph dialog proper window size
Graph dialog scroll speed increased
This commit is contained in:
Jindra Petřík
2021-01-23 15:27:28 +01:00
parent 8f856fefe4
commit 4e6b59e2ac
3 changed files with 21 additions and 3 deletions

View File

@@ -9,6 +9,9 @@ All notable changes to this project will be documented in this file.
- Better goto detection/for continue
- Support for comma operator in switch case statements
- AS3: Losing script tree focus on script selection (disallowed walking tree with keyboard up/down)
- Proper window screen centering
- Graph dialog proper window size
- Graph dialog scroll speed increased
### Changed
- AS3 test methods separated to classes

View File

@@ -30,6 +30,8 @@ import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Toolkit;
@@ -120,6 +122,7 @@ public class GraphDialog extends AppDialog {
setTitle(translate("graph") + " " + name);
JScrollPane scrollPane = new JScrollPane(gp);
scrollPane.getVerticalScrollBar().setUnitIncrement(20);
scrollBarWidth = scrollPane.getVerticalScrollBar().getPreferredSize().width;
scrollBarHeight = scrollPane.getHorizontalScrollBar().getPreferredSize().height;
cnt.add(scrollPane, BorderLayout.CENTER);
@@ -191,7 +194,9 @@ public class GraphDialog extends AppDialog {
public void setVisible(boolean b) {
super.setVisible(b);
Dimension screen = getToolkit().getScreenSize();
Rectangle screenBounds = getGraphicsConfiguration().getBounds();
Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(getGraphicsConfiguration());
Dimension screen = new Dimension(screenBounds.width - insets.left - insets.right, screenBounds.height - insets.top - insets.bottom);
Dimension dim = new Dimension(0, 0);
Dimension panDim = gp.getPreferredSize();
// add some magic constants
@@ -203,13 +208,13 @@ public class GraphDialog extends AppDialog {
if (panDim.width + frameWidthDiff < screen.width) {
dim.width = panDim.width;
} else {
dim.width = screen.width;
dim.width = screen.width - frameWidthDiff;
tooWide = true;
}
if (panDim.height + frameHeightDiff < screen.height) {
dim.height = panDim.height;
} else {
dim.height = screen.height;
dim.height = screen.height - frameHeightDiff;
tooHigh = true;
}

View File

@@ -29,9 +29,11 @@ import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Image;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.SystemColor;
import java.awt.TexturePaint;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
@@ -356,12 +358,20 @@ public class View {
screenX = allDevices[screen].getDefaultConfiguration().getBounds().width;
screenY = allDevices[screen].getDefaultConfiguration().getBounds().height;
Insets bounds = Toolkit.getDefaultToolkit().getScreenInsets(allDevices[screen].getDefaultConfiguration());
screenX = screenX - bounds.right;
screenY = screenY - bounds.bottom;
} else {
topLeftX = allDevices[0].getDefaultConfiguration().getBounds().x;
topLeftY = allDevices[0].getDefaultConfiguration().getBounds().y;
screenX = allDevices[0].getDefaultConfiguration().getBounds().width;
screenY = allDevices[0].getDefaultConfiguration().getBounds().height;
Insets bounds = Toolkit.getDefaultToolkit().getScreenInsets(allDevices[0].getDefaultConfiguration());
screenX = screenX - bounds.right;
screenY = screenY - bounds.bottom;
}
windowPosX = ((screenX - f.getWidth()) / 2) + topLeftX;