| 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/device_chooser_content_view_cocoa.h" | 5 #import "chrome/browser/ui/cocoa/device_chooser_content_view_cocoa.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> |
| 8 | 9 |
| 9 #include "base/macros.h" | 10 #include "base/macros.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 11 #include "base/strings/sys_string_conversions.h" |
| 11 #include "chrome/browser/chooser_controller/chooser_controller.h" | 12 #include "chrome/browser/chooser_controller/chooser_controller.h" |
| 12 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h" | 13 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h" |
| 13 #include "chrome/browser/ui/cocoa/spinner_view.h" | 14 #include "chrome/browser/ui/cocoa/spinner_view.h" |
| 14 #include "chrome/grit/generated_resources.h" | 15 #include "chrome/grit/generated_resources.h" |
| 15 #include "skia/ext/skia_utils_mac.h" | 16 #include "skia/ext/skia_utils_mac.h" |
| 16 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw
eaker.h" | 17 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw
eaker.h" |
| 17 #import "ui/base/cocoa/controls/hyperlink_button_cell.h" | 18 #import "ui/base/cocoa/controls/hyperlink_button_cell.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 // Separator alpha value. | 54 // Separator alpha value. |
| 54 const CGFloat kSeparatorAlphaValue = 0.6f; | 55 const CGFloat kSeparatorAlphaValue = 0.6f; |
| 55 | 56 |
| 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 const CGFloat kAdapterOffHelpLinkPadding = 5.0f; | |
| 65 | |
| 66 // The lookup table for signal strength level image. | 64 // The lookup table for signal strength level image. |
| 67 const int kSignalStrengthLevelImageIds[5] = {IDR_SIGNAL_0_BAR, IDR_SIGNAL_1_BAR, | 65 const int kSignalStrengthLevelImageIds[5] = {IDR_SIGNAL_0_BAR, IDR_SIGNAL_1_BAR, |
| 68 IDR_SIGNAL_2_BAR, IDR_SIGNAL_3_BAR, | 66 IDR_SIGNAL_2_BAR, IDR_SIGNAL_3_BAR, |
| 69 IDR_SIGNAL_4_BAR}; | 67 IDR_SIGNAL_4_BAR}; |
| 70 const int kSignalStrengthLevelImageSelectedIds[5] = { | 68 const int kSignalStrengthLevelImageSelectedIds[5] = { |
| 71 IDR_SIGNAL_0_BAR_SELECTED, IDR_SIGNAL_1_BAR_SELECTED, | 69 IDR_SIGNAL_0_BAR_SELECTED, IDR_SIGNAL_1_BAR_SELECTED, |
| 72 IDR_SIGNAL_2_BAR_SELECTED, IDR_SIGNAL_3_BAR_SELECTED, | 70 IDR_SIGNAL_2_BAR_SELECTED, IDR_SIGNAL_3_BAR_SELECTED, |
| 73 IDR_SIGNAL_4_BAR_SELECTED}; | 71 IDR_SIGNAL_4_BAR_SELECTED}; |
| 74 | 72 |
| 75 // Creates a label with |text|. | 73 // Creates a label with |text|. |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 createHyperlinkButtonWithText: | 425 createHyperlinkButtonWithText: |
| 428 l10n_util::GetNSString( | 426 l10n_util::GetNSString( |
| 429 IDS_BLUETOOTH_DEVICE_CHOOSER_TURN_ON_BLUETOOTH_LINK_TEXT)]; | 427 IDS_BLUETOOTH_DEVICE_CHOOSER_TURN_ON_BLUETOOTH_LINK_TEXT)]; |
| 430 CGFloat adapterOffHelpButtonWidth = NSWidth([adapterOffHelpButton_ frame]); | 428 CGFloat adapterOffHelpButtonWidth = NSWidth([adapterOffHelpButton_ frame]); |
| 431 CGFloat adapterOffHelpButtonHeight = | 429 CGFloat adapterOffHelpButtonHeight = |
| 432 NSHeight([adapterOffHelpButton_ frame]); | 430 NSHeight([adapterOffHelpButton_ frame]); |
| 433 | 431 |
| 434 // Adapter turned off message. | 432 // Adapter turned off message. |
| 435 adapterOffMessage_ = CreateLabel(l10n_util::GetNSStringF( | 433 adapterOffMessage_ = CreateLabel(l10n_util::GetNSStringF( |
| 436 IDS_BLUETOOTH_DEVICE_CHOOSER_TURN_ADAPTER_OFF, base::string16())); | 434 IDS_BLUETOOTH_DEVICE_CHOOSER_TURN_ADAPTER_OFF, base::string16())); |
| 435 CGFloat adapterOffMessageWidth = NSWidth([adapterOffMessage_ frame]); |
| 437 | 436 |
| 438 // Connect button. | 437 // Connect button. |
| 439 connectButton_ = [self createConnectButton]; | 438 connectButton_ = [self createConnectButton]; |
| 440 CGFloat connectButtonWidth = NSWidth([connectButton_ frame]); | 439 CGFloat connectButtonWidth = NSWidth([connectButton_ frame]); |
| 441 CGFloat connectButtonHeight = NSHeight([connectButton_ frame]); | 440 CGFloat connectButtonHeight = NSHeight([connectButton_ frame]); |
| 442 | 441 |
| 443 // Cancel button. | 442 // Cancel button. |
| 444 cancelButton_ = [self createCancelButton]; | 443 cancelButton_ = [self createCancelButton]; |
| 445 CGFloat cancelButtonWidth = NSWidth([cancelButton_ frame]); | 444 CGFloat cancelButtonWidth = NSWidth([cancelButton_ frame]); |
| 446 | 445 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 kSpinnerSize)]); | 520 kSpinnerSize)]); |
| 522 | 521 |
| 523 // Lay out the views. | 522 // Lay out the views. |
| 524 // Title. | 523 // Title. |
| 525 CGFloat titleOriginX = kMarginX; | 524 CGFloat titleOriginX = kMarginX; |
| 526 CGFloat titleOriginY = kChooserHeight - kMarginY - titleHeight; | 525 CGFloat titleOriginY = kChooserHeight - kMarginY - titleHeight; |
| 527 [titleView_ setFrameOrigin:NSMakePoint(titleOriginX, titleOriginY)]; | 526 [titleView_ setFrameOrigin:NSMakePoint(titleOriginX, titleOriginY)]; |
| 528 [self addSubview:titleView_]; | 527 [self addSubview:titleView_]; |
| 529 | 528 |
| 530 // Adapter turned off help button. | 529 // Adapter turned off help button. |
| 531 CGFloat adapterOffHelpButtonOriginX = kMarginX + kAdapterOffHelpLinkPadding; | 530 CGFloat adapterOffHelpButtonOriginX = std::floor( |
| 532 CGFloat adapterOffHelpButtonOriginY = titleOriginY - kVerticalPadding - | 531 scrollViewOriginX + |
| 533 adapterOffHelpButtonHeight - | 532 (scrollViewWidth - adapterOffHelpButtonWidth - adapterOffMessageWidth) / |
| 534 kAdapterOffHelpLinkPadding; | 533 2); |
| 534 CGFloat adapterOffHelpButtonOriginY = |
| 535 std::floor(scrollViewOriginY + |
| 536 (scrollViewHeight - adapterOffHelpButtonHeight) / 2); |
| 535 [adapterOffHelpButton_ | 537 [adapterOffHelpButton_ |
| 536 setFrameOrigin:NSMakePoint(adapterOffHelpButtonOriginX, | 538 setFrameOrigin:NSMakePoint(adapterOffHelpButtonOriginX, |
| 537 adapterOffHelpButtonOriginY)]; | 539 adapterOffHelpButtonOriginY)]; |
| 538 [adapterOffHelpButton_ setTarget:self]; | 540 [adapterOffHelpButton_ setTarget:self]; |
| 539 [adapterOffHelpButton_ setAction:@selector(onAdapterOffHelp:)]; | 541 [adapterOffHelpButton_ setAction:@selector(onAdapterOffHelp:)]; |
| 540 [adapterOffHelpButton_ setHidden:YES]; | 542 [adapterOffHelpButton_ setHidden:YES]; |
| 541 [self addSubview:adapterOffHelpButton_]; | 543 [self addSubview:adapterOffHelpButton_]; |
| 542 | 544 |
| 543 // Adapter turned off message. | 545 // Adapter turned off message. |
| 544 CGFloat adapterOffMessageOriginX = adapterOffHelpButtonOriginX + | 546 CGFloat adapterOffMessageOriginX = adapterOffHelpButtonOriginX + |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 | 902 |
| 901 - (void)drawRect:(NSRect)rect { | 903 - (void)drawRect:(NSRect)rect { |
| 902 [[NSColor colorWithCalibratedWhite:245.0f / 255.0f alpha:1.0f] setFill]; | 904 [[NSColor colorWithCalibratedWhite:245.0f / 255.0f alpha:1.0f] setFill]; |
| 903 NSRect footnoteFrame = | 905 NSRect footnoteFrame = |
| 904 NSMakeRect(0.0f, 0.0f, kChooserWidth, separatorOriginY_); | 906 NSMakeRect(0.0f, 0.0f, kChooserWidth, separatorOriginY_); |
| 905 NSRectFill(footnoteFrame); | 907 NSRectFill(footnoteFrame); |
| 906 [super drawRect:footnoteFrame]; | 908 [super drawRect:footnoteFrame]; |
| 907 } | 909 } |
| 908 | 910 |
| 909 @end | 911 @end |
| OLD | NEW |