summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-17 00:45:08 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-17 00:45:08 +0000
commit53b35b1ad9587c497a693ef57940b392bf9390dc (patch)
tree1b2ab9beefdba71b75a9f12ccbc8a1108466bdf7
parenteedff55de48a12a7d61abf7b71601c7d48ee3f64 (diff)
downloadchromium_src-53b35b1ad9587c497a693ef57940b392bf9390dc.zip
chromium_src-53b35b1ad9587c497a693ef57940b392bf9390dc.tar.gz
chromium_src-53b35b1ad9587c497a693ef57940b392bf9390dc.tar.bz2
ash: Make sure all the popups from the tray have the same width.
This should keep things sane and good if username, email, network name etc. are too long. This also fixes alignment/padding issues for the sliders, chevron icons etc. BUG=110130 TEST=none Review URL: https://chromiumcodereview.appspot.com/9703125 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@127312 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/shell.cc2
-rw-r--r--ash/system/audio/tray_volume.cc9
-rw-r--r--ash/system/brightness/tray_brightness.cc9
-rw-r--r--ash/system/network/tray_network.cc19
-rw-r--r--ash/system/power/tray_power_date.cc4
-rw-r--r--ash/system/settings/tray_settings.cc14
-rw-r--r--ash/system/tray/system_tray.cc5
-rw-r--r--ash/system/tray/tray_constants.cc4
-rw-r--r--ash/system/tray/tray_constants.h4
-rw-r--r--ui/views/controls/slider.cc4
10 files changed, 51 insertions, 23 deletions
diff --git a/ash/shell.cc b/ash/shell.cc
index 5aec3bd..3f66ee0 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -236,7 +236,7 @@ class DummySystemTrayDelegate : public SystemTrayDelegate {
// Overridden from SystemTrayDelegate:
virtual const std::string GetUserDisplayName() const OVERRIDE {
- return "Über tray";
+ return "Über tray Über tray Über tray Über tray";
}
virtual const std::string GetUserEmail() const OVERRIDE {
diff --git a/ash/system/audio/tray_volume.cc b/ash/system/audio/tray_volume.cc
index 45d1d1d..e02fd1a 100644
--- a/ash/system/audio/tray_volume.cc
+++ b/ash/system/audio/tray_volume.cc
@@ -98,7 +98,7 @@ class VolumeView : public views::View,
public:
VolumeView() {
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal,
- 0, 0, 5));
+ kTrayPopupPaddingHorizontal, 0, kTrayPopupPaddingBetweenItems));
icon_ = new VolumeButton(this);
AddChildView(icon_);
@@ -107,7 +107,6 @@ class VolumeView : public views::View,
ash::Shell::GetInstance()->tray_delegate();
slider_ = new views::Slider(this, views::Slider::HORIZONTAL);
slider_->SetValue(delegate->GetVolumeLevel());
- slider_->set_border(views::Border::CreateEmptyBorder(0, 0, 0, 20));
AddChildView(slider_);
}
@@ -122,6 +121,12 @@ class VolumeView : public views::View,
}
private:
+ // Overridden from views::View.
+ virtual void OnBoundsChanged(const gfx::Rect& old_bounds) OVERRIDE {
+ int w = width() - slider_->x();
+ slider_->SetSize(gfx::Size(w, slider_->height()));
+ }
+
// Overridden from views::ButtonListener.
virtual void ButtonPressed(views::Button* sender,
const views::Event& event) OVERRIDE {
diff --git a/ash/system/brightness/tray_brightness.cc b/ash/system/brightness/tray_brightness.cc
index 2335ab4..9afb238 100644
--- a/ash/system/brightness/tray_brightness.cc
+++ b/ash/system/brightness/tray_brightness.cc
@@ -31,7 +31,7 @@ class BrightnessView : public views::View,
public:
BrightnessView() {
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal,
- 0, 0, 5));
+ kTrayPopupPaddingHorizontal, 0, kTrayPopupPaddingBetweenItems));
views::ImageView* icon = new views::ImageView();
gfx::Image image = ui::ResourceBundle::GetSharedInstance().GetImageNamed(
@@ -44,7 +44,6 @@ 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_);
}
@@ -55,6 +54,12 @@ class BrightnessView : public views::View,
}
private:
+ // Overridden from views::View.
+ virtual void OnBoundsChanged(const gfx::Rect& old_bounds) OVERRIDE {
+ int w = width() - slider_->x();
+ slider_->SetSize(gfx::Size(w, slider_->height()));
+ }
+
// Overridden from views:SliderListener.
virtual void SliderValueChanged(views::Slider* sender,
float value,
diff --git a/ash/system/network/tray_network.cc b/ash/system/network/tray_network.cc
index d679675..b6d8f59 100644
--- a/ash/system/network/tray_network.cc
+++ b/ash/system/network/tray_network.cc
@@ -197,7 +197,7 @@ class NetworkDefaultView : public views::View {
public:
explicit NetworkDefaultView(SystemTrayItem* owner) : owner_(owner) {
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal,
- 0, 0, 5));
+ kTrayPopupPaddingHorizontal, 0, kTrayPopupPaddingBetweenItems));
icon_ = new NetworkTrayView(LARGE);
AddChildView(icon_);
@@ -205,10 +205,10 @@ class NetworkDefaultView : public views::View {
label_ = new views::Label();
AddChildView(label_);
- views::ImageView* more = new views::ImageView;
- more->SetImage(ui::ResourceBundle::GetSharedInstance().GetImageNamed(
+ more_ = new views::ImageView;
+ more_->SetImage(ui::ResourceBundle::GetSharedInstance().GetImageNamed(
IDR_AURA_UBER_TRAY_MORE).ToSkBitmap());
- AddChildView(more);
+ AddChildView(more_);
Update(Shell::GetInstance()->tray_delegate()->
GetMostRelevantNetworkIcon(true));
@@ -223,6 +223,16 @@ class NetworkDefaultView : public views::View {
private:
// Overridden from views::View.
+ virtual void Layout() OVERRIDE {
+ // Let the box-layout do the layout first. Then move the '>' arrow to right
+ // align.
+ views::View::Layout();
+
+ gfx::Rect bounds = more_->bounds();
+ bounds.set_x(width() - more_->width());
+ more_->SetBoundsRect(bounds);
+ }
+
virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE {
owner_->PopupDetailedView(0, true);
return true;
@@ -231,6 +241,7 @@ class NetworkDefaultView : public views::View {
SystemTrayItem* owner_;
NetworkTrayView* icon_;
views::Label* label_;
+ views::ImageView* more_;
DISALLOW_COPY_AND_ASSIGN(NetworkDefaultView);
};
diff --git a/ash/system/power/tray_power_date.cc b/ash/system/power/tray_power_date.cc
index 5aceea4..6bb8530 100644
--- a/ash/system/power/tray_power_date.cc
+++ b/ash/system/power/tray_power_date.cc
@@ -309,8 +309,8 @@ views::View* TrayPowerDate::CreateDefaultView(user::LoginStatus status) {
date_->set_actionable(true);
views::View* container = new views::View;
- views::BoxLayout* layout = new
- views::BoxLayout(views::BoxLayout::kHorizontal, 18, 10, 0);
+ views::BoxLayout* layout = new views::BoxLayout(views::BoxLayout::kHorizontal,
+ kTrayPopupPaddingHorizontal, 10, 0);
layout->set_spread_blank_space(true);
container->SetLayoutManager(layout);
container->set_background(views::Background::CreateSolidBackground(
diff --git a/ash/system/settings/tray_settings.cc b/ash/system/settings/tray_settings.cc
index 3e3cabf..77ebd7e 100644
--- a/ash/system/settings/tray_settings.cc
+++ b/ash/system/settings/tray_settings.cc
@@ -6,6 +6,7 @@
#include "ash/shell.h"
#include "ash/system/tray/system_tray_delegate.h"
+#include "ash/system/tray/tray_constants.h"
#include "base/logging.h"
#include "base/utf_string_conversions.h"
#include "grit/ash_strings.h"
@@ -25,7 +26,8 @@ class SettingsView : public views::View {
public:
SettingsView() {
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal,
- 0, 0, 3));
+ ash::kTrayPopupPaddingHorizontal, 0,
+ ash::kTrayPopupPaddingBetweenItems));
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
views::ImageView* icon = new views::ImageView;
@@ -68,15 +70,7 @@ views::View* TraySettings::CreateDefaultView(user::LoginStatus status) {
if (status == user::LOGGED_IN_NONE)
return NULL;
- views::View* container = new views::View;
- views::BoxLayout* layout =
- new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 5);
- layout->set_spread_blank_space(true);
- container->SetLayoutManager(layout);
-
- views::View* settings = new SettingsView;
- container->AddChildView(settings);
- return container;
+ return new SettingsView;
}
views::View* TraySettings::CreateDetailedView(user::LoginStatus status) {
diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc
index f769a93..12e31ac 100644
--- a/ash/system/tray/system_tray.cc
+++ b/ash/system/tray/system_tray.cc
@@ -292,6 +292,11 @@ class SystemTrayBubble : public views::BubbleDelegateView {
return can_activate_;
}
+ virtual gfx::Size GetPreferredSize() OVERRIDE {
+ gfx::Size size = views::BubbleDelegateView::GetPreferredSize();
+ return gfx::Size(kTrayPopupWidth, size.height());
+ }
+
virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE {
autoclose_.Stop();
}
diff --git a/ash/system/tray/tray_constants.cc b/ash/system/tray/tray_constants.cc
index 21e3331..0c4d77b 100644
--- a/ash/system/tray/tray_constants.cc
+++ b/ash/system/tray/tray_constants.cc
@@ -10,8 +10,12 @@ namespace ash {
const int kTrayPaddingBetweenItems = 8;
const int kTrayPopupAutoCloseDelayInSeconds = 2;
+extern const int kTrayPopupPaddingHorizontal = 18;
+const int kTrayPopupPaddingBetweenItems = 5;
const SkColor kBackgroundColor = SK_ColorWHITE;
const SkColor kHoverBackgroundColor = SkColorSetRGB(0xfb, 0xfc, 0xfb);
+const int kTrayPopupWidth = 300;
+
} // namespace ash
diff --git a/ash/system/tray/tray_constants.h b/ash/system/tray/tray_constants.h
index d2a33e4..1ad27c6 100644
--- a/ash/system/tray/tray_constants.h
+++ b/ash/system/tray/tray_constants.h
@@ -12,10 +12,14 @@ namespace ash {
extern const int kTrayPaddingBetweenItems;
extern const int kTrayPopupAutoCloseDelayInSeconds;
+extern const int kTrayPopupPaddingHorizontal;
+extern const int kTrayPopupPaddingBetweenItems;
extern const SkColor kBackgroundColor;
extern const SkColor kHoverBackgroundColor;
+extern const int kTrayPopupWidth;
+
} // namespace ash
#endif // ASH_SYSTEM_TRAY_TRAY_CONSTANTS_H_
diff --git a/ui/views/controls/slider.cc b/ui/views/controls/slider.cc
index 2721335..c42902b 100644
--- a/ui/views/controls/slider.cc
+++ b/ui/views/controls/slider.cc
@@ -81,8 +81,8 @@ gfx::Size Slider::GetPreferredSize() {
const int kSizeMinor = 40;
if (orientation_ == HORIZONTAL)
- return gfx::Size(kSizeMajor, kSizeMinor);
- return gfx::Size(kSizeMinor, kSizeMajor);
+ return gfx::Size(std::max(width(), kSizeMajor), kSizeMinor);
+ return gfx::Size(kSizeMinor, std::max(height(), kSizeMajor));
}
void Slider::OnPaint(gfx::Canvas* canvas) {