summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-10 19:21:53 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-10 19:21:53 +0000
commitf6d21d18df3cc2916fe4715cf4c2cdc64229b87e (patch)
treeb138af2a347bd2bb85523ecbb0302fe23732fd20 /ui
parentb02f4d85f25f243cd0143db798ff45f15faddc4b (diff)
downloadchromium_src-f6d21d18df3cc2916fe4715cf4c2cdc64229b87e.zip
chromium_src-f6d21d18df3cc2916fe4715cf4c2cdc64229b87e.tar.gz
chromium_src-f6d21d18df3cc2916fe4715cf4c2cdc64229b87e.tar.bz2
mac notifications: Show settings below the control area.
This matches the current mocks. 1. The settings dialog is now below the control area, rather than on top of it. 2. The back button moves from the settings view to the tray view. It's shown only when the settings are visible. 3. Disable the "clear all" button while the settings are up. This completes v1 of the settings view (except for the tests missing from the last CL, I'll look at that next). http://imgur.com/XQqapVC BUG=238247 TEST=Look at settings. R=rsesek@chromium.org Review URL: https://codereview.chromium.org/16720003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@205268 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/message_center/cocoa/settings_controller.h11
-rw-r--r--ui/message_center/cocoa/settings_controller.mm45
-rw-r--r--ui/message_center/cocoa/tray_view_controller.h12
-rw-r--r--ui/message_center/cocoa/tray_view_controller.mm97
4 files changed, 75 insertions, 90 deletions
diff --git a/ui/message_center/cocoa/settings_controller.h b/ui/message_center/cocoa/settings_controller.h
index 976172c..a802ad4 100644
--- a/ui/message_center/cocoa/settings_controller.h
+++ b/ui/message_center/cocoa/settings_controller.h
@@ -12,7 +12,6 @@
#include "ui/message_center/message_center_export.h"
#include "ui/message_center/notifier_settings.h"
-@class HoverImageButton;
@class MCSettingsController;
namespace message_center {
@@ -47,9 +46,6 @@ MESSAGE_CENTER_EXPORT
scoped_ptr<message_center::NotifierSettingsDelegateMac> delegate_;
message_center::NotifierSettingsProvider* provider_;
- // The back button at the top.
- scoped_nsobject<HoverImageButton> backButton_;
-
// The "Settings" text at the top.
scoped_nsobject<NSTextField> settingsText_;
@@ -68,13 +64,6 @@ MESSAGE_CENTER_EXPORT
// Returns the bridge object for this controller.
- (message_center::NotifierSettingsDelegateMac*)delegate;
-// Returns a view that should be initial first responder.
-- (NSView*)responderView;
-
-// Set up the close target and action.
-- (void)setCloseTarget:(id)target;
-- (void)setCloseAction:(SEL)action;
-
@end
// Testing API /////////////////////////////////////////////////////////////////
diff --git a/ui/message_center/cocoa/settings_controller.mm b/ui/message_center/cocoa/settings_controller.mm
index 5c897a2..bdbe3c8 100644
--- a/ui/message_center/cocoa/settings_controller.mm
+++ b/ui/message_center/cocoa/settings_controller.mm
@@ -6,9 +6,7 @@
#include "base/mac/foundation_util.h"
#include "base/strings/sys_string_conversions.h"
-#include "grit/ui_resources.h"
#include "grit/ui_strings.h"
-#import "ui/base/cocoa/hover_image_button.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#import "base/memory/scoped_nsobject.h"
@@ -16,7 +14,6 @@
#include "ui/message_center/message_center_style.h"
#include "skia/ext/skia_utils_mac.h"
-const int kBackButtonSize = 32;
const int kMarginWidth = 16;
const int kEntryHeight = 32;
const int kIconSize = 16;
@@ -143,7 +140,7 @@ NotifierSettingsDelegate* ShowSettings(NotifierSettingsProvider* provider,
- (void)loadView {
provider_->GetNotifierList(&notifiers_);
- CGFloat maxHeight = [MCTrayViewController maxTrayHeight];
+ CGFloat maxHeight = [MCTrayViewController maxTrayClientHeight];
// Container view.
NSRect fullFrame =
@@ -157,27 +154,9 @@ NotifierSettingsDelegate* ShowSettings(NotifierSettingsProvider* provider,
[view setTitlePosition:NSNoTitle];
[self setView:view];
- // Back button.
- NSRect backButtonFrame = NSMakeRect(
- kMarginWidth, kMarginWidth, kBackButtonSize, kBackButtonSize);
- backButton_.reset([[HoverImageButton alloc] initWithFrame:backButtonFrame]);
- ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- [backButton_ setDefaultImage:
- rb.GetNativeImageNamed(IDR_NOTIFICATION_ARROW).ToNSImage()];
- [backButton_ setHoverImage:
- rb.GetNativeImageNamed(IDR_NOTIFICATION_ARROW_HOVER).ToNSImage()];
- [backButton_ setPressedImage:
- rb.GetNativeImageNamed(IDR_NOTIFICATION_ARROW_PRESSED).ToNSImage()];
- [[backButton_ cell] setHighlightsBy:NSOnState];
- [backButton_ setBordered:NO];
- [backButton_ setAutoresizingMask:NSViewMinYMargin];
- [[self view] addSubview:backButton_];
-
// "Settings" text.
- NSRect headerFrame = NSMakeRect(NSMaxX(backButtonFrame),
- kMarginWidth,
- NSWidth(fullFrame) - NSMaxX(backButtonFrame),
- NSHeight(fullFrame));
+ NSRect headerFrame = NSMakeRect(
+ kMarginWidth, kMarginWidth, NSWidth(fullFrame), NSHeight(fullFrame));
settingsText_.reset([self newLabelWithFrame:headerFrame]);
[settingsText_ setAutoresizingMask:NSViewMinYMargin];
[settingsText_ setTextColor:gfx::SkColorToCalibratedNSColor(
@@ -193,10 +172,6 @@ NotifierSettingsDelegate* ShowSettings(NotifierSettingsProvider* provider,
NSMaxY(fullFrame) - kMarginWidth - NSHeight(headerFrame);
[[self view] addSubview:settingsText_];
- // Vertically center back button with "Settings" text.
- backButtonFrame.origin.y =
- NSMidY(headerFrame) - NSHeight(backButtonFrame) / 2;
-
// Subheader.
NSRect subheaderFrame = NSMakeRect(
kMarginWidth, kMarginWidth, NSWidth(fullFrame), NSHeight(fullFrame));
@@ -257,7 +232,6 @@ NotifierSettingsDelegate* ShowSettings(NotifierSettingsProvider* provider,
// Everything fits without scrolling.
CGFloat delta = remainingHeight - NSHeight(documentFrame);
headerFrame.origin.y -= delta;
- backButtonFrame.origin.y -= delta;
subheaderFrame.origin.y -= delta;
fullFrame.size.height -= delta;
} else {
@@ -275,7 +249,6 @@ NotifierSettingsDelegate* ShowSettings(NotifierSettingsProvider* provider,
// Set final sizes.
[[self view] setFrame:fullFrame];
[[self view] addSubview:scrollView_];
- [backButton_ setFrame:backButtonFrame];
[settingsText_ setFrame:headerFrame];
[detailsText_ setFrame:subheaderFrame];
}
@@ -289,18 +262,6 @@ NotifierSettingsDelegate* ShowSettings(NotifierSettingsProvider* provider,
return delegate_.get();
}
-- (NSView*)responderView {
- return backButton_;
-}
-
-- (void)setCloseTarget:(id)target {
- [backButton_ setTarget:target];
-}
-
-- (void)setCloseAction:(SEL)action {
- [backButton_ setAction:action];
-}
-
// Testing API /////////////////////////////////////////////////////////////////
- (NSScrollView*)scrollView {
diff --git a/ui/message_center/cocoa/tray_view_controller.h b/ui/message_center/cocoa/tray_view_controller.h
index 3c02360..a20f3e4 100644
--- a/ui/message_center/cocoa/tray_view_controller.h
+++ b/ui/message_center/cocoa/tray_view_controller.h
@@ -21,6 +21,8 @@ namespace message_center {
class MessageCenter;
}
+@class HoverImageButton;
+
// The view controller responsible for the content of the message center tray
// UI. This hosts a scroll view of all the notifications, as well as buttons
// to enter quiet mode and the settings panel.
@@ -30,6 +32,12 @@ MESSAGE_CENTER_EXPORT
// Controller of the notifications, where action messages are forwarded. Weak.
message_center::MessageCenter* messageCenter_;
+ // The back button shown while the settings are open.
+ scoped_nsobject<HoverImageButton> backButton_;
+
+ // The "Notifications" label at the top.
+ scoped_nsobject<NSTextField> title_;
+
// The scroll view that contains all the notifications in its documentView.
scoped_nsobject<NSScrollView> scrollView_;
@@ -79,8 +87,8 @@ MESSAGE_CENTER_EXPORT
// Scroll to the topmost notification in the tray.
- (void)scrollToTop;
-// Returns the maximum height of the notifications tray.
-+ (CGFloat)maxTrayHeight;
+// Returns the maximum height of the client area of the notifications tray.
++ (CGFloat)maxTrayClientHeight;
// Returns the width of the notifications tray.
+ (CGFloat)trayWidth;
diff --git a/ui/message_center/cocoa/tray_view_controller.mm b/ui/message_center/cocoa/tray_view_controller.mm
index c344dc9..6c8b651 100644
--- a/ui/message_center/cocoa/tray_view_controller.mm
+++ b/ui/message_center/cocoa/tray_view_controller.mm
@@ -19,6 +19,8 @@
#include "ui/message_center/message_center.h"
#include "ui/message_center/message_center_style.h"
+const int kBackButtonSize = 16;
+
@interface MCTrayViewController (Private)
// Creates all the views for the control area of the tray.
- (void)layoutControlArea;
@@ -199,10 +201,8 @@ const CGFloat kTrayBottomMargin = 75;
}
- (void)showSettings:(id)sender {
- if (settingsController_) {
- NOTREACHED();
+ if (settingsController_)
return [self hideSettings:sender];
- }
{
// ShowNotificationSettingsDialog() returns an object owned by an
@@ -220,11 +220,14 @@ const CGFloat kTrayBottomMargin = 75;
[[self view] addSubview:[settingsController_ view]];
- [settingsController_ setCloseTarget:self];
- [settingsController_ setCloseAction:@selector(hideSettings:)];
+ NSRect titleFrame = [title_ frame];
+ titleFrame.origin.x =
+ NSMaxX([backButton_ frame]) + message_center::kMarginBetweenItems / 2;
+ [title_ setFrame:titleFrame];
+ [backButton_ setHidden:NO];
+ [clearAllButton_ setEnabled:NO];
[[[self view] window] recalculateKeyViewLoop];
- [[[self view] window] makeFirstResponder:[settingsController_ responderView]];
[self forceWindowSizeUpdate];
}
@@ -232,8 +235,14 @@ const CGFloat kTrayBottomMargin = 75;
- (void)hideSettings:(id)sender {
[[settingsController_ view] removeFromSuperview];
settingsController_.reset();
+
+ NSRect titleFrame = [title_ frame];
+ titleFrame.origin.x = NSMinX([backButton_ frame]);
+ [title_ setFrame:titleFrame];
+ [backButton_ setHidden:YES];
+ [clearAllButton_ setEnabled:YES];
+
[[[self view] window] recalculateKeyViewLoop];
- [[[self view] window] makeFirstResponder:pauseButton_];
[self forceWindowSizeUpdate];
}
@@ -243,9 +252,9 @@ const CGFloat kTrayBottomMargin = 75;
[[scrollView_ documentView] scrollPoint:topPoint];
}
-+ (CGFloat)maxTrayHeight {
++ (CGFloat)maxTrayClientHeight {
NSRect screenFrame = [[[NSScreen screens] objectAtIndex:0] visibleFrame];
- return NSHeight(screenFrame) - kTrayBottomMargin;
+ return NSHeight(screenFrame) - kTrayBottomMargin - kControlAreaHeight;
}
+ (CGFloat)trayWidth {
@@ -270,30 +279,56 @@ const CGFloat kTrayBottomMargin = 75;
// Private /////////////////////////////////////////////////////////////////////
- (void)layoutControlArea {
+ ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
NSView* view = [self view];
// Create the "Notifications" label at the top of the tray.
NSFont* font = [NSFont labelFontOfSize:message_center::kTitleFontSize];
- scoped_nsobject<NSTextField> title(
- [[NSTextField alloc] initWithFrame:NSZeroRect]);
- [title setAutoresizingMask:NSViewMinYMargin];
- [title setBezeled:NO];
- [title setBordered:NO];
- [title setDrawsBackground:NO];
- [title setEditable:NO];
- [title setFont:font];
- [title setSelectable:NO];
- [title setStringValue:
+ title_.reset([[NSTextField alloc] initWithFrame:NSZeroRect]);
+ [title_ setAutoresizingMask:NSViewMinYMargin];
+ [title_ setBezeled:NO];
+ [title_ setBordered:NO];
+ [title_ setDrawsBackground:NO];
+ [title_ setEditable:NO];
+ [title_ setFont:font];
+ [title_ setSelectable:NO];
+ [title_ setStringValue:
l10n_util::GetNSString(IDS_MESSAGE_CENTER_FOOTER_TITLE)];
- [title setTextColor:gfx::SkColorToCalibratedNSColor(
+ [title_ setTextColor:gfx::SkColorToCalibratedNSColor(
message_center::kFooterTextColor)];
- [title sizeToFit];
+ [title_ sizeToFit];
- NSRect titleFrame = [title frame];
+ NSRect titleFrame = [title_ frame];
titleFrame.origin.x = message_center::kMarginBetweenItems;
titleFrame.origin.y = kControlAreaHeight/2 - NSMidY(titleFrame);
- [title setFrame:titleFrame];
- [view addSubview:title];
+ [title_ setFrame:titleFrame];
+ [view addSubview:title_];
+
+ auto configureButton = ^(HoverImageButton* button) {
+ [[button cell] setHighlightsBy:NSOnState];
+ [button setTrackingEnabled:YES];
+ [button setBordered:NO];
+ [button setAutoresizingMask:NSViewMinYMargin];
+ [button setTarget:self];
+ };
+
+ // Back button. On top of the "Notifications" label, hidden by default.
+ NSRect backButtonFrame =
+ NSMakeRect(NSMinX(titleFrame),
+ (kControlAreaHeight - kBackButtonSize) / 2,
+ kBackButtonSize,
+ kBackButtonSize);
+ backButton_.reset([[HoverImageButton alloc] initWithFrame:backButtonFrame]);
+ [backButton_ setDefaultImage:
+ rb.GetNativeImageNamed(IDR_NOTIFICATION_ARROW).ToNSImage()];
+ [backButton_ setHoverImage:
+ rb.GetNativeImageNamed(IDR_NOTIFICATION_ARROW_HOVER).ToNSImage()];
+ [backButton_ setPressedImage:
+ rb.GetNativeImageNamed(IDR_NOTIFICATION_ARROW_PRESSED).ToNSImage()];
+ [backButton_ setAction:@selector(hideSettings:)];
+ configureButton(backButton_);
+ [backButton_ setHidden:YES];
+ [[self view] addSubview:backButton_];
// Create the divider line between the control area and the notifications.
scoped_nsobject<NSBox> divider(
@@ -316,16 +351,7 @@ const CGFloat kTrayBottomMargin = 75;
size.height);
};
- auto configureButton = ^(HoverImageButton* button) {
- [[button cell] setHighlightsBy:NSOnState];
- [button setTrackingEnabled:YES];
- [button setBordered:NO];
- [button setAutoresizingMask:NSViewMinYMargin];
- [button setTarget:self];
- };
-
// Create the settings button at the far-right.
- ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
NSImage* defaultImage =
rb.GetNativeImageNamed(IDR_NOTIFICATION_SETTINGS).ToNSImage();
NSRect settingsButtonFrame = getButtonFrame(
@@ -400,9 +426,10 @@ const CGFloat kTrayBottomMargin = 75;
if (settingsController_) {
frame.size.height = NSHeight([[settingsController_ view] frame]);
} else {
- frame.size.height = std::min([MCTrayViewController maxTrayHeight],
- scrollContentHeight + kControlAreaHeight);
+ frame.size.height = std::min([MCTrayViewController maxTrayClientHeight],
+ scrollContentHeight);
}
+ frame.size.height += kControlAreaHeight;
CGFloat newHeight = NSHeight(frame);
[[self view] setFrame:frame];