power_status_view.h revision a1401311d1ab56c4ed0a474bd38c108f75cb0cd9
1// Copyright (c) 2012 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef ASH_SYSTEM_CHROMEOS_POWER_POWER_STATUS_VIEW_H_ 6#define ASH_SYSTEM_CHROMEOS_POWER_POWER_STATUS_VIEW_H_ 7 8#include "ash/ash_export.h" 9#include "ash/system/chromeos/power/power_status.h" 10#include "ui/views/view.h" 11 12namespace views { 13class ImageView; 14class Label; 15} 16 17namespace ash { 18namespace internal { 19 20class ASH_EXPORT PowerStatusView : public views::View, 21 public PowerStatus::Observer { 22 public: 23 enum ViewType { 24 VIEW_DEFAULT, 25 VIEW_NOTIFICATION 26 }; 27 28 PowerStatusView(ViewType view_type, bool default_view_right_align); 29 virtual ~PowerStatusView(); 30 31 // Overridden from views::View. 32 virtual gfx::Size GetPreferredSize() OVERRIDE; 33 virtual int GetHeightForWidth(int width) OVERRIDE; 34 virtual void Layout() OVERRIDE; 35 36 // Overridden from PowerStatus::Observer. 37 virtual void OnPowerStatusChanged() OVERRIDE; 38 39 private: 40 friend class PowerStatusDefaultViewTest; 41 friend class PowerStatusNotificationViewTest; 42 43 void LayoutDefaultView(); 44 void LayoutNotificationView(); 45 void UpdateTextForDefaultView(); 46 void UpdateTextForNotificationView(); 47 48 // Overridden from views::View. 49 virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE; 50 51 // Layout default view UI items on the right side of system tray pop up item 52 // if true; otherwise, layout the UI items on the left side. 53 bool default_view_right_align_; 54 55 // Labels used only for VIEW_NOTIFICATION. 56 views::Label* status_label_; 57 views::Label* time_label_; 58 59 // Labels used only for VIEW_DEFAULT. 60 views::Label* time_status_label_; 61 views::Label* percentage_label_; 62 63 // Battery status indicator icon. 64 views::ImageView* icon_; 65 66 ViewType view_type_; 67 68 DISALLOW_COPY_AND_ASSIGN(PowerStatusView); 69}; 70 71} // namespace internal 72} // namespace ash 73 74#endif // ASH_SYSTEM_CHROMEOS_POWER_POWER_STATUS_VIEW_H_ 75