summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-10 16:01:33 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-10 16:01:33 +0000
commitea1b011cfcbf0d7ce1de5faba28ecbe7059b33cc (patch)
tree4db35535c7a3ad462112736bfb27eef247b8fc6b /ash
parent6fa7c10f85421abf617f9ee2a5e79bc61baca8ce (diff)
downloadchromium_src-ea1b011cfcbf0d7ce1de5faba28ecbe7059b33cc.zip
chromium_src-ea1b011cfcbf0d7ce1de5faba28ecbe7059b33cc.tar.gz
chromium_src-ea1b011cfcbf0d7ce1de5faba28ecbe7059b33cc.tar.bz2
ash: Remove the row for power, and add a row for date + system buttons.
BUG=127430 TEST=none Review URL: https://chromiumcodereview.appspot.com/10381081 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136318 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/system/date/date_view.cc1
-rw-r--r--ash/system/date/tray_date.cc112
-rw-r--r--ash/system/power/tray_power.cc52
-rw-r--r--ash/system/power/tray_power.h4
4 files changed, 114 insertions, 55 deletions
diff --git a/ash/system/date/date_view.cc b/ash/system/date/date_view.cc
index 97669f1..3481d2a 100644
--- a/ash/system/date/date_view.cc
+++ b/ash/system/date/date_view.cc
@@ -107,6 +107,7 @@ DateView::DateView() : actionable_(false) {
new views::BoxLayout(
views::BoxLayout::kVertical, 0, 0, kTrayPopupTextSpacingVertical));
date_label_ = CreateLabel();
+ date_label_->SetFont(date_label_->font().DeriveFont(0, gfx::Font::BOLD));
day_of_week_label_ = CreateLabel();
UpdateTextInternal(base::Time::Now());
AddChildView(date_label_);
diff --git a/ash/system/date/tray_date.cc b/ash/system/date/tray_date.cc
index f243113..cf89036 100644
--- a/ash/system/date/tray_date.cc
+++ b/ash/system/date/tray_date.cc
@@ -26,12 +26,122 @@
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/box_layout.h"
+#include "ui/views/layout/fill_layout.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
#include "unicode/datefmt.h"
#include "unicode/fieldpos.h"
#include "unicode/fmtable.h"
+namespace {
+
+const int kPaddingVertical = 10;
+
+class DateDefaultView : public views::View,
+ public views::ButtonListener {
+ public:
+ explicit DateDefaultView(ash::user::LoginStatus login)
+ : button_container_(NULL) {
+ SetLayoutManager(new views::BoxLayout(
+ views::BoxLayout::kHorizontal, 0, 0, 0));
+ set_background(views::Background::CreateSolidBackground(
+ ash::kHeaderBackgroundColor));
+
+ ash::internal::tray::DateView* date_view =
+ new ash::internal::tray::DateView();
+ date_view->set_border(views::Border::CreateEmptyBorder(kPaddingVertical,
+ ash::kTrayPopupPaddingHorizontal,
+ kPaddingVertical,
+ ash::kTrayPopupPaddingHorizontal));
+ ash::internal::HoverHighlightView* view =
+ new ash::internal::HoverHighlightView(NULL);
+ view->SetLayoutManager(new views::FillLayout);
+ view->set_focusable(false);
+ view->set_highlight_color(SkColorSetARGB(0, 0, 0, 0));
+ view->AddChildView(date_view);
+ AddChildView(view);
+
+ if (login == ash::user::LOGGED_IN_LOCKED ||
+ login == ash::user::LOGGED_IN_NONE)
+ return;
+
+ date_view->SetActionable(true);
+ view->set_highlight_color(ash::kHeaderHoverBackgroundColor);
+ date_ = view;
+
+ button_container_ = new views::View;
+ button_container_->SetLayoutManager(new
+ views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0));
+
+ help_ = new ash::internal::TrayPopupHeaderButton(this,
+ IDR_AURA_UBER_TRAY_HELP,
+ IDR_AURA_UBER_TRAY_HELP);
+ button_container_->AddChildView(help_);
+
+ shutdown_ = lock_ = NULL;
+
+ if (login != ash::user::LOGGED_IN_LOCKED &&
+ login != ash::user::LOGGED_IN_KIOSK) {
+ shutdown_ = new ash::internal::TrayPopupHeaderButton(this,
+ IDR_AURA_UBER_TRAY_SHUTDOWN,
+ IDR_AURA_UBER_TRAY_SHUTDOWN);
+ button_container_->AddChildView(shutdown_);
+
+ if (login != ash::user::LOGGED_IN_GUEST) {
+ lock_ = new ash::internal::TrayPopupHeaderButton(this,
+ IDR_AURA_UBER_TRAY_LOCKSCREEN,
+ IDR_AURA_UBER_TRAY_LOCKSCREEN);
+ button_container_->AddChildView(lock_);
+ }
+ }
+ AddChildView(button_container_);
+ }
+
+ virtual ~DateDefaultView() {}
+
+ private:
+ // Overridden from views::View.
+ virtual void Layout() OVERRIDE {
+ views::View::Layout();
+ if (!button_container_)
+ return;
+
+ gfx::Rect bounds(button_container_->GetPreferredSize());
+ bounds.set_height(height());
+ bounds = gfx::Rect(size()).Center(bounds.size());
+ bounds.set_x(width() - bounds.width());
+ button_container_->SetBoundsRect(bounds);
+
+ bounds = date_->bounds();
+ bounds.set_width(button_container_->x());
+ date_->SetBoundsRect(bounds);
+ }
+
+ // Overridden from views::ButtonListener.
+ virtual void ButtonPressed(views::Button* sender,
+ const views::Event& event) OVERRIDE {
+ ash::SystemTrayDelegate* tray = ash::Shell::GetInstance()->tray_delegate();
+ if (sender == help_)
+ tray->ShowHelp();
+ else if (sender == shutdown_)
+ tray->ShutDown();
+ else if (sender == lock_)
+ tray->RequestLockScreen();
+ else
+ NOTREACHED();
+ }
+
+ views::View* button_container_;
+ views::View* date_;
+ views::ToggleImageButton* help_;
+ views::ToggleImageButton* shutdown_;
+ views::ToggleImageButton* lock_;
+
+ DISALLOW_COPY_AND_ASSIGN(DateDefaultView);
+};
+
+} // namespace
+
namespace ash {
namespace internal {
@@ -58,7 +168,7 @@ views::View* TrayDate::CreateTrayView(user::LoginStatus status) {
}
views::View* TrayDate::CreateDefaultView(user::LoginStatus status) {
- return NULL;
+ return new DateDefaultView(status);
}
views::View* TrayDate::CreateDetailedView(user::LoginStatus status) {
diff --git a/ash/system/power/tray_power.cc b/ash/system/power/tray_power.cc
index 4cd4a96..361bd93 100644
--- a/ash/system/power/tray_power.cc
+++ b/ash/system/power/tray_power.cc
@@ -190,9 +190,7 @@ class PowerPopupView : public views::View {
} // namespace tray
TrayPower::TrayPower()
- : date_(NULL),
- power_(NULL),
- power_tray_(NULL) {
+ : power_tray_(NULL) {
}
TrayPower::~TrayPower() {
@@ -211,49 +209,7 @@ views::View* TrayPower::CreateTrayView(user::LoginStatus status) {
}
views::View* TrayPower::CreateDefaultView(user::LoginStatus status) {
- CHECK(date_ == NULL);
- date_ = new tray::DateView();
-
- views::View* container = new views::View;
- views::BoxLayout* layout = new views::BoxLayout(views::BoxLayout::kHorizontal,
- 0, 0, 0);
-
- layout->set_spread_blank_space(true);
- container->SetLayoutManager(layout);
- container->set_background(views::Background::CreateSolidBackground(
- kHeaderBackgroundColor));
- HoverHighlightView* view = new HoverHighlightView(NULL);
- view->SetLayoutManager(new views::FillLayout);
- view->AddChildView(date_);
- date_->set_border(views::Border::CreateEmptyBorder(kPaddingVertical,
- kTrayPopupPaddingHorizontal,
- kPaddingVertical,
- kTrayPopupPaddingHorizontal));
- container->AddChildView(view);
- view->set_focusable(false);
-
- if (status != user::LOGGED_IN_NONE && status != user::LOGGED_IN_LOCKED) {
- date_->SetActionable(true);
- view->set_highlight_color(kHeaderHoverBackgroundColor);
- } else {
- view->set_highlight_color(SkColorSetARGB(0, 0, 0, 0));
- }
-
- PowerSupplyStatus power_status =
- ash::Shell::GetInstance()->tray_delegate()->GetPowerSupplyStatus();
- if (power_status.battery_is_present) {
- CHECK(power_ == NULL);
- power_ = new tray::PowerPopupView();
- power_->UpdatePowerStatus(power_status);
- power_->set_border(views::Border::CreateSolidSidedBorder(
- kPaddingVertical, kTrayPopupPaddingHorizontal,
- kPaddingVertical, kTrayPopupPaddingHorizontal,
- SkColorSetARGB(0, 0, 0, 0)));
- container->AddChildView(power_);
- }
- ash::Shell::GetInstance()->tray_delegate()->RequestStatusUpdate();
-
- return container;
+ return NULL;
}
views::View* TrayPower::CreateDetailedView(user::LoginStatus status) {
@@ -265,8 +221,6 @@ void TrayPower::DestroyTrayView() {
}
void TrayPower::DestroyDefaultView() {
- date_ = NULL;
- power_ = NULL;
}
void TrayPower::DestroyDetailedView() {
@@ -278,8 +232,6 @@ void TrayPower::UpdateAfterLoginStatusChange(user::LoginStatus status) {
void TrayPower::OnPowerStatusChanged(const PowerSupplyStatus& status) {
if (power_tray_)
power_tray_->UpdatePowerStatus(status);
- if (power_)
- power_->UpdatePowerStatus(status);
}
} // namespace internal
diff --git a/ash/system/power/tray_power.h b/ash/system/power/tray_power.h
index 548f005..7c8f576 100644
--- a/ash/system/power/tray_power.h
+++ b/ash/system/power/tray_power.h
@@ -13,8 +13,6 @@ namespace ash {
namespace internal {
namespace tray {
-class DateView;
-class PowerPopupView;
class PowerTrayView;
}
@@ -37,8 +35,6 @@ class TrayPower : public SystemTrayItem,
// Overridden from PowerStatusObserver.
virtual void OnPowerStatusChanged(const PowerSupplyStatus& status) OVERRIDE;
- tray::DateView* date_;
- tray::PowerPopupView* power_;
tray::PowerTrayView* power_tray_;
DISALLOW_COPY_AND_ASSIGN(TrayPower);