aboutsummaryrefslogtreecommitdiffstats
path: root/Source/TableDocument.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2009-09-02 00:08:18 +0000
committerrowanbeentje <rowan@beent.je>2009-09-02 00:08:18 +0000
commit52be9acb4e46b3ef67bd278f49951379cebeafaa (patch)
tree7e6146cfc3c44ad290da1b285e7755f550761801 /Source/TableDocument.m
parent1a6b920d5982840a405a6a53e0c3928b79066a9b (diff)
downloadsequelpro-52be9acb4e46b3ef67bd278f49951379cebeafaa.tar.gz
sequelpro-52be9acb4e46b3ef67bd278f49951379cebeafaa.tar.bz2
sequelpro-52be9acb4e46b3ef67bd278f49951379cebeafaa.zip
- Improve on r1242, improving window cascading (especially for maximised windows) and addressing Issue #383
Diffstat (limited to 'Source/TableDocument.m')
-rw-r--r--Source/TableDocument.m26
1 files changed, 20 insertions, 6 deletions
diff --git a/Source/TableDocument.m b/Source/TableDocument.m
index fab71faf..c58c21bf 100644
--- a/Source/TableDocument.m
+++ b/Source/TableDocument.m
@@ -116,15 +116,29 @@
NSScreen* candidate;
for(candidate in [NSScreen screens])
if(NSMinX([candidate frame]) < topLeftPoint.x && NSMinX([candidate frame]) > NSMinX(screenFrame))
- screenFrame = [candidate frame];
+ screenFrame = [candidate visibleFrame];
previousFrame = [tableWindow frame];
- if(previousFrame.origin.x - screenFrame.origin.x + previousFrame.size.width > screenFrame.size.width-1) {
- previousFrame.size.width -= 50;
- previousFrame.size.height -= 50;
- previousFrame.origin.y += 50;
- if(previousFrame.size.width >= [tableWindow minSize].width && previousFrame.size.height >= [tableWindow minSize].height)
+
+ // Determine if move/resize is required
+ if(previousFrame.origin.x - screenFrame.origin.x + previousFrame.size.width >= screenFrame.size.width
+ || previousFrame.origin.y - screenFrame.origin.y + previousFrame.size.height >= screenFrame.size.height)
+ {
+
+ // First try to move the window back onto the screen if it will fit
+ if (previousFrame.size.width <= screenFrame.size.width && previousFrame.size.height <= screenFrame.size.height) {
+ previousFrame.origin.x -= (previousFrame.origin.x + previousFrame.size.width) - (screenFrame.origin.x + screenFrame.size.width);
+ previousFrame.origin.y -= (previousFrame.origin.y + previousFrame.size.height) - (screenFrame.origin.y + screenFrame.size.height);
[tableWindow setFrame:previousFrame display:YES];
+
+ // Otherwise, resize and de-cascade a little
+ } else {
+ previousFrame.size.width -= 50;
+ previousFrame.size.height -= 50;
+ previousFrame.origin.y += 50;
+ if(previousFrame.size.width >= [tableWindow minSize].width && previousFrame.size.height >= [tableWindow minSize].height)
+ [tableWindow setFrame:previousFrame display:YES];
+ }
}
}