aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/PSMTabBar/PSMTabBarControl.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2012-04-02 00:23:52 +0000
committerrowanbeentje <rowan@beent.je>2012-04-02 00:23:52 +0000
commit09ed4be7e668dc10e0c4ca9178f8e1c414997b57 (patch)
treebe27a884f60f33fe2eb6cabd1270983900d2ebe4 /Frameworks/PSMTabBar/PSMTabBarControl.m
parent389b86985d977f81f840112249da5e3e278921e2 (diff)
downloadsequelpro-09ed4be7e668dc10e0c4ca9178f8e1c414997b57.tar.gz
sequelpro-09ed4be7e668dc10e0c4ca9178f8e1c414997b57.tar.bz2
sequelpro-09ed4be7e668dc10e0c4ca9178f8e1c414997b57.zip
PSMTabBar improvements:
- Add a new -destroyAnimations method to the tab bar and call it when tearing down the parent SPWindowController; this prevents animations redrawing the document after window close, fixing a number of crashes. - Improve the logic for collapsing and uncollapsing the tab bar as tabs are added and removed, fixing height calculation errors leading to Issue #1082 - Improve tab bar draw when animating in the Sequel Pro tab style
Diffstat (limited to 'Frameworks/PSMTabBar/PSMTabBarControl.m')
-rw-r--r--Frameworks/PSMTabBar/PSMTabBarControl.m94
1 files changed, 40 insertions, 54 deletions
diff --git a/Frameworks/PSMTabBar/PSMTabBarControl.m b/Frameworks/PSMTabBar/PSMTabBarControl.m
index a38c50b0..416b10d8 100644
--- a/Frameworks/PSMTabBar/PSMTabBarControl.m
+++ b/Frameworks/PSMTabBar/PSMTabBarControl.m
@@ -202,17 +202,8 @@
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
-
- //stop any animations that may be running
- [_animationTimer invalidate];
- [_animationTimer release]; _animationTimer = nil;
-
- [_showHideAnimationTimer invalidate];
- [_showHideAnimationTimer release]; _showHideAnimationTimer = nil;
- //Also unwind the spring, if it's wound.
- [_springTimer invalidate];
- [_springTimer release]; _springTimer = nil;
+ [self destroyAnimations];
//unbind all the items to prevent crashing
//not sure if this is necessary or not
@@ -796,7 +787,7 @@
- (void)hideTabBar:(BOOL)hide animate:(BOOL)animate
{
- if (!_awakenedFromNib || (_isHidden && hide) || (!_isHidden && !hide) || (_currentStep != kPSMIsNotBeingResized)) {
+ if (!_awakenedFromNib || (_isHidden && hide) || (!_isHidden && !hide)) {
return;
}
@@ -830,55 +821,35 @@
partnerOriginalSize = [[self window] frame].size.height;
partnerOriginalOrigin = [[self window] frame].origin.y;
}
-
+
+ // Determine the target sizes
+ if (_isHidden) {
+ myTargetSize = kPSMTabBarControlHeightCollapsed;
+ } else {
+ myTargetSize = kPSMTabBarControlHeight;
+ }
+
if (partnerView) {
+ partnerTargetSize = partnerOriginalSize + myOriginalSize - myTargetSize;
+
// above or below me?
- if ((myOriginalOrigin - 22) > partnerOriginalOrigin) {
- // partner is below me
- if (_isHidden) {
- // I'm shrinking
- myTargetOrigin = myOriginalOrigin + 21;
- myTargetSize = myOriginalSize - 21;
- partnerTargetOrigin = partnerOriginalOrigin;
- partnerTargetSize = partnerOriginalSize + 21;
- } else {
- // I'm growing
- myTargetOrigin = myOriginalOrigin - 21;
- myTargetSize = myOriginalSize + 21;
- partnerTargetOrigin = partnerOriginalOrigin;
- partnerTargetSize = partnerOriginalSize - 21;
- }
+ if ((myOriginalOrigin - kPSMTabBarControlHeight) > partnerOriginalOrigin) {
+
+ // partner is below me, keeps its origin
+ partnerTargetOrigin = partnerOriginalOrigin;
+ myTargetOrigin = myOriginalOrigin + myOriginalSize - myTargetSize;
} else {
- // partner is above me
- if (_isHidden) {
- // I'm shrinking
- myTargetOrigin = myOriginalOrigin;
- myTargetSize = myOriginalSize - 21;
- partnerTargetOrigin = partnerOriginalOrigin - 21;
- partnerTargetSize = partnerOriginalSize + 21;
- } else {
- // I'm growing
- myTargetOrigin = myOriginalOrigin;
- myTargetSize = myOriginalSize + 21;
- partnerTargetOrigin = partnerOriginalOrigin + 21;
- partnerTargetSize = partnerOriginalSize - 21;
- }
+
+ // partner is above me, I keep my origin
+ myTargetOrigin = myOriginalOrigin;
+ partnerTargetOrigin = partnerOriginalOrigin + myOriginalSize - myTargetSize;
}
} else {
+
// for window movement
- if (_isHidden) {
- // I'm shrinking
- myTargetOrigin = myOriginalOrigin;
- myTargetSize = myOriginalSize - 21;
- partnerTargetOrigin = partnerOriginalOrigin + 21;
- partnerTargetSize = partnerOriginalSize - 21;
- } else {
- // I'm growing
- myTargetOrigin = myOriginalOrigin;
- myTargetSize = myOriginalSize + 21;
- partnerTargetOrigin = partnerOriginalOrigin - 21;
- partnerTargetSize = partnerOriginalSize + 21;
- }
+ myTargetOrigin = myOriginalOrigin;
+ partnerTargetOrigin = partnerOriginalOrigin + myOriginalSize - myTargetSize;
+ partnerTargetSize = partnerOriginalSize - myOriginalSize + myTargetSize;
}
} else /* vertical */ {
// current (original) values
@@ -1046,6 +1017,21 @@
partnerView = view;
}
+- (void)destroyAnimations
+{
+ // Stop any animations that may be running
+
+ [_animationTimer invalidate];
+ [_animationTimer release]; _animationTimer = nil;
+
+ [_showHideAnimationTimer invalidate];
+ [_showHideAnimationTimer release]; _showHideAnimationTimer = nil;
+
+ // Also unwind the spring, if it's wound.
+ [_springTimer invalidate];
+ [_springTimer release]; _springTimer = nil;
+}
+
#pragma mark -
#pragma mark Drawing