Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(872)

Unified Diff: chrome/browser/cocoa/tab_strip_controller.mm

Issue 159346: Live resize of tabs as the window resizes.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/cocoa/tab_strip_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/tab_strip_controller.mm
===================================================================
--- chrome/browser/cocoa/tab_strip_controller.mm (revision 21526)
+++ chrome/browser/cocoa/tab_strip_controller.mm (working copy)
@@ -66,10 +66,23 @@
initWithFrame:NSZeroRect]);
[view addSubview:dragBlockingView_];
newTabTargetFrame_ = NSMakeRect(0, 0, 0, 0);
+
+ // Watch for notifications that the tab strip view has changed size so
+ // we can tell it to layout for the new size.
+ [[NSNotificationCenter defaultCenter]
+ addObserver:self
+ selector:@selector(tabViewFrameChanged:)
+ name:NSViewFrameDidChangeNotification
+ object:tabView_];
}
return self;
}
+- (void)dealloc {
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+ [super dealloc];
+}
+
+ (CGFloat)defaultTabHeight {
return 24.0;
}
@@ -194,13 +207,13 @@
// Lay out all tabs in the order of their TabContentsControllers, which matches
// the ordering in the TabStripModel. This call isn't that expensive, though
// it is O(n) in the number of tabs. Tabs will animate to their new position
-// if the window is visible.
+// if the window is visible and |animate| is YES.
// TODO(pinkerton): Handle drag placeholders via proxy objects, perhaps a
// subclass of TabContentsController with everything stubbed out or by
// abstracting a base class interface.
// TODO(pinkerton): Note this doesn't do too well when the number of min-sized
// tabs would cause an overflow.
-- (void)layoutTabs {
+- (void)layoutTabsWithAnimation:(BOOL)animate {
const float kIndentLeavingSpaceForControls = 64.0;
const float kTabOverlap = 20.0;
const float kNewTabButtonOffset = 8.0;
@@ -252,7 +265,8 @@
tabFrame.origin.x = placeholderFrame_.origin.x;
// TODO(alcor): reenable this
//tabFrame.size.height += 10.0 * placeholderStretchiness_;
- [[[tab view] animator] setFrame:tabFrame];
+ id target = animate ? [[tab view] animator] : [tab view];
+ [target setFrame:tabFrame];
[NSAnimationContext endGrouping];
// Store the frame by identifier to aviod redundant calls to animator.
@@ -271,7 +285,7 @@
}
// Animate the tab in by putting it below the horizon.
- if (newTab && visible) {
+ if (newTab && visible && animate) {
[[tab view] setFrame:NSOffsetRect(tabFrame, 0, -NSHeight(tabFrame))];
}
@@ -282,7 +296,7 @@
baseTabWidth;
// Check the frame by identifier to avoid redundant calls to animator.
- id frameTarget = visible ? [[tab view] animator] : [tab view];
+ id frameTarget = visible && animate ? [[tab view] animator] : [tab view];
TVL 2009/07/24 16:27:03 line 268 this was "target", here it's "frameTarget
NSValue *identifier = [NSValue valueWithPointer:[tab view]];
NSValue *oldTargetValue = [targetFrames_ objectForKey:identifier];
if (!oldTargetValue ||
@@ -317,7 +331,8 @@
newTabNewFrame.origin.x = MAX(newTabNewFrame.origin.x,
NSMaxX(placeholderFrame_));
if (i > 0 && [newTabButton_ isHidden]) {
- [[newTabButton_ animator] setHidden:NO];
+ id target = animate ? [newTabButton_ animator] : newTabButton_;
+ [target setHidden:NO];
}
if (!NSEqualRects(newTabTargetFrame_, newTabNewFrame)) {
@@ -330,6 +345,11 @@
[dragBlockingView_ setFrame:enclosingRect];
}
+// When we're told to layout from the public API we always want to animate.
+- (void)layoutTabs {
+ [self layoutTabsWithAnimation:YES];
+}
+
// Handles setting the title of the tab based on the given |contents|. Uses
// a canned string if |contents| is NULL.
- (void)setTabTitle:(NSViewController*)tab withContents:(TabContents*)contents {
@@ -626,4 +646,12 @@
}
}
+// Called when the tab strip view changes size. As we only registered for
+// changes on our view, we know it's only for our view. Layout w/out
+// animations since they are blocked by the resize nested runloop. We need
+// the views to adjust immediately.
+- (void)tabViewFrameChanged:(NSNotification*)info {
+ [self layoutTabsWithAnimation:NO];
+}
+
@end
« no previous file with comments | « chrome/browser/cocoa/tab_strip_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698