summaryrefslogtreecommitdiffstats
path: root/ash/system
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-28 18:25:56 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-28 18:25:56 +0000
commitd4f5a50beaad958134dd429ac903ff3166746a1d (patch)
treeafe90c5da294e7d581ed5b135aaa83021173d980 /ash/system
parentb73c4605fdc4651570992f777560f91025e2053b (diff)
downloadchromium_src-d4f5a50beaad958134dd429ac903ff3166746a1d.zip
chromium_src-d4f5a50beaad958134dd429ac903ff3166746a1d.tar.gz
chromium_src-d4f5a50beaad958134dd429ac903ff3166746a1d.tar.bz2
ash uber tray: Some adjustments after discussing with UX.
* Add padding for the volume/brightness sliders. * Consolidate 'Settings' and 'Help' items into one. * Remove margin of the popup. * Move the trays in ash::internal namespace. * Hover effect on settings/help items. * Fix a crash when clicking on the status-view without closing the popup. BUG=110130 TEST=none Review URL: https://chromiumcodereview.appspot.com/9475041 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124002 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/system')
-rw-r--r--ash/system/audio/tray_volume.cc7
-rw-r--r--ash/system/audio/tray_volume.h10
-rw-r--r--ash/system/brightness/tray_brightness.cc8
-rw-r--r--ash/system/brightness/tray_brightness.h12
-rw-r--r--ash/system/settings/tray_settings.cc49
-rw-r--r--ash/system/settings/tray_settings.h16
-rw-r--r--ash/system/tray/system_tray.cc21
-rw-r--r--ash/system/tray/system_tray.h14
8 files changed, 97 insertions, 40 deletions
diff --git a/ash/system/audio/tray_volume.cc b/ash/system/audio/tray_volume.cc
index 8db5ee6..c76ba04 100644
--- a/ash/system/audio/tray_volume.cc
+++ b/ash/system/audio/tray_volume.cc
@@ -47,6 +47,7 @@ class VolumeView : public views::View,
views::Slider* slider = new views::Slider(this, views::Slider::HORIZONTAL);
slider->SetValue(delegate->VolumeLevel());
+ slider->set_border(views::Border::CreateEmptyBorder(0, 0, 0, 20));
AddChildView(slider);
}
@@ -79,6 +80,9 @@ class VolumeView : public views::View,
} // namespace tray
+namespace ash {
+namespace internal {
+
TrayVolume::TrayVolume() {
}
@@ -112,3 +116,6 @@ void TrayVolume::DestroyDefaultView() {
void TrayVolume::DestroyDetailedView() {
}
+
+} // namespace internal
+} // namespace ash
diff --git a/ash/system/audio/tray_volume.h b/ash/system/audio/tray_volume.h
index f43dc33..994f0a0 100644
--- a/ash/system/audio/tray_volume.h
+++ b/ash/system/audio/tray_volume.h
@@ -17,13 +17,16 @@ namespace tray {
class VolumeView;
}
-class TrayVolume : public ash::SystemTrayItem {
+namespace ash {
+namespace internal {
+
+class TrayVolume : public SystemTrayItem {
public:
TrayVolume();
virtual ~TrayVolume();
private:
- // Overridden from ash::SystemTrayItem
+ // Overridden from SystemTrayItem
virtual views::View* CreateTrayView() OVERRIDE;
virtual views::View* CreateDefaultView() OVERRIDE;
virtual views::View* CreateDetailedView() OVERRIDE;
@@ -37,4 +40,7 @@ class TrayVolume : public ash::SystemTrayItem {
DISALLOW_COPY_AND_ASSIGN(TrayVolume);
};
+} // namespace internal
+} // namespace ash
+
#endif // ASH_SYSTEM_AUDIO_TRAY_VOLUME_H_
diff --git a/ash/system/brightness/tray_brightness.cc b/ash/system/brightness/tray_brightness.cc
index 9db3e4d..edbc36c 100644
--- a/ash/system/brightness/tray_brightness.cc
+++ b/ash/system/brightness/tray_brightness.cc
@@ -40,6 +40,7 @@ class BrightnessView : public views::View,
// level of the system. So start with a random value.
// http://crosbug.com/26935
slider->SetValue(0.8f);
+ slider->set_border(views::Border::CreateEmptyBorder(0, 0, 0, 20));
AddChildView(slider);
}
@@ -66,7 +67,11 @@ class BrightnessView : public views::View,
} // namespace
+namespace ash {
+namespace internal {
+
TrayBrightness::TrayBrightness() {}
+
TrayBrightness::~TrayBrightness() {}
views::View* TrayBrightness::CreateTrayView() {
@@ -90,3 +95,6 @@ void TrayBrightness::DestroyDefaultView() {
void TrayBrightness::DestroyDetailedView() {
}
+
+} // namespace internal
+} // namespace ash
diff --git a/ash/system/brightness/tray_brightness.h b/ash/system/brightness/tray_brightness.h
index c84b2de..b9b64df 100644
--- a/ash/system/brightness/tray_brightness.h
+++ b/ash/system/brightness/tray_brightness.h
@@ -7,15 +7,18 @@
#pragma once
#include "ash/system/tray/system_tray_item.h"
-#include "base/memory/scoped_ptr.h"
+#include "base/compiler_specific.h"
-class TrayBrightness : public ash::SystemTrayItem {
+namespace ash {
+namespace internal {
+
+class TrayBrightness : public SystemTrayItem {
public:
TrayBrightness();
virtual ~TrayBrightness();
private:
- // Overridden from ash::SystemTrayItem
+ // Overridden from SystemTrayItem
virtual views::View* CreateTrayView() OVERRIDE;
virtual views::View* CreateDefaultView() OVERRIDE;
virtual views::View* CreateDetailedView() OVERRIDE;
@@ -26,4 +29,7 @@ class TrayBrightness : public ash::SystemTrayItem {
DISALLOW_COPY_AND_ASSIGN(TrayBrightness);
};
+} // namespace internal
+} // namespace ash
+
#endif // ASH_SYSTEM_BRIGHTNESS_TRAY_BRIGHTNESS_H_
diff --git a/ash/system/settings/tray_settings.cc b/ash/system/settings/tray_settings.cc
index c277c5f..3281fa0 100644
--- a/ash/system/settings/tray_settings.cc
+++ b/ash/system/settings/tray_settings.cc
@@ -9,6 +9,7 @@
#include "base/logging.h"
#include "base/utf_string_conversions.h"
#include "grit/ui_resources.h"
+#include "third_party/skia/include/core/SkColor.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/image/image.h"
#include "ui/views/controls/image_view.h"
@@ -24,44 +25,51 @@ class SettingsView : public views::View {
SettingsView() {
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal,
0, 0, 3));
+
views::ImageView* icon = new views::ImageView;
icon->SetImage(ui::ResourceBundle::GetSharedInstance().
GetImageNamed(IDR_AURA_UBER_TRAY_SETTINGS).ToSkBitmap());
- views::Label* label = new views::Label(ASCIIToUTF16("Settings"));
-
AddChildView(icon);
- AddChildView(label);
+
+ label_ = new views::Label(ASCIIToUTF16("Help and Settings"));
+ AddChildView(label_);
}
+ // Overridden from views::View.
virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE {
ash::Shell::GetInstance()->tray_delegate()->ShowSettings();
return true;
}
- private:
- DISALLOW_COPY_AND_ASSIGN(SettingsView);
-};
-
-class HelpView : public views::View {
- public:
- HelpView() {
- SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal,
- 0, 0, 3));
- views::Label* label = new views::Label(ASCIIToUTF16("Help"));
- AddChildView(label);
+ virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE {
+ gfx::Font font = label_->font();
+ label_->SetFont(font.DeriveFont(0,
+ font.GetStyle() | gfx::Font::UNDERLINED));
+ SchedulePaint();
}
- virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE {
- ash::Shell::GetInstance()->tray_delegate()->ShowHelp();
- return true;
+ virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE {
+ gfx::Font font = label_->font();
+ label_->SetFont(font.DeriveFont(0,
+ font.GetStyle() & ~gfx::Font::UNDERLINED));
+ SchedulePaint();
}
private:
- DISALLOW_COPY_AND_ASSIGN(HelpView);
+ views::Label* label_;
+
+ DISALLOW_COPY_AND_ASSIGN(SettingsView);
};
} // namespace
+namespace ash {
+namespace internal {
+
+TraySettings::TraySettings() {}
+
+TraySettings::~TraySettings() {}
+
views::View* TraySettings::CreateTrayView() {
return NULL;
}
@@ -75,8 +83,6 @@ views::View* TraySettings::CreateDefaultView() {
views::View* settings = new SettingsView;
container->AddChildView(settings);
- views::View* help = new HelpView;
- container->AddChildView(help);
return container;
}
@@ -93,3 +99,6 @@ void TraySettings::DestroyDefaultView() {
void TraySettings::DestroyDetailedView() {
}
+
+} // namespace internal
+} // namespace ash
diff --git a/ash/system/settings/tray_settings.h b/ash/system/settings/tray_settings.h
index 701f1aa..008a65c 100644
--- a/ash/system/settings/tray_settings.h
+++ b/ash/system/settings/tray_settings.h
@@ -8,15 +8,16 @@
#include "ash/system/tray/system_tray_item.h"
-class TraySettings : public ash::SystemTrayItem {
- public:
- TraySettings() {
- }
+namespace ash {
+namespace internal {
- virtual ~TraySettings() {}
+class TraySettings : public SystemTrayItem {
+ public:
+ TraySettings();
+ virtual ~TraySettings();
private:
- // Overridden from ash::SystemTrayItem
+ // Overridden from SystemTrayItem
virtual views::View* CreateTrayView() OVERRIDE;
virtual views::View* CreateDefaultView() OVERRIDE;
virtual views::View* CreateDetailedView() OVERRIDE;
@@ -27,4 +28,7 @@ class TraySettings : public ash::SystemTrayItem {
DISALLOW_COPY_AND_ASSIGN(TraySettings);
};
+} // namespace internal
+} // namespace ash
+
#endif // ASH_SYSTEM_SETTINGS_TRAY_SETTINGS_H_
diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc
index 5b29bbf..9ff924e 100644
--- a/ash/system/tray/system_tray.cc
+++ b/ash/system/tray/system_tray.cc
@@ -25,6 +25,7 @@ class SystemTrayBubble : public views::BubbleDelegateView {
explicit SystemTrayBubble(ash::SystemTray* tray)
: views::BubbleDelegateView(tray, views::BubbleBorder::BOTTOM_RIGHT),
tray_(tray) {
+ set_margin(1);
}
virtual ~SystemTrayBubble() {
@@ -63,7 +64,9 @@ class SystemTrayBubble : public views::BubbleDelegateView {
namespace ash {
-SystemTray::SystemTray() : items_() {
+SystemTray::SystemTray()
+ : items_(),
+ popup_(NULL) {
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal,
5, 10, 3));
}
@@ -91,10 +94,20 @@ void SystemTray::RemoveTrayItem(SystemTrayItem* item) {
}
bool SystemTray::OnMousePressed(const views::MouseEvent& event) {
- SystemTrayBubble* bubble = new SystemTrayBubble(this);
- views::BubbleDelegateView::CreateBubble(bubble);
- bubble->Show();
+ if (popup_) {
+ popup_->Show();
+ } else {
+ SystemTrayBubble* bubble = new SystemTrayBubble(this);
+ popup_ = views::BubbleDelegateView::CreateBubble(bubble);
+ popup_->AddObserver(this);
+ bubble->Show();
+ }
return true;
}
+void SystemTray::OnWidgetClosing(views::Widget* widget) {
+ CHECK_EQ(popup_, widget);
+ popup_ = NULL;
+}
+
} // namespace ash
diff --git a/ash/system/tray/system_tray.h b/ash/system/tray/system_tray.h
index fb9b8ce..dda6b8c 100644
--- a/ash/system/tray/system_tray.h
+++ b/ash/system/tray/system_tray.h
@@ -9,18 +9,16 @@
#include "ash/ash_export.h"
#include "base/basictypes.h"
#include "ui/views/view.h"
+#include "ui/views/widget/widget.h"
#include <vector>
-namespace views {
-class View;
-}
-
namespace ash {
class SystemTrayItem;
-class ASH_EXPORT SystemTray : public views::View {
+class ASH_EXPORT SystemTray : public views::View,
+ public views::Widget::Observer {
public:
SystemTray();
virtual ~SystemTray();
@@ -37,8 +35,14 @@ class ASH_EXPORT SystemTray : public views::View {
// Overridden from views::View.
virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
+ // Overridden from views::Widget::Observer.
+ virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE;
+
std::vector<SystemTrayItem*> items_;
+ // The popup widget.
+ views::Widget* popup_;
+
DISALLOW_COPY_AND_ASSIGN(SystemTray);
};