Commit 038300d6 authored by Oscar Johansson's avatar Oscar Johansson Committed by Commit Bot

Make variable names unique (mac)

When building using jumbo, files gets merged and
variables with the same name may end up in the same
scope. This commit renames such varaibles to something
more descriptive or file specific.

Bug: 803406
Change-Id: Ia43af0d95b0693ce917722397bc23db655441c29
Reviewed-on: https://chromium-review.googlesource.com/1141579Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Oscar Johansson <oscarj@opera.com>
Cr-Commit-Position: refs/heads/master@{#576139}
parent f998ad7f
......@@ -58,7 +58,7 @@ CGFloat kTooltipInset = 10;
hints:nil];
}
- (void)setHoverState:(HoverState)state {
- (void)setHoverState:(CloseButtonHoverState)state {
[super setHoverState:state];
[tooltipController_ updateTooltipDisplayState];
}
......
......@@ -32,7 +32,7 @@
// |hoverButton_| using this state information. This serialization is to
// avoid race conditions where one hover button is being opened while another
// is closing.
enum HoverState {
enum BookmarkBarButtonHoverState {
kHoverStateClosed = 0,
kHoverStateOpening = 1,
kHoverStateOpen = 2,
......@@ -47,7 +47,7 @@
// We model hover state as a state machine with specific allowable
// transitions. |hoverState_| is the state of this machine at any
// given time.
HoverState hoverState_;
BookmarkBarButtonHoverState hoverState_;
}
// Designated initializer.
......@@ -77,7 +77,7 @@
@interface BookmarkBarFolderHoverState(TestingAPI)
// Accessors and setters for button and hover state.
- (BookmarkButton*)hoverButton;
- (HoverState)hoverState;
- (BookmarkBarButtonHoverState)hoverState;
@end
#endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BAR_FOLDER_HOVER_STATE_H_
......@@ -7,7 +7,7 @@
#import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h"
@interface BookmarkBarFolderHoverState(Private)
- (void)setHoverState:(HoverState)state;
- (void)setHoverState:(BookmarkBarButtonHoverState)state;
- (void)closeBookmarkFolderOnHoverButton:(BookmarkButton*)button;
- (void)openBookmarkFolderOnHoverButton:(BookmarkButton*)button;
@end
......@@ -129,7 +129,7 @@
}
// Hover state accessor. For testing only.
- (HoverState)hoverState {
- (BookmarkBarButtonHoverState)hoverState {
return hoverState_;
}
......@@ -139,7 +139,7 @@
// pending open must complete before scheduling a close, and vice versa. And
// it is not possible to make a transition directly from open to closed, and
// vice versa.
- (void)setHoverState:(HoverState)state {
- (void)setHoverState:(BookmarkBarButtonHoverState)state {
DCHECK(
(hoverState_ == kHoverStateClosed && state == kHoverStateOpening) ||
(hoverState_ == kHoverStateOpening && state == kHoverStateClosed) ||
......
......@@ -19,7 +19,7 @@ class BookmarkBarFolderHoverStateTest : public CocoaTest {
// Hover state machine interface.
// A strict call order is implied with these calls. It is ONLY valid to make
// these specific state transitions.
TEST_F(BookmarkBarFolderHoverStateTest, HoverState) {
TEST_F(BookmarkBarFolderHoverStateTest, BookmarkBarButtonHoverState) {
base::MessageLoopForUI message_loop;
base::scoped_nsobject<BookmarkBarFolderHoverState> bbfhs;
bbfhs.reset([[BookmarkBarFolderHoverState alloc] init]);
......
......@@ -30,7 +30,7 @@ NSString* const kBrowserActionsContainerKeyEventKey =
@"BrowserActionsContainerKeyEventKey";
namespace {
const CGFloat kAnimationDuration = 0.2;
const CGFloat kBrowserActionsResizeAnimationDuration = 0.2;
const CGFloat kGrippyWidth = 3.0;
} // namespace
......@@ -59,7 +59,7 @@ const CGFloat kGrippyWidth = 3.0;
resizable_ = YES;
resizeAnimation_.reset([[NSViewAnimation alloc] init]);
[resizeAnimation_ setDuration:kAnimationDuration];
[resizeAnimation_ setDuration:kBrowserActionsResizeAnimationDuration];
[resizeAnimation_ setAnimationBlockingMode:NSAnimationNonblocking];
[resizeAnimation_ setDelegate:self];
......
......@@ -37,7 +37,7 @@ using extensions::ExtensionViewHost;
namespace {
// The duration for any animations that might be invoked by this controller.
const NSTimeInterval kAnimationDuration = 0.2;
const NSTimeInterval kPopupAnimationDuration = 0.2;
// There should only be one extension popup showing at one time. Keep a
// reference to it here.
......@@ -378,7 +378,7 @@ class ExtensionPopupNotificationBridge :
([animator alphaValue] != targetAlpha ||
!NSEqualRects([window frame], [animator frame]))) {
[NSAnimationContext beginGrouping];
[[NSAnimationContext currentContext] setDuration:kAnimationDuration];
[[NSAnimationContext currentContext] setDuration:kPopupAnimationDuration];
[animator setAlphaValue:targetAlpha];
[animator setFrame:frame display:YES];
[NSAnimationContext endGrouping];
......
......@@ -10,7 +10,7 @@
#import "ui/base/cocoa/menu_controller.h"
#include "ui/base/resource/resource_bundle.h"
const CGFloat kCheckboxMargin = 10;
const CGFloat kGalleryEntryCheckboxMargin = 10;
ui::MenuModel* MediaGalleryListEntryController::GetContextMenu(
MediaGalleryPrefId pref_id) {
......@@ -147,13 +147,13 @@ ui::MenuModel* MediaGalleryListEntryController::GetContextMenu(
[details_ sizeToFit];
// Auto size everything and lay it out horizontally.
CGFloat xPos = kCheckboxMargin;
CGFloat xPos = kGalleryEntryCheckboxMargin;
for (NSView* view in [self subviews]) {
NSRect viewFrame = [view frame];
viewFrame.origin.x = xPos;
viewFrame.size.height = std::min(NSHeight(bounds), NSHeight(viewFrame));
[view setFrame:viewFrame];
xPos = NSMaxX([view frame]) + kCheckboxMargin;
xPos = NSMaxX([view frame]) + kGalleryEntryCheckboxMargin;
}
// Size the views. If all the elements don't naturally fit, the checkbox
......@@ -161,16 +161,16 @@ ui::MenuModel* MediaGalleryListEntryController::GetContextMenu(
// squish too much so it gets at least half of the max width and the details
// text should elide as well in that case.
if (xPos > NSWidth(bounds)) {
CGFloat maxRHSContent = NSWidth(bounds) / 2 - kCheckboxMargin;
CGFloat maxRHSContent = NSWidth(bounds) / 2 - kGalleryEntryCheckboxMargin;
NSRect detailsFrame = [details_ frame];
NSRect checkboxFrame = [checkbox_ frame];
if (NSMaxX(detailsFrame) - NSMaxX(checkboxFrame) > maxRHSContent) {
detailsFrame.size.width = std::max(
maxRHSContent - (NSMinX(detailsFrame) - NSMaxX(checkboxFrame)),
NSWidth(bounds) - kCheckboxMargin - NSMinX(detailsFrame));
NSWidth(bounds) - kGalleryEntryCheckboxMargin - NSMinX(detailsFrame));
[details_ setFrameSize:detailsFrame.size];
xPos = NSMaxX(detailsFrame) + kCheckboxMargin;
xPos = NSMaxX(detailsFrame) + kGalleryEntryCheckboxMargin;
}
CGFloat overflow = xPos - NSWidth(bounds);
if (overflow > 0) {
......@@ -188,7 +188,7 @@ ui::MenuModel* MediaGalleryListEntryController::GetContextMenu(
for (NSView* view in [self subviews]) {
frame = NSUnionRect(frame, [view frame]);
}
frame.size.width += kCheckboxMargin;
frame.size.width += kGalleryEntryCheckboxMargin;
[super setFrameSize:frame.size];
}
}
......
......@@ -13,7 +13,7 @@
namespace {
NSColor* GetBackgroundColor(HoverState state, BOOL dark_theme) {
NSColor* GetBackgroundColor(CloseButtonHoverState state, BOOL dark_theme) {
if (dark_theme) {
switch (state) {
case kHoverStateNone:
......@@ -43,28 +43,28 @@ NSColor* GetShadowColor() {
return NSColor.blackColor;
}
constexpr CGFloat kFontSize = 12;
constexpr CGFloat kHarmonyButtonFontSize = 12;
constexpr CGFloat kTextAlpha = 0x8A / (CGFloat)0xFF;
constexpr CGFloat kHarmonyButtonTextAlpha = 0x8A / (CGFloat)0xFF;
constexpr CGSize kNormalShadowOffset{0, 0};
constexpr CGSize kMouseOverShadowOffset{0, 1};
constexpr CGSize kHarmonyButtonNormalShadowOffset{0, 0};
constexpr CGSize kHarmonyButtonMouseOverShadowOffset{0, 1};
constexpr CGFloat kNormalShadowOpacity = 0;
constexpr CGFloat kMouseOverShadowOpacity = 0.1;
constexpr CGFloat kHarmonyButtonNormalShadowOpacity = 0;
constexpr CGFloat kHarmonyButtonMouseOverShadowOpacity = 0.1;
constexpr CGFloat kNormalShadowRadius = 0;
constexpr CGFloat kMouseOverShadowRadius = 2;
constexpr CGFloat kHarmonyButtonNormalShadowRadius = 0;
constexpr CGFloat kHarmonyButtonMouseOverShadowRadius = 2;
constexpr CGFloat kCornerRadius = 3;
constexpr CGFloat kXPadding = 16;
constexpr CGFloat kMinWidth = 64;
constexpr CGFloat kHeight = 28;
constexpr CGFloat kHarmonyButtonCornerRadius = 3;
constexpr CGFloat kHarmonyButtonXPadding = 16;
constexpr CGFloat kHarmonyButtonMinWidth = 64;
constexpr CGFloat kHarmonyButtonHeight = 28;
// The text is a bit too low by default; offset the title rect to center it.
constexpr CGFloat kTextYOffset = 1;
constexpr CGFloat kHarmonyButtonTextYOffset = 1;
constexpr NSTimeInterval kTransitionDuration = 0.25;
constexpr NSTimeInterval kHarmonyButtonTransitionDuration = 0.25;
} // namespace
......@@ -73,7 +73,7 @@ constexpr NSTimeInterval kTransitionDuration = 0.25;
@implementation HarmonyButtonCell
- (NSRect)titleRectForBounds:(NSRect)rect {
rect.origin.y -= kTextYOffset;
rect.origin.y -= kHarmonyButtonTextYOffset;
return rect;
}
@end
......@@ -102,7 +102,7 @@ constexpr NSTimeInterval kTransitionDuration = 0.25;
self.wantsLayer = YES;
CALayer* layer = self.layer;
layer.shadowColor = GetShadowColor().CGColor;
layer.cornerRadius = kCornerRadius;
layer.cornerRadius = kHarmonyButtonCornerRadius;
[self updateBorderWidth];
[self updateHoverButtonAppearanceAnimated:NO];
}
......@@ -125,22 +125,22 @@ constexpr NSTimeInterval kTransitionDuration = 0.25;
[NSAnimationContext beginGrouping];
NSAnimationContext* context = [NSAnimationContext currentContext];
context.allowsImplicitAnimation = YES;
context.duration = kTransitionDuration;
context.duration = kHarmonyButtonTransitionDuration;
} else {
[layer removeAllAnimations];
}
switch (self.hoverState) {
case kHoverStateNone:
layer.shadowOffset = kNormalShadowOffset;
layer.shadowOpacity = kNormalShadowOpacity;
layer.shadowRadius = kNormalShadowRadius;
layer.shadowOffset = kHarmonyButtonNormalShadowOffset;
layer.shadowOpacity = kHarmonyButtonNormalShadowOpacity;
layer.shadowRadius = kHarmonyButtonNormalShadowRadius;
break;
case kHoverStateMouseOver:
case kHoverStateMouseDown:
layer.shadowOffset = kMouseOverShadowOffset;
layer.shadowOpacity = kMouseOverShadowOpacity;
layer.shadowRadius = kMouseOverShadowRadius;
layer.shadowOffset = kHarmonyButtonMouseOverShadowOffset;
layer.shadowOpacity = kHarmonyButtonMouseOverShadowOpacity;
layer.shadowRadius = kHarmonyButtonMouseOverShadowRadius;
break;
}
......@@ -158,7 +158,7 @@ constexpr NSTimeInterval kTransitionDuration = 0.25;
// HoverButtonCocoa overrides.
- (void)setHoverState:(HoverState)state {
- (void)setHoverState:(CloseButtonHoverState)state {
if (state == hoverState_) {
return;
}
......@@ -175,18 +175,19 @@ constexpr NSTimeInterval kTransitionDuration = 0.25;
if (const ui::ThemeProvider* themeProvider = [self.window themeProvider]) {
textColor = themeProvider->GetNSColor(ThemeProperties::COLOR_TAB_TEXT);
if (!themeProvider->ShouldIncreaseContrast())
textColor = [textColor colorWithAlphaComponent:kTextAlpha];
textColor = [textColor colorWithAlphaComponent:kHarmonyButtonTextAlpha];
} else {
textColor = [NSColor controlTextColor];
}
NSFont* font;
if (@available(macOS 10.11, *)) {
font = [NSFont systemFontOfSize:kFontSize weight:NSFontWeightMedium];
font = [NSFont systemFontOfSize:kHarmonyButtonFontSize
weight:NSFontWeightMedium];
} else {
font = [[NSFontManager sharedFontManager]
convertWeight:YES
ofFont:[NSFont systemFontOfSize:kFontSize]];
ofFont:[NSFont systemFontOfSize:kHarmonyButtonFontSize]];
}
base::scoped_nsobject<NSMutableParagraphStyle> paragraphStyle(
......@@ -208,12 +209,14 @@ constexpr NSTimeInterval kTransitionDuration = 0.25;
- (void)sizeToFit {
NSSize size = self.attributedTitle.size;
size.width += kXPadding * 2;
size.width += kHarmonyButtonXPadding * 2;
size = [self backingAlignedRect:NSMakeRect(0, 0, size.width, size.height)
options:NSAlignAllEdgesOutward]
.size;
[self setFrameSize:NSMakeSize(size.width > kMinWidth ? size.width : kMinWidth,
kHeight)];
[self setFrameSize:NSMakeSize(size.width > kHarmonyButtonMinWidth
? size.width
: kHarmonyButtonMinWidth,
kHarmonyButtonHeight)];
}
// NSView overrides.
......
......@@ -17,7 +17,7 @@
@interface HoverCloseButton : HoverButtonCocoa<NSAnimationDelegate> {
@private
GTMKeyValueAnimation* fadeOutAnimation_;
HoverState previousState_;
CloseButtonHoverState previousState_;
}
// The color of the icon in its idle (not-hovering) state.
......
......@@ -42,7 +42,7 @@ const SkColor kDefaultIconColor = SkColorSetARGB(0xA0, 0x00, 0x00, 0x00);
- (void)setFadeOutValue:(CGFloat)value;
// Gets the image for the given hover state.
- (NSImage*)imageForHoverState:(HoverState)hoverState;
- (NSImage*)imageForHoverState:(CloseButtonHoverState)hoverState;
@end
......@@ -153,7 +153,7 @@ const SkColor kDefaultIconColor = SkColorSetARGB(0xA0, 0x00, 0x00, 0x00);
[self setNeedsDisplay];
}
- (NSImage*)imageForHoverState:(HoverState)hoverState {
- (NSImage*)imageForHoverState:(CloseButtonHoverState)hoverState {
const gfx::VectorIcon* vectorHighlightIcon = nullptr;
SkColor vectorIconColor = gfx::kPlaceholderColor;
......@@ -186,7 +186,7 @@ const SkColor kDefaultIconColor = SkColorSetARGB(0xA0, 0x00, 0x00, 0x00);
return NSImageFromImageSkia(iconImage);
}
- (void)setHoverState:(HoverState)state {
- (void)setHoverState:(CloseButtonHoverState)state {
if (state != self.hoverState) {
previousState_ = self.hoverState;
[super setHoverState:state];
......@@ -250,7 +250,7 @@ const SkColor kDefaultIconColor = SkColorSetARGB(0xA0, 0x00, 0x00, 0x00);
@implementation WebUIHoverCloseButton
- (NSImage*)imageForHoverState:(HoverState)hoverState {
- (NSImage*)imageForHoverState:(CloseButtonHoverState)hoverState {
int imageID = IDR_CLOSE_DIALOG;
switch (hoverState) {
case kHoverStateNone:
......
......@@ -22,8 +22,7 @@
#include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
namespace {
const CGFloat kAnimationDuration = 0.2;
const CGFloat kResizeAnimationDuration = 0.2;
}
@implementation AutocompleteTextField
......@@ -45,7 +44,7 @@ const CGFloat kAnimationDuration = 0.2;
[[self cell] setLineBreakMode:NSLineBreakByTruncatingTail];
currentToolTips_.reset([[NSMutableArray alloc] init]);
resizeAnimation_.reset([[NSViewAnimation alloc] init]);
[resizeAnimation_ setDuration:kAnimationDuration];
[resizeAnimation_ setDuration:kResizeAnimationDuration];
[resizeAnimation_ setAnimationBlockingMode:NSAnimationNonblocking];
[self setAlignment:cocoa_l10n_util::ShouldDoExperimentalRTLLayout()
? NSRightTextAlignment
......
......@@ -19,10 +19,11 @@
namespace {
// Layout and color values for the vertical divider.
const CGFloat kDividerHeight = 16.0;
const CGFloat kDividerPadding = 6.0; // Between the divider and label.
const CGFloat kDividerGray = 0xFFA6A6A6;
const CGFloat kDividerGrayIncognito = 0xFFCCCCCC;
const CGFloat kDecorationDividerHeight = 16.0;
const CGFloat kDecorationDividerPadding =
6.0; // Between the divider and label.
const CGFloat kDecorationDividerGray = 0xFFA6A6A6;
const CGFloat kDecorationDividerGrayIncognito = 0xFFCCCCCC;
// Color values for the hover and pressed background.
const SkColor kHoverBackgroundColor = 0x14000000;
......@@ -165,7 +166,7 @@ LocationBarDecoration::~LocationBarDecoration() {
}
CGFloat LocationBarDecoration::DividerPadding() const {
return kDividerPadding;
return kDecorationDividerPadding;
}
bool LocationBarDecoration::IsVisible() const {
......@@ -469,7 +470,7 @@ void LocationBarDecoration::DrawDivider(NSView* control_view,
// the line between the label and URL.
divider_origin.x -= line_width / 2.;
CGFloat divider_y_frame_offset =
(NSHeight(decoration_frame) - kDividerHeight) / 2.0;
(NSHeight(decoration_frame) - kDecorationDividerHeight) / 2.0;
divider_origin.y = NSMinY(decoration_frame) + divider_y_frame_offset;
// Adjust the divider origin by 1/2 a point to visually center the
// divider vertically on Retina.
......@@ -477,15 +478,15 @@ void LocationBarDecoration::DrawDivider(NSView* control_view,
divider_origin.y -= 0.5;
}
[line moveToPoint:divider_origin];
[line relativeLineToPoint:NSMakePoint(0, kDividerHeight)];
[line relativeLineToPoint:NSMakePoint(0, kDecorationDividerHeight)];
NSColor* divider_color = nil;
bool location_bar_is_dark =
[[control_view window] inIncognitoModeWithSystemTheme];
if (location_bar_is_dark) {
divider_color = skia::SkColorToSRGBNSColor(kDividerGrayIncognito);
divider_color = skia::SkColorToSRGBNSColor(kDecorationDividerGrayIncognito);
} else {
divider_color = skia::SkColorToSRGBNSColor(kDividerGray);
divider_color = skia::SkColorToSRGBNSColor(kDecorationDividerGray);
}
if (alpha < 1) {
......
......@@ -14,9 +14,9 @@
#include "ui/gfx/paint_vector_icon.h"
namespace {
constexpr int kDefaultIconSize = 16;
constexpr SkAlpha kIconAlpha = 0x8A;
constexpr CGFloat kHoverAnimationDuration = 0.25;
constexpr int kMDHoverButtonDefaultIconSize = 16;
constexpr SkAlpha kMDHoverButtonIconAlpha = 0x8A;
constexpr CGFloat kMDHoverButtonHoverAnimationDuration = 0.25;
NSColor* GetHoveringColor(BOOL dark_theme) {
return [NSColor colorWithWhite:dark_theme ? 1 : 0 alpha:0.08];
......@@ -37,7 +37,7 @@ NSColor* GetActiveColor(BOOL dark_theme) {
- (instancetype)initWithFrame:(NSRect)frameRect {
if ((self = [super initWithFrame:frameRect])) {
iconSize_ = kDefaultIconSize;
iconSize_ = kMDHoverButtonDefaultIconSize;
self.bezelStyle = NSRoundedBezelStyle;
self.bordered = NO;
self.wantsLayer = YES;
......@@ -67,7 +67,7 @@ NSColor* GetActiveColor(BOOL dark_theme) {
return gfx::kPlaceholderColor;
return SkColorSetA(
[[self window] hasDarkTheme] ? SK_ColorWHITE : SK_ColorBLACK,
provider->ShouldIncreaseContrast() ? 0xFF : kIconAlpha);
provider->ShouldIncreaseContrast() ? 0xFF : kMDHoverButtonIconAlpha);
}
- (void)updateIcon {
......@@ -102,7 +102,7 @@ NSColor* GetActiveColor(BOOL dark_theme) {
return;
}
[NSAnimationContext runAnimationGroup:^(NSAnimationContext* context) {
context.duration = kHoverAnimationDuration;
context.duration = kMDHoverButtonHoverAnimationDuration;
CABasicAnimation* animation =
[CABasicAnimation animationWithKeyPath:@"backgroundColor"];
self.layer.backgroundColor = targetBackgroundColor;
......@@ -113,7 +113,7 @@ NSColor* GetActiveColor(BOOL dark_theme) {
// HoverButtonCocoa overrides.
- (void)setHoverState:(HoverState)state {
- (void)setHoverState:(CloseButtonHoverState)state {
if (state == hoverState_)
return;
const BOOL animated =
......
......@@ -33,26 +33,28 @@ using content::DesktopMediaID;
namespace {
const CGFloat kInitialContentWidth = 620;
const CGFloat kMinimumContentWidth = 500;
const CGFloat kMinimumContentHeight = 390;
const CGFloat kThumbnailWidth = 150;
const CGFloat kThumbnailHeight = 150;
const CGFloat kSingleScreenWidth = 300;
const CGFloat kSingleScreenHeight = 300;
const CGFloat kMultipleScreenWidth = 220;
const CGFloat kMultipleScreenHeight = 220;
const CGFloat kFramePadding = 20;
const CGFloat kControlSpacing = 10;
const CGFloat kExcessButtonPadding = 6;
const CGFloat kRowHeight = 20;
const CGFloat kRowWidth = 500;
const CGFloat kIconWidth = 20;
const CGFloat kPaddedWidth = kInitialContentWidth - (kFramePadding * 2);
const CGFloat kFontSize = 13;
NSString* const kIconId = @"icon";
NSString* const kTitleId = @"title";
const CGFloat kDesktopMediaPickerInitialContentWidth = 620;
const CGFloat kDesktopMediaPickerMinimumContentWidth = 500;
const CGFloat kDesktopMediaPickerMinimumContentHeight = 390;
const CGFloat kDesktopMediaPickerThumbnailWidth = 150;
const CGFloat kDesktopMediaPickerThumbnailHeight = 150;
const CGFloat kDesktopMediaPickerSingleScreenWidth = 300;
const CGFloat kDesktopMediaPickerSingleScreenHeight = 300;
const CGFloat kDesktopMediaPickerMultipleScreenWidth = 220;
const CGFloat kDesktopMediaPickerMultipleScreenHeight = 220;
const CGFloat kDesktopMediaPickerFramePadding = 20;
const CGFloat kDesktopMediaPickerControlSpacing = 10;
const CGFloat kDesktopMediaPickerExcessButtonPadding = 6;
const CGFloat kDesktopMediaPickerRowHeight = 20;
const CGFloat kDesktopMediaPickerRowWidth = 500;
const CGFloat kDesktopMediaPickerIconWidth = 20;
const CGFloat kDesktopMediaPickerPaddedWidth =
kDesktopMediaPickerInitialContentWidth -
(kDesktopMediaPickerFramePadding * 2);
const CGFloat kDesktopMediaPickerFontSize = 13;
NSString* const kDesktopMediaPickerIconId = @"icon";
NSString* const kDesktopMediaPickerTitleId = @"title";
} // namespace
......@@ -176,7 +178,8 @@ NSString* const kTitleId = @"title";
base::scoped_nsobject<FlippedView> content(
[[FlippedView alloc] initWithFrame:NSZeroRect]);
[[self window] setContentView:content];
NSPoint origin = NSMakePoint(kFramePadding, kFramePadding);
NSPoint origin = NSMakePoint(kDesktopMediaPickerFramePadding,
kDesktopMediaPickerFramePadding);
// Set the dialog's title.
NSString* titleText = l10n_util::GetNSString(IDS_DESKTOP_MEDIA_PICKER_TITLE);
......@@ -191,32 +194,40 @@ NSString* const kTitleId = @"title";
descriptionText = l10n_util::GetNSStringF(
IDS_DESKTOP_MEDIA_PICKER_TEXT_DELEGATED, appName, targetName);
}
NSTextField* description = [self createTextFieldWithText:descriptionText
frameWidth:kPaddedWidth];
NSTextField* description =
[self createTextFieldWithText:descriptionText
frameWidth:kDesktopMediaPickerPaddedWidth];
[description setFrameOrigin:origin];
[content addSubview:description];
origin.y += NSHeight([description frame]) + kControlSpacing;
origin.y += NSHeight([description frame]) + kDesktopMediaPickerControlSpacing;
[self createTypeButtonAtOrigin:origin];
origin.y += NSHeight([sourceTypeControl_ frame]) + kControlSpacing;
origin.y +=
NSHeight([sourceTypeControl_ frame]) + kDesktopMediaPickerControlSpacing;
[self createSourceViewsAtOrigin:origin];
origin.y += NSHeight([imageBrowserScroll_ frame]) + kControlSpacing;
origin.y +=
NSHeight([imageBrowserScroll_ frame]) + kDesktopMediaPickerControlSpacing;
if (requestAudio) {
[self createAudioCheckboxAtOrigin:origin];
origin.y += NSHeight([audioShareCheckbox_ frame]) + kControlSpacing;
origin.y += NSHeight([audioShareCheckbox_ frame]) +
kDesktopMediaPickerControlSpacing;
}
[self createActionButtonsAtOrigin:origin];
origin.y +=
kFramePadding + (NSHeight([cancelButton_ frame]) - kExcessButtonPadding);
origin.y += kDesktopMediaPickerFramePadding +
(NSHeight([cancelButton_ frame]) -
kDesktopMediaPickerExcessButtonPadding);
// Resize window to fit.
[content setAutoresizesSubviews:NO];
[[self window] setContentSize:NSMakeSize(kInitialContentWidth, origin.y)];
[[self window] setContentMinSize:NSMakeSize(kMinimumContentWidth,
kMinimumContentHeight)];
[[self window]
setContentSize:NSMakeSize(kDesktopMediaPickerInitialContentWidth,
origin.y)];
[[self window]
setContentMinSize:NSMakeSize(kDesktopMediaPickerMinimumContentWidth,
kDesktopMediaPickerMinimumContentHeight)];
[content setAutoresizesSubviews:YES];
// Initialize the type selection at the first segment.
......@@ -280,7 +291,8 @@ NSString* const kTitleId = @"title";
[sourceTypeControl_ setAutoresizingMask:NSViewMaxXMargin | NSViewMinXMargin];
CGFloat controlWidth = NSWidth([sourceTypeControl_ frame]);
CGFloat controlHeight = NSHeight([sourceTypeControl_ frame]);
NSRect centerFrame = NSMakeRect((kInitialContentWidth - controlWidth) / 2,
NSRect centerFrame =
NSMakeRect((kDesktopMediaPickerInitialContentWidth - controlWidth) / 2,
origin.y, controlWidth, controlHeight);
[sourceTypeControl_ setFrame:NSIntegralRect(centerFrame)];
......@@ -295,10 +307,12 @@ NSString* const kTitleId = @"title";
}
case DesktopMediaID::TYPE_SCREEN: {
const bool is_single = sourceList->GetSourceCount() <= 1;
const CGFloat width =
is_single ? kSingleScreenWidth : kMultipleScreenWidth;
const CGFloat height =
is_single ? kSingleScreenHeight : kMultipleScreenHeight;
const CGFloat width = is_single
? kDesktopMediaPickerSingleScreenWidth
: kDesktopMediaPickerMultipleScreenWidth;
const CGFloat height = is_single
? kDesktopMediaPickerSingleScreenHeight
: kDesktopMediaPickerMultipleScreenHeight;
screenBrowser_.reset([[self
createImageBrowserWithSize:NSMakeSize(width, height)] retain]);
break;
......@@ -306,8 +320,10 @@ NSString* const kTitleId = @"title";
case DesktopMediaID::TYPE_WINDOW: {
windowBrowser_.reset([[self
createImageBrowserWithSize:NSMakeSize(kThumbnailWidth,
kThumbnailHeight)] retain]);
createImageBrowserWithSize:NSMakeSize(
kDesktopMediaPickerThumbnailWidth,
kDesktopMediaPickerThumbnailHeight)]
retain]);
break;
}
case DesktopMediaID::TYPE_WEB_CONTENTS: {
......@@ -315,17 +331,17 @@ NSString* const kTitleId = @"title";
[tabBrowser_ setDelegate:self];
[tabBrowser_ setDataSource:self];
[tabBrowser_ setAllowsMultipleSelection:NO];
[tabBrowser_ setRowHeight:kRowHeight];
[tabBrowser_ setRowHeight:kDesktopMediaPickerRowHeight];
[tabBrowser_ setDoubleAction:@selector(sharePressed:)];
base::scoped_nsobject<NSTableColumn> iconColumn(
[[NSTableColumn alloc] initWithIdentifier:kIconId]);
base::scoped_nsobject<NSTableColumn> iconColumn([[NSTableColumn alloc]
initWithIdentifier:kDesktopMediaPickerIconId]);
[iconColumn setEditable:NO];
[iconColumn setWidth:kIconWidth];
[iconColumn setWidth:kDesktopMediaPickerIconWidth];
[tabBrowser_ addTableColumn:iconColumn];
base::scoped_nsobject<NSTableColumn> titleColumn(
[[NSTableColumn alloc] initWithIdentifier:kTitleId]);
base::scoped_nsobject<NSTableColumn> titleColumn([[NSTableColumn alloc]
initWithIdentifier:kDesktopMediaPickerTitleId]);
[titleColumn setEditable:NO];
[titleColumn setWidth:kRowWidth];
[titleColumn setWidth:kDesktopMediaPickerRowWidth];
[tabBrowser_ addTableColumn:titleColumn];
[tabBrowser_ setHeaderView:nil];
break;
......@@ -334,7 +350,7 @@ NSString* const kTitleId = @"title";
}
// Create a scroll view to host the image browsers.
NSRect imageBrowserScrollFrame =
NSMakeRect(origin.x, origin.y, kPaddedWidth, 350);
NSMakeRect(origin.x, origin.y, kDesktopMediaPickerPaddedWidth, 350);
imageBrowserScroll_.reset(
[[NSScrollView alloc] initWithFrame:imageBrowserScrollFrame]);
[imageBrowserScroll_ setHasVerticalScroller:YES];
......@@ -363,8 +379,9 @@ NSString* const kTitleId = @"title";
shareButton_ =
[self createButtonWithTitle:l10n_util::GetNSString(
IDS_DESKTOP_MEDIA_PICKER_SHARE)];
origin.x = kInitialContentWidth - kFramePadding -
(NSWidth([shareButton_ frame]) - kExcessButtonPadding);
origin.x =
kDesktopMediaPickerInitialContentWidth - kDesktopMediaPickerFramePadding -
(NSWidth([shareButton_ frame]) - kDesktopMediaPickerExcessButtonPadding);
[shareButton_ setEnabled:NO];
[shareButton_ setFrameOrigin:origin];
[shareButton_ setAutoresizingMask:NSViewMinXMargin | NSViewMinYMargin];
......@@ -376,8 +393,9 @@ NSString* const kTitleId = @"title";
// Create the cancel button.
cancelButton_ =
[self createButtonWithTitle:l10n_util::GetNSString(IDS_CANCEL)];
origin.x -= kControlSpacing +
(NSWidth([cancelButton_ frame]) - (kExcessButtonPadding * 2));
origin.x -= kDesktopMediaPickerControlSpacing +
(NSWidth([cancelButton_ frame]) -
(kDesktopMediaPickerExcessButtonPadding * 2));
[cancelButton_ setFrameOrigin:origin];
[cancelButton_ setAutoresizingMask:NSViewMinXMargin | NSViewMinYMargin];
[cancelButton_ setTarget:self];
......@@ -396,7 +414,7 @@ NSString* const kTitleId = @"title";
[textField setDrawsBackground:NO];
[textField setBezeled:NO];
[textField setStringValue:text];
[textField setFont:[NSFont systemFontOfSize:kFontSize]];
[textField setFont:[NSFont systemFontOfSize:kDesktopMediaPickerFontSize]];
[textField setAutoresizingMask:NSViewWidthSizable];
[GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:textField];
return textField.autorelease();
......@@ -437,18 +455,21 @@ NSString* const kTitleId = @"title";
}
case DesktopMediaID::TYPE_SCREEN: {
sourceList->SetThumbnailSize(
gfx::Size(kSingleScreenWidth, kSingleScreenHeight));
gfx::Size(kDesktopMediaPickerSingleScreenWidth,
kDesktopMediaPickerSingleScreenHeight));
sourceList->StartUpdating(bridge_.get());
break;
}
case DesktopMediaID::TYPE_WINDOW: {
sourceList->SetThumbnailSize(
gfx::Size(kThumbnailWidth, kThumbnailHeight));
gfx::Size(kDesktopMediaPickerThumbnailWidth,
kDesktopMediaPickerThumbnailHeight));
sourceList->StartUpdating(bridge_.get());
break;
}
case DesktopMediaID::TYPE_WEB_CONTENTS: {
sourceList->SetThumbnailSize(gfx::Size(kIconWidth, kRowHeight));
sourceList->SetThumbnailSize(gfx::Size(kDesktopMediaPickerIconWidth,
kDesktopMediaPickerRowHeight));
sourceList->StartUpdating(bridge_.get());
break;
}
......@@ -660,14 +681,16 @@ NSString* const kTitleId = @"title";
- (NSView*)tableView:(NSTableView*)table
viewForTableColumn:(NSTableColumn*)column
row:(NSInteger)rowIndex {
if ([[column identifier] isEqualToString:kIconId]) {
if ([[column identifier] isEqualToString:kDesktopMediaPickerIconId]) {
NSImage* image = [[tabItems_ objectAtIndex:rowIndex] imageRepresentation];
base::scoped_nsobject<NSImageView> iconView(
[[table makeViewWithIdentifier:kIconId owner:self] retain]);
[[table makeViewWithIdentifier:kDesktopMediaPickerIconId owner:self]
retain]);
if (!iconView) {
iconView.reset([[NSImageView alloc]
initWithFrame:NSMakeRect(0, 0, kIconWidth, kRowWidth)]);
[iconView setIdentifier:kIconId];
initWithFrame:NSMakeRect(0, 0, kDesktopMediaPickerIconWidth,
kDesktopMediaPickerRowWidth)]);
[iconView setIdentifier:kDesktopMediaPickerIconId];
}
[iconView setImage:image];
return iconView.autorelease();
......@@ -675,12 +698,14 @@ NSString* const kTitleId = @"title";
NSString* string = [[tabItems_ objectAtIndex:rowIndex] imageTitle];
base::scoped_nsobject<NSTextField> titleView(
[[table makeViewWithIdentifier:kTitleId owner:self] retain]);
[[table makeViewWithIdentifier:kDesktopMediaPickerTitleId owner:self]
retain]);
if (!titleView) {
titleView.reset(
[[self createTextFieldWithText:string frameWidth:kMinimumContentWidth]
[[self createTextFieldWithText:string
frameWidth:kDesktopMediaPickerMinimumContentWidth]
retain]);
[titleView setIdentifier:kTitleId];
[titleView setIdentifier:kDesktopMediaPickerTitleId];
} else {
[titleView setStringValue:string];
}
......@@ -723,8 +748,8 @@ NSString* const kTitleId = @"title";
byExtendingSelection:NO];
} else if ([items count] == 2) {
// Switch to multiple sources mode.
[browser
setCellSize:NSMakeSize(kMultipleScreenWidth, kMultipleScreenHeight)];
[browser setCellSize:NSMakeSize(kDesktopMediaPickerMultipleScreenWidth,
kDesktopMediaPickerMultipleScreenHeight)];
}
}
......@@ -761,7 +786,8 @@ NSString* const kTitleId = @"title";
}
[items removeObjectAtIndex:index];
if (sourceType == DesktopMediaID::TYPE_SCREEN && [items count] == 1)
[browser setCellSize:NSMakeSize(kSingleScreenWidth, kSingleScreenHeight)];
[browser setCellSize:NSMakeSize(kDesktopMediaPickerSingleScreenWidth,
kDesktopMediaPickerSingleScreenHeight)];
[browser reloadData];
}
......
......@@ -32,14 +32,14 @@
namespace {
constexpr SkColor kButtonHoverColor = SkColorSetARGB(20, 0, 0, 0);
constexpr SkColor kButtonPressedColor = SkColorSetARGB(31, 0, 0, 0);
constexpr SkColor kAvatarButtonHoverColor = SkColorSetARGB(20, 0, 0, 0);
constexpr SkColor kAvatarButtonPressedColor = SkColorSetARGB(31, 0, 0, 0);
const CGFloat kButtonHeight = 24;
const CGFloat kAvatarButtonHeight = 24;
// NSButtons have a default padding of 5px. Buttons should have a padding of
// 6px.
const CGFloat kButtonExtraPadding = 6 - 5;
const CGFloat kAvatarButtonExtraPadding = 6 - 5;
// Extra padding for the signed out avatar button.
const CGFloat kSignedOutWidthPadding = 2;
......@@ -80,15 +80,15 @@ const CGFloat kFrameColorDarkUpperBound = 0.33;
// is square. Otherwise, we are displaying the profile's name and an
// optional authentication error icon.
if ([self image] && !hasError_)
buttonSize.width = kButtonHeight + kSignedOutWidthPadding;
buttonSize.width = kAvatarButtonHeight + kSignedOutWidthPadding;
else
buttonSize.width += 2 * kButtonExtraPadding;
buttonSize.height = kButtonHeight;
buttonSize.width += 2 * kAvatarButtonExtraPadding;
buttonSize.height = kAvatarButtonHeight;
return buttonSize;
}
- (void)drawInteriorWithFrame:(NSRect)frame inView:(NSView*)controlView {
NSRect frameAfterPadding = NSInsetRect(frame, kButtonExtraPadding, 0);
NSRect frameAfterPadding = NSInsetRect(frame, kAvatarButtonExtraPadding, 0);
[super drawInteriorWithFrame:frameAfterPadding inView:controlView];
}
......@@ -106,13 +106,13 @@ const CGFloat kFrameColorDarkUpperBound = 0.33;
inView:(NSView*)controlView {
AvatarButtonCocoa* button =
base::mac::ObjCCastStrict<AvatarButtonCocoa>(controlView);
HoverState hoverState = [button hoverState];
CloseButtonHoverState hoverState = [button hoverState];
NSColor* backgroundColor = nil;
if (hoverState == kHoverStateMouseDown || [button isActive]) {
backgroundColor = skia::SkColorToSRGBNSColor(kButtonPressedColor);
backgroundColor = skia::SkColorToSRGBNSColor(kAvatarButtonPressedColor);
} else if (hoverState == kHoverStateMouseOver) {
backgroundColor = skia::SkColorToSRGBNSColor(kButtonHoverColor);
backgroundColor = skia::SkColorToSRGBNSColor(kAvatarButtonHoverColor);
}
if (backgroundColor) {
......
......@@ -32,10 +32,10 @@
namespace {
const int kWindowHeight = 18;
const int kStatusBubbleWindowHeight = 18;
// The width of the bubble in relation to the width of the parent window.
const CGFloat kWindowWidthPercent = 1.0 / 3.0;
const CGFloat kStatusBubbleWindowWidthPercent = 1.0 / 3.0;
// How close the mouse can get to the infobubble before it starts sliding
// off-screen.
......@@ -759,13 +759,13 @@ NSRect StatusBubbleMac::CalculateWindowFrame(bool expanded_width) {
screenRect = [parent_ frame];
}
NSSize size = NSMakeSize(0, kWindowHeight);
NSSize size = NSMakeSize(0, kStatusBubbleWindowHeight);
size = [[parent_ contentView] convertSize:size toView:nil];
if (expanded_width) {
size.width = screenRect.size.width;
} else {
size.width = kWindowWidthPercent * screenRect.size.width;
size.width = kStatusBubbleWindowWidthPercent * screenRect.size.width;
}
screenRect.size = size;
......
......@@ -106,7 +106,7 @@ const CGFloat kMaxTopMargin = 130;
[message_.textStorage
appendAttributedString:[[[NSAttributedString alloc]
initWithString:l10n_util::GetNSString(
sadTab->GetMessage())
sadTab->GetInfoMessage())
attributes:@{
NSFontAttributeName : messageFont,
NSForegroundColorAttributeName :
......
......@@ -71,21 +71,22 @@ class TranslateDenialComboboxModel : public ui::ComboboxModel {
DISALLOW_COPY_AND_ASSIGN(TranslateDenialComboboxModel);
};
const CGFloat kIconWidth = 30;
const CGFloat kIconHeight = 30;
const CGFloat kIconPadding = 12;
const CGFloat kTranslateBubbleIconWidth = 30;
const CGFloat kTranslateBubbleIconHeight = 30;
const CGFloat kTranslateBubbleIconPadding = 12;
const CGFloat kWindowWidth = 320;
const CGFloat kTranslateBubbleWindowWidth = 320;
// Padding between the window frame and content.
const CGFloat kFramePadding = 16;
const CGFloat kTranslateBubbleFramePadding = 16;
const CGFloat kRelatedControlHorizontalSpacing = -2;
const CGFloat kTranslateBubbleRelatedControlHorizontalSpacing = -2;
const CGFloat kRelatedControlVerticalSpacing = 8;
const CGFloat kUnrelatedControlVerticalSpacing = 20;
const CGFloat kTranslateBubbleRelatedControlVerticalSpacing = 8;
const CGFloat kTranslateBubbleUnrelatedControlVerticalSpacing = 20;
const CGFloat kContentWidth = kWindowWidth - 2 * kFramePadding;
const CGFloat kTranslateBubbleContentWidth =
kTranslateBubbleWindowWidth - 2 * kTranslateBubbleFramePadding;
@interface TranslateBubbleController()
......@@ -288,16 +289,21 @@ const CGFloat kContentWidth = kWindowWidth - 2 * kFramePadding;
[[window contentView] setSubviews:@[ [self currentView], closeButton_ ]];
CGFloat height = NSHeight([[self currentView] frame]) +
2 * kFramePadding + info_bubble::kBubbleArrowHeight;
2 * kTranslateBubbleFramePadding +
info_bubble::kBubbleArrowHeight;
NSRect windowFrame = [window contentRectForFrameRect:[[self window] frame]];
NSRect newWindowFrame = [window frameRectForContentRect:NSMakeRect(
NSMinX(windowFrame), NSMaxY(windowFrame) - height, kWindowWidth, height)];
NSRect newWindowFrame = [window
frameRectForContentRect:NSMakeRect(NSMinX(windowFrame),
NSMaxY(windowFrame) - height,
kTranslateBubbleWindowWidth, height)];
// Adjust the origin of closeButton.
CGFloat closeX = kWindowWidth - chrome_style::kCloseButtonPadding -
CGFloat closeX = kTranslateBubbleWindowWidth -
chrome_style::kCloseButtonPadding -
chrome_style::GetCloseButtonSize();
CGFloat closeY = height - kFramePadding - chrome_style::kCloseButtonPadding -
CGFloat closeY = height - kTranslateBubbleFramePadding -
chrome_style::kCloseButtonPadding -
info_bubble::kBubbleArrowHeight;
[closeButton_ setFrameOrigin:NSMakePoint(closeX, closeY)];
......@@ -307,11 +313,9 @@ const CGFloat kContentWidth = kWindowWidth - 2 * kFramePadding;
}
- (NSView*)newBeforeTranslateView {
NSRect contentFrame = NSMakeRect(
kFramePadding,
kFramePadding,
kContentWidth,
0);
NSRect contentFrame =
NSMakeRect(kTranslateBubbleFramePadding, kTranslateBubbleFramePadding,
kTranslateBubbleContentWidth, 0);
NSView* view = [[NSView alloc] initWithFrame:contentFrame];
base::string16 originalLanguageName =
......@@ -382,43 +386,49 @@ const CGFloat kContentWidth = kWindowWidth - 2 * kFramePadding;
// Layout
CGFloat yPos = 0;
[translateButton setFrameOrigin:NSMakePoint(
kContentWidth - NSWidth([translateButton frame]), yPos)];
[translateButton
setFrameOrigin:NSMakePoint(kTranslateBubbleContentWidth -
NSWidth([translateButton frame]),
yPos)];
NSRect denyPopUpButtonFrame = [denyPopUpButton frame];
CGFloat diffY = [[denyPopUpButton cell]
titleRectForBounds:[denyPopUpButton bounds]].origin.y;
[denyPopUpButton setFrameOrigin:NSMakePoint(
NSMinX([translateButton frame]) - denyPopUpButtonFrame.size.width
- kRelatedControlHorizontalSpacing,
[denyPopUpButton
setFrameOrigin:NSMakePoint(
NSMinX([translateButton frame]) -
denyPopUpButtonFrame.size.width -
kTranslateBubbleRelatedControlHorizontalSpacing,
yPos + diffY)];
yPos += NSHeight([translateButton frame]) +
kUnrelatedControlVerticalSpacing;
kTranslateBubbleUnrelatedControlVerticalSpacing;
if (beforeAlwaysTranslateCheckbox_) {
[beforeAlwaysTranslateCheckbox_
setFrameOrigin:NSMakePoint(kIconWidth + kIconPadding, yPos)];
setFrameOrigin:NSMakePoint(kTranslateBubbleIconWidth +
kTranslateBubbleIconPadding,
yPos)];
yPos += NSHeight([beforeAlwaysTranslateCheckbox_ frame]) +
kRelatedControlVerticalSpacing;
kTranslateBubbleRelatedControlVerticalSpacing;
}
[textLabel setFrameOrigin:NSMakePoint(kIconWidth + kIconPadding, yPos)];
[textLabel setFrameOrigin:NSMakePoint(kTranslateBubbleIconWidth +
kTranslateBubbleIconPadding,
yPos)];
yPos = NSMaxY([textLabel frame]);
[icon setFrameOrigin:NSMakePoint(0, yPos - kIconHeight)];
[view setFrameSize:NSMakeSize(kContentWidth, yPos)];
[icon setFrameOrigin:NSMakePoint(0, yPos - kTranslateBubbleIconHeight)];
[view setFrameSize:NSMakeSize(kTranslateBubbleContentWidth, yPos)];
return view;
}
- (NSView*)newTranslatingView {
NSRect contentFrame = NSMakeRect(
kFramePadding,
kFramePadding,
kContentWidth,
0);
NSRect contentFrame =
NSMakeRect(kTranslateBubbleFramePadding, kTranslateBubbleFramePadding,
kTranslateBubbleContentWidth, 0);
NSView* view = [[NSView alloc] initWithFrame:contentFrame];
NSString* message =
......@@ -438,27 +448,29 @@ const CGFloat kContentWidth = kWindowWidth - 2 * kFramePadding;
// TODO(hajimehoshi): Use l10n_util::VerticallyReflowGroup.
CGFloat yPos = 0;
[showOriginalButton setFrameOrigin:NSMakePoint(
kContentWidth - NSWidth([showOriginalButton frame]), yPos)];
[showOriginalButton
setFrameOrigin:NSMakePoint(kTranslateBubbleContentWidth -
NSWidth([showOriginalButton frame]),
yPos)];
yPos += NSHeight([showOriginalButton frame]) +
kUnrelatedControlVerticalSpacing;
kTranslateBubbleUnrelatedControlVerticalSpacing;
[textLabel setFrameOrigin:NSMakePoint(kIconWidth + kIconPadding, yPos)];
[textLabel setFrameOrigin:NSMakePoint(kTranslateBubbleIconWidth +
kTranslateBubbleIconPadding,
yPos)];
yPos = NSMaxY([textLabel frame]);
[icon setFrameOrigin:NSMakePoint(0, yPos - kIconHeight)];
[view setFrameSize:NSMakeSize(kContentWidth, yPos)];
[icon setFrameOrigin:NSMakePoint(0, yPos - kTranslateBubbleIconHeight)];
[view setFrameSize:NSMakeSize(kTranslateBubbleContentWidth, yPos)];
return view;
}
- (NSView*)newAfterTranslateView {
NSRect contentFrame = NSMakeRect(
kFramePadding,
kFramePadding,
kContentWidth,
0);
NSRect contentFrame =
NSMakeRect(kTranslateBubbleFramePadding, kTranslateBubbleFramePadding,
kTranslateBubbleContentWidth, 0);
NSView* view = [[NSView alloc] initWithFrame:contentFrame];
NSString* message =
......@@ -482,29 +494,31 @@ const CGFloat kContentWidth = kWindowWidth - 2 * kFramePadding;
// Layout
CGFloat yPos = 0;
[showOriginalButton setFrameOrigin:NSMakePoint(
kContentWidth - NSWidth([showOriginalButton frame]), yPos)];
[showOriginalButton
setFrameOrigin:NSMakePoint(kTranslateBubbleContentWidth -
NSWidth([showOriginalButton frame]),
yPos)];
yPos += NSHeight([showOriginalButton frame]) +
kUnrelatedControlVerticalSpacing;
kTranslateBubbleUnrelatedControlVerticalSpacing;
[textLabel setFrameOrigin:NSMakePoint(kIconWidth + kIconPadding, yPos)];
[textLabel setFrameOrigin:NSMakePoint(kTranslateBubbleIconWidth +
kTranslateBubbleIconPadding,
yPos)];
[advancedLinkButton setFrameOrigin:NSMakePoint(
NSMaxX([textLabel frame]), yPos)];
yPos = NSMaxY([textLabel frame]);
[icon setFrameOrigin:NSMakePoint(0, yPos - kIconHeight)];
[view setFrameSize:NSMakeSize(kContentWidth, yPos)];
[icon setFrameOrigin:NSMakePoint(0, yPos - kTranslateBubbleIconHeight)];
[view setFrameSize:NSMakeSize(kTranslateBubbleContentWidth, yPos)];
return view;
}
- (NSView*)newErrorView {
NSRect contentFrame = NSMakeRect(
kFramePadding,
kFramePadding,
kContentWidth,
0);
NSRect contentFrame =
NSMakeRect(kTranslateBubbleFramePadding, kTranslateBubbleFramePadding,
kTranslateBubbleContentWidth, 0);
NSView* view = [[NSView alloc] initWithFrame:contentFrame];
NSString* message =
......@@ -527,29 +541,30 @@ const CGFloat kContentWidth = kWindowWidth - 2 * kFramePadding;
CGFloat yPos = 0;
[tryAgainButton_
setFrameOrigin:NSMakePoint(
kContentWidth - NSWidth([tryAgainButton_ frame]),
setFrameOrigin:NSMakePoint(kTranslateBubbleContentWidth -
NSWidth([tryAgainButton_ frame]),
yPos)];
yPos += NSHeight([tryAgainButton_ frame]) + kUnrelatedControlVerticalSpacing;
yPos += NSHeight([tryAgainButton_ frame]) +
kTranslateBubbleUnrelatedControlVerticalSpacing;
[textLabel setFrameOrigin:NSMakePoint(kIconWidth + kIconPadding, yPos)];
[textLabel setFrameOrigin:NSMakePoint(kTranslateBubbleIconWidth +
kTranslateBubbleIconPadding,
yPos)];
[advancedLinkButton
setFrameOrigin:NSMakePoint(NSMaxX([textLabel frame]), yPos)];
yPos = NSMaxY([textLabel frame]);
[icon setFrameOrigin:NSMakePoint(0, yPos - kIconHeight)];
[view setFrameSize:NSMakeSize(kContentWidth, yPos)];
[icon setFrameOrigin:NSMakePoint(0, yPos - kTranslateBubbleIconHeight)];
[view setFrameSize:NSMakeSize(kTranslateBubbleContentWidth, yPos)];
return view;
}
- (NSView*)newAdvancedView {
NSRect contentFrame = NSMakeRect(
kFramePadding,
kFramePadding,
kContentWidth,
0);
NSRect contentFrame =
NSMakeRect(kTranslateBubbleFramePadding, kTranslateBubbleFramePadding,
kTranslateBubbleContentWidth, 0);
NSView* view = [[NSView alloc] initWithFrame:contentFrame];
NSString* title = l10n_util::GetNSStringWithFixup(
......@@ -627,14 +642,14 @@ const CGFloat kContentWidth = kWindowWidth - 2 * kFramePadding;
[languageSettingsLinkButton setFrameOrigin:NSMakePoint(0, yPos)];
yPos = NSHeight([advancedDoneButton_ frame]) +
kUnrelatedControlVerticalSpacing;
kTranslateBubbleUnrelatedControlVerticalSpacing;
if (advancedAlwaysTranslateCheckbox_) {
[advancedAlwaysTranslateCheckbox_
setFrameOrigin:NSMakePoint(textLabelWidth, yPos)];
yPos += NSHeight([advancedAlwaysTranslateCheckbox_ frame]) +
kRelatedControlVerticalSpacing;
kTranslateBubbleRelatedControlVerticalSpacing;
}
CGFloat diffY = [[sourcePopUpButton cell]
......@@ -645,11 +660,13 @@ const CGFloat kContentWidth = kWindowWidth - 2 * kFramePadding;
NSRect frame = [targetPopUpButton frame];
frame.origin = NSMakePoint(textLabelWidth, yPos);
frame.size.width = (kWindowWidth - 2 * kFramePadding) - textLabelWidth;
frame.size.width =
(kTranslateBubbleWindowWidth - 2 * kTranslateBubbleFramePadding) -
textLabelWidth;
[targetPopUpButton setFrame:frame];
yPos += NSHeight([targetPopUpButton frame]) +
kRelatedControlVerticalSpacing;
kTranslateBubbleRelatedControlVerticalSpacing;
[sourceLanguageLabel setFrameOrigin:NSMakePoint(
textLabelWidth - NSWidth([sourceLanguageLabel frame]), yPos + diffY)];
......@@ -659,9 +676,9 @@ const CGFloat kContentWidth = kWindowWidth - 2 * kFramePadding;
frame.size.width = NSWidth([targetPopUpButton frame]);
[sourcePopUpButton setFrame:frame];
[view
setFrameSize:NSMakeSize(kContentWidth, NSMaxY([sourcePopUpButton frame]) +
kIconPadding)];
[view setFrameSize:NSMakeSize(kTranslateBubbleContentWidth,
NSMaxY([sourcePopUpButton frame]) +
kTranslateBubbleIconPadding)];
[self updateAdvancedView];
......@@ -678,12 +695,14 @@ const CGFloat kContentWidth = kWindowWidth - 2 * kFramePadding;
[advancedDoneButton_ sizeToFit];
NSRect frame = [advancedDoneButton_ frame];
frame.origin.x = (kWindowWidth - 2 * kFramePadding) - NSWidth(frame);
frame.origin.x =
(kTranslateBubbleWindowWidth - 2 * kTranslateBubbleFramePadding) -
NSWidth(frame);
[advancedDoneButton_ setFrameOrigin:frame.origin];
frame = [advancedCancelButton_ frame];
frame.origin.x = NSMinX([advancedDoneButton_ frame]) - NSWidth(frame)
- kRelatedControlHorizontalSpacing;
frame.origin.x = NSMinX([advancedDoneButton_ frame]) - NSWidth(frame) -
kTranslateBubbleRelatedControlHorizontalSpacing;
[advancedCancelButton_ setFrameOrigin:frame.origin];
}
......@@ -694,7 +713,8 @@ const CGFloat kContentWidth = kWindowWidth - 2 * kFramePadding;
}
- (NSImageView*)addIcon:(NSView*)view {
NSRect imageFrame = NSMakeRect(0, 0, kIconWidth, kIconHeight);
NSRect imageFrame =
NSMakeRect(0, 0, kTranslateBubbleIconWidth, kTranslateBubbleIconHeight);
base::scoped_nsobject<NSImageView> image(
[[NSImageView alloc] initWithFrame:imageFrame]);
[image setImage:(ui::ResourceBundle::GetSharedInstance()
......@@ -709,8 +729,12 @@ const CGFloat kContentWidth = kWindowWidth - 2 * kFramePadding;
withRanges:(std::vector<NSRange>)ranges
delegate:(id<NSTextViewDelegate>)delegate {
NSRect frame =
NSMakeRect(kFramePadding + kIconWidth + kIconPadding, kFramePadding,
kContentWidth - kIconWidth - kIconPadding, 0);
NSMakeRect(kTranslateBubbleFramePadding + kTranslateBubbleIconWidth +
kTranslateBubbleIconPadding,
kTranslateBubbleFramePadding,
kTranslateBubbleContentWidth - kTranslateBubbleIconWidth -
kTranslateBubbleIconPadding,
0);
base::scoped_nsobject<HyperlinkTextView> styledText(
[[HyperlinkTextView alloc] initWithFrame:frame]);
[styledText setMessage:message
......
......@@ -128,7 +128,7 @@ int SadTab::GetTitle() {
return 0;
}
int SadTab::GetMessage() {
int SadTab::GetInfoMessage() {
switch (kind_) {
#if defined(OS_CHROMEOS)
case SAD_TAB_KIND_KILLED_BY_OOM:
......
......@@ -46,7 +46,7 @@ class SadTab {
// different for each sad tab. (Right now, the first sad tab in a session
// suggests reloading and subsequent ones suggest sending feedback.)
int GetTitle();
int GetMessage();
int GetInfoMessage();
int GetButtonTitle();
int GetHelpLinkTitle();
......
......@@ -107,7 +107,7 @@ SadTabView::SadTabView(content::WebContents* web_contents, SadTabKind kind)
unrelated_vertical_spacing_large);
layout->AddView(title_, 2, 1.0);
message_ = CreateFormattedLabel(l10n_util::GetStringUTF16(GetMessage()));
message_ = CreateFormattedLabel(l10n_util::GetStringUTF16(GetInfoMessage()));
layout->StartRowWithPadding(views::GridLayout::kFixedSize, column_set_id,
views::GridLayout::kFixedSize,
kTitleBottomSpacing);
......
......@@ -107,7 +107,7 @@ const int kFontSizeDelta = ui::ResourceBundle::kSmallFontDelta;
NSColor* centerColor;
NSColor* innerColor;
NSColor* outerColor;
HoverState hoverState =
CloseButtonHoverState hoverState =
[base::mac::ObjCCastStrict<HoverButtonCocoa>(controlView) hoverState];
// Leave a sliver of height 1 for the button drop shadow.
frame.size.height -= 1;
......
......@@ -33,13 +33,13 @@ UI_BASE_EXPORT
@protected
// Enumeration of the hover states that the close button can be in at any one
// time. The button cannot be in more than one hover state at a time.
enum HoverState {
enum CloseButtonHoverState {
kHoverStateNone = 0,
kHoverStateMouseOver = 1,
kHoverStateMouseDown = 2
};
HoverState hoverState_;
CloseButtonHoverState hoverState_;
@private
// Tracking area for button mouseover states. Nil if not enabled.
......@@ -48,7 +48,7 @@ UI_BASE_EXPORT
BOOL sendActionOnMouseDown_;
}
@property(nonatomic) HoverState hoverState;
@property(nonatomic) CloseButtonHoverState hoverState;
// Enables or disables the tracking for the button.
@property(nonatomic) BOOL trackingEnabled;
......
......@@ -192,7 +192,7 @@ constexpr CGFloat kDragDistance = 5;
}
}
- (void)setHoverState:(HoverState)hoverState {
- (void)setHoverState:(CloseButtonHoverState)hoverState {
if (hoverState == hoverState_)
return;
hoverState_ = hoverState;
......
......@@ -73,7 +73,7 @@ class HoverButtonTest : public ui::CocoaTest {
}
protected:
void HoverAndExpect(HoverState hoverState) {
void HoverAndExpect(CloseButtonHoverState hoverState) {
EXPECT_EQ(kHoverStateNone, button_.hoverState);
[button_ mouseEntered:cocoa_test_event_utils::EnterEvent()];
EXPECT_EQ(hoverState, button_.hoverState);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment