summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-04 18:45:15 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-04 18:45:15 +0000
commit60d4167c122aab34faf9b6dc5af0f4b3a5a17a30 (patch)
treeda7fa4dabbb6f42a74d354ed5a3865f5256c7c3d /ash
parent42463cfc2579c54857ef43300cc55af08471a43f (diff)
downloadchromium_src-60d4167c122aab34faf9b6dc5af0f4b3a5a17a30.zip
chromium_src-60d4167c122aab34faf9b6dc5af0f4b3a5a17a30.tar.gz
chromium_src-60d4167c122aab34faf9b6dc5af0f4b3a5a17a30.tar.bz2
ash uber tray: Make the user-card float a few pixels above the rest of the items.
BUG=110130 TEST=none Review URL: https://chromiumcodereview.appspot.com/9585012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124900 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/ash.gyp2
-rw-r--r--ash/shell.cc2
-rw-r--r--ash/system/tray/system_tray.cc135
-rw-r--r--ash/system/tray/tray_empty.cc44
-rw-r--r--ash/system/tray/tray_empty.h34
5 files changed, 208 insertions, 9 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index c69b6b8..a9c4593 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -123,6 +123,8 @@
'system/tray/system_tray_delegate.h',
'system/tray/system_tray_item.cc',
'system/tray/system_tray_item.h',
+ 'system/tray/tray_empty.cc',
+ 'system/tray/tray_empty.h',
'system/user/login_status.h',
'system/user/tray_user.cc',
'system/user/tray_user.h',
diff --git a/ash/shell.cc b/ash/shell.cc
index 913d585..1153e94 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -22,6 +22,7 @@
#include "ash/system/power/tray_power_date.h"
#include "ash/system/tray/system_tray_delegate.h"
#include "ash/system/tray/system_tray.h"
+#include "ash/system/tray/tray_empty.h"
#include "ash/system/user/tray_user.h"
#include "ash/tooltips/tooltip_controller.h"
#include "ash/wm/activation_controller.h"
@@ -439,6 +440,7 @@ void Shell::Init() {
power_status_controller_ = tray_power_date;
tray_->AddTrayItem(new internal::TrayUser());
+ tray_->AddTrayItem(new internal::TrayEmpty());
tray_->AddTrayItem(tray_power_date);
tray_->AddTrayItem(tray_volume);
tray_->AddTrayItem(tray_brightness);
diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc
index 763efc0..dde23b1 100644
--- a/ash/system/tray/system_tray.cc
+++ b/ash/system/tray/system_tray.cc
@@ -12,7 +12,11 @@
#include "ash/wm/shadow_types.h"
#include "base/logging.h"
#include "base/utf_string_conversions.h"
+#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColor.h"
+#include "third_party/skia/include/core/SkPaint.h"
+#include "third_party/skia/include/core/SkPath.h"
+#include "ui/gfx/canvas.h"
#include "ui/views/border.h"
#include "ui/views/bubble/bubble_delegate.h"
#include "ui/views/controls/label.h"
@@ -21,8 +25,121 @@
namespace {
-const int kTrayIconHeight = 50;
-const int kPadding = 5;
+const int kArrowHeight = 10;
+const int kArrowWidth = 20;
+const int kArrowPaddingFromRight = 20;
+
+const int kShadowOffset = 3;
+const int kShadowHeight = 3;
+
+const SkColor kDarkColor = SkColorSetRGB(120, 120, 120);
+const SkColor kLightColor = SkColorSetRGB(240, 240, 240);
+const SkColor kBackgroundColor = SK_ColorWHITE;
+const SkColor kShadowColor = SkColorSetARGB(25, 0, 0, 0);
+
+class SystemTrayBubbleBackground : public views::Background {
+ public:
+ explicit SystemTrayBubbleBackground(views::View* owner)
+ : owner_(owner) {
+ }
+
+ virtual ~SystemTrayBubbleBackground() {}
+
+ private:
+ // Overridden from views::Background.
+ virtual void Paint(gfx::Canvas* canvas, views::View* view) const OVERRIDE {
+ views::View* last_view = NULL;
+ for (int i = 0; i < owner_->child_count(); i++) {
+ views::View* v = owner_->child_at(i);
+
+ if (!v->background()) {
+ canvas->FillRect(v->bounds(), kBackgroundColor);
+ } else if (last_view) {
+ canvas->FillRect(gfx::Rect(v->x() + kShadowOffset, v->y(),
+ v->width() - kShadowOffset, kShadowHeight),
+ kShadowColor);
+ }
+
+ if (!v->border()) {
+ canvas->DrawLine(gfx::Point(v->x() - 1, v->y() - 1),
+ gfx::Point(v->x() + v->width() + 1, v->y() - 1),
+ !last_view || last_view->border() ? kDarkColor : kLightColor);
+ canvas->DrawLine(gfx::Point(v->x() - 1, v->y() - 1),
+ gfx::Point(v->x() - 1, v->y() + v->height() + 1),
+ kDarkColor);
+ canvas->DrawLine(gfx::Point(v->x() + v->width(), v->y() - 1),
+ gfx::Point(v->x() + v->width(), v->y() + v->height() + 1),
+ kDarkColor);
+ } else if (last_view && !last_view->border()) {
+ canvas->DrawLine(gfx::Point(v->x() - 1, v->y() - 1),
+ gfx::Point(v->x() + v->width() + 1, v->y() - 1),
+ kDarkColor);
+ }
+
+ last_view = v;
+ }
+ }
+
+ views::View* owner_;
+
+ DISALLOW_COPY_AND_ASSIGN(SystemTrayBubbleBackground);
+};
+
+class SystemTrayBubbleBorder : public views::Border {
+ public:
+ explicit SystemTrayBubbleBorder(views::View* owner)
+ : owner_(owner) {
+ }
+
+ virtual ~SystemTrayBubbleBorder() {}
+
+ private:
+ // Overridden from views::Border.
+ virtual void Paint(const views::View& view,
+ gfx::Canvas* canvas) const OVERRIDE {
+ // Draw a line first.
+ int x = 4;
+ int y = owner_->height() + 1;
+ canvas->DrawLine(gfx::Point(x, y),
+ gfx::Point(owner_->width() + x, y),
+ kDarkColor);
+
+ // Now, draw a shadow.
+ canvas->FillRect(gfx::Rect(x + kShadowOffset, y,
+ owner_->width() - kShadowOffset, kShadowHeight),
+ kShadowColor);
+
+ // Draw the arrow.
+ int left_base_x = owner_->width() - kArrowPaddingFromRight - kArrowWidth;
+ int left_base_y = y;
+ int tip_x = left_base_x + kArrowWidth / 2;
+ int tip_y = left_base_y + kArrowHeight;
+ SkPath path;
+ path.incReserve(4);
+ path.moveTo(SkIntToScalar(left_base_x), SkIntToScalar(left_base_y));
+ path.lineTo(SkIntToScalar(tip_x), SkIntToScalar(tip_y));
+ path.lineTo(SkIntToScalar(left_base_x + kArrowWidth),
+ SkIntToScalar(left_base_y));
+
+ SkPaint paint;
+ paint.setStyle(SkPaint::kFill_Style);
+ paint.setColor(kBackgroundColor);
+ canvas->GetSkCanvas()->drawPath(path, paint);
+
+ // Now the draw the outline.
+ paint.setStyle(SkPaint::kStroke_Style);
+ paint.setColor(kDarkColor);
+ canvas->GetSkCanvas()->drawPath(path, paint);
+ }
+
+ virtual void GetInsets(gfx::Insets* insets) const OVERRIDE {
+ insets->Set(0, 0, kArrowHeight, 0);
+ }
+
+ views::View* owner_;
+
+ DISALLOW_COPY_AND_ASSIGN(SystemTrayBubbleBorder);
+};
class SystemTrayBubble : public views::BubbleDelegateView {
public:
@@ -51,7 +168,8 @@ class SystemTrayBubble : public views::BubbleDelegateView {
// Overridden from views::BubbleDelegateView.
virtual void Init() OVERRIDE {
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical,
- 0, 0, 1));
+ 1, 1, 1));
+ set_background(new SystemTrayBubbleBackground(this));
ash::SystemTrayDelegate* delegate =
ash::Shell::GetInstance()->tray_delegate();
@@ -61,12 +179,8 @@ class SystemTrayBubble : public views::BubbleDelegateView {
++it) {
views::View* view = detailed_ ? (*it)->CreateDetailedView(login_status) :
(*it)->CreateDefaultView(login_status);
- if (!view)
- continue;
- if (it != items_.begin())
- view->set_border(views::Border::CreateSolidSidedBorder(
- 1, 0, 0, 0, SkColorSetARGB(25, 0, 0, 0)));
- AddChildView(view);
+ if (view)
+ AddChildView(view);
}
}
@@ -150,6 +264,9 @@ void SystemTray::ShowItems(std::vector<SystemTrayItem*>& items, bool detailed) {
CHECK(!popup_);
SystemTrayBubble* bubble = new SystemTrayBubble(this, items, detailed);
popup_ = views::BubbleDelegateView::CreateBubble(bubble);
+ popup_->non_client_view()->frame_view()->set_background(NULL);
+ popup_->non_client_view()->frame_view()->set_border(
+ new SystemTrayBubbleBorder(bubble));
popup_->AddObserver(this);
bubble->Show();
}
diff --git a/ash/system/tray/tray_empty.cc b/ash/system/tray/tray_empty.cc
new file mode 100644
index 0000000..d10c595
--- /dev/null
+++ b/ash/system/tray/tray_empty.cc
@@ -0,0 +1,44 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/system/tray/tray_empty.h"
+
+#include "ui/views/layout/box_layout.h"
+#include "ui/views/view.h"
+
+namespace ash {
+namespace internal {
+
+TrayEmpty::TrayEmpty() {}
+
+TrayEmpty::~TrayEmpty() {}
+
+views::View* TrayEmpty::CreateTrayView(user::LoginStatus status) {
+ return NULL;
+}
+
+views::View* TrayEmpty::CreateDefaultView(user::LoginStatus status) {
+ views::View* view = new views::View;
+
+ view->set_background(views::Background::CreateSolidBackground(
+ SkColorSetARGB(0, 0, 0, 0)));
+ view->set_border(views::Border::CreateEmptyBorder(10, 0, 0, 0));
+ view->SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical,
+ 0, 0, 0));
+
+ return view;
+}
+
+views::View* TrayEmpty::CreateDetailedView(user::LoginStatus status) {
+ return NULL;
+}
+
+void TrayEmpty::DestroyTrayView() {}
+
+void TrayEmpty::DestroyDefaultView() {}
+
+void TrayEmpty::DestroyDetailedView() {}
+
+} // namespace internal
+} // namespace ash
diff --git a/ash/system/tray/tray_empty.h b/ash/system/tray/tray_empty.h
new file mode 100644
index 0000000..263e9c1
--- /dev/null
+++ b/ash/system/tray/tray_empty.h
@@ -0,0 +1,34 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ASH_SYSTEM_TRAY_TRAY_EMPTY_H_
+#define ASH_SYSTEM_TRAY_TRAY_EMPTY_H_
+#pragma once
+
+#include "ash/system/tray/system_tray_item.h"
+
+namespace ash {
+namespace internal {
+
+class TrayEmpty : public SystemTrayItem {
+ public:
+ TrayEmpty();
+ virtual ~TrayEmpty();
+
+ private:
+ // Overridden from SystemTrayItem.
+ virtual views::View* CreateTrayView(user::LoginStatus status) OVERRIDE;
+ virtual views::View* CreateDefaultView(user::LoginStatus status) OVERRIDE;
+ virtual views::View* CreateDetailedView(user::LoginStatus status) OVERRIDE;
+ virtual void DestroyTrayView() OVERRIDE;
+ virtual void DestroyDefaultView() OVERRIDE;
+ virtual void DestroyDetailedView() OVERRIDE;
+
+ DISALLOW_COPY_AND_ASSIGN(TrayEmpty);
+};
+
+} // namespace internal
+} // namespace ash
+
+#endif // ASH_SYSTEM_TRAY_TRAY_EMPTY_H_