Commit 73bd924d authored by pkotwicz's avatar pkotwicz Committed by Commit bot

[Athena] Add status icons and system time to the desktop background

BUG=404156
TEST=Manual, see bug
TBR=sadrul, oshima (TBRing because of DEPS file modifications)

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

Cr-Commit-Position: refs/heads/master@{#292895}
parent 04ecdba1
...@@ -11,7 +11,11 @@ ...@@ -11,7 +11,11 @@
'target_name': 'athena_lib', 'target_name': 'athena_lib',
'type': '<(component)', 'type': '<(component)',
'dependencies': [ 'dependencies': [
# status_icon_container_view.cc depends on this. Remove this once there
# are athena specific assets.
'../ash/ash_resources.gyp:ash_resources',
'../base/base.gyp:test_support_base', '../base/base.gyp:test_support_base',
'../chromeos/chromeos.gyp:power_manager_proto',
'../extensions/shell/app_shell.gyp:app_shell_version_header', '../extensions/shell/app_shell.gyp:app_shell_version_header',
'../ipc/ipc.gyp:ipc', '../ipc/ipc.gyp:ipc',
'../skia/skia.gyp:skia', '../skia/skia.gyp:skia',
...@@ -71,19 +75,25 @@ ...@@ -71,19 +75,25 @@
'input/input_manager_impl.cc', 'input/input_manager_impl.cc',
'input/public/accelerator_manager.h', 'input/public/accelerator_manager.h',
'input/public/input_manager.h', 'input/public/input_manager.h',
'screen/background_controller.cc',
'screen/background_controller.h',
'screen/public/screen_manager.h', 'screen/public/screen_manager.h',
'screen/screen_accelerator_handler.cc', 'screen/screen_accelerator_handler.cc',
'screen/screen_accelerator_handler.h', 'screen/screen_accelerator_handler.h',
'screen/screen_manager_impl.cc', 'screen/screen_manager_impl.cc',
'system/background_controller.cc',
'system/background_controller.h',
'system/device_socket_listener.cc', 'system/device_socket_listener.cc',
'system/device_socket_listener.h', 'system/device_socket_listener.h',
'system/network_selector.cc',
'system/network_selector.h',
'system/orientation_controller.cc', 'system/orientation_controller.cc',
'system/orientation_controller.h', 'system/orientation_controller.h',
'system/power_button_controller.cc', 'system/power_button_controller.cc',
'system/power_button_controller.h', 'system/power_button_controller.h',
'system/public/system_ui.h', 'system/status_icon_container_view.cc',
'system/status_icon_container_view.h',
'system/time_view.cc',
'system/time_view.h',
'system/public/system_ui.h',
'system/system_ui_impl.cc', 'system/system_ui_impl.cc',
'wm/bezel_controller.cc', 'wm/bezel_controller.cc',
'wm/bezel_controller.h', 'wm/bezel_controller.h',
......
...@@ -11,7 +11,7 @@ enum ContainerPriorities { ...@@ -11,7 +11,7 @@ enum ContainerPriorities {
CP_BACKGROUND = 0, CP_BACKGROUND = 0,
CP_DEFAULT, CP_DEFAULT,
CP_HOME_CARD, CP_HOME_CARD,
CP_DEBUG, CP_SYSTEM_MODAL,
CP_VIRTUAL_KEYBOARD, CP_VIRTUAL_KEYBOARD,
}; };
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "athena/extensions/public/extensions_delegate.h" #include "athena/extensions/public/extensions_delegate.h"
#include "athena/home/public/home_card.h" #include "athena/home/public/home_card.h"
#include "athena/input/public/input_manager.h" #include "athena/input/public/input_manager.h"
#include "athena/main/debug/debug_window.h"
#include "athena/main/placeholder.h" #include "athena/main/placeholder.h"
#include "athena/main/placeholder.h" #include "athena/main/placeholder.h"
#include "athena/main/url_search_provider.h" #include "athena/main/url_search_provider.h"
...@@ -119,9 +118,9 @@ void StartAthenaEnv(scoped_refptr<base::TaskRunner> file_runner) { ...@@ -119,9 +118,9 @@ void StartAthenaEnv(scoped_refptr<base::TaskRunner> file_runner) {
aura::client::SetVisibilityClient(root_window, aura::client::SetVisibilityClient(root_window,
env_state->visibility_client.get()); env_state->visibility_client.get());
athena::SystemUI::Create(file_runner);
athena::InputManager::Create()->OnRootWindowCreated(root_window); athena::InputManager::Create()->OnRootWindowCreated(root_window);
athena::ScreenManager::Create(root_window); athena::ScreenManager::Create(root_window);
athena::SystemUI::Create(file_runner);
athena::WindowManager::Create(); athena::WindowManager::Create();
athena::AppRegistry::Create(); athena::AppRegistry::Create();
SetupBackgroundImage(); SetupBackgroundImage();
...@@ -142,7 +141,6 @@ void StartAthenaSessionWithContext(content::BrowserContext* context) { ...@@ -142,7 +141,6 @@ void StartAthenaSessionWithContext(content::BrowserContext* context) {
env_state->virtual_keyboard_observer.reset(new VirtualKeyboardObserver); env_state->virtual_keyboard_observer.reset(new VirtualKeyboardObserver);
CreateTestPages(context); CreateTestPages(context);
CreateDebugWindow();
} }
void StartAthenaSession(athena::ActivityFactory* activity_factory, void StartAthenaSession(athena::ActivityFactory* activity_factory,
...@@ -160,9 +158,9 @@ void ShutdownAthena() { ...@@ -160,9 +158,9 @@ void ShutdownAthena() {
athena::HomeCard::Shutdown(); athena::HomeCard::Shutdown();
athena::AppRegistry::ShutDown(); athena::AppRegistry::ShutDown();
athena::WindowManager::Shutdown(); athena::WindowManager::Shutdown();
athena::SystemUI::Shutdown();
athena::ScreenManager::Shutdown(); athena::ScreenManager::Shutdown();
athena::InputManager::Shutdown(); athena::InputManager::Shutdown();
athena::SystemUI::Shutdown();
athena::ExtensionsDelegate::Shutdown(); athena::ExtensionsDelegate::Shutdown();
athena::AthenaEnv::Shutdown(); athena::AthenaEnv::Shutdown();
......
...@@ -14,10 +14,6 @@ ...@@ -14,10 +14,6 @@
'../athena.gyp:athena_lib', '../athena.gyp:athena_lib',
'../athena.gyp:athena_content_lib', '../athena.gyp:athena_content_lib',
'../resources/athena_resources.gyp:athena_resources', '../resources/athena_resources.gyp:athena_resources',
# debug_widow.cc depends on this. Remove this once debug_window
# is removed.
'../../ash/ash_resources.gyp:ash_resources',
'../../chromeos/chromeos.gyp:power_manager_proto',
'../../components/components.gyp:component_metrics_proto', '../../components/components.gyp:component_metrics_proto',
'../../components/components.gyp:history_core_browser', '../../components/components.gyp:history_core_browser',
# infobars_test_support is required to declare some symbols used in the # infobars_test_support is required to declare some symbols used in the
...@@ -45,10 +41,6 @@ ...@@ -45,10 +41,6 @@
'athena_launcher.h', 'athena_launcher.h',
'athena_renderer_pdf_helper.cc', 'athena_renderer_pdf_helper.cc',
'athena_renderer_pdf_helper.h', 'athena_renderer_pdf_helper.h',
'debug/debug_window.cc',
'debug/debug_window.h',
'debug/network_selector.cc',
'debug/network_selector.h',
'url_search_provider.cc', 'url_search_provider.cc',
'url_search_provider.h', 'url_search_provider.h',
'placeholder.cc', 'placeholder.cc',
......
include_rules = [
"+athena/resources",
"+chromeos",
"+third_party/cros_system_api/dbus/service_constants.h",
"+ui/aura",
"+ui/chromeos",
"+ui/gfx",
"+ui/views",
]
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATHENA_MAIN_DEBUG_DEBUG_WINDOW_H_
#define ATHENA_MAIN_DEBUG_DEBUG_WINDOW_H_
void CreateDebugWindow();
#endif // ATHENA_MAIN_DEBUG_DEBUG_WINDOW_H_
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "athena/activity/public/activity_factory.h" #include "athena/activity/public/activity_factory.h"
#include "athena/activity/public/activity_manager.h" #include "athena/activity/public/activity_manager.h"
#include "athena/resources/grit/athena_resources.h" #include "athena/resources/grit/athena_resources.h"
#include "athena/screen/public/screen_manager.h" #include "athena/system/public/system_ui.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/image/image_skia.h" #include "ui/gfx/image/image_skia.h"
...@@ -26,5 +26,5 @@ void CreateTestPages(content::BrowserContext* browser_context) { ...@@ -26,5 +26,5 @@ void CreateTestPages(content::BrowserContext* browser_context) {
void SetupBackgroundImage() { void SetupBackgroundImage() {
const gfx::ImageSkia wallpaper = *ui::ResourceBundle::GetSharedInstance() const gfx::ImageSkia wallpaper = *ui::ResourceBundle::GetSharedInstance()
.GetImageSkiaNamed(IDR_ATHENA_BACKGROUND); .GetImageSkiaNamed(IDR_ATHENA_BACKGROUND);
athena::ScreenManager::Get()->SetBackgroundImage(wallpaper); athena::SystemUI::Get()->SetBackgroundImage(wallpaper);
} }
include_rules = [ include_rules = [
"+athena/input/public", "+athena/input/public",
"+third_party/skia/include/core/SkColor.h",
"+ui/aura", "+ui/aura",
"+ui/compositor", "+ui/compositor",
"+ui/events", "+ui/events",
"+ui/gfx", "+ui/gfx",
"+ui/views",
"+ui/wm", "+ui/wm",
] ]
specific_include_rules = {
"background_controller.cc": [
"+extensions/shell/common/version.h",
],
}
...@@ -14,11 +14,6 @@ namespace aura { ...@@ -14,11 +14,6 @@ namespace aura {
class Window; class Window;
} }
namespace gfx {
class ImageSkia;
class Insets;
}
namespace ui { namespace ui {
class LayerAnimator; class LayerAnimator;
} }
...@@ -68,9 +63,6 @@ class ATHENA_EXPORT ScreenManager { ...@@ -68,9 +63,6 @@ class ATHENA_EXPORT ScreenManager {
// Return the context object to be used for widget creation. // Return the context object to be used for widget creation.
virtual aura::Window* GetContext() = 0; virtual aura::Window* GetContext() = 0;
// Sets the background image.
virtual void SetBackgroundImage(const gfx::ImageSkia& image) = 0;
// Set screen rotation. // Set screen rotation.
// TODO(flackr): Extract and use ash DisplayManager to set rotation // TODO(flackr): Extract and use ash DisplayManager to set rotation
// instead: http://crbug.com/401044. // instead: http://crbug.com/401044.
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include "athena/common/container_priorities.h" #include "athena/common/container_priorities.h"
#include "athena/common/fill_layout_manager.h" #include "athena/common/fill_layout_manager.h"
#include "athena/input/public/accelerator_manager.h" #include "athena/input/public/accelerator_manager.h"
#include "athena/screen/background_controller.h"
#include "athena/screen/screen_accelerator_handler.h" #include "athena/screen/screen_accelerator_handler.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
...@@ -192,7 +191,7 @@ class AthenaEventTargeter : public aura::WindowTargeter, ...@@ -192,7 +191,7 @@ class AthenaEventTargeter : public aura::WindowTargeter,
class ScreenManagerImpl : public ScreenManager { class ScreenManagerImpl : public ScreenManager {
public: public:
ScreenManagerImpl(aura::Window* root_window); explicit ScreenManagerImpl(aura::Window* root_window);
virtual ~ScreenManagerImpl(); virtual ~ScreenManagerImpl();
void Init(); void Init();
...@@ -203,16 +202,13 @@ class ScreenManagerImpl : public ScreenManager { ...@@ -203,16 +202,13 @@ class ScreenManagerImpl : public ScreenManager {
const ContainerParams& params) OVERRIDE; const ContainerParams& params) OVERRIDE;
virtual aura::Window* CreateContainer(const ContainerParams& params) OVERRIDE; virtual aura::Window* CreateContainer(const ContainerParams& params) OVERRIDE;
virtual aura::Window* GetContext() OVERRIDE { return root_window_; } virtual aura::Window* GetContext() OVERRIDE { return root_window_; }
virtual void SetBackgroundImage(const gfx::ImageSkia& image) OVERRIDE;
virtual void SetRotation(gfx::Display::Rotation rotation) OVERRIDE; virtual void SetRotation(gfx::Display::Rotation rotation) OVERRIDE;
virtual ui::LayerAnimator* GetScreenAnimator() OVERRIDE; virtual ui::LayerAnimator* GetScreenAnimator() OVERRIDE;
// Not owned. // Not owned.
aura::Window* root_window_; aura::Window* root_window_;
aura::Window* background_window_;
scoped_ptr<aura::client::FocusClient> focus_client_; scoped_ptr<aura::client::FocusClient> focus_client_;
scoped_ptr<BackgroundController> background_controller_;
scoped_ptr<aura::client::WindowTreeClient> window_tree_client_; scoped_ptr<aura::client::WindowTreeClient> window_tree_client_;
scoped_ptr<AcceleratorHandler> accelerator_handler_; scoped_ptr<AcceleratorHandler> accelerator_handler_;
scoped_ptr< ::wm::ScopedCaptureClient> capture_client_; scoped_ptr< ::wm::ScopedCaptureClient> capture_client_;
...@@ -248,15 +244,7 @@ void ScreenManagerImpl::Init() { ...@@ -248,15 +244,7 @@ void ScreenManagerImpl::Init() {
aura::client::SetActivationClient(root_window_, focus_controller); aura::client::SetActivationClient(root_window_, focus_controller);
focus_client_.reset(focus_controller); focus_client_.reset(focus_controller);
// TODO(oshima): Move the background out from ScreenManager.
root_window_->SetLayoutManager(new FillLayoutManager(root_window_)); root_window_->SetLayoutManager(new FillLayoutManager(root_window_));
background_window_ =
CreateContainer(ContainerParams("AthenaBackground", CP_BACKGROUND));
background_window_->SetLayoutManager(
new FillLayoutManager(background_window_));
background_controller_.reset(new BackgroundController(background_window_));
capture_client_.reset(new ::wm::ScopedCaptureClient(root_window_)); capture_client_.reset(new ::wm::ScopedCaptureClient(root_window_));
accelerator_handler_.reset(new ScreenAcceleratorHandler(root_window_)); accelerator_handler_.reset(new ScreenAcceleratorHandler(root_window_));
} }
...@@ -340,10 +328,6 @@ aura::Window* ScreenManagerImpl::CreateContainer( ...@@ -340,10 +328,6 @@ aura::Window* ScreenManagerImpl::CreateContainer(
return container; return container;
} }
void ScreenManagerImpl::SetBackgroundImage(const gfx::ImageSkia& image) {
background_controller_->SetImage(image);
}
void ScreenManagerImpl::SetRotation(gfx::Display::Rotation rotation) { void ScreenManagerImpl::SetRotation(gfx::Display::Rotation rotation) {
if (rotation == if (rotation ==
gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().rotation()) { gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().rotation()) {
......
include_rules = [ include_rules = [
"+athena/resources",
"+athena/screen/public", "+athena/screen/public",
"+athena/system/public", "+athena/system/public",
"+chromeos/dbus", "+chromeos",
"+third_party/cros_system_api/dbus/service_constants.h",
"+third_party/skia/include",
"+ui", "+ui",
] ]
specific_include_rules = {
"status_icon_container_view.cc": [
"+extensions/shell/common/version.h",
],
}
...@@ -2,55 +2,25 @@ ...@@ -2,55 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "athena/screen/background_controller.h" #include "athena/system/background_controller.h"
#include "base/strings/stringprintf.h" #include "athena/system/public/system_ui.h"
#include "base/strings/utf_string_conversions.h"
#include "extensions/shell/common/version.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/compositor/layer.h" #include "ui/compositor/layer.h"
#include "ui/gfx/canvas.h" #include "ui/gfx/canvas.h"
#include "ui/gfx/image/image_skia.h" #include "ui/gfx/image/image_skia.h"
#include "ui/views/controls/label.h"
#include "ui/views/view.h" #include "ui/views/view.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
namespace athena { namespace athena {
namespace {
const SkColor kVersionColor = SK_ColorWHITE;
const SkColor kVersionBackground = SK_ColorTRANSPARENT;
const SkColor kVersionShadow = 0xB0000000;
const int kVersionShadowBlur = 10;
class VersionView : public views::Label {
public:
VersionView() {
SetEnabledColor(kVersionColor);
SetBackgroundColor(kVersionBackground);
SetShadows(gfx::ShadowValues(1, gfx::ShadowValue(gfx::Point(0, 1),
kVersionShadowBlur,
kVersionShadow)));
SetText(base::UTF8ToUTF16(base::StringPrintf("%s (Build %s)",
PRODUCT_VERSION,
LAST_CHANGE)));
SetBoundsRect(gfx::Rect(gfx::Point(), GetPreferredSize()));
}
virtual ~VersionView() {
}
private:
DISALLOW_COPY_AND_ASSIGN(VersionView);
};
} // namespace
class BackgroundView : public views::View { class BackgroundView : public views::View {
public: public:
BackgroundView() { BackgroundView()
AddChildView(new VersionView); : time_view_(SystemUI::Get()->CreateTimeView()),
status_icon_view_(SystemUI::Get()->CreateStatusIconView()) {
AddChildView(time_view_);
AddChildView(status_icon_view_);
} }
virtual ~BackgroundView() {} virtual ~BackgroundView() {}
...@@ -59,7 +29,22 @@ class BackgroundView : public views::View { ...@@ -59,7 +29,22 @@ class BackgroundView : public views::View {
SchedulePaint(); SchedulePaint();
} }
// views::View // views::View:
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_->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 {
canvas->DrawImageInt(image_, canvas->DrawImageInt(image_,
0, 0,
...@@ -75,20 +60,17 @@ class BackgroundView : public views::View { ...@@ -75,20 +60,17 @@ class BackgroundView : public views::View {
private: private:
gfx::ImageSkia image_; gfx::ImageSkia image_;
views::View* time_view_;
views::View* status_icon_view_;
DISALLOW_COPY_AND_ASSIGN(BackgroundView); DISALLOW_COPY_AND_ASSIGN(BackgroundView);
}; };
BackgroundController::BackgroundController(aura::Window* container) { BackgroundController::BackgroundController(aura::Window* background_container) {
// TODO(oshima): Using widget to just draw an image is probably
// overkill. Just use WindowDelegate to draw the background and
// remove dependency to ui/views.
views::Widget* background_widget = new views::Widget; views::Widget* background_widget = new views::Widget;
views::Widget::InitParams params( views::Widget::InitParams params(
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
params.accept_events = false; params.parent = background_container;
params.parent = container;
background_widget->Init(params); background_widget->Init(params);
background_widget->GetNativeWindow()->layer()->SetMasksToBounds(true); background_widget->GetNativeWindow()->layer()->SetMasksToBounds(true);
background_view_ = new BackgroundView; background_view_ = new BackgroundView;
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef ATHENA_SCREEN_BACKGROUND_CONTROLLER_H_ #ifndef ATHENA_SYSTEM_BACKGROUND_CONTROLLER_H_
#define ATHENA_SCREEN_BACKGROUND_CONTROLLER_H_ #define ATHENA_SYSTEM_BACKGROUND_CONTROLLER_H_
#include "base/macros.h" #include "base/macros.h"
...@@ -21,7 +21,7 @@ class BackgroundView; ...@@ -21,7 +21,7 @@ class BackgroundView;
// Controls background image switching. // Controls background image switching.
class BackgroundController { class BackgroundController {
public: public:
explicit BackgroundController(aura::Window* container); explicit BackgroundController(aura::Window* background_container);
~BackgroundController(); ~BackgroundController();
void SetImage(const gfx::ImageSkia& image); void SetImage(const gfx::ImageSkia& image);
...@@ -31,6 +31,7 @@ class BackgroundController { ...@@ -31,6 +31,7 @@ class BackgroundController {
DISALLOW_COPY_AND_ASSIGN(BackgroundController); DISALLOW_COPY_AND_ASSIGN(BackgroundController);
}; };
}
#endif // ATHENA_SCREEN_BACKGROUND_CONTROLLER_H_ } // namespace athena
#endif // ATHENA_SYSTEM_BACKGROUND_CONTROLLER_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "athena/main/debug/network_selector.h" #include "athena/system/network_selector.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
...@@ -460,10 +460,10 @@ class NetworkSelector : public ui::NetworkListDelegate, ...@@ -460,10 +460,10 @@ class NetworkSelector : public ui::NetworkListDelegate,
} // namespace } // namespace
namespace debug { namespace athena {
void CreateNetworkSelector(aura::Window* container) { void CreateNetworkSelector(aura::Window* container) {
new NetworkSelector(container); new NetworkSelector(container);
} }
} // namespace debug } // namespace athena
...@@ -2,17 +2,17 @@ ...@@ -2,17 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef ATHENA_MAIN_DEBUG_NETWORK_SELECTOR_H_ #ifndef ATHENA_SYSTEM_NETWORK_SELECTOR_H_
#define ATHENA_MAIN_DEBUG_NETWORK_SELECTOR_H_ #define ATHENA_SYSTEM_NETWORK_SELECTOR_H_
namespace aura { namespace aura {
class Window; class Window;
} }
namespace debug { namespace athena {
void CreateNetworkSelector(aura::Window* window); void CreateNetworkSelector(aura::Window* window);
} // namespace debug } // namespace athena
#endif // ATHENA_MAIN_DEBUG_NETWORK_SELECTOR_H_ #endif // ATHENA_SYSTEM_NETWORK_SELECTOR_H_
...@@ -12,15 +12,33 @@ namespace base { ...@@ -12,15 +12,33 @@ namespace base {
class TaskRunner; class TaskRunner;
} }
namespace gfx {
class ImageSkia;
}
namespace views {
class View;
}
namespace athena { namespace athena {
class ATHENA_EXPORT SystemUI { class ATHENA_EXPORT SystemUI {
public: public:
// 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 void Shutdown(); static void Shutdown();
virtual ~SystemUI() {} virtual ~SystemUI() {}
// Sets the background image.
virtual void SetBackgroundImage(const gfx::ImageSkia& image) = 0;
// Creates a view which displays the time.
virtual views::View* CreateTimeView() = 0;
// Creates a view which displays status icons and debug information.
virtual views::View* CreateStatusIconView() = 0;
}; };
} // namespace athena } // namespace athena
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATHENA_SYSTEM_STATUS_ICON_CONTAINER_VIEW_H_
#define ATHENA_SYSTEM_STATUS_ICON_CONTAINER_VIEW_H_
#include "athena/system/public/system_ui.h"
#include "base/memory/scoped_ptr.h"
#include "ui/views/view.h"
namespace aura {
class Window;
}
namespace athena {
// View which displays the system tray icons.
class StatusIconContainerView : public views::View {
public:
explicit StatusIconContainerView(aura::Window* system_modal_container);
virtual ~StatusIconContainerView();
private:
// views::View:
virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE;
// Parent container that the "select network" dialog should use.
aura::Window* system_modal_container_;
class PowerStatus;
scoped_ptr<PowerStatus> power_status_;
class NetworkStatus;
scoped_ptr<NetworkStatus> network_status_;
class UpdateStatus;
scoped_ptr<UpdateStatus> update_status_;
DISALLOW_COPY_AND_ASSIGN(StatusIconContainerView);
};
} // namespace athena
#endif // ATHENA_SYSTEM_STATUS_ICON_CONTAINER_VIEW_H_
...@@ -4,12 +4,19 @@ ...@@ -4,12 +4,19 @@
#include "athena/system/public/system_ui.h" #include "athena/system/public/system_ui.h"
#include "athena/common/container_priorities.h"
#include "athena/common/fill_layout_manager.h"
#include "athena/screen/public/screen_manager.h"
#include "athena/system/background_controller.h"
#include "athena/system/device_socket_listener.h" #include "athena/system/device_socket_listener.h"
#include "athena/system/orientation_controller.h" #include "athena/system/orientation_controller.h"
#include "athena/system/power_button_controller.h" #include "athena/system/power_button_controller.h"
#include "athena/system/status_icon_container_view.h"
#include "athena/system/time_view.h"
#include "base/logging.h" #include "base/logging.h"
#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"
namespace athena { namespace athena {
namespace { namespace {
...@@ -20,7 +27,9 @@ class SystemUIImpl : public SystemUI { ...@@ -20,7 +27,9 @@ class SystemUIImpl : public SystemUI {
public: public:
SystemUIImpl(scoped_refptr<base::TaskRunner> file_task_runner) SystemUIImpl(scoped_refptr<base::TaskRunner> file_task_runner)
: orientation_controller_(new OrientationController()), : orientation_controller_(new OrientationController()),
power_button_controller_(new PowerButtonController) { power_button_controller_(new PowerButtonController),
background_container_(NULL),
system_modal_container_(NULL) {
orientation_controller_->InitWith(file_task_runner); orientation_controller_->InitWith(file_task_runner);
} }
...@@ -30,9 +39,43 @@ class SystemUIImpl : public SystemUI { ...@@ -30,9 +39,43 @@ class SystemUIImpl : public SystemUI {
orientation_controller_->Shutdown(); orientation_controller_->Shutdown();
} }
void Init() {
background_container_ = ScreenManager::Get()->CreateContainer(
ScreenManager::ContainerParams("AthenaBackground", CP_BACKGROUND));
background_container_->SetLayoutManager(
new FillLayoutManager(background_container_));
ScreenManager::ContainerParams system_modal_params(
"AthenaSystemModalContainer", CP_SYSTEM_MODAL);
system_modal_params.can_activate_children = true;
system_modal_container_ =
ScreenManager::Get()->CreateContainer(system_modal_params);
background_controller_.reset(
new BackgroundController(background_container_));
}
virtual void SetBackgroundImage(const gfx::ImageSkia& image) OVERRIDE {
background_controller_->SetImage(image);
}
virtual views::View* CreateTimeView() OVERRIDE {
return new TimeView;
}
virtual views::View* CreateStatusIconView() OVERRIDE {
return new StatusIconContainerView(system_modal_container_);
}
private: private:
scoped_refptr<OrientationController> orientation_controller_; scoped_refptr<OrientationController> orientation_controller_;
scoped_ptr<PowerButtonController> power_button_controller_; scoped_ptr<PowerButtonController> power_button_controller_;
scoped_ptr<BackgroundController> background_controller_;
// The parent container for the background.
aura::Window* background_container_;
// The parent container used by the "select network" dialog.
aura::Window* system_modal_container_;
DISALLOW_COPY_AND_ASSIGN(SystemUIImpl); DISALLOW_COPY_AND_ASSIGN(SystemUIImpl);
}; };
...@@ -42,7 +85,15 @@ class SystemUIImpl : public SystemUI { ...@@ -42,7 +85,15 @@ class SystemUIImpl : public SystemUI {
// static // static
SystemUI* SystemUI::Create(scoped_refptr<base::TaskRunner> file_task_runner) { SystemUI* SystemUI::Create(scoped_refptr<base::TaskRunner> file_task_runner) {
DeviceSocketListener::CreateSocketManager(file_task_runner); DeviceSocketListener::CreateSocketManager(file_task_runner);
instance = new SystemUIImpl(file_task_runner); SystemUIImpl* system_ui = new SystemUIImpl(file_task_runner);
instance = system_ui;
system_ui->Init();
return instance;
}
// static
SystemUI* SystemUI::Get() {
DCHECK(instance);
return instance; return instance;
} }
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "athena/system/time_view.h"
#include "base/i18n/time_formatting.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/views/border.h"
namespace athena {
namespace {
// Amount of slop to add into the timer to make sure we're into the next minute
// when the timer goes off.
const int kTimerSlopSeconds = 1;
} // namespace
TimeView::TimeView() {
SetHorizontalAlignment(gfx::ALIGN_LEFT);
SetEnabledColor(SK_ColorWHITE);
SetAutoColorReadabilityEnabled(false);
SetFontList(gfx::FontList().DeriveWithStyle(gfx::Font::BOLD));
const int kHorizontalSpacing = 10;
const int kVerticalSpacing = 3;
SetBorder(views::Border::CreateEmptyBorder(kVerticalSpacing,
kHorizontalSpacing,
kVerticalSpacing,
kHorizontalSpacing));
UpdateText();
}
TimeView::~TimeView() {
}
void TimeView::SetTimer(base::Time now) {
// Try to set the timer to go off at the next change of the minute. We don't
// want to have the timer go off more than necessary since that will cause
// the CPU to wake up and consume power.
base::Time::Exploded exploded;
now.LocalExplode(&exploded);
// Often this will be called at minute boundaries, and we'll actually want
// 60 seconds from now.
int seconds_left = 60 - exploded.second;
if (seconds_left == 0)
seconds_left = 60;
// Make sure that the timer fires on the next minute. Without this, if it is
// called just a teeny bit early, then it will skip the next minute.
seconds_left += kTimerSlopSeconds;
timer_.Stop();
timer_.Start(
FROM_HERE, base::TimeDelta::FromSeconds(seconds_left),
this, &TimeView::UpdateText);
}
void TimeView::UpdateText() {
base::Time now = base::Time::Now();
SetText(base::TimeFormatTimeOfDayWithHourClockType(
now, base::k12HourClock, base::kKeepAmPm));
SetTimer(now);
}
} // namespace athena
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATHENA_SYSTEM_TIME_VIEW_H_
#define ATHENA_SYSTEM_TIME_VIEW_H_
#include "athena/system/public/system_ui.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "ui/views/controls/label.h"
namespace athena {
// View which displays the current time.
class TimeView : public views::Label {
public:
TimeView();
virtual ~TimeView();
private:
// Starts |timer_| to schedule the next update.
void SetTimer(base::Time now);
// Updates the current time.
void UpdateText();
base::OneShotTimer<TimeView> timer_;
DISALLOW_COPY_AND_ASSIGN(TimeView);
};
} // namespace athena
#endif // ATHENA_SYSTEM_TIME_VIEW_H_
...@@ -7,7 +7,7 @@ include_rules = [ ...@@ -7,7 +7,7 @@ include_rules = [
"+athena/screen/public", "+athena/screen/public",
"+athena/main", "+athena/main",
"+athena/resource_manager/public", "+athena/resource_manager/public",
"+chromeos/dbus", "+chromeos",
"+third_party/skia/include", "+third_party/skia/include",
"+ui/app_list", "+ui/app_list",
"+ui/aura", "+ui/aura",
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/threading/thread.h" #include "base/threading/thread.h"
#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/network/network_handler.h"
#include "ui/aura/env.h" #include "ui/aura/env.h"
#include "ui/aura/input_state_lookup.h" #include "ui/aura/input_state_lookup.h"
#include "ui/aura/test/env_test_helper.h" #include "ui/aura/test/env_test_helper.h"
...@@ -49,6 +50,7 @@ void AthenaTestHelper::SetUp(ui::ContextFactory* context_factory) { ...@@ -49,6 +50,7 @@ void AthenaTestHelper::SetUp(ui::ContextFactory* context_factory) {
file_thread_->StartWithOptions(options); file_thread_->StartWithOptions(options);
chromeos::DBusThreadManager::Initialize(); chromeos::DBusThreadManager::Initialize();
chromeos::NetworkHandler::Initialize();
ui::InitializeInputMethodForTesting(); ui::InitializeInputMethodForTesting();
aura::Env::CreateInstance(true); aura::Env::CreateInstance(true);
aura::Env::GetInstance()->set_context_factory(context_factory); aura::Env::GetInstance()->set_context_factory(context_factory);
...@@ -75,6 +77,7 @@ void AthenaTestHelper::TearDown() { ...@@ -75,6 +77,7 @@ void AthenaTestHelper::TearDown() {
#endif #endif
ui::ShutdownInputMethodForTesting(); ui::ShutdownInputMethodForTesting();
chromeos::NetworkHandler::Shutdown();
chromeos::DBusThreadManager::Shutdown(); chromeos::DBusThreadManager::Shutdown();
} }
......
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