summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-22 02:21:59 +0000
committerdcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-22 02:21:59 +0000
commitc0e9e19f313f9bcf893fce686464f8bc2013cdf7 (patch)
treeec69c2524fc433d4373e5aebf8aa2b80ca4fa3fe
parent92b89c2b5f91bce6ce4987168f8b324fd018cd43 (diff)
downloadchromium_src-c0e9e19f313f9bcf893fce686464f8bc2013cdf7.zip
chromium_src-c0e9e19f313f9bcf893fce686464f8bc2013cdf7.tar.gz
chromium_src-c0e9e19f313f9bcf893fce686464f8bc2013cdf7.tar.bz2
Update Panel titlebar text and icon layout when resized on Mac.
BUG=100831 TEST=attached test case on bug Review URL: http://codereview.chromium.org/8365020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106839 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/panels/panel_browser_window_cocoa_unittest.mm14
-rw-r--r--chrome/browser/ui/panels/panel_titlebar_view_cocoa.h6
-rw-r--r--chrome/browser/ui/panels/panel_titlebar_view_cocoa.mm16
3 files changed, 30 insertions, 6 deletions
diff --git a/chrome/browser/ui/panels/panel_browser_window_cocoa_unittest.mm b/chrome/browser/ui/panels/panel_browser_window_cocoa_unittest.mm
index 9b4648d..7c38439 100644
--- a/chrome/browser/ui/panels/panel_browser_window_cocoa_unittest.mm
+++ b/chrome/browser/ui/panels/panel_browser_window_cocoa_unittest.mm
@@ -251,8 +251,11 @@ TEST_F(PanelBrowserWindowCocoaTest, TitlebarViewSizing) {
// content view of the window. They both use the same scale factor.
EXPECT_EQ(NSWidth([contentView bounds]), NSWidth([titlebar bounds]));
+ NSRect oldTitleFrame = [[titlebar title] frame];
+ NSRect oldIconFrame = [[titlebar icon] frame];
+
// Now resize the Panel, see that titlebar follows.
- const int kDelta = 153; // random number
+ const int kDelta = 153; // random number
gfx::Rect bounds = panel->GetBounds();
// Grow panel in a way so that its titlebar moves and grows.
bounds.set_x(bounds.x() - kDelta);
@@ -272,6 +275,15 @@ TEST_F(PanelBrowserWindowCocoaTest, TitlebarViewSizing) {
// Verify the titlebar is still on top of regular titlebar.
VerifyTitlebarLocation(contentView, titlebar);
+ // Verify that the title/icon frames were updated.
+ NSRect newTitleFrame = [[titlebar title] frame];
+ NSRect newIconFrame = [[titlebar icon] frame];
+
+ EXPECT_EQ(newTitleFrame.origin.x - newIconFrame.origin.x,
+ oldTitleFrame.origin.x - oldIconFrame.origin.x);
+ EXPECT_NE(newTitleFrame.origin.x, oldTitleFrame.origin.x);
+ EXPECT_NE(newIconFrame.origin.x, oldIconFrame.origin.x);
+
ClosePanelAndWait(panel->browser());
}
diff --git a/chrome/browser/ui/panels/panel_titlebar_view_cocoa.h b/chrome/browser/ui/panels/panel_titlebar_view_cocoa.h
index cb4011a..dc7c83d 100644
--- a/chrome/browser/ui/panels/panel_titlebar_view_cocoa.h
+++ b/chrome/browser/ui/panels/panel_titlebar_view_cocoa.h
@@ -69,8 +69,8 @@ enum PanelDragState {
- (void)updateCloseButtonLayout;
- (void)updateIconAndTitleLayout;
-// We need to update our look when the Chrome theme changes or window focus
-// changes.
+// Various events that we'll need to redraw our titlebar for.
+- (void)didChangeFrame:(NSNotification*)notification;
- (void)didChangeTheme:(NSNotification*)notification;
- (void)didChangeMainWindow:(NSNotification*)notification;
@@ -96,6 +96,8 @@ enum PanelDragState {
- (PanelWindowControllerCocoa*)controller;
+- (NSTextField*)title;
+
// Simulates click on a close button. Used to test panel closing.
- (void)simulateCloseButtonClick;
diff --git a/chrome/browser/ui/panels/panel_titlebar_view_cocoa.mm b/chrome/browser/ui/panels/panel_titlebar_view_cocoa.mm
index 8f572cc..293855b 100644
--- a/chrome/browser/ui/panels/panel_titlebar_view_cocoa.mm
+++ b/chrome/browser/ui/panels/panel_titlebar_view_cocoa.mm
@@ -194,7 +194,6 @@ static NSEvent* MakeMouseEvent(NSEventType type,
// Update layout of controls in the titlebar.
[self updateCloseButtonLayout];
- [self updateIconAndTitleLayout];
// Set autoresizing behavior: glued to edges on left, top and right.
[self setAutoresizingMask:(NSViewMinYMargin | NSViewWidthSizable)];
@@ -204,8 +203,11 @@ static NSEvent* MakeMouseEvent(NSEventType type,
selector:@selector(didChangeTheme:)
name:kBrowserThemeDidChangeNotification
object:nil];
- // Register for various window focus changes, so we can update our custom
- // titlebar appropriately.
+ [[NSNotificationCenter defaultCenter]
+ addObserver:self
+ selector:@selector(didChangeFrame:)
+ name:NSViewFrameDidChangeNotification
+ object:self];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(didChangeMainWindow:)
@@ -300,6 +302,10 @@ static NSEvent* MakeMouseEvent(NSEventType type,
[[closeButton_ cell] setHighlighted:NO];
}
+- (void)didChangeFrame:(NSNotification*)notification {
+ [self updateIconAndTitleLayout];
+}
+
- (void)didChangeTheme:(NSNotification*)notification {
[self setNeedsDisplay:YES];
}
@@ -411,6 +417,10 @@ static NSEvent* MakeMouseEvent(NSEventType type,
return controller_;
}
+- (NSTextField*)title {
+ return title_;
+}
+
- (void)simulateCloseButtonClick {
[[closeButton_ cell] performClick:closeButton_];
}