summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorjennyz@chromium.org <jennyz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-13 22:32:38 +0000
committerjennyz@chromium.org <jennyz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-13 22:32:38 +0000
commitf6ad9f25acf1318955be8664deee40dafcd59651 (patch)
tree4612a189451f682842a393d2cdbc647ebc963187 /ash
parent9dc4794d2759fde611f89b6e808a104fe490d7ef (diff)
downloadchromium_src-f6ad9f25acf1318955be8664deee40dafcd59651.zip
chromium_src-f6ad9f25acf1318955be8664deee40dafcd59651.tar.gz
chromium_src-f6ad9f25acf1318955be8664deee40dafcd59651.tar.bz2
Add left/right launcher support to web notification.
BUG=127579 TEST=The web notification tray and bubble should looks right for left/right launcher. Review URL: https://chromiumcodereview.appspot.com/10698179 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146673 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/system/web_notification/web_notification_tray.cc58
-rw-r--r--ash/system/web_notification/web_notification_tray.h2
2 files changed, 55 insertions, 5 deletions
diff --git a/ash/system/web_notification/web_notification_tray.cc b/ash/system/web_notification/web_notification_tray.cc
index bce9b2e..8455de7 100644
--- a/ash/system/web_notification/web_notification_tray.cc
+++ b/ash/system/web_notification/web_notification_tray.cc
@@ -30,9 +30,15 @@
namespace {
// Tray constants
-const int kTrayBorder = 4;
+const int kTrayContainerVeritcalPaddingBottomAlignment = 3;
+const int kTrayContainerHorizontalPaddingBottomAlignment = 1;
+const int kTrayContainerVerticalPaddingVerticalAlignment = 1;
+const int kTrayContainerHorizontalPaddingVerticalAlignment = 0;
+const int kPaddingFromLeftEdgeOfSystemTrayBottomAlignment = 8;
+const int kPaddingFromTopEdgeOfSystemTrayVerticalAlignment = 10;
const int kNotificationImageIconWidth = 40;
const int kNotificationImageIconHeight = 25;
+const int kNotificationImageIconInset = 4;
// Web Notification Bubble constants
const int kWebNotificationBubbleMinHeight = 80;
@@ -60,9 +66,13 @@ SkBitmap GetNotificationImage(int notification_count) {
IDR_AURA_UBER_TRAY_WEB_NOTIFICATON);
int image_index = notification_count - 1;
image_index = std::max(0, std::min(image_index, 2));
+ // The original width of the image looks too big, so we need to inset
+ // it somewhat.
SkIRect region = SkIRect::MakeXYWH(
- 0, image_index * kNotificationImageIconHeight,
- kNotificationImageIconWidth, kNotificationImageIconHeight);
+ kNotificationImageIconInset, image_index * kNotificationImageIconHeight,
+ kNotificationImageIconWidth - 2 * kNotificationImageIconInset,
+ kNotificationImageIconHeight);
+
all.ToSkBitmap()->extractSubset(&image, region);
return image;
}
@@ -670,8 +680,6 @@ WebNotificationTray::WebNotificationTray(
delegate_(NULL),
show_bubble_on_unlock_(false) {
tray_container_ = new views::View;
- tray_container_->set_border(views::Border::CreateEmptyBorder(
- kTrayBorder, kTrayBorder, kTrayBorder, kTrayBorder));
SetShelfAlignment(shelf_alignment());
icon_ = new views::ImageView;
@@ -804,6 +812,8 @@ void WebNotificationTray::OnClicked(const std::string& id) {
void WebNotificationTray::SetShelfAlignment(ShelfAlignment alignment) {
internal::TrayBackgroundView::SetShelfAlignment(alignment);
+ SetTrayContainerBorder();
+ SetBorder();
tray_container_->SetLayoutManager(new views::BoxLayout(
alignment == SHELF_ALIGNMENT_BOTTOM ?
views::BoxLayout::kHorizontal : views::BoxLayout::kVertical,
@@ -820,6 +830,44 @@ bool WebNotificationTray::PerformAction(const views::Event& event) {
return true;
}
+void WebNotificationTray::SetBorder() {
+ // Change the border padding for different shelf alignment.
+ // This affects the position of the web notification tray.
+ if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) {
+ set_border(views::Border::CreateEmptyBorder(0, 0,
+ kPaddingFromBottomOfScreenBottomAlignment,
+ kPaddingFromLeftEdgeOfSystemTrayBottomAlignment));
+ } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) {
+ set_border(views::Border::CreateEmptyBorder(0,
+ kPaddingFromOuterEdgeOfLauncherVerticalAlignment,
+ kPaddingFromTopEdgeOfSystemTrayVerticalAlignment,
+ kPaddingFromInnerEdgeOfLauncherVerticalAlignment));
+ } else {
+ set_border(views::Border::CreateEmptyBorder(0,
+ kPaddingFromInnerEdgeOfLauncherVerticalAlignment,
+ kPaddingFromTopEdgeOfSystemTrayVerticalAlignment,
+ kPaddingFromOuterEdgeOfLauncherVerticalAlignment));
+ }
+}
+
+void WebNotificationTray::SetTrayContainerBorder() {
+ // Adjust the size of web notification tray dark background by adding
+ // additional empty border.
+ if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) {
+ tray_container_->set_border(views::Border::CreateEmptyBorder(
+ kTrayContainerVeritcalPaddingBottomAlignment,
+ kTrayContainerHorizontalPaddingBottomAlignment,
+ kTrayContainerVeritcalPaddingBottomAlignment,
+ kTrayContainerHorizontalPaddingBottomAlignment));
+ } else {
+ tray_container_->set_border(views::Border::CreateEmptyBorder(
+ kTrayContainerVerticalPaddingVerticalAlignment,
+ kTrayContainerHorizontalPaddingVerticalAlignment,
+ kTrayContainerVerticalPaddingVerticalAlignment,
+ kTrayContainerHorizontalPaddingVerticalAlignment));
+ }
+}
+
int WebNotificationTray::GetNotificationCount() const {
return notification_list()->notifications().size();
}
diff --git a/ash/system/web_notification/web_notification_tray.h b/ash/system/web_notification/web_notification_tray.h
index 63956c2..ae78d7a 100644
--- a/ash/system/web_notification/web_notification_tray.h
+++ b/ash/system/web_notification/web_notification_tray.h
@@ -134,6 +134,8 @@ class ASH_EXPORT WebNotificationTray : public internal::TrayBackgroundView {
class BubbleContentsView;
FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, WebNotifications);
+ void SetBorder();
+ void SetTrayContainerBorder();
int GetNotificationCount() const;
void UpdateIcon();
void UpdateBubbleAndIcon();