summaryrefslogtreecommitdiffstats
path: root/ash/system/power
diff options
context:
space:
mode:
Diffstat (limited to 'ash/system/power')
-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
3 files changed, 32 insertions, 12 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_);
}