summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ash/system/audio/tray_volume.cc5
-rw-r--r--ash/system/brightness/tray_brightness.cc5
-rw-r--r--ash/system/tray/system_tray.cc61
-rw-r--r--ash/system/tray/system_tray.h5
-rw-r--r--ash/system/tray/system_tray_item.cc4
5 files changed, 56 insertions, 24 deletions
diff --git a/ash/system/audio/tray_volume.cc b/ash/system/audio/tray_volume.cc
index dbc5b41..be57c89 100644
--- a/ash/system/audio/tray_volume.cc
+++ b/ash/system/audio/tray_volume.cc
@@ -110,8 +110,8 @@ views::View* TrayVolume::CreateDefaultView() {
}
views::View* TrayVolume::CreateDetailedView() {
- NOTIMPLEMENTED();
- return NULL;
+ volume_view_.reset(new tray::VolumeView);
+ return volume_view_.get();
}
void TrayVolume::DestroyTrayView() {
@@ -123,6 +123,7 @@ void TrayVolume::DestroyDefaultView() {
}
void TrayVolume::DestroyDetailedView() {
+ volume_view_.reset();
}
void TrayVolume::OnVolumeChanged(float percent) {
diff --git a/ash/system/brightness/tray_brightness.cc b/ash/system/brightness/tray_brightness.cc
index 1555d49..3aeb53b 100644
--- a/ash/system/brightness/tray_brightness.cc
+++ b/ash/system/brightness/tray_brightness.cc
@@ -93,8 +93,8 @@ views::View* TrayBrightness::CreateDefaultView() {
}
views::View* TrayBrightness::CreateDetailedView() {
- NOTIMPLEMENTED();
- return NULL;
+ brightness_view_.reset(new tray::BrightnessView);
+ return brightness_view_.get();
}
void TrayBrightness::DestroyTrayView() {
@@ -105,6 +105,7 @@ void TrayBrightness::DestroyDefaultView() {
}
void TrayBrightness::DestroyDetailedView() {
+ brightness_view_.reset();
}
void TrayBrightness::OnBrightnessChanged(float percent, bool user_initiated) {
diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc
index 9ff924e..1f7104a 100644
--- a/ash/system/tray/system_tray.cc
+++ b/ash/system/tray/system_tray.cc
@@ -6,6 +6,7 @@
#include "ash/shell/panel_window.h"
#include "ash/system/tray/system_tray_item.h"
+#include "ash/wm/shadow_types.h"
#include "base/logging.h"
#include "base/utf_string_conversions.h"
#include "third_party/skia/include/core/SkColor.h"
@@ -22,18 +23,24 @@ const int kPadding = 5;
class SystemTrayBubble : public views::BubbleDelegateView {
public:
- explicit SystemTrayBubble(ash::SystemTray* tray)
+ SystemTrayBubble(ash::SystemTray* tray,
+ std::vector<ash::SystemTrayItem*>& items,
+ bool detailed)
: views::BubbleDelegateView(tray, views::BubbleBorder::BOTTOM_RIGHT),
- tray_(tray) {
+ tray_(tray),
+ items_(items),
+ detailed_(detailed) {
set_margin(1);
}
virtual ~SystemTrayBubble() {
- std::vector<ash::SystemTrayItem*> items = tray_->items();
- for (std::vector<ash::SystemTrayItem*>::iterator it = items.begin();
- it != items.end();
+ for (std::vector<ash::SystemTrayItem*>::iterator it = items_.begin();
+ it != items_.end();
++it) {
- (*it)->DestroyDefaultView();
+ if (detailed_)
+ (*it)->DestroyDetailedView();
+ else
+ (*it)->DestroyDefaultView();
}
}
@@ -43,12 +50,12 @@ class SystemTrayBubble : public views::BubbleDelegateView {
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical,
0, 0, 1));
- std::vector<ash::SystemTrayItem*> items = tray_->items();
- for (std::vector<ash::SystemTrayItem*>::iterator it = items.begin();
- it != items.end();
+ for (std::vector<ash::SystemTrayItem*>::iterator it = items_.begin();
+ it != items_.end();
++it) {
- views::View* view = (*it)->CreateDefaultView();
- if (it != items.begin())
+ views::View* view = detailed_ ? (*it)->CreateDetailedView() :
+ (*it)->CreateDefaultView();
+ if (it != items_.begin())
view->set_border(views::Border::CreateSolidSidedBorder(
1, 0, 0, 0, SkColorSetARGB(25, 0, 0, 0)));
AddChildView(view);
@@ -56,6 +63,8 @@ class SystemTrayBubble : public views::BubbleDelegateView {
}
ash::SystemTray* tray_;
+ std::vector<ash::SystemTrayItem*> items_;
+ bool detailed_;
DISALLOW_COPY_AND_ASSIGN(SystemTrayBubble);
};
@@ -72,7 +81,7 @@ SystemTray::SystemTray()
}
SystemTray::~SystemTray() {
- for (std::vector<ash::SystemTrayItem*>::iterator it = items_.begin();
+ for (std::vector<SystemTrayItem*>::iterator it = items_.begin();
it != items_.end();
++it) {
(*it)->DestroyTrayView();
@@ -93,15 +102,29 @@ void SystemTray::RemoveTrayItem(SystemTrayItem* item) {
NOTIMPLEMENTED();
}
+void SystemTray::ShowDetailedView(SystemTrayItem* item) {
+ if (popup_)
+ popup_->Close();
+ popup_ = NULL;
+
+ std::vector<SystemTrayItem*> items;
+ items.push_back(item);
+ ShowItems(items, true);
+}
+
+void SystemTray::ShowItems(std::vector<SystemTrayItem*>& items, bool detailed) {
+ CHECK(!popup_);
+ SystemTrayBubble* bubble = new SystemTrayBubble(this, items, detailed);
+ popup_ = views::BubbleDelegateView::CreateBubble(bubble);
+ popup_->AddObserver(this);
+ bubble->Show();
+}
+
bool SystemTray::OnMousePressed(const views::MouseEvent& event) {
- if (popup_) {
+ if (popup_)
popup_->Show();
- } else {
- SystemTrayBubble* bubble = new SystemTrayBubble(this);
- popup_ = views::BubbleDelegateView::CreateBubble(bubble);
- popup_->AddObserver(this);
- bubble->Show();
- }
+ else
+ ShowItems(items_, false);
return true;
}
diff --git a/ash/system/tray/system_tray.h b/ash/system/tray/system_tray.h
index dda6b8c..13de3f6 100644
--- a/ash/system/tray/system_tray.h
+++ b/ash/system/tray/system_tray.h
@@ -29,9 +29,14 @@ class ASH_EXPORT SystemTray : public views::View,
// Removes an existing tray item.
void RemoveTrayItem(SystemTrayItem* item);
+ // Shows details of a particular item.
+ void ShowDetailedView(SystemTrayItem* item);
+
const std::vector<SystemTrayItem*>& items() const { return items_; }
private:
+ void ShowItems(std::vector<SystemTrayItem*>& items, bool details);
+
// Overridden from views::View.
virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
diff --git a/ash/system/tray/system_tray_item.cc b/ash/system/tray/system_tray_item.cc
index ed76fec..d9e7875 100644
--- a/ash/system/tray/system_tray_item.cc
+++ b/ash/system/tray/system_tray_item.cc
@@ -4,6 +4,8 @@
#include "ash/system/tray/system_tray_item.h"
+#include "ash/shell.h"
+#include "ash/system/tray/system_tray.h"
#include "ui/views/view.h"
namespace ash {
@@ -15,7 +17,7 @@ SystemTrayItem::~SystemTrayItem() {
}
void SystemTrayItem::PopupDetailedView() {
- NOTIMPLEMENTED();
+ Shell::GetInstance()->tray()->ShowDetailedView(this);
}
} // namespace ash