OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/cocoa/bookmark_bar_toolbar_view.h" | 5 #import "chrome/browser/cocoa/bookmark_bar_toolbar_view.h" |
6 | 6 |
7 #include "app/gfx/canvas_paint.h" | 7 #include "app/gfx/canvas_paint.h" |
8 #include "app/theme_provider.h" | 8 #include "app/theme_provider.h" |
9 #include "base/gfx/rect.h" | 9 #include "base/gfx/rect.h" |
10 #include "chrome/browser/browser_theme_provider.h" | 10 #include "chrome/browser/browser_theme_provider.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 - (void)drawRect:(NSRect)rect { | 29 - (void)drawRect:(NSRect)rect { |
30 if ([controller_ drawAsFloatingBar]) { | 30 if ([controller_ drawAsFloatingBar]) { |
31 [self drawRectAsFloating:rect]; | 31 [self drawRectAsFloating:rect]; |
32 } else { | 32 } else { |
33 NSPoint phase = [self gtm_themePatternPhase]; | 33 NSPoint phase = [self gtm_themePatternPhase]; |
34 [[NSGraphicsContext currentContext] setPatternPhase:phase]; | 34 [[NSGraphicsContext currentContext] setPatternPhase:phase]; |
35 [self drawBackground]; | 35 [self drawBackground]; |
36 } | 36 } |
37 } | 37 } |
38 | 38 |
39 - (void)layoutViews { | |
40 if ([controller_ drawAsFloatingBar]) { | |
41 // The internal bookmark bar should have padding to center it. | |
42 NSRect frame = [self frame]; | |
43 [buttonView_ setFrame: | |
44 NSMakeRect(bookmarks::kNTPBookmarkBarPadding, | |
45 bookmarks::kNTPBookmarkBarPadding, | |
46 NSWidth(frame) - | |
47 bookmarks::kNTPBookmarkBarPadding, | |
48 NSHeight(frame) - | |
49 bookmarks::kNTPBookmarkBarPadding)]; | |
50 } else { | |
51 // The frame of our child should be equal to our frame. | |
52 NSRect frame = [self frame]; | |
53 [buttonView_ setFrame:NSMakeRect(0, 0, NSWidth(frame), NSHeight(frame))]; | |
54 } | |
55 } | |
56 | |
57 - (void)drawRectAsFloating:(NSRect)rect { | 39 - (void)drawRectAsFloating:(NSRect)rect { |
58 NSRect bounds = [self bounds]; | 40 NSRect bounds = [self bounds]; |
59 | 41 |
60 ThemeProvider* themeProvider = [controller_ themeProvider]; | 42 ThemeProvider* themeProvider = [controller_ themeProvider]; |
61 if (!themeProvider) | 43 if (!themeProvider) |
62 return; | 44 return; |
63 | 45 |
64 NSGraphicsContext* theContext = [NSGraphicsContext currentContext]; | 46 NSGraphicsContext* theContext = [NSGraphicsContext currentContext]; |
65 [theContext saveGraphicsState]; | 47 [theContext saveGraphicsState]; |
66 | 48 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 NSColor* borderColor = | 84 NSColor* borderColor = |
103 [[self gtm_theme] strokeColorForStyle:GTMThemeStyleToolBar | 85 [[self gtm_theme] strokeColorForStyle:GTMThemeStyleToolBar |
104 state:GTMThemeStateActiveWindow]; | 86 state:GTMThemeStateActiveWindow]; |
105 [borderColor set]; | 87 [borderColor set]; |
106 [border stroke]; | 88 [border stroke]; |
107 | 89 |
108 [theContext restoreGraphicsState]; | 90 [theContext restoreGraphicsState]; |
109 } | 91 } |
110 | 92 |
111 @end // @implementation BookmarkBarToolbarView | 93 @end // @implementation BookmarkBarToolbarView |
OLD | NEW |