| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "chrome/browser/ui/cocoa/framed_browser_window.h" | 5 #import "chrome/browser/ui/cocoa/framed_browser_window.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/mac/sdk_forward_declarations.h" | 8 #include "base/mac/sdk_forward_declarations.h" |
| 9 #include "chrome/browser/global_keyboard_shortcuts_mac.h" | 9 #include "chrome/browser/global_keyboard_shortcuts_mac.h" |
| 10 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 10 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 const CGFloat kBrowserFrameViewPaintHeight = 60.0; | 31 const CGFloat kBrowserFrameViewPaintHeight = 60.0; |
| 32 | 32 |
| 33 // Size of the gradient. Empirically determined so that the gradient looks | 33 // Size of the gradient. Empirically determined so that the gradient looks |
| 34 // like what the heuristic does when there are just a few tabs. | 34 // like what the heuristic does when there are just a few tabs. |
| 35 const CGFloat kWindowGradientHeight = 24.0; | 35 const CGFloat kWindowGradientHeight = 24.0; |
| 36 | 36 |
| 37 } | 37 } |
| 38 | 38 |
| 39 @interface FramedBrowserWindow (Private) | 39 @interface FramedBrowserWindow () |
| 40 | 40 |
| 41 - (void)adjustCloseButton:(NSNotification*)notification; | 41 - (void)adjustCloseButton:(NSNotification*)notification; |
| 42 - (void)adjustMiniaturizeButton:(NSNotification*)notification; | 42 - (void)adjustMiniaturizeButton:(NSNotification*)notification; |
| 43 - (void)adjustZoomButton:(NSNotification*)notification; | 43 - (void)adjustZoomButton:(NSNotification*)notification; |
| 44 - (void)adjustButton:(NSButton*)button | 44 - (void)adjustButton:(NSButton*)button |
| 45 ofKind:(NSWindowButton)kind; | 45 ofKind:(NSWindowButton)kind; |
| 46 - (NSView*)frameView; | 46 - (NSView*)frameView; |
| 47 | 47 |
| 48 @end | 48 @end |
| 49 | 49 |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 eventHandled = YES; | 245 eventHandled = YES; |
| 246 } | 246 } |
| 247 } | 247 } |
| 248 } | 248 } |
| 249 if (!eventHandled) { | 249 if (!eventHandled) { |
| 250 [super sendEvent:event]; | 250 [super sendEvent:event]; |
| 251 } | 251 } |
| 252 } | 252 } |
| 253 | 253 |
| 254 - (void)setShouldHideTitle:(BOOL)flag { | 254 - (void)setShouldHideTitle:(BOOL)flag { |
| 255 shouldHideTitle_ = flag; | 255 if ([self respondsToSelector:@selector(setTitleVisibility:)]) |
| 256 self.titleVisibility = flag ? NSWindowTitleHidden : NSWindowTitleVisible; |
| 257 else |
| 258 shouldHideTitle_ = flag; |
| 256 } | 259 } |
| 257 | 260 |
| 258 - (BOOL)_isTitleHidden { | 261 - (BOOL)_isTitleHidden { |
| 259 return shouldHideTitle_; | 262 // Only intervene with 10.6-10.9. |
| 263 if ([self respondsToSelector:@selector(setTitleVisibility:)]) |
| 264 return [super _isTitleHidden]; |
| 265 else |
| 266 return shouldHideTitle_; |
| 260 } | 267 } |
| 261 | 268 |
| 262 - (CGFloat)windowButtonsInterButtonSpacing { | 269 - (CGFloat)windowButtonsInterButtonSpacing { |
| 263 return windowButtonsInterButtonSpacing_; | 270 return windowButtonsInterButtonSpacing_; |
| 264 } | 271 } |
| 265 | 272 |
| 266 // This method is called whenever a window is moved in order to ensure it fits | 273 // This method is called whenever a window is moved in order to ensure it fits |
| 267 // on the screen. We cannot always handle resizes without breaking, so we | 274 // on the screen. We cannot always handle resizes without breaking, so we |
| 268 // prevent frame constraining in those cases. | 275 // prevent frame constraining in those cases. |
| 269 - (NSRect)constrainFrameRect:(NSRect)frame toScreen:(NSScreen*)screen { | 276 - (NSRect)constrainFrameRect:(NSRect)frame toScreen:(NSScreen*)screen { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 yRadius:cornerRadius] addClip]; | 349 yRadius:cornerRadius] addClip]; |
| 343 [[NSBezierPath bezierPathWithRect:rect] addClip]; | 350 [[NSBezierPath bezierPathWithRect:rect] addClip]; |
| 344 | 351 |
| 345 // Do the theming. | 352 // Do the theming. |
| 346 BOOL themed = [FramedBrowserWindow | 353 BOOL themed = [FramedBrowserWindow |
| 347 drawWindowThemeInDirtyRect:rect | 354 drawWindowThemeInDirtyRect:rect |
| 348 forView:view | 355 forView:view |
| 349 bounds:windowRect | 356 bounds:windowRect |
| 350 forceBlackBackground:NO]; | 357 forceBlackBackground:NO]; |
| 351 | 358 |
| 352 // If the window needs a title and we painted over the title as drawn by the | 359 // In Yosemite: The title is drawn by a subview and not painted on. Therefore, |
| 353 // default window paint, paint it ourselves. | 360 // never worry about drawing it. Pre-Yosemite: If the window needs a title and |
| 354 if (themed && [view respondsToSelector:@selector(_titlebarTitleRect)] && | 361 // we painted over the title as drawn by the default window paint, paint it |
| 362 // ourselves. |
| 363 if (![self respondsToSelector:@selector(setTitleVisibility:)] && |
| 364 themed && [view respondsToSelector:@selector(_titlebarTitleRect)] && |
| 355 [view respondsToSelector:@selector(_drawTitleStringIn:withColor:)] && | 365 [view respondsToSelector:@selector(_drawTitleStringIn:withColor:)] && |
| 356 ![self _isTitleHidden]) { | 366 ![self _isTitleHidden]) { |
| 357 [view _drawTitleStringIn:[view _titlebarTitleRect] | 367 [view _drawTitleStringIn:[view _titlebarTitleRect] |
| 358 withColor:[self titleColor]]; | 368 withColor:[self titleColor]]; |
| 359 } | 369 } |
| 360 | 370 |
| 361 // Pinstripe the top. | 371 // Pinstripe the top. |
| 362 if (themed) { | 372 if (themed) { |
| 363 CGFloat lineWidth = [view cr_lineWidth]; | 373 CGFloat lineWidth = [view cr_lineWidth]; |
| 364 | 374 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 ThemedWindowStyle windowStyle = [self themedWindowStyle]; | 497 ThemedWindowStyle windowStyle = [self themedWindowStyle]; |
| 488 BOOL incognito = windowStyle & THEMED_INCOGNITO; | 498 BOOL incognito = windowStyle & THEMED_INCOGNITO; |
| 489 | 499 |
| 490 if (incognito) | 500 if (incognito) |
| 491 return [NSColor whiteColor]; | 501 return [NSColor whiteColor]; |
| 492 else | 502 else |
| 493 return [NSColor windowFrameTextColor]; | 503 return [NSColor windowFrameTextColor]; |
| 494 } | 504 } |
| 495 | 505 |
| 496 @end | 506 @end |
| OLD | NEW |