| 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/focus_cycler.h" |
| 7 #include "ash/launcher/launcher_delegate.h" | 8 #include "ash/launcher/launcher_delegate.h" |
| 8 #include "ash/launcher/launcher_model.h" | 9 #include "ash/launcher/launcher_model.h" |
| 9 #include "ash/launcher/launcher_view.h" | 10 #include "ash/launcher/launcher_view.h" |
| 10 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 11 #include "ash/shell_delegate.h" | 12 #include "ash/shell_delegate.h" |
| 12 #include "ash/shell_window_ids.h" | 13 #include "ash/shell_window_ids.h" |
| 13 #include "grit/ui_resources.h" | 14 #include "grit/ui_resources.h" |
| 14 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
| 15 #include "ui/base/resource/resource_bundle.h" | 16 #include "ui/base/resource/resource_bundle.h" |
| 16 #include "ui/gfx/canvas.h" | 17 #include "ui/gfx/canvas.h" |
| 17 #include "ui/gfx/compositor/layer.h" | 18 #include "ui/gfx/compositor/layer.h" |
| 18 #include "ui/gfx/image/image.h" | 19 #include "ui/gfx/image/image.h" |
| 19 #include "ui/views/accessible_pane_view.h" | 20 #include "ui/views/accessible_pane_view.h" |
| 20 #include "ui/views/painter.h" | 21 #include "ui/views/painter.h" |
| 21 #include "ui/views/widget/widget.h" | 22 #include "ui/views/widget/widget.h" |
| 23 #include "ui/views/widget/widget_delegate.h" |
| 22 | 24 |
| 23 namespace ash { | 25 namespace ash { |
| 24 | 26 |
| 25 namespace { | 27 namespace { |
| 26 | 28 |
| 27 // Used to draw the background of the shelf. | 29 // Used to draw the background of the shelf. |
| 28 class ShelfPainter : public views::Painter { | 30 class ShelfPainter : public views::Painter { |
| 29 public: | 31 public: |
| 30 ShelfPainter() { | 32 ShelfPainter() { |
| 31 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 33 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 49 // sizes it to the width of the widget minus the size of the status area. | 51 // sizes it to the width of the widget minus the size of the status area. |
| 50 class Launcher::DelegateView : public views::WidgetDelegate, | 52 class Launcher::DelegateView : public views::WidgetDelegate, |
| 51 public views::AccessiblePaneView { | 53 public views::AccessiblePaneView { |
| 52 public: | 54 public: |
| 53 explicit DelegateView(); | 55 explicit DelegateView(); |
| 54 virtual ~DelegateView(); | 56 virtual ~DelegateView(); |
| 55 | 57 |
| 56 void SetStatusWidth(int width); | 58 void SetStatusWidth(int width); |
| 57 int status_width() const { return status_width_; } | 59 int status_width() const { return status_width_; } |
| 58 | 60 |
| 61 void set_focus_cycler(const internal::FocusCycler* focus_cycler) { |
| 62 focus_cycler_ = focus_cycler; |
| 63 } |
| 64 |
| 59 // views::View overrides | 65 // views::View overrides |
| 60 virtual gfx::Size GetPreferredSize() OVERRIDE; | 66 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 61 virtual void Layout() OVERRIDE; | 67 virtual void Layout() OVERRIDE; |
| 62 | 68 |
| 63 virtual views::Widget* GetWidget() OVERRIDE { | 69 virtual views::Widget* GetWidget() OVERRIDE { |
| 64 return View::GetWidget(); | 70 return View::GetWidget(); |
| 65 } | 71 } |
| 66 | 72 |
| 67 virtual const views::Widget* GetWidget() const OVERRIDE { | 73 virtual const views::Widget* GetWidget() const OVERRIDE { |
| 68 return View::GetWidget(); | 74 return View::GetWidget(); |
| 69 } | 75 } |
| 70 | 76 |
| 77 // views::WidgetDelegateView overrides: |
| 78 virtual bool CanActivate() const OVERRIDE { |
| 79 // We don't want mouse clicks to activate us, but we need to allow |
| 80 // activation when the user is using the keyboard (FocusCycler). |
| 81 return focus_cycler_ && focus_cycler_->widget_activating() == GetWidget(); |
| 82 } |
| 71 | 83 |
| 72 private: | 84 private: |
| 73 int status_width_; | 85 int status_width_; |
| 86 const internal::FocusCycler* focus_cycler_; |
| 74 | 87 |
| 75 DISALLOW_COPY_AND_ASSIGN(DelegateView); | 88 DISALLOW_COPY_AND_ASSIGN(DelegateView); |
| 76 }; | 89 }; |
| 77 | 90 |
| 78 Launcher::DelegateView::DelegateView() | 91 Launcher::DelegateView::DelegateView() |
| 79 : status_width_(0) { | 92 : status_width_(0), |
| 93 focus_cycler_(NULL) { |
| 80 set_background( | 94 set_background( |
| 81 views::Background::CreateBackgroundPainter(true, new ShelfPainter())); | 95 views::Background::CreateBackgroundPainter(true, new ShelfPainter())); |
| 82 } | 96 } |
| 83 | 97 |
| 84 Launcher::DelegateView::~DelegateView() { | 98 Launcher::DelegateView::~DelegateView() { |
| 85 } | 99 } |
| 86 | 100 |
| 101 void Launcher::SetFocusCycler(const internal::FocusCycler* focus_cycler) { |
| 102 delegate_view_->set_focus_cycler(focus_cycler); |
| 103 } |
| 104 |
| 87 void Launcher::DelegateView::SetStatusWidth(int width) { | 105 void Launcher::DelegateView::SetStatusWidth(int width) { |
| 88 if (status_width_ == width) | 106 if (status_width_ == width) |
| 89 return; | 107 return; |
| 90 | 108 |
| 91 status_width_ = width; | 109 status_width_ = width; |
| 92 Layout(); | 110 Layout(); |
| 93 } | 111 } |
| 94 | 112 |
| 95 gfx::Size Launcher::DelegateView::GetPreferredSize() { | 113 gfx::Size Launcher::DelegateView::GetPreferredSize() { |
| 96 return child_count() > 0 ? child_at(0)->GetPreferredSize() : gfx::Size(); | 114 return child_count() > 0 ? child_at(0)->GetPreferredSize() : gfx::Size(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 158 |
| 141 void Launcher::SetStatusWidth(int width) { | 159 void Launcher::SetStatusWidth(int width) { |
| 142 delegate_view_->SetStatusWidth(width); | 160 delegate_view_->SetStatusWidth(width); |
| 143 } | 161 } |
| 144 | 162 |
| 145 int Launcher::GetStatusWidth() { | 163 int Launcher::GetStatusWidth() { |
| 146 return delegate_view_->status_width(); | 164 return delegate_view_->status_width(); |
| 147 } | 165 } |
| 148 | 166 |
| 149 } // namespace ash | 167 } // namespace ash |
| OLD | NEW |