diff options
author | stevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-11 18:27:52 +0000 |
---|---|---|
committer | stevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-11 18:27:52 +0000 |
commit | 725e862d06e7b89e4d7fd753d9a90635c2035a90 (patch) | |
tree | 7a615657faac5c45fd332c458da8046421e87ceb /ash/system/tray | |
parent | b1ccedda2a9aaa94d1831897a127e77c02eebfb1 (diff) | |
download | chromium_src-725e862d06e7b89e4d7fd753d9a90635c2035a90.zip chromium_src-725e862d06e7b89e4d7fd753d9a90635c2035a90.tar.gz chromium_src-725e862d06e7b89e4d7fd753d9a90635c2035a90.tar.bz2 |
Add power notifications and add an icon to the power tray views
Adds a switch for ash/aura notifications.
Improves the stub power implementation for testing.
BUG=124725,124074
TEST=Linux: click on status area to start stub batetry drain. ChromeOS: Test battery notifications.
Review URL: https://chromiumcodereview.appspot.com/10388057
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136618 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/system/tray')
-rw-r--r-- | ash/system/tray/tray_views.cc | 50 | ||||
-rw-r--r-- | ash/system/tray/tray_views.h | 24 |
2 files changed, 74 insertions, 0 deletions
diff --git a/ash/system/tray/tray_views.cc b/ash/system/tray/tray_views.cc index 84f5f16..50aa8aa 100644 --- a/ash/system/tray/tray_views.cc +++ b/ash/system/tray/tray_views.cc @@ -8,14 +8,17 @@ #include "third_party/skia/include/core/SkBitmap.h" #include "grit/ash_strings.h" #include "grit/ui_resources.h" +#include "grit/ui_resources_standard.h" #include "ui/base/accessibility/accessible_view_state.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/canvas.h" #include "ui/gfx/image/image.h" #include "ui/views/border.h" +#include "ui/views/controls/button/image_button.h" #include "ui/views/controls/label.h" #include "ui/views/layout/box_layout.h" #include "ui/views/layout/fill_layout.h" +#include "ui/views/layout/grid_layout.h" #include "ui/views/painter.h" namespace ash { @@ -33,6 +36,7 @@ views::View* CreatePopupHeaderButtonsContainer() { return view; } +const int kNotificationCloseButtonWidth = 60; } //////////////////////////////////////////////////////////////////////////////// @@ -448,5 +452,51 @@ void SetupLabelForTray(views::Label* label) { label->SetShadowOffset(0, 1); } +//////////////////////////////////////////////////////////////////////////////// +// TrayNotificationView + +TrayNotificationView::TrayNotificationView() { +} + +void TrayNotificationView::InitView(views::View* contents) { + set_background(views::Background::CreateSolidBackground(kBackgroundColor)); + + views::GridLayout* layout = new views::GridLayout(this); + SetLayoutManager(layout); + + AddChildView(contents); + + views::ImageButton* close_button = new views::ImageButton(this); + close_button->SetImage(views::CustomButton::BS_NORMAL, + ResourceBundle::GetSharedInstance().GetBitmapNamed( + IDR_AURA_WINDOW_CLOSE)); + AddChildView(close_button); + + int contents_width = kTrayPopupWidth - kNotificationCloseButtonWidth; + views::ColumnSet* columns = layout->AddColumnSet(0); + columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::FILL, + 0, /* resize percent */ + views::GridLayout::FIXED, + contents_width, + contents_width); + columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER, + 0, /* resize percent */ + views::GridLayout::FIXED, + kNotificationCloseButtonWidth, + kNotificationCloseButtonWidth); + + layout->StartRow(0, 0); + layout->AddView(contents); + layout->AddView(close_button); +} + +TrayNotificationView::~TrayNotificationView() { +} + +void TrayNotificationView::ButtonPressed(views::Button* sender, + const views::Event& event) { + OnClose(); +} + } // namespace internal } // namespace ash diff --git a/ash/system/tray/tray_views.h b/ash/system/tray/tray_views.h index dab672e..440036d 100644 --- a/ash/system/tray/tray_views.h +++ b/ash/system/tray/tray_views.h @@ -238,6 +238,30 @@ class SpecialPopupRow : public views::View { DISALLOW_COPY_AND_ASSIGN(SpecialPopupRow); }; +// A view for closable notification views, laid out like: +// [ contents (x) ] +// The close button will call OnClose() when pressed. +class TrayNotificationView : public views::View, + public views::ButtonListener { + public: + TrayNotificationView(); + virtual ~TrayNotificationView(); + + // InitView must be called once with the contents to be displayed. + void InitView(views::View* contents); + + // Overridden from ButtonListener. + virtual void ButtonPressed(views::Button* sender, + const views::Event& event) OVERRIDE; + + protected: + // Called when the closed button is pressed. + virtual void OnClose() = 0; + + private: + DISALLOW_COPY_AND_ASSIGN(TrayNotificationView); +}; + // Sets up a Label properly for the tray (sets color, font etc.). void SetupLabelForTray(views::Label* label); |