summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorjennyz@chromium.org <jennyz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-24 17:09:02 +0000
committerjennyz@chromium.org <jennyz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-24 17:09:02 +0000
commitdf2d3870b7aa31a7d0362706f5ab9f1e51c44d49 (patch)
treeee00eb911c54931f3ad947d1f4588a78d1c7c0fe /ash
parentb84d459957a85bfcbba9f429511650806fca10ec (diff)
downloadchromium_src-df2d3870b7aa31a7d0362706f5ab9f1e51c44d49.zip
chromium_src-df2d3870b7aa31a7d0362706f5ab9f1e51c44d49.tar.gz
chromium_src-df2d3870b7aa31a7d0362706f5ab9f1e51c44d49.tar.bz2
Adjust the power status UI to left aligned UI if the Settings is not displayed on the uber tray bubble.
BUG=138186 Review URL: https://chromiumcodereview.appspot.com/10877029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@153233 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/system/power/power_status_view.cc36
-rw-r--r--ash/system/power/power_status_view.h6
-rw-r--r--ash/system/power/tray_power.cc2
-rw-r--r--ash/system/settings/tray_settings.cc12
4 files changed, 40 insertions, 16 deletions
diff --git a/ash/system/power/power_status_view.cc b/ash/system/power/power_status_view.cc
index 3b39426..8fabe3b 100644
--- a/ash/system/power/power_status_view.cc
+++ b/ash/system/power/power_status_view.cc
@@ -6,6 +6,7 @@
#include "ash/system/power/tray_power.h"
#include "ash/system/tray/tray_constants.h"
+#include "ash/system/tray/tray_views.h"
#include "base/string_number_conversions.h"
#include "base/utf_string_conversions.h"
#include "grit/ash_strings.h"
@@ -29,8 +30,10 @@ const int kLabelMinWidth = 120;
const int kPaddingBetweenBatteryStatusAndIcon = 3;
} // namespace
-PowerStatusView::PowerStatusView(ViewType view_type)
- : status_label_(NULL),
+PowerStatusView::PowerStatusView(ViewType view_type,
+ bool default_view_right_align)
+ : default_view_right_align_(default_view_right_align),
+ status_label_(NULL),
time_label_(NULL),
time_status_label_(NULL),
icon_(NULL),
@@ -56,16 +59,29 @@ void PowerStatusView::UpdatePowerStatus(const PowerSupplyStatus& status) {
}
void PowerStatusView::LayoutDefaultView() {
- views::BoxLayout* layout =
- new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0,
- kPaddingBetweenBatteryStatusAndIcon);
- SetLayoutManager(layout);
+ if (default_view_right_align_) {
+ views::BoxLayout* layout =
+ new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0,
+ kPaddingBetweenBatteryStatusAndIcon);
+ SetLayoutManager(layout);
- time_status_label_->SetHorizontalAlignment(views::Label::ALIGN_RIGHT);
- AddChildView(time_status_label_);
+ AddChildView(time_status_label_);
- icon_ = new views::ImageView;
- AddChildView(icon_);
+ icon_ = new views::ImageView;
+ AddChildView(icon_);
+ } else {
+ // PowerStatusView is left aligned on the system tray pop up item.
+ views::BoxLayout* layout =
+ new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0,
+ kTrayPopupPaddingBetweenItems);
+ SetLayoutManager(layout);
+
+ icon_ =
+ new ash::internal::FixedSizedImageView(0, ash::kTrayPopupItemHeight);
+ AddChildView(icon_);
+
+ AddChildView(time_status_label_);
+ }
}
void PowerStatusView::LayoutNotificationView() {
diff --git a/ash/system/power/power_status_view.h b/ash/system/power/power_status_view.h
index c4eca99..340cd46 100644
--- a/ash/system/power/power_status_view.h
+++ b/ash/system/power/power_status_view.h
@@ -23,7 +23,7 @@ class PowerStatusView : public views::View {
VIEW_NOTIFICATION
};
- explicit PowerStatusView(ViewType view_type);
+ PowerStatusView(ViewType view_type, bool default_view_right_align);
virtual ~PowerStatusView() {}
void UpdatePowerStatus(const PowerSupplyStatus& status);
@@ -43,6 +43,10 @@ class PowerStatusView : public views::View {
// Overridden from views::View.
virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE;
+ // Layout default view UI items on the right side of system tray pop up item
+ // if true; otherwise, layout the UI items on the left side.
+ bool default_view_right_align_;
+
// labels used only for VIEW_NOTIFICATION.
views::Label* status_label_;
views::Label* time_label_;
diff --git a/ash/system/power/tray_power.cc b/ash/system/power/tray_power.cc
index 48d3f3c..cb8f037 100644
--- a/ash/system/power/tray_power.cc
+++ b/ash/system/power/tray_power.cc
@@ -95,7 +95,7 @@ class PowerNotificationView : public TrayNotificationView {
explicit PowerNotificationView(TrayPower* tray)
: TrayNotificationView(tray, 0) {
power_status_view_ =
- new PowerStatusView(PowerStatusView::VIEW_NOTIFICATION);
+ new PowerStatusView(PowerStatusView::VIEW_NOTIFICATION, true);
InitView(power_status_view_);
}
diff --git a/ash/system/settings/tray_settings.cc b/ash/system/settings/tray_settings.cc
index c28a3ea..a79ea5f 100644
--- a/ash/system/settings/tray_settings.cc
+++ b/ash/system/settings/tray_settings.cc
@@ -32,11 +32,13 @@ class SettingsDefaultView : public ash::internal::ActionableView {
public:
explicit SettingsDefaultView(user::LoginStatus status)
: login_status_(status),
+ label_(NULL),
power_status_view_(NULL) {
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal,
ash::kTrayPopupPaddingHorizontal, 0,
ash::kTrayPopupPaddingBetweenItems));
+ bool power_view_right_align = false;
if (login_status_ != user::LOGGED_IN_NONE &&
login_status_ != user::LOGGED_IN_LOCKED) {
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
@@ -50,13 +52,15 @@ class SettingsDefaultView : public ash::internal::ActionableView {
label_ = new views::Label(text);
AddChildView(label_);
SetAccessibleName(text);
+
+ power_view_right_align = true;
}
PowerSupplyStatus power_status =
ash::Shell::GetInstance()->tray_delegate()->GetPowerSupplyStatus();
if (power_status.battery_is_present) {
power_status_view_ = new ash::internal::PowerStatusView(
- ash::internal::PowerStatusView::VIEW_DEFAULT);
+ ash::internal::PowerStatusView::VIEW_DEFAULT, power_view_right_align);
AddChildView(power_status_view_);
UpdatePowerStatus(power_status);
}
@@ -81,11 +85,11 @@ class SettingsDefaultView : public ash::internal::ActionableView {
// Overridden from views::View.
virtual void Layout() OVERRIDE {
- // Let the box-layout do the layout first. Then move power_status_view_
- // to right align if it is created.
views::View::Layout();
- if (power_status_view_) {
+ if (label_ && power_status_view_) {
+ // Let the box-layout do the layout first. Then move power_status_view_
+ // to right align if it is created.
gfx::Size size = power_status_view_->GetPreferredSize();
gfx::Rect bounds(size);
bounds.set_x(width() - size.width() - ash::kTrayPopupPaddingBetweenItems);