Commit 9c8d4962 authored by pkotwicz's avatar pkotwicz Committed by Commit bot

[Athena] Add status icons and system time to the centered home card

BUG=404156
TEST=Manual, see bug

Review URL: https://codereview.chromium.org/483033003

Cr-Commit-Position: refs/heads/master@{#293042}
parent 6e1f2a87
...@@ -3,6 +3,7 @@ include_rules = [ ...@@ -3,6 +3,7 @@ include_rules = [
"+athena/env/public", "+athena/env/public",
"+athena/input/public", "+athena/input/public",
"+athena/screen/public", "+athena/screen/public",
"+athena/system/public",
"+athena/wm/public", "+athena/wm/public",
"+third_party/skia/include", "+third_party/skia/include",
"+ui/aura", "+ui/aura",
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "athena/home/athena_start_page_view.h" #include "athena/home/athena_start_page_view.h"
#include "athena/home/home_card_constants.h" #include "athena/home/home_card_constants.h"
#include "athena/system/public/system_ui.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "third_party/skia/include/core/SkPaint.h" #include "third_party/skia/include/core/SkPaint.h"
...@@ -155,7 +156,8 @@ namespace athena { ...@@ -155,7 +156,8 @@ namespace athena {
const char AthenaStartPageView::kViewClassName[] = "AthenaStartPageView"; const char AthenaStartPageView::kViewClassName[] = "AthenaStartPageView";
AthenaStartPageView::LayoutData::LayoutData() AthenaStartPageView::LayoutData::LayoutData()
: logo_opacity(1.0f), : system_info_opacity(1.0f),
logo_opacity(1.0f),
background_opacity(1.0f) { background_opacity(1.0f) {
} }
...@@ -171,6 +173,12 @@ AthenaStartPageView::AthenaStartPageView( ...@@ -171,6 +173,12 @@ AthenaStartPageView::AthenaStartPageView(
background_->SetFillsBoundsOpaquely(false); background_->SetFillsBoundsOpaquely(false);
AddChildView(background_); AddChildView(background_);
system_info_view_ =
SystemUI::Get()->CreateSystemInfoView(SystemUI::COLOR_SCHEME_DARK);
system_info_view_->SetPaintToLayer(true);
system_info_view_->SetFillsBoundsOpaquely(false);
AddChildView(system_info_view_);
logo_ = view_delegate->CreateStartPageWebView( logo_ = view_delegate->CreateStartPageWebView(
gfx::Size(kWebViewWidth, kWebViewHeight)); gfx::Size(kWebViewWidth, kWebViewHeight));
logo_->SetPaintToLayer(true); logo_->SetPaintToLayer(true);
...@@ -234,6 +242,8 @@ void AthenaStartPageView::SetLayoutState(float layout_state) { ...@@ -234,6 +242,8 @@ void AthenaStartPageView::SetLayoutState(float layout_state) {
} }
void AthenaStartPageView::SetLayoutStateWithAnimation(float layout_state) { void AthenaStartPageView::SetLayoutStateWithAnimation(float layout_state) {
ui::ScopedLayerAnimationSettings system_info(
system_info_view_->layer()->GetAnimator());
ui::ScopedLayerAnimationSettings logo(logo_->layer()->GetAnimator()); ui::ScopedLayerAnimationSettings logo(logo_->layer()->GetAnimator());
ui::ScopedLayerAnimationSettings search_box( ui::ScopedLayerAnimationSettings search_box(
search_box_container_->layer()->GetAnimator()); search_box_container_->layer()->GetAnimator());
...@@ -242,6 +252,7 @@ void AthenaStartPageView::SetLayoutStateWithAnimation(float layout_state) { ...@@ -242,6 +252,7 @@ void AthenaStartPageView::SetLayoutStateWithAnimation(float layout_state) {
ui::ScopedLayerAnimationSettings controls( ui::ScopedLayerAnimationSettings controls(
control_icon_container_->layer()->GetAnimator()); control_icon_container_->layer()->GetAnimator());
system_info.SetTweenType(gfx::Tween::EASE_IN_OUT);
logo.SetTweenType(gfx::Tween::EASE_IN_OUT); logo.SetTweenType(gfx::Tween::EASE_IN_OUT);
search_box.SetTweenType(gfx::Tween::EASE_IN_OUT); search_box.SetTweenType(gfx::Tween::EASE_IN_OUT);
icons.SetTweenType(gfx::Tween::EASE_IN_OUT); icons.SetTweenType(gfx::Tween::EASE_IN_OUT);
...@@ -268,6 +279,7 @@ AthenaStartPageView::LayoutData AthenaStartPageView::CreateBottomBounds( ...@@ -268,6 +279,7 @@ AthenaStartPageView::LayoutData AthenaStartPageView::CreateBottomBounds(
state.search_box.set_x((width - state.search_box.width()) / 2); state.search_box.set_x((width - state.search_box.width()) / 2);
state.search_box.set_y((kHomeCardHeight - state.search_box.height()) / 2); state.search_box.set_y((kHomeCardHeight - state.search_box.height()) / 2);
state.system_info_opacity = 0.0f;
state.logo_opacity = 0.0f; state.logo_opacity = 0.0f;
state.background_opacity = 0.9f; state.background_opacity = 0.9f;
return state; return state;
...@@ -289,6 +301,7 @@ AthenaStartPageView::LayoutData AthenaStartPageView::CreateCenteredBounds( ...@@ -289,6 +301,7 @@ AthenaStartPageView::LayoutData AthenaStartPageView::CreateCenteredBounds(
state.controls.set_x(width / 2 + kIconMargin / 2 + kIconMargin % 2); state.controls.set_x(width / 2 + kIconMargin / 2 + kIconMargin % 2);
state.controls.set_y(state.icons.y()); state.controls.set_y(state.icons.y());
state.system_info_opacity = 1.0f;
state.logo_opacity = 1.0f; state.logo_opacity = 1.0f;
state.background_opacity = 1.0f; state.background_opacity = 1.0f;
return state; return state;
...@@ -364,6 +377,10 @@ void AthenaStartPageView::OnSearchResultLayoutAnimationCompleted( ...@@ -364,6 +377,10 @@ void AthenaStartPageView::OnSearchResultLayoutAnimationCompleted(
void AthenaStartPageView::Layout() { void AthenaStartPageView::Layout() {
search_results_view_->SetVisible(false); search_results_view_->SetVisible(false);
system_info_view_->SetBounds(
0, 0, width(), system_info_view_->GetPreferredSize().height());
gfx::Rect logo_bounds(x() + width() / 2 - kWebViewWidth / 2, y() + kTopMargin, gfx::Rect logo_bounds(x() + width() / 2 - kWebViewWidth / 2, y() + kTopMargin,
kWebViewWidth, kWebViewHeight); kWebViewWidth, kWebViewHeight);
logo_->SetBoundsRect(logo_bounds); logo_->SetBoundsRect(logo_bounds);
...@@ -371,6 +388,12 @@ void AthenaStartPageView::Layout() { ...@@ -371,6 +388,12 @@ void AthenaStartPageView::Layout() {
LayoutData bottom_bounds = CreateBottomBounds(width()); LayoutData bottom_bounds = CreateBottomBounds(width());
LayoutData centered_bounds = CreateCenteredBounds(width()); LayoutData centered_bounds = CreateCenteredBounds(width());
system_info_view_->layer()->SetOpacity(gfx::Tween::FloatValueBetween(
gfx::Tween::CalculateValue(gfx::Tween::EASE_IN_2, layout_state_),
bottom_bounds.system_info_opacity, centered_bounds.system_info_opacity));
system_info_view_->SetVisible(
system_info_view_->layer()->GetTargetOpacity() != 0.0f);
logo_->layer()->SetOpacity(gfx::Tween::FloatValueBetween( logo_->layer()->SetOpacity(gfx::Tween::FloatValueBetween(
gfx::Tween::CalculateValue(gfx::Tween::EASE_IN_2, layout_state_), gfx::Tween::CalculateValue(gfx::Tween::EASE_IN_2, layout_state_),
bottom_bounds.logo_opacity, centered_bounds.logo_opacity)); bottom_bounds.logo_opacity, centered_bounds.logo_opacity));
......
...@@ -45,6 +45,7 @@ class ATHENA_EXPORT AthenaStartPageView ...@@ -45,6 +45,7 @@ class ATHENA_EXPORT AthenaStartPageView
gfx::Rect search_box; gfx::Rect search_box;
gfx::Rect icons; gfx::Rect icons;
gfx::Rect controls; gfx::Rect controls;
float system_info_opacity;
float logo_opacity; float logo_opacity;
float background_opacity; float background_opacity;
...@@ -76,6 +77,7 @@ class ATHENA_EXPORT AthenaStartPageView ...@@ -76,6 +77,7 @@ class ATHENA_EXPORT AthenaStartPageView
app_list::AppListViewDelegate* delegate_; app_list::AppListViewDelegate* delegate_;
// Views are owned through its hierarchy. // Views are owned through its hierarchy.
views::View* system_info_view_;
views::View* app_icon_container_; views::View* app_icon_container_;
views::View* search_box_container_; views::View* search_box_container_;
views::View* control_icon_container_; views::View* control_icon_container_;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "athena/home/athena_start_page_view.h" #include "athena/home/athena_start_page_view.h"
#include "athena/home/home_card_constants.h" #include "athena/home/home_card_constants.h"
#include "base/command_line.h" #include "athena/test/athena_test_base.h"
#include "base/format_macros.h" #include "base/format_macros.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "ui/app_list/views/search_box_view.h" #include "ui/app_list/views/search_box_view.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
#include "ui/views/controls/textfield/textfield.h" #include "ui/views/controls/textfield/textfield.h"
#include "ui/views/test/views_test_base.h"
namespace athena { namespace athena {
...@@ -41,16 +40,14 @@ class AthenaTestViewDelegate : public app_list::test::AppListTestViewDelegate { ...@@ -41,16 +40,14 @@ class AthenaTestViewDelegate : public app_list::test::AppListTestViewDelegate {
DISALLOW_COPY_AND_ASSIGN(AthenaTestViewDelegate); DISALLOW_COPY_AND_ASSIGN(AthenaTestViewDelegate);
}; };
class AthenaStartPageViewTest : public views::ViewsTestBase { class AthenaStartPageViewTest : public test::AthenaTestBase {
public: public:
AthenaStartPageViewTest() {} AthenaStartPageViewTest() {}
virtual ~AthenaStartPageViewTest() {} virtual ~AthenaStartPageViewTest() {}
// testing::Test: // testing::Test:
virtual void SetUp() OVERRIDE { virtual void SetUp() OVERRIDE {
views::ViewsTestBase::SetUp(); test::AthenaTestBase::SetUp();
base::CommandLine::ForCurrentProcess()->AppendSwitch(
app_list::switches::kEnableExperimentalAppList);
app_list::test::AppListTestModel* model = view_delegate_.GetTestModel(); app_list::test::AppListTestModel* model = view_delegate_.GetTestModel();
for (size_t i = 0; i < kNumApps; ++i) { for (size_t i = 0; i < kNumApps; ++i) {
model->AddItem(new app_list::test::AppListTestModel::AppListTestItem( model->AddItem(new app_list::test::AppListTestModel::AppListTestItem(
...@@ -62,7 +59,7 @@ class AthenaStartPageViewTest : public views::ViewsTestBase { ...@@ -62,7 +59,7 @@ class AthenaStartPageViewTest : public views::ViewsTestBase {
} }
virtual void TearDown() OVERRIDE { virtual void TearDown() OVERRIDE {
view_.reset(); view_.reset();
views::ViewsTestBase::TearDown(); test::AthenaTestBase::TearDown();
} }
protected: protected:
......
...@@ -16,11 +16,10 @@ namespace athena { ...@@ -16,11 +16,10 @@ namespace athena {
class BackgroundView : public views::View { class BackgroundView : public views::View {
public: public:
BackgroundView() BackgroundView() : system_info_view_(NULL) {
: time_view_(SystemUI::Get()->CreateTimeView()), system_info_view_ =
status_icon_view_(SystemUI::Get()->CreateStatusIconView()) { SystemUI::Get()->CreateSystemInfoView(SystemUI::COLOR_SCHEME_LIGHT);
AddChildView(time_view_); AddChildView(system_info_view_);
AddChildView(status_icon_view_);
} }
virtual ~BackgroundView() {} virtual ~BackgroundView() {}
...@@ -31,18 +30,8 @@ class BackgroundView : public views::View { ...@@ -31,18 +30,8 @@ class BackgroundView : public views::View {
// views::View: // views::View:
virtual void Layout() OVERRIDE { virtual void Layout() OVERRIDE {
time_view_->SetBoundsRect(gfx::Rect(time_view_->GetPreferredSize())); system_info_view_->SetBounds(
gfx::Size status_icon_preferred_size = 0, 0, width(), system_info_view_->GetPreferredSize().height());
status_icon_view_->GetPreferredSize();
status_icon_view_->SetBounds(width() - status_icon_preferred_size.width(),
0,
status_icon_preferred_size.width(),
status_icon_preferred_size.height());
}
virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE {
// Relayout when |status_icon_view_| changes its preferred size.
Layout();
} }
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
...@@ -60,8 +49,7 @@ class BackgroundView : public views::View { ...@@ -60,8 +49,7 @@ class BackgroundView : public views::View {
private: private:
gfx::ImageSkia image_; gfx::ImageSkia image_;
views::View* time_view_; views::View* system_info_view_;
views::View* status_icon_view_;
DISALLOW_COPY_AND_ASSIGN(BackgroundView); DISALLOW_COPY_AND_ASSIGN(BackgroundView);
}; };
......
...@@ -24,6 +24,11 @@ namespace athena { ...@@ -24,6 +24,11 @@ namespace athena {
class ATHENA_EXPORT SystemUI { class ATHENA_EXPORT SystemUI {
public: public:
enum ColorScheme {
COLOR_SCHEME_LIGHT,
COLOR_SCHEME_DARK
};
// Creates and deletes the singleton object of the SystemUI implementation. // Creates and deletes the singleton object of the SystemUI implementation.
static SystemUI* Create(scoped_refptr<base::TaskRunner> io_task_runner); static SystemUI* Create(scoped_refptr<base::TaskRunner> io_task_runner);
static SystemUI* Get(); static SystemUI* Get();
...@@ -34,11 +39,9 @@ class ATHENA_EXPORT SystemUI { ...@@ -34,11 +39,9 @@ class ATHENA_EXPORT SystemUI {
// Sets the background image. // Sets the background image.
virtual void SetBackgroundImage(const gfx::ImageSkia& image) = 0; virtual void SetBackgroundImage(const gfx::ImageSkia& image) = 0;
// Creates a view which displays the time. // Creates a view which displays the time, status icons, and debug
virtual views::View* CreateTimeView() = 0; // information.
virtual views::View* CreateSystemInfoView(ColorScheme color_scheme) = 0;
// Creates a view which displays status icons and debug information.
virtual views::View* CreateStatusIconView() = 0;
}; };
} // namespace athena } // namespace athena
......
...@@ -31,10 +31,14 @@ ...@@ -31,10 +31,14 @@
namespace athena { namespace athena {
namespace { namespace {
views::Label* CreateLabel(const std::string& text) { views::Label* CreateLabel(SystemUI::ColorScheme color_scheme,
const std::string& text) {
views::Label* label = new views::Label(base::UTF8ToUTF16(text)); views::Label* label = new views::Label(base::UTF8ToUTF16(text));
label->SetEnabledColor(SK_ColorWHITE); label->SetEnabledColor((color_scheme == SystemUI::COLOR_SCHEME_LIGHT)
? SK_ColorWHITE
: SK_ColorDKGRAY);
label->SetAutoColorReadabilityEnabled(false); label->SetAutoColorReadabilityEnabled(false);
label->SetSubpixelRenderingEnabled(false);
label->SetFontList(gfx::FontList().DeriveWithStyle(gfx::Font::BOLD)); label->SetFontList(gfx::FontList().DeriveWithStyle(gfx::Font::BOLD));
return label; return label;
} }
...@@ -44,7 +48,10 @@ views::Label* CreateLabel(const std::string& text) { ...@@ -44,7 +48,10 @@ views::Label* CreateLabel(const std::string& text) {
class StatusIconContainerView::PowerStatus class StatusIconContainerView::PowerStatus
: public chromeos::PowerManagerClient::Observer { : public chromeos::PowerManagerClient::Observer {
public: public:
explicit PowerStatus(views::ImageView* icon) : icon_(icon) { PowerStatus(SystemUI::ColorScheme color_scheme,
views::ImageView* icon)
: color_scheme_(color_scheme),
icon_(icon) {
chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver( chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(
this); this);
chromeos::DBusThreadManager::Get() chromeos::DBusThreadManager::Get()
...@@ -68,7 +75,9 @@ class StatusIconContainerView::PowerStatus ...@@ -68,7 +75,9 @@ class StatusIconContainerView::PowerStatus
const int kNumPowerImages = 15; const int kNumPowerImages = 15;
gfx::Image all = ui::ResourceBundle::GetSharedInstance().GetImageNamed( gfx::Image all = ui::ResourceBundle::GetSharedInstance().GetImageNamed(
IDR_AURA_UBER_TRAY_POWER_SMALL); (color_scheme_ == SystemUI::COLOR_SCHEME_LIGHT)
? IDR_AURA_UBER_TRAY_POWER_SMALL
: IDR_AURA_UBER_TRAY_POWER_SMALL_DARK);
int horiz_offset = IsCharging(proto) ? 1 : 0; int horiz_offset = IsCharging(proto) ? 1 : 0;
int vert_offset = -1; int vert_offset = -1;
if (proto.battery_percent() >= 100) { if (proto.battery_percent() >= 100) {
...@@ -96,6 +105,7 @@ class StatusIconContainerView::PowerStatus ...@@ -96,6 +105,7 @@ class StatusIconContainerView::PowerStatus
icon_->SetImage(GetPowerIcon(proto)); icon_->SetImage(GetPowerIcon(proto));
} }
SystemUI::ColorScheme color_scheme_;
views::ImageView* icon_; views::ImageView* icon_;
DISALLOW_COPY_AND_ASSIGN(PowerStatus); DISALLOW_COPY_AND_ASSIGN(PowerStatus);
...@@ -162,7 +172,9 @@ void StartUpdateCallback( ...@@ -162,7 +172,9 @@ void StartUpdateCallback(
class StatusIconContainerView::UpdateStatus class StatusIconContainerView::UpdateStatus
: public chromeos::UpdateEngineClient::Observer { : public chromeos::UpdateEngineClient::Observer {
public: public:
explicit UpdateStatus(views::ImageView* icon) : icon_(icon) { UpdateStatus(SystemUI::ColorScheme color_scheme, views::ImageView* icon)
: color_scheme_(color_scheme),
icon_(icon) {
chromeos::DBusThreadManager::Get()->GetUpdateEngineClient()->AddObserver( chromeos::DBusThreadManager::Get()->GetUpdateEngineClient()->AddObserver(
this); this);
chromeos::DBusThreadManager::Get()->GetUpdateEngineClient()-> chromeos::DBusThreadManager::Get()->GetUpdateEngineClient()->
...@@ -181,17 +193,22 @@ class StatusIconContainerView::UpdateStatus ...@@ -181,17 +193,22 @@ class StatusIconContainerView::UpdateStatus
chromeos::UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT) { chromeos::UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT) {
return; return;
} }
icon_->SetImage(ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( int image_id = (color_scheme_ == SystemUI::COLOR_SCHEME_LIGHT)
IDR_AURA_UBER_TRAY_UPDATE)); ? IDR_AURA_UBER_TRAY_UPDATE
: IDR_AURA_UBER_TRAY_UPDATE_DARK;
icon_->SetImage(
ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(image_id));
} }
private: private:
SystemUI::ColorScheme color_scheme_;
views::ImageView* icon_; views::ImageView* icon_;
DISALLOW_COPY_AND_ASSIGN(UpdateStatus); DISALLOW_COPY_AND_ASSIGN(UpdateStatus);
}; };
StatusIconContainerView::StatusIconContainerView( StatusIconContainerView::StatusIconContainerView(
SystemUI::ColorScheme color_scheme,
aura::Window* system_modal_container) aura::Window* system_modal_container)
: system_modal_container_(system_modal_container) { : system_modal_container_(system_modal_container) {
const int kHorizontalSpacing = 10; const int kHorizontalSpacing = 10;
...@@ -204,20 +221,20 @@ StatusIconContainerView::StatusIconContainerView( ...@@ -204,20 +221,20 @@ StatusIconContainerView::StatusIconContainerView(
std::string version_text = std::string version_text =
base::StringPrintf("%s (Build %s)", PRODUCT_VERSION, LAST_CHANGE); base::StringPrintf("%s (Build %s)", PRODUCT_VERSION, LAST_CHANGE);
AddChildView(CreateLabel(version_text)); AddChildView(CreateLabel(color_scheme, version_text));
AddChildView(CreateLabel("Network:")); AddChildView(CreateLabel(color_scheme, "Network:"));
views::Label* network_label = CreateLabel(std::string()); views::Label* network_label = CreateLabel(color_scheme, std::string());
AddChildView(network_label); AddChildView(network_label);
network_status_.reset(new NetworkStatus(network_label)); network_status_.reset(new NetworkStatus(network_label));
views::ImageView* battery_view = new views::ImageView(); views::ImageView* battery_view = new views::ImageView();
AddChildView(battery_view); AddChildView(battery_view);
power_status_.reset(new PowerStatus(battery_view)); power_status_.reset(new PowerStatus(color_scheme, battery_view));
views::ImageView* update_view = new views::ImageView(); views::ImageView* update_view = new views::ImageView();
AddChildView(update_view); AddChildView(update_view);
update_status_.reset(new UpdateStatus(update_view)); update_status_.reset(new UpdateStatus(color_scheme, update_view));
} }
StatusIconContainerView::~StatusIconContainerView() { StatusIconContainerView::~StatusIconContainerView() {
......
...@@ -18,7 +18,8 @@ namespace athena { ...@@ -18,7 +18,8 @@ namespace athena {
// View which displays the system tray icons. // View which displays the system tray icons.
class StatusIconContainerView : public views::View { class StatusIconContainerView : public views::View {
public: public:
explicit StatusIconContainerView(aura::Window* system_modal_container); StatusIconContainerView(SystemUI::ColorScheme color_scheme,
aura::Window* popup_container);
virtual ~StatusIconContainerView(); virtual ~StatusIconContainerView();
private: private:
......
...@@ -17,12 +17,62 @@ ...@@ -17,12 +17,62 @@
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/views/view.h"
namespace athena { namespace athena {
namespace { namespace {
SystemUI* instance = NULL; SystemUI* instance = NULL;
// View which positions the TimeView on the left and the StatusIconView on the
// right.
class SystemInfoView : public views::View {
public:
SystemInfoView(SystemUI::ColorScheme color_scheme,
aura::Window* system_modal_container)
: time_view_(new TimeView(color_scheme)),
status_icon_view_(
new StatusIconContainerView(color_scheme, system_modal_container)) {
AddChildView(time_view_);
AddChildView(status_icon_view_);
}
virtual ~SystemInfoView() {
}
// views::View:
virtual gfx::Size GetPreferredSize() const OVERRIDE {
// The view should be as wide as its parent view.
return gfx::Size(0,
std::max(time_view_->GetPreferredSize().height(),
status_icon_view_->GetPreferredSize().height()));
}
virtual void Layout() OVERRIDE {
time_view_->SetBoundsRect(gfx::Rect(time_view_->GetPreferredSize()));
gfx::Size status_icon_preferred_size =
status_icon_view_->GetPreferredSize();
status_icon_view_->SetBoundsRect(
gfx::Rect(width() - status_icon_preferred_size.width(),
0,
status_icon_preferred_size.width(),
status_icon_preferred_size.height()));
}
virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE {
// Relayout to take into account changes in |status_icon_view_|'s width.
// Assume that |time_view_|'s and |status_icon_view_|'s preferred height
// does not change.
Layout();
}
private:
views::View* time_view_;
views::View* status_icon_view_;
DISALLOW_COPY_AND_ASSIGN(SystemInfoView);
};
class SystemUIImpl : public SystemUI { class SystemUIImpl : public SystemUI {
public: public:
SystemUIImpl(scoped_refptr<base::TaskRunner> file_task_runner) SystemUIImpl(scoped_refptr<base::TaskRunner> file_task_runner)
...@@ -58,12 +108,8 @@ class SystemUIImpl : public SystemUI { ...@@ -58,12 +108,8 @@ class SystemUIImpl : public SystemUI {
background_controller_->SetImage(image); background_controller_->SetImage(image);
} }
virtual views::View* CreateTimeView() OVERRIDE { virtual views::View* CreateSystemInfoView(ColorScheme color_scheme) OVERRIDE {
return new TimeView; return new SystemInfoView(color_scheme, system_modal_container_);
}
virtual views::View* CreateStatusIconView() OVERRIDE {
return new StatusIconContainerView(system_modal_container_);
} }
private: private:
......
...@@ -17,11 +17,14 @@ const int kTimerSlopSeconds = 1; ...@@ -17,11 +17,14 @@ const int kTimerSlopSeconds = 1;
} // namespace } // namespace
TimeView::TimeView() { TimeView::TimeView(SystemUI::ColorScheme color_scheme) {
SetHorizontalAlignment(gfx::ALIGN_LEFT); SetHorizontalAlignment(gfx::ALIGN_LEFT);
SetEnabledColor(SK_ColorWHITE); SetEnabledColor((color_scheme == SystemUI::COLOR_SCHEME_LIGHT)
? SK_ColorWHITE
: SK_ColorDKGRAY);
SetAutoColorReadabilityEnabled(false); SetAutoColorReadabilityEnabled(false);
SetFontList(gfx::FontList().DeriveWithStyle(gfx::Font::BOLD)); SetFontList(gfx::FontList().DeriveWithStyle(gfx::Font::BOLD));
SetSubpixelRenderingEnabled(false);
const int kHorizontalSpacing = 10; const int kHorizontalSpacing = 10;
const int kVerticalSpacing = 3; const int kVerticalSpacing = 3;
......
...@@ -15,7 +15,7 @@ namespace athena { ...@@ -15,7 +15,7 @@ namespace athena {
// View which displays the current time. // View which displays the current time.
class TimeView : public views::Label { class TimeView : public views::Label {
public: public:
TimeView(); explicit TimeView(SystemUI::ColorScheme color_scheme);
virtual ~TimeView(); virtual ~TimeView();
private: private:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment