| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/launcher/launcher.h" | 5 #include "ash/launcher/launcher.h" |
| 6 | 6 |
| 7 #include "ash/launcher/launcher_model.h" | 7 #include "ash/launcher/launcher_model.h" |
| 8 #include "ash/launcher/launcher_view.h" | 8 #include "ash/launcher/launcher_view.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_delegate.h" | 10 #include "ash/shell_delegate.h" |
| 11 #include "ash/shell_window_ids.h" | 11 #include "ash/shell_window_ids.h" |
| 12 #include "grit/ui_resources.h" | 12 #include "grit/ui_resources.h" |
| 13 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
| 14 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
| 15 #include "ui/gfx/canvas.h" | 15 #include "ui/gfx/canvas.h" |
| 16 #include "ui/gfx/compositor/layer.h" | 16 #include "ui/gfx/compositor/layer.h" |
| 17 #include "ui/gfx/image/image.h" | 17 #include "ui/gfx/image/image.h" |
| 18 #include "ui/views/accessible_pane_view.h" |
| 18 #include "ui/views/painter.h" | 19 #include "ui/views/painter.h" |
| 19 #include "ui/views/widget/widget.h" | 20 #include "ui/views/widget/widget.h" |
| 20 | 21 |
| 21 namespace ash { | 22 namespace ash { |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 // Used to draw the background of the shelf. | 26 // Used to draw the background of the shelf. |
| 26 class ShelfPainter : public views::Painter { | 27 class ShelfPainter : public views::Painter { |
| 27 public: | 28 public: |
| 28 ShelfPainter() { | 29 ShelfPainter() { |
| 29 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 30 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 30 image_ = *rb.GetImageNamed(IDR_AURA_LAUNCHER_BACKGROUND).ToSkBitmap(); | 31 image_ = *rb.GetImageNamed(IDR_AURA_LAUNCHER_BACKGROUND).ToSkBitmap(); |
| 31 } | 32 } |
| 32 | 33 |
| 33 virtual void Paint(int w, int h, gfx::Canvas* canvas) OVERRIDE { | 34 virtual void Paint(int w, int h, gfx::Canvas* canvas) OVERRIDE { |
| 34 canvas->TileImageInt(image_, 0, 0, w, h); | 35 canvas->TileImageInt(image_, 0, 0, w, h); |
| 35 } | 36 } |
| 36 | 37 |
| 37 private: | 38 private: |
| 38 SkBitmap image_; | 39 SkBitmap image_; |
| 39 | 40 |
| 40 DISALLOW_COPY_AND_ASSIGN(ShelfPainter); | 41 DISALLOW_COPY_AND_ASSIGN(ShelfPainter); |
| 41 }; | 42 }; |
| 42 | 43 |
| 43 } // namespace | 44 } // namespace |
| 44 | 45 |
| 45 // The contents view of the Widget. This view contains LauncherView and | 46 // The contents view of the Widget. This view contains LauncherView and |
| 46 // sizes it to the width of the widget minus the size of the status area. | 47 // sizes it to the width of the widget minus the size of the status area. |
| 47 class Launcher::DelegateView : public views::WidgetDelegateView { | 48 class Launcher::DelegateView : public views::WidgetDelegate, |
| 49 public views::AccessiblePaneView { |
| 48 public: | 50 public: |
| 49 explicit DelegateView(); | 51 explicit DelegateView(); |
| 50 virtual ~DelegateView(); | 52 virtual ~DelegateView(); |
| 51 | 53 |
| 52 void SetStatusWidth(int width); | 54 void SetStatusWidth(int width); |
| 53 int status_width() const { return status_width_; } | 55 int status_width() const { return status_width_; } |
| 54 | 56 |
| 55 // views::View overrides | 57 // views::View overrides |
| 56 virtual gfx::Size GetPreferredSize() OVERRIDE; | 58 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 57 virtual void Layout() OVERRIDE; | 59 virtual void Layout() OVERRIDE; |
| 58 | 60 |
| 61 virtual views::Widget* GetWidget() OVERRIDE { |
| 62 return View::GetWidget(); |
| 63 } |
| 64 |
| 65 virtual const views::Widget* GetWidget() const OVERRIDE { |
| 66 return View::GetWidget(); |
| 67 } |
| 68 |
| 69 |
| 59 private: | 70 private: |
| 60 int status_width_; | 71 int status_width_; |
| 61 | 72 |
| 62 DISALLOW_COPY_AND_ASSIGN(DelegateView); | 73 DISALLOW_COPY_AND_ASSIGN(DelegateView); |
| 63 }; | 74 }; |
| 64 | 75 |
| 65 Launcher::DelegateView::DelegateView() | 76 Launcher::DelegateView::DelegateView() |
| 66 : status_width_(0) { | 77 : status_width_(0) { |
| 67 set_background( | 78 set_background( |
| 68 views::Background::CreateBackgroundPainter(true, new ShelfPainter())); | 79 views::Background::CreateBackgroundPainter(true, new ShelfPainter())); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 135 |
| 125 void Launcher::SetStatusWidth(int width) { | 136 void Launcher::SetStatusWidth(int width) { |
| 126 delegate_view_->SetStatusWidth(width); | 137 delegate_view_->SetStatusWidth(width); |
| 127 } | 138 } |
| 128 | 139 |
| 129 int Launcher::GetStatusWidth() { | 140 int Launcher::GetStatusWidth() { |
| 130 return delegate_view_->status_width(); | 141 return delegate_view_->status_width(); |
| 131 } | 142 } |
| 132 | 143 |
| 133 } // namespace ash | 144 } // namespace ash |
| OLD | NEW |