OLD | NEW |
(Empty) | |
| 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 #include "ash/wm/workspace/system_background_controller.h" |
| 6 |
| 7 #include "ash/shell_window_ids.h" |
| 8 #include "ui/aura/root_window.h" |
| 9 #include "ui/gfx/canvas.h" |
| 10 #include "ui/views/widget/widget.h" |
| 11 #include "ui/views/widget/widget_delegate.h" |
| 12 |
| 13 namespace ash { |
| 14 namespace internal { |
| 15 |
| 16 // View implementation responsible for rendering the background. |
| 17 class SystemBackgroundController::View : public views::WidgetDelegateView { |
| 18 public: |
| 19 explicit View(SystemBackgroundController* controller); |
| 20 virtual ~View(); |
| 21 |
| 22 // Closes the hosting widget. |
| 23 void Close(); |
| 24 |
| 25 // WidgetDelegate overrides: |
| 26 virtual views::View* GetContentsView() OVERRIDE; |
| 27 |
| 28 // View overrides: |
| 29 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
| 30 |
| 31 private: |
| 32 SystemBackgroundController* controller_; |
| 33 |
| 34 DISALLOW_COPY_AND_ASSIGN(View); |
| 35 }; |
| 36 |
| 37 SystemBackgroundController::View::View(SystemBackgroundController* controller) |
| 38 : controller_(controller) { |
| 39 } |
| 40 |
| 41 SystemBackgroundController::View::~View() { |
| 42 if (controller_) |
| 43 controller_->view_ = NULL; |
| 44 } |
| 45 |
| 46 void SystemBackgroundController::View::Close() { |
| 47 controller_ = NULL; |
| 48 GetWidget()->Close(); |
| 49 } |
| 50 |
| 51 views::View* SystemBackgroundController::View::GetContentsView() { |
| 52 return this; |
| 53 } |
| 54 |
| 55 void SystemBackgroundController::View::OnPaint(gfx::Canvas* canvas) { |
| 56 // TODO: get image! |
| 57 canvas->DrawColor(SK_ColorRED); |
| 58 } |
| 59 |
| 60 SystemBackgroundController::SystemBackgroundController(aura::RootWindow* root) |
| 61 : ALLOW_THIS_IN_INITIALIZER_LIST(view_(new View(this))) { |
| 62 views::Widget* widget = new views::Widget; |
| 63 views::Widget::InitParams params( |
| 64 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
| 65 params.delegate = view_; |
| 66 params.parent = root->GetChildById(kShellWindowId_SystemBackgroundContainer); |
| 67 widget->Init(params); |
| 68 widget->SetBounds(params.parent->bounds()); |
| 69 widget->Show(); |
| 70 widget->GetNativeView()->SetName("SystemBackground"); |
| 71 } |
| 72 |
| 73 SystemBackgroundController::~SystemBackgroundController() { |
| 74 if (view_) |
| 75 view_->Close(); |
| 76 } |
| 77 |
| 78 } // namespace internal |
| 79 } // namespace ash |
OLD | NEW |