Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/chooser_content_view_cocoa.h" | 5 #import "chrome/browser/ui/cocoa/chooser_content_view_cocoa.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| 11 #include "chrome/browser/chooser_controller/chooser_controller.h" | 11 #include "chrome/browser/chooser_controller/chooser_controller.h" |
| 12 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h" | 12 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h" |
| 13 #include "chrome/browser/ui/cocoa/spinner_view.h" | 13 #include "chrome/browser/ui/cocoa/spinner_view.h" |
| 14 #include "chrome/grit/generated_resources.h" | 14 #include "chrome/grit/generated_resources.h" |
| 15 #include "skia/ext/skia_utils_mac.h" | 15 #include "skia/ext/skia_utils_mac.h" |
| 16 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw eaker.h" | 16 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw eaker.h" |
| 17 #include "third_party/skia/include/core/SkColor.h" | |
| 17 #import "ui/base/cocoa/controls/hyperlink_button_cell.h" | 18 #import "ui/base/cocoa/controls/hyperlink_button_cell.h" |
| 18 #include "ui/base/l10n/l10n_util_mac.h" | 19 #include "ui/base/l10n/l10n_util_mac.h" |
| 19 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
| 20 #include "ui/gfx/color_palette.h" | 21 #include "ui/gfx/color_palette.h" |
| 21 #include "ui/gfx/image/image_skia_util_mac.h" | 22 #include "ui/gfx/image/image_skia_util_mac.h" |
| 22 #include "ui/gfx/paint_vector_icon.h" | 23 #include "ui/gfx/paint_vector_icon.h" |
| 23 #include "ui/gfx/vector_icons_public.h" | 24 #include "ui/gfx/vector_icons_public.h" |
| 24 #include "ui/resources/grit/ui_resources.h" | 25 #include "ui/resources/grit/ui_resources.h" |
| 25 | 26 |
| 26 namespace { | 27 namespace { |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 56 // Separator height. | 57 // Separator height. |
| 57 const CGFloat kSeparatorHeight = 1.0f; | 58 const CGFloat kSeparatorHeight = 1.0f; |
| 58 | 59 |
| 59 // Distance between two views inside the table row view. | 60 // Distance between two views inside the table row view. |
| 60 const CGFloat kTableRowViewHorizontalPadding = 5.0f; | 61 const CGFloat kTableRowViewHorizontalPadding = 5.0f; |
| 61 const CGFloat kTableRowViewVerticalPadding = 1.0f; | 62 const CGFloat kTableRowViewVerticalPadding = 1.0f; |
| 62 | 63 |
| 63 // Distance between the adapter off help link and the scroll view boundaries. | 64 // Distance between the adapter off help link and the scroll view boundaries. |
| 64 const CGFloat kAdapterOffHelpLinkPadding = 5.0f; | 65 const CGFloat kAdapterOffHelpLinkPadding = 5.0f; |
| 65 | 66 |
| 67 // Background color of the footnote view. | |
| 68 const SkColor kFootnoteBackgroundColor = SkColorSetRGB(245, 245, 245); | |
| 69 | |
| 66 // The lookup table for signal strength level image. | 70 // The lookup table for signal strength level image. |
| 67 const int kSignalStrengthLevelImageIds[5] = {IDR_SIGNAL_0_BAR, IDR_SIGNAL_1_BAR, | 71 const int kSignalStrengthLevelImageIds[5] = {IDR_SIGNAL_0_BAR, IDR_SIGNAL_1_BAR, |
| 68 IDR_SIGNAL_2_BAR, IDR_SIGNAL_3_BAR, | 72 IDR_SIGNAL_2_BAR, IDR_SIGNAL_3_BAR, |
| 69 IDR_SIGNAL_4_BAR}; | 73 IDR_SIGNAL_4_BAR}; |
| 70 const int kSignalStrengthLevelImageSelectedIds[5] = { | 74 const int kSignalStrengthLevelImageSelectedIds[5] = { |
| 71 IDR_SIGNAL_0_BAR_SELECTED, IDR_SIGNAL_1_BAR_SELECTED, | 75 IDR_SIGNAL_0_BAR_SELECTED, IDR_SIGNAL_1_BAR_SELECTED, |
| 72 IDR_SIGNAL_2_BAR_SELECTED, IDR_SIGNAL_3_BAR_SELECTED, | 76 IDR_SIGNAL_2_BAR_SELECTED, IDR_SIGNAL_3_BAR_SELECTED, |
| 73 IDR_SIGNAL_4_BAR_SELECTED}; | 77 IDR_SIGNAL_4_BAR_SELECTED}; |
| 74 | 78 |
| 75 // Creates a label with |text|. | 79 // Creates a label with |text|. |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 560 | 564 |
| 561 // Cancel button. | 565 // Cancel button. |
| 562 CGFloat cancelButtonOriginX = kChooserWidth - kMarginX - cancelButtonWidth; | 566 CGFloat cancelButtonOriginX = kChooserWidth - kMarginX - cancelButtonWidth; |
| 563 CGFloat cancelButtonOriginY = connectButtonOriginY; | 567 CGFloat cancelButtonOriginY = connectButtonOriginY; |
| 564 [cancelButton_ | 568 [cancelButton_ |
| 565 setFrameOrigin:NSMakePoint(cancelButtonOriginX, cancelButtonOriginY)]; | 569 setFrameOrigin:NSMakePoint(cancelButtonOriginX, cancelButtonOriginY)]; |
| 566 [self addSubview:cancelButton_]; | 570 [self addSubview:cancelButton_]; |
| 567 | 571 |
| 568 // Separator. | 572 // Separator. |
| 569 CGFloat separatorOriginX = 0.0f; | 573 CGFloat separatorOriginX = 0.0f; |
| 570 CGFloat separatorOriginY = kMarginY + helpButtonHeight + kVerticalPadding; | 574 separatorOriginY_ = kMarginY + helpButtonHeight + kVerticalPadding; |
| 571 [separator_ setFrameOrigin:NSMakePoint(separatorOriginX, separatorOriginY)]; | 575 [separator_ |
| 576 setFrameOrigin:NSMakePoint(separatorOriginX, separatorOriginY_)]; | |
| 572 [self addSubview:separator_]; | 577 [self addSubview:separator_]; |
| 573 | 578 |
| 574 // Help button. | 579 // Help button. |
| 575 CGFloat helpButtonOriginX = kMarginX; | 580 CGFloat helpButtonOriginX = kMarginX; |
| 576 CGFloat helpButtonOriginY = (kVerticalPadding + kMarginY) / 2; | 581 CGFloat helpButtonOriginY = (kVerticalPadding + kMarginY) / 2; |
| 577 [helpButton_ | 582 [helpButton_ |
| 578 setFrameOrigin:NSMakePoint(helpButtonOriginX, helpButtonOriginY)]; | 583 setFrameOrigin:NSMakePoint(helpButtonOriginX, helpButtonOriginY)]; |
| 579 [helpButton_ setTarget:self]; | 584 [helpButton_ setTarget:self]; |
| 580 [helpButton_ setAction:@selector(onHelpPressed:)]; | 585 [helpButton_ setAction:@selector(onHelpPressed:)]; |
| 581 [self addSubview:helpButton_]; | 586 [self addSubview:helpButton_]; |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 871 [tableView_ viewAtColumn:0 row:row makeIfNecessary:YES]; | 876 [tableView_ viewAtColumn:0 row:row makeIfNecessary:YES]; |
| 872 return [tableRowView text]; | 877 return [tableRowView text]; |
| 873 } | 878 } |
| 874 | 879 |
| 875 - (NSTextField*)tableRowViewPairedStatus:(NSInteger)row { | 880 - (NSTextField*)tableRowViewPairedStatus:(NSInteger)row { |
| 876 ChooserContentTableRowView* tableRowView = | 881 ChooserContentTableRowView* tableRowView = |
| 877 [tableView_ viewAtColumn:0 row:row makeIfNecessary:YES]; | 882 [tableView_ viewAtColumn:0 row:row makeIfNecessary:YES]; |
| 878 return [tableRowView pairedStatus]; | 883 return [tableRowView pairedStatus]; |
| 879 } | 884 } |
| 880 | 885 |
| 886 - (void)drawRect:(NSRect)rect { | |
| 887 [skia::SkColorToCalibratedNSColor(kFootnoteBackgroundColor) setFill]; | |
|
Robert Sesek
2016/11/10 22:01:08
I'd use +[NSColor colorWithCalibratedWhite:245.0 /
juncai
2016/11/11 01:46:33
Done.
| |
| 888 NSRect footnoteFrame = NSMakeRect(0, 0, kChooserWidth, separatorOriginY_); | |
| 889 NSRectFill(footnoteFrame); | |
| 890 [super drawRect:footnoteFrame]; | |
| 891 } | |
| 892 | |
| 881 @end | 893 @end |
| OLD | NEW |