OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 | 6 |
7 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" | 7 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" |
8 | 8 |
9 #include "base/mac/bundle_locations.h" | 9 #include "base/mac/bundle_locations.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 #import "ui/base/cocoa/cocoa_base_utils.h" | 53 #import "ui/base/cocoa/cocoa_base_utils.h" |
54 #import "ui/base/cocoa/controls/blue_label_button.h" | 54 #import "ui/base/cocoa/controls/blue_label_button.h" |
55 #import "ui/base/cocoa/controls/hyperlink_button_cell.h" | 55 #import "ui/base/cocoa/controls/hyperlink_button_cell.h" |
56 #import "ui/base/cocoa/hover_image_button.h" | 56 #import "ui/base/cocoa/hover_image_button.h" |
57 #include "ui/base/cocoa/window_size_constants.h" | 57 #include "ui/base/cocoa/window_size_constants.h" |
58 #include "ui/base/l10n/l10n_util.h" | 58 #include "ui/base/l10n/l10n_util.h" |
59 #include "ui/base/l10n/l10n_util_mac.h" | 59 #include "ui/base/l10n/l10n_util_mac.h" |
60 #include "ui/base/resource/resource_bundle.h" | 60 #include "ui/base/resource/resource_bundle.h" |
61 #include "ui/gfx/image/image.h" | 61 #include "ui/gfx/image/image.h" |
62 #include "ui/gfx/text_elider.h" | 62 #include "ui/gfx/text_elider.h" |
63 #include "ui/native_theme/common_theme.h" | |
63 #include "ui/native_theme/native_theme.h" | 64 #include "ui/native_theme/native_theme.h" |
64 | 65 |
65 namespace { | 66 namespace { |
66 | 67 |
67 // Constants taken from the Windows/Views implementation at: | 68 // Constants taken from the Windows/Views implementation at: |
68 // chrome/browser/ui/views/profile_chooser_view.cc | 69 // chrome/browser/ui/views/profile_chooser_view.cc |
69 const int kLargeImageSide = 88; | 70 const int kLargeImageSide = 88; |
70 const int kSmallImageSide = 32; | 71 const int kSmallImageSide = 32; |
71 const CGFloat kFixedMenuWidth = 250; | 72 const CGFloat kFixedMenuWidth = 250; |
72 | 73 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 frame.origin = frame_origin; | 178 frame.origin = frame_origin; |
178 [text_view setFrame:frame]; | 179 [text_view setFrame:frame]; |
179 [text_view setDelegate:delegate]; | 180 [text_view setDelegate:delegate]; |
180 return text_view.autorelease(); | 181 return text_view.autorelease(); |
181 } | 182 } |
182 | 183 |
183 // Returns the native dialog background color. | 184 // Returns the native dialog background color. |
184 NSColor* GetDialogBackgroundColor() { | 185 NSColor* GetDialogBackgroundColor() { |
185 return gfx::SkColorToCalibratedNSColor( | 186 return gfx::SkColorToCalibratedNSColor( |
186 ui::NativeTheme::instance()->GetSystemColor( | 187 ui::NativeTheme::instance()->GetSystemColor( |
187 ui::NativeTheme::kColorId_DialogBackground)); | 188 ui::NativeTheme::kColorId_DialogBackground)); |
tapted
2014/08/04 03:11:47
note, I might be looking to change this later too.
groby-ooo-7-16
2014/08/06 00:05:25
It'd be nice if the theme called out a color id fo
tapted
2014/08/06 01:49:08
Maybe a separate colors for NSAlert-style dialog b
groby-ooo-7-16
2014/08/07 00:37:09
I <3 yaks! ;)
In that vein - maybe there should b
| |
188 } | 189 } |
189 | 190 |
190 // Builds a title card with one back button right aligned and one label center | 191 // Builds a title card with one back button right aligned and one label center |
191 // aligned. | 192 // aligned. |
192 NSView* BuildTitleCard(NSRect frame_rect, | 193 NSView* BuildTitleCard(NSRect frame_rect, |
193 int message_id, | 194 int message_id, |
194 id back_button_target, | 195 id back_button_target, |
195 SEL back_button_action) { | 196 SEL back_button_action) { |
196 base::scoped_nsobject<NSView> container( | 197 base::scoped_nsobject<NSView> container( |
197 [[NSView alloc] initWithFrame:frame_rect]); | 198 [[NSView alloc] initWithFrame:frame_rect]); |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
635 } | 636 } |
636 @end | 637 @end |
637 | 638 |
638 @implementation BackgroundColorHoverButton | 639 @implementation BackgroundColorHoverButton |
639 | 640 |
640 - (id)initWithFrame:(NSRect)frameRect | 641 - (id)initWithFrame:(NSRect)frameRect |
641 imageTitleSpacing:(int)imageTitleSpacing | 642 imageTitleSpacing:(int)imageTitleSpacing |
642 backgroundColor:(NSColor*)backgroundColor { | 643 backgroundColor:(NSColor*)backgroundColor { |
643 if ((self = [super initWithFrame:frameRect])) { | 644 if ((self = [super initWithFrame:frameRect])) { |
644 backgroundColor_.reset([backgroundColor retain]); | 645 backgroundColor_.reset([backgroundColor retain]); |
645 hoverColor_.reset([gfx::SkColorToCalibratedNSColor( | 646 // Use a color from the common theme, since this button is not trying to |
646 ui::NativeTheme::instance()->GetSystemColor( | 647 // look like a native control. |
647 ui::NativeTheme::kColorId_ButtonHoverBackgroundColor)) retain]); | 648 SkColor hoverColor; |
649 bool found = ui::CommonThemeGetSystemColor( | |
650 ui::NativeTheme::kColorId_ButtonHoverBackgroundColor, &hoverColor); | |
groby-ooo-7-16
2014/08/06 00:05:25
I wish CommonTheme followed the NativeTheme API an
tapted
2014/08/06 01:49:09
Yeah :/ - I think it's to avoid something special
| |
651 DCHECK(found); | |
652 hoverColor_.reset([gfx::SkColorToSRGBNSColor(hoverColor) retain]); | |
tapted
2014/08/04 03:11:47
Note it's using sRGB rather than "Calibrated" here
groby-ooo-7-16
2014/08/06 00:05:24
+1 on fixing the color space. (I believe I suggest
tapted
2014/08/06 01:49:09
Good idea - I think something like https://coderev
| |
648 | 653 |
649 [self setBordered:NO]; | 654 [self setBordered:NO]; |
650 [self setFont:[NSFont labelFontOfSize:kTextFontSize]]; | 655 [self setFont:[NSFont labelFontOfSize:kTextFontSize]]; |
651 [self setButtonType:NSMomentaryChangeButton]; | 656 [self setButtonType:NSMomentaryChangeButton]; |
652 | 657 |
653 base::scoped_nsobject<CustomPaddingImageButtonCell> cell( | 658 base::scoped_nsobject<CustomPaddingImageButtonCell> cell( |
654 [[CustomPaddingImageButtonCell alloc] | 659 [[CustomPaddingImageButtonCell alloc] |
655 initWithLeftMarginSpacing:kHorizontalSpacing | 660 initWithLeftMarginSpacing:kHorizontalSpacing |
656 imageTitleSpacing:imageTitleSpacing]); | 661 imageTitleSpacing:imageTitleSpacing]); |
657 [cell setLineBreakMode:NSLineBreakByTruncatingTail]; | 662 [cell setLineBreakMode:NSLineBreakByTruncatingTail]; |
(...skipping 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1891 | 1896 |
1892 return button.autorelease(); | 1897 return button.autorelease(); |
1893 } | 1898 } |
1894 | 1899 |
1895 - (void)postActionPerformed:(ProfileMetrics::ProfileDesktopMenu)action { | 1900 - (void)postActionPerformed:(ProfileMetrics::ProfileDesktopMenu)action { |
1896 ProfileMetrics::LogProfileDesktopMenu(action, serviceType_); | 1901 ProfileMetrics::LogProfileDesktopMenu(action, serviceType_); |
1897 serviceType_ = signin::GAIA_SERVICE_TYPE_NONE; | 1902 serviceType_ = signin::GAIA_SERVICE_TYPE_NONE; |
1898 } | 1903 } |
1899 | 1904 |
1900 @end | 1905 @end |
OLD | NEW |