summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-19 00:43:01 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-19 00:43:01 +0000
commitc47b7300a746a237d5641476132636f1ad0cc43c (patch)
tree46e34baa34ce6af51af9ba401a093fd2c18523a8
parente91185e7f3446ade0dc6c1c41e1cbfc34fb7d996 (diff)
downloadchromium_src-c47b7300a746a237d5641476132636f1ad0cc43c.zip
chromium_src-c47b7300a746a237d5641476132636f1ad0cc43c.tar.gz
chromium_src-c47b7300a746a237d5641476132636f1ad0cc43c.tar.bz2
ash: Make the rows in IME and bluetooth tray-popups larger.
Use an image-button to enable/disable bluetooth, and move it to the popup header. BUG=123916 TEST=none Review URL: https://chromiumcodereview.appspot.com/10041041 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132906 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/system/bluetooth/tray_bluetooth.cc84
-rw-r--r--ash/system/ime/tray_ime.cc3
-rw-r--r--ash/system/network/tray_network.cc48
-rw-r--r--ash/system/tray/tray_views.cc34
-rw-r--r--ash/system/tray/tray_views.h21
-rw-r--r--ui/resources/aura/status_bluetooth_disabled.pngbin0 -> 1019 bytes
-rw-r--r--ui/resources/aura/status_bluetooth_enabled.pngbin0 -> 1026 bytes
-rw-r--r--ui/resources/ui_resources.grd2
8 files changed, 124 insertions, 68 deletions
diff --git a/ash/system/bluetooth/tray_bluetooth.cc b/ash/system/bluetooth/tray_bluetooth.cc
index 3a4d17d..6f4dd50 100644
--- a/ash/system/bluetooth/tray_bluetooth.cc
+++ b/ash/system/bluetooth/tray_bluetooth.cc
@@ -19,7 +19,7 @@
#include "ui/views/layout/box_layout.h"
namespace {
-const int kDeviceListHeight = 190;
+const int kDeviceListHeight = 276;
}
namespace ash {
@@ -52,11 +52,13 @@ class BluetoothDefaultView : public TrayItemMore {
};
class BluetoothDetailedView : public views::View,
- public ViewClickListener {
+ public ViewClickListener,
+ public views::ButtonListener {
public:
explicit BluetoothDetailedView(user::LoginStatus login)
: login_(login),
header_(NULL),
+ header_text_(NULL),
add_device_(NULL),
toggle_bluetooth_(NULL) {
SetLayoutManager(new views::BoxLayout(
@@ -74,6 +76,7 @@ class BluetoothDetailedView : public views::View,
RemoveAllChildViews(true);
header_ = NULL;
+ header_text_ = NULL;
add_device_ = NULL;
toggle_bluetooth_ = NULL;
@@ -86,8 +89,26 @@ class BluetoothDetailedView : public views::View,
private:
void AppendHeaderEntry() {
- header_ = CreateDetailedHeaderEntry(IDS_ASH_STATUS_TRAY_BLUETOOTH, this);
+ header_ = new views::View;
+ header_->SetLayoutManager(new
+ views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0));
AddChildView(header_);
+
+ header_text_ = CreateDetailedHeaderEntry(IDS_ASH_STATUS_TRAY_BLUETOOTH,
+ this);
+ header_->AddChildView(header_text_);
+
+ if (login_ == user::LOGGED_IN_LOCKED)
+ return;
+
+ // Do not allow toggling bluetooth in the lock screen.
+ ash::SystemTrayDelegate* delegate =
+ ash::Shell::GetInstance()->tray_delegate();
+ toggle_bluetooth_ = new TrayPopupHeaderButton(this,
+ IDR_AURA_UBER_TRAY_BLUETOOTH_ENABLED,
+ IDR_AURA_UBER_TRAY_BLUETOOTH_DISABLED);
+ toggle_bluetooth_->SetToggled(!delegate->GetBluetoothEnabled());
+ header_->AddChildView(toggle_bluetooth_);
}
void AppendDeviceList(const BluetoothDeviceList& list) {
@@ -98,6 +119,7 @@ class BluetoothDetailedView : public views::View,
for (size_t i = 0; i < list.size(); i++) {
HoverHighlightView* container = new HoverHighlightView(this);
+ container->set_fixed_height(kTrayPopupItemHeight);
container->AddLabel(list[i].display_name,
list[i].connected ? gfx::Font::BOLD : gfx::Font::NORMAL);
devices->AddChildView(container);
@@ -117,30 +139,36 @@ class BluetoothDetailedView : public views::View,
// Add settings entries.
void AppendSettingsEntries() {
- // If screen is locked, hide all settings entries as user should not be able
- // to modify state.
- if (login_ == user::LOGGED_IN_LOCKED)
+ // Add bluetooth device requires a browser window, hide it for non logged in
+ // user.
+ if (login_ == user::LOGGED_IN_NONE ||
+ login_ == user::LOGGED_IN_LOCKED)
return;
ash::SystemTrayDelegate* delegate =
ash::Shell::GetInstance()->tray_delegate();
- HoverHighlightView* container = new HoverHighlightView(this);
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
+ HoverHighlightView* container = new HoverHighlightView(this);
+ container->set_fixed_height(kTrayPopupItemHeight);
container->AddLabel(rb.GetLocalizedString(
- delegate->GetBluetoothEnabled() ?
- IDS_ASH_STATUS_TRAY_DISABLE_BLUETOOTH :
- IDS_ASH_STATUS_TRAY_ENABLE_BLUETOOTH), gfx::Font::NORMAL);
+ IDS_ASH_STATUS_TRAY_BLUETOOTH_ADD_DEVICE), gfx::Font::NORMAL);
+ container->SetEnabled(delegate->GetBluetoothEnabled());
AddChildView(container);
- toggle_bluetooth_ = container;
+ add_device_ = container;
+ }
- // Add bluetooth device requires a browser window, hide it for non logged in
- // user.
- if (login_ != user::LOGGED_IN_NONE) {
- container = new HoverHighlightView(this);
- container->AddLabel(rb.GetLocalizedString(
- IDS_ASH_STATUS_TRAY_BLUETOOTH_ADD_DEVICE), gfx::Font::NORMAL);
- AddChildView(container);
- add_device_ = container;
+ // Overridden from views::View.
+ virtual void Layout() OVERRIDE {
+ views::View::Layout();
+ if (toggle_bluetooth_) {
+ // Right-align the toggle-bluetooth button.
+ gfx::Rect header_bounds = header_->bounds();
+ gfx::Size button_size = toggle_bluetooth_->size();
+
+ toggle_bluetooth_->SetBounds(header_->width() - button_size.width(), 0,
+ button_size.width(), header_->height());
+ header_text_->SetBounds(0, 0, header_->width() - button_size.width(),
+ header_->height());
}
}
@@ -148,10 +176,8 @@ class BluetoothDetailedView : public views::View,
virtual void ClickedOn(views::View* sender) OVERRIDE {
ash::SystemTrayDelegate* delegate =
ash::Shell::GetInstance()->tray_delegate();
- if (sender == header_) {
+ if (sender == header_text_) {
Shell::GetInstance()->tray()->ShowDefaultView();
- } else if (sender == toggle_bluetooth_) {
- delegate->ToggleBluetooth();
} else if (sender == add_device_) {
delegate->AddBluetoothDevice();
} else {
@@ -164,12 +190,24 @@ class BluetoothDetailedView : public views::View,
}
}
+ // Overridden from ButtonListener.
+ virtual void ButtonPressed(views::Button* sender,
+ const views::Event& event) OVERRIDE {
+ ash::SystemTrayDelegate* delegate =
+ ash::Shell::GetInstance()->tray_delegate();
+ if (sender == toggle_bluetooth_)
+ delegate->ToggleBluetooth();
+ else
+ NOTREACHED();
+ }
+
user::LoginStatus login_;
std::map<views::View*, std::string> device_map_;
views::View* header_;
+ views::View* header_text_;
views::View* add_device_;
- views::View* toggle_bluetooth_;
+ TrayPopupHeaderButton* toggle_bluetooth_;
views::View* settings_;
DISALLOW_COPY_AND_ASSIGN(BluetoothDetailedView);
diff --git a/ash/system/ime/tray_ime.cc b/ash/system/ime/tray_ime.cc
index 8f3588e9..2cba5c9 100644
--- a/ash/system/ime/tray_ime.cc
+++ b/ash/system/ime/tray_ime.cc
@@ -101,6 +101,7 @@ class IMEDetailedView : public views::View,
views::BoxLayout::kVertical, 0, 0, 1));
for (size_t i = 0; i < list.size(); i++) {
HoverHighlightView* container = new HoverHighlightView(this);
+ container->set_fixed_height(kTrayPopupItemHeight);
container->AddLabel(list[i].name,
list[i].selected ? gfx::Font::BOLD : gfx::Font::NORMAL);
imes->AddChildView(container);
@@ -118,6 +119,7 @@ class IMEDetailedView : public views::View,
views::BoxLayout::kVertical, 0, 0, 1));
for (size_t i = 0; i < property_list.size(); i++) {
HoverHighlightView* container = new HoverHighlightView(this);
+ container->set_fixed_height(kTrayPopupItemHeight);
container->AddLabel(
property_list[i].name,
property_list[i].selected ? gfx::Font::BOLD : gfx::Font::NORMAL);
@@ -131,6 +133,7 @@ class IMEDetailedView : public views::View,
void AppendSettings() {
HoverHighlightView* container = new HoverHighlightView(this);
+ container->set_fixed_height(kTrayPopupItemHeight);
container->AddLabel(ui::ResourceBundle::GetSharedInstance().
GetLocalizedString(IDS_ASH_STATUS_TRAY_IME_SETTINGS),
gfx::Font::NORMAL);
diff --git a/ash/system/network/tray_network.cc b/ash/system/network/tray_network.cc
index 8f9be34..41f5826 100644
--- a/ash/system/network/tray_network.cc
+++ b/ash/system/network/tray_network.cc
@@ -86,48 +86,6 @@ class NonActivatableSettingsBubble : public views::BubbleDelegateView {
DISALLOW_COPY_AND_ASSIGN(NonActivatableSettingsBubble);
};
-// A ToggleImageButton with fixed size, paddings and hover effects. These
-// buttons are used in the header.
-class HeaderButton : public views::ToggleImageButton {
- public:
- HeaderButton(views::ButtonListener* listener,
- int enabled_resource_id,
- int disabled_resource_id)
- : views::ToggleImageButton(listener) {
- ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
- SetImage(views::CustomButton::BS_NORMAL,
- bundle.GetImageNamed(enabled_resource_id).ToSkBitmap());
- SetToggledImage(views::CustomButton::BS_NORMAL,
- bundle.GetImageNamed(disabled_resource_id).ToSkBitmap());
- SetImageAlignment(views::ImageButton::ALIGN_CENTER,
- views::ImageButton::ALIGN_MIDDLE);
- set_background(views::Background::CreateSolidBackground(
- ash::kHeaderBackgroundColor));
- }
-
- virtual ~HeaderButton() {}
-
- private:
- // Overridden from views::View.
- virtual gfx::Size GetPreferredSize() OVERRIDE {
- return gfx::Size(ash::kTrayPopupItemHeight, ash::kTrayPopupItemHeight);
- }
-
- virtual void OnPaintBorder(gfx::Canvas* canvas) OVERRIDE {
- // Left border.
- canvas->FillRect(gfx::Rect(0, 0, 1, height()), ash::kBorderDarkColor);
- }
-
- // Overridden from views::CustomButton.
- virtual void StateChanged() OVERRIDE {
- set_background(views::Background::CreateSolidBackground(
- IsHotTracked() ? ash::kHeaderHoverBackgroundColor :
- ash::kHeaderBackgroundColor));
- }
-
- DISALLOW_COPY_AND_ASSIGN(HeaderButton);
-};
-
} // namespace
namespace ash {
@@ -275,21 +233,21 @@ class NetworkDetailedView : public views::View,
header_buttons_->SetLayoutManager(new
views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0));
- button_wifi_ = new HeaderButton(this,
+ button_wifi_ = new TrayPopupHeaderButton(this,
IDR_AURA_UBER_TRAY_WIFI_ENABLED,
IDR_AURA_UBER_TRAY_WIFI_DISABLED);
button_wifi_->SetToggled(!delegate->GetWifiEnabled());
header_buttons_->AddChildView(button_wifi_);
if (delegate->GetCellularAvailable()) {
- button_cellular_ = new HeaderButton(this,
+ button_cellular_ = new TrayPopupHeaderButton(this,
IDR_AURA_UBER_TRAY_CELLULAR_ENABLED,
IDR_AURA_UBER_TRAY_CELLULAR_DISABLED);
button_cellular_->SetToggled(!delegate->GetCellularEnabled());
header_buttons_->AddChildView(button_cellular_);
}
- info_icon_ = new HeaderButton(this,
+ info_icon_ = new TrayPopupHeaderButton(this,
IDR_AURA_UBER_TRAY_NETWORK_INFO,
IDR_AURA_UBER_TRAY_NETWORK_INFO);
header_buttons_->AddChildView(info_icon_);
diff --git a/ash/system/tray/tray_views.cc b/ash/system/tray/tray_views.cc
index beba708..1c2e75e 100644
--- a/ash/system/tray/tray_views.cc
+++ b/ash/system/tray/tray_views.cc
@@ -276,6 +276,40 @@ void TrayPopupTextButtonContainer::AddTextButton(TrayPopupTextButton* button) {
AddChildView(button);
}
+////////////////////////////////////////////////////////////////////////////////
+// TrayPopupTextButtonContainer
+
+TrayPopupHeaderButton::TrayPopupHeaderButton(views::ButtonListener* listener,
+ int enabled_resource_id,
+ int disabled_resource_id)
+ : views::ToggleImageButton(listener) {
+ ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
+ SetImage(views::CustomButton::BS_NORMAL,
+ bundle.GetImageNamed(enabled_resource_id).ToSkBitmap());
+ SetToggledImage(views::CustomButton::BS_NORMAL,
+ bundle.GetImageNamed(disabled_resource_id).ToSkBitmap());
+ SetImageAlignment(views::ImageButton::ALIGN_CENTER,
+ views::ImageButton::ALIGN_MIDDLE);
+ set_background(views::Background::CreateSolidBackground(
+ ash::kHeaderBackgroundColor));
+}
+
+TrayPopupHeaderButton::~TrayPopupHeaderButton() {}
+
+gfx::Size TrayPopupHeaderButton::GetPreferredSize() {
+ return gfx::Size(ash::kTrayPopupItemHeight, ash::kTrayPopupItemHeight);
+}
+
+void TrayPopupHeaderButton::OnPaintBorder(gfx::Canvas* canvas) {
+ // Left border.
+ canvas->FillRect(gfx::Rect(0, 0, 1, height()), ash::kBorderDarkColor);
+}
+
+void TrayPopupHeaderButton::StateChanged() {
+ set_background(views::Background::CreateSolidBackground(
+ IsHotTracked() ? ash::kHeaderHoverBackgroundColor :
+ ash::kHeaderBackgroundColor));
+}
views::View* CreateDetailedHeaderEntry(int string_id,
ViewClickListener* listener) {
diff --git a/ash/system/tray/tray_views.h b/ash/system/tray/tray_views.h
index aa9e242..8b61ffdc 100644
--- a/ash/system/tray/tray_views.h
+++ b/ash/system/tray/tray_views.h
@@ -8,6 +8,7 @@
#include "ui/gfx/font.h"
#include "ui/gfx/size.h"
+#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/button/text_button.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/scroll_view.h"
@@ -174,6 +175,26 @@ class TrayPopupTextButtonContainer : public views::View {
DISALLOW_COPY_AND_ASSIGN(TrayPopupTextButtonContainer);
};
+// A ToggleImageButton with fixed size, paddings and hover effects. These
+// buttons are used in the header.
+class TrayPopupHeaderButton : public views::ToggleImageButton {
+ public:
+ TrayPopupHeaderButton(views::ButtonListener* listener,
+ int enabled_resource_id,
+ int disabled_resource_id);
+ virtual ~TrayPopupHeaderButton();
+
+ private:
+ // Overridden from views::View.
+ virtual gfx::Size GetPreferredSize() OVERRIDE;
+ virtual void OnPaintBorder(gfx::Canvas* canvas) OVERRIDE;
+
+ // Overridden from views::CustomButton.
+ virtual void StateChanged() OVERRIDE;
+
+ DISALLOW_COPY_AND_ASSIGN(TrayPopupHeaderButton);
+};
+
// Creates a container for the various detailed popups. Clicking on the view
// triggers the callback in ViewClickListener.
views::View* CreateDetailedHeaderEntry(int string_id,
diff --git a/ui/resources/aura/status_bluetooth_disabled.png b/ui/resources/aura/status_bluetooth_disabled.png
new file mode 100644
index 0000000..ecd156d
--- /dev/null
+++ b/ui/resources/aura/status_bluetooth_disabled.png
Binary files differ
diff --git a/ui/resources/aura/status_bluetooth_enabled.png b/ui/resources/aura/status_bluetooth_enabled.png
new file mode 100644
index 0000000..04c481a
--- /dev/null
+++ b/ui/resources/aura/status_bluetooth_enabled.png
Binary files differ
diff --git a/ui/resources/ui_resources.grd b/ui/resources/ui_resources.grd
index 7321b5c..e18196a 100644
--- a/ui/resources/ui_resources.grd
+++ b/ui/resources/ui_resources.grd
@@ -331,6 +331,8 @@
<include name="IDR_AURA_UBER_TRAY_WIFI_DISABLED" file="aura/status_wifi_disabled.png" type="BINDATA" />
<include name="IDR_AURA_UBER_TRAY_CELLULAR_ENABLED" file="aura/status_cellular_enabled.png" type="BINDATA" />
<include name="IDR_AURA_UBER_TRAY_CELLULAR_DISABLED" file="aura/status_cellular_disabled.png" type="BINDATA" />
+ <include name="IDR_AURA_UBER_TRAY_BLUETOOTH_ENABLED" file="aura/status_bluetooth_enabled.png" type="BINDATA" />
+ <include name="IDR_AURA_UBER_TRAY_BLUETOOTH_DISABLED" file="aura/status_bluetooth_disabled.png" type="BINDATA" />
<include name="IDR_AURA_SWITCH_MONITOR" file="aura/switch_monitor.png" type="BINDATA" />
<include name="IDR_OAK" file="oak.png" type="BINDATA"/>