| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef CHROME_BROWSER_UI_COCOA_PASSWORDS_PASSWORDS_BUBBLE_UTILS_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_PASSWORDS_PASSWORDS_BUBBLE_UTILS_H_ |
| 6 #define CHROME_BROWSER_UI_COCOA_PASSWORDS_PASSWORDS_BUBBLE_UTILS_H_ | 6 #define CHROME_BROWSER_UI_COCOA_PASSWORDS_PASSWORDS_BUBBLE_UTILS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #import <Cocoa/Cocoa.h> | 10 #import <Cocoa/Cocoa.h> |
| 11 | 11 |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 #include "third_party/skia/include/core/SkColor.h" | 13 #include "third_party/skia/include/core/SkColor.h" |
| 14 #include "ui/gfx/range/range.h" | 14 #include "ui/gfx/range/range.h" |
| 15 | 15 |
| 16 @class HyperlinkTextView; | 16 @class HyperlinkTextView; |
| 17 | 17 |
| 18 constexpr CGFloat kDesiredBubbleWidth = 370; | 18 constexpr CGFloat kDesiredBubbleWidth = 370; |
| 19 constexpr CGFloat kFramePadding = 16; | 19 constexpr CGFloat kFramePadding = 16; |
| 20 constexpr CGFloat kDesiredRowWidth = kDesiredBubbleWidth - 2 * kFramePadding; | 20 constexpr CGFloat kDesiredRowWidth = kDesiredBubbleWidth - 2 * kFramePadding; |
| 21 constexpr CGFloat kItemLabelSpacing = 10; | 21 constexpr CGFloat kItemLabelSpacing = 10; |
| 22 constexpr CGFloat kMinUsernameSize = 50; |
| 22 constexpr CGFloat kRelatedControlHorizontalPadding = 2; | 23 constexpr CGFloat kRelatedControlHorizontalPadding = 2; |
| 23 constexpr CGFloat kRelatedControlVerticalSpacing = 8; | 24 constexpr CGFloat kRelatedControlVerticalSpacing = 8; |
| 24 constexpr CGFloat kTitleTextInset = 2; | 25 constexpr CGFloat kTitleTextInset = 2; |
| 25 constexpr CGFloat kUnrelatedControlVerticalPadding = 15; | 26 constexpr CGFloat kUnrelatedControlVerticalPadding = 15; |
| 26 constexpr CGFloat kVerticalAvatarMargin = 8; | 27 constexpr CGFloat kVerticalAvatarMargin = 8; |
| 27 | 28 |
| 28 // Returns a font for password bubbles. | 29 // Returns a font for password bubbles. |
| 29 NSFont* LabelFont(); | 30 NSFont* LabelFont(); |
| 30 | 31 |
| 31 // Returns a size of a text that is defined by |resourceID| with a font | 32 // Returns a size of a text that is defined by |resourceID| with a font |
| 32 // returned by LabelFont(). | 33 // returned by LabelFont(). |
| 33 NSSize LabelSize(int resourceID); | 34 NSSize LabelSize(int resourceID); |
| 34 | 35 |
| 35 // Initialize |textField| with |text| and default style parameters. | 36 // Initialize |textField| with |text| and default style parameters. |
| 36 void InitLabel(NSTextField* textField, const base::string16& text); | 37 void InitLabel(NSTextField* textField, const base::string16& text); |
| 37 | 38 |
| 38 // Returns widths of 2 columns, that are proportional to |columnsWidth| and | 39 // Returns widths of 2 columns, that are proportional to |columnsWidth| and |
| 39 // their total width is equal to |maxWidth|. | 40 // their total width is equal to |maxWidth|. The first column won't be shrunk to |
| 41 // less than |kMinUsernameSize|. |
| 40 std::pair<CGFloat, CGFloat> GetResizedColumns( | 42 std::pair<CGFloat, CGFloat> GetResizedColumns( |
| 41 CGFloat maxWidth, | 43 CGFloat maxWidth, |
| 42 std::pair<CGFloat, CGFloat> columnsWidth); | 44 std::pair<CGFloat, CGFloat> columnsWidth); |
| 43 | 45 |
| 44 // Returns a password text field initialized with |text|. | 46 // Returns a password text field initialized with |text|. |
| 45 NSSecureTextField* PasswordLabel(const base::string16& text); | 47 NSSecureTextField* PasswordLabel(const base::string16& text); |
| 46 | 48 |
| 47 // Returns a button of the standard style for the bubble. | 49 // Returns a button of the standard style for the bubble. |
| 48 NSButton* DialogButton(NSString* title); | 50 NSButton* DialogButton(NSString* title); |
| 49 | 51 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 64 id<NSTextViewDelegate> delegate); | 66 id<NSTextViewDelegate> delegate); |
| 65 | 67 |
| 66 // Returns a label with |text| and small font. Nonempty |range| may specify a | 68 // Returns a label with |text| and small font. Nonempty |range| may specify a |
| 67 // link range. | 69 // link range. |
| 68 HyperlinkTextView* LabelWithLink(const base::string16& text, | 70 HyperlinkTextView* LabelWithLink(const base::string16& text, |
| 69 SkColor color, | 71 SkColor color, |
| 70 gfx::Range range, | 72 gfx::Range range, |
| 71 id<NSTextViewDelegate> delegate); | 73 id<NSTextViewDelegate> delegate); |
| 72 | 74 |
| 73 #endif // CHROME_BROWSER_UI_COCOA_PASSWORDS_PASSWORDS_BUBBLE_UTILS_H_ | 75 #endif // CHROME_BROWSER_UI_COCOA_PASSWORDS_PASSWORDS_BUBBLE_UTILS_H_ |
| OLD | NEW |