OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "athena/home/public/home_card.h" | 5 #include "athena/home/public/home_card.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "athena/common/container_priorities.h" | 9 #include "athena/common/container_priorities.h" |
10 #include "athena/home/app_list_view_delegate.h" | 10 #include "athena/home/app_list_view_delegate.h" |
11 #include "athena/home/bottom_home_view.h" | 11 #include "athena/home/bottom_home_view.h" |
12 #include "athena/home/minimized_home.h" | 12 #include "athena/home/minimized_home.h" |
13 #include "athena/home/public/app_model_builder.h" | 13 #include "athena/home/public/app_model_builder.h" |
14 #include "athena/input/public/accelerator_manager.h" | 14 #include "athena/input/public/accelerator_manager.h" |
15 #include "athena/screen/public/screen_manager.h" | 15 #include "athena/screen/public/screen_manager.h" |
16 #include "athena/wm/public/window_manager.h" | 16 #include "athena/wm/public/window_manager.h" |
17 #include "athena/wm/public/window_manager_observer.h" | 17 #include "athena/wm/public/window_manager_observer.h" |
18 #include "base/bind.h" | 18 #include "base/bind.h" |
19 #include "ui/app_list/search_provider.h" | 19 #include "ui/app_list/search_provider.h" |
20 #include "ui/app_list/views/app_list_main_view.h" | 20 #include "ui/app_list/views/app_list_main_view.h" |
21 #include "ui/app_list/views/contents_view.h" | 21 #include "ui/app_list/views/contents_view.h" |
22 #include "ui/aura/layout_manager.h" | 22 #include "ui/aura/layout_manager.h" |
23 #include "ui/aura/window.h" | 23 #include "ui/aura/window.h" |
24 #include "ui/views/background.h" | 24 #include "ui/views/background.h" |
25 #include "ui/views/layout/box_layout.h" | 25 #include "ui/views/layout/box_layout.h" |
26 #include "ui/views/widget/widget.h" | 26 #include "ui/views/widget/widget.h" |
27 #include "ui/views/widget/widget_delegate.h" | 27 #include "ui/views/widget/widget_delegate.h" |
| 28 #include "ui/wm/core/shadow.h" |
28 #include "ui/wm/core/visibility_controller.h" | 29 #include "ui/wm/core/visibility_controller.h" |
29 #include "ui/wm/core/window_animations.h" | 30 #include "ui/wm/core/window_animations.h" |
30 #include "ui/wm/public/activation_change_observer.h" | 31 #include "ui/wm/public/activation_change_observer.h" |
31 #include "ui/wm/public/activation_client.h" | 32 #include "ui/wm/public/activation_client.h" |
32 | 33 |
33 namespace athena { | 34 namespace athena { |
34 namespace { | 35 namespace { |
35 | 36 |
36 HomeCard* instance = NULL; | 37 HomeCard* instance = NULL; |
37 | 38 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 | 95 |
95 DISALLOW_COPY_AND_ASSIGN(HomeCardLayoutManager); | 96 DISALLOW_COPY_AND_ASSIGN(HomeCardLayoutManager); |
96 }; | 97 }; |
97 | 98 |
98 // The container view of home card contents of each state. | 99 // The container view of home card contents of each state. |
99 class HomeCardView : public views::WidgetDelegateView { | 100 class HomeCardView : public views::WidgetDelegateView { |
100 public: | 101 public: |
101 HomeCardView(app_list::AppListViewDelegate* view_delegate, | 102 HomeCardView(app_list::AppListViewDelegate* view_delegate, |
102 aura::Window* container, | 103 aura::Window* container, |
103 MinimizedHomeDragDelegate* minimized_delegate) { | 104 MinimizedHomeDragDelegate* minimized_delegate) { |
104 set_background(views::Background::CreateSolidBackground(SK_ColorWHITE)); | |
105 | |
106 bottom_view_ = new BottomHomeView(view_delegate); | 105 bottom_view_ = new BottomHomeView(view_delegate); |
107 AddChildView(bottom_view_); | 106 AddChildView(bottom_view_); |
108 | 107 |
109 main_view_ = new app_list::AppListMainView( | 108 main_view_ = new app_list::AppListMainView( |
110 view_delegate, 0 /* initial_apps_page */, container); | 109 view_delegate, 0 /* initial_apps_page */, container); |
111 AddChildView(main_view_); | 110 AddChildView(main_view_); |
| 111 main_view_->set_background( |
| 112 views::Background::CreateSolidBackground(SK_ColorWHITE)); |
112 | 113 |
113 minimized_view_ = CreateMinimizedHome(minimized_delegate); | 114 minimized_view_ = CreateMinimizedHome(minimized_delegate); |
114 AddChildView(minimized_view_); | 115 AddChildView(minimized_view_); |
115 } | 116 } |
116 | 117 |
117 void SetState(HomeCard::State state) { | 118 void SetState(HomeCard::State state) { |
118 bottom_view_->SetVisible(state == HomeCard::VISIBLE_BOTTOM); | 119 bottom_view_->SetVisible(state == HomeCard::VISIBLE_BOTTOM); |
119 main_view_->SetVisible(state == HomeCard::VISIBLE_CENTERED); | 120 main_view_->SetVisible(state == HomeCard::VISIBLE_CENTERED); |
120 minimized_view_->SetVisible(state == HomeCard::VISIBLE_MINIMIZED); | 121 minimized_view_->SetVisible(state == HomeCard::VISIBLE_MINIMIZED); |
121 if (state == HomeCard::VISIBLE_CENTERED) { | 122 if (state == HomeCard::VISIBLE_CENTERED) { |
122 app_list::ContentsView* contents_view = main_view_->contents_view(); | 123 app_list::ContentsView* contents_view = main_view_->contents_view(); |
123 contents_view->SetActivePage(contents_view->GetPageIndexForNamedPage( | 124 contents_view->SetActivePage(contents_view->GetPageIndexForNamedPage( |
124 app_list::ContentsView::NAMED_PAGE_START)); | 125 app_list::ContentsView::NAMED_PAGE_START)); |
125 } | 126 } |
| 127 |
| 128 if (state != HomeCard::VISIBLE_BOTTOM) |
| 129 shadow_.reset(); |
| 130 // Do not create the shadow yet. Instead, create it in OnWidgetMove(), to |
| 131 // make sure that widget has been resized correctly (because the size of the |
| 132 // shadow depends on the size of the widget). |
126 } | 133 } |
127 | 134 |
128 // views::View: | 135 // views::View: |
129 virtual void Layout() OVERRIDE { | 136 virtual void Layout() OVERRIDE { |
130 for (int i = 0; i < child_count(); ++i) { | 137 for (int i = 0; i < child_count(); ++i) { |
131 views::View* child = child_at(i); | 138 views::View* child = child_at(i); |
132 if (child->visible()) { | 139 if (child->visible()) { |
133 child->SetBoundsRect(bounds()); | 140 child->SetBoundsRect(bounds()); |
134 return; | 141 return; |
135 } | 142 } |
136 } | 143 } |
137 | 144 |
138 // One of the child views has to be visible. | 145 // One of the child views has to be visible. |
139 NOTREACHED(); | 146 NOTREACHED(); |
140 } | 147 } |
141 | 148 |
142 private: | 149 private: |
143 // views::WidgetDelegate: | 150 // views::WidgetDelegate: |
| 151 virtual void OnWidgetMove() OVERRIDE { |
| 152 if (bottom_view_->visible() && !shadow_) { |
| 153 aura::Window* window = GetWidget()->GetNativeWindow(); |
| 154 shadow_.reset(new wm::Shadow()); |
| 155 shadow_->Init(wm::Shadow::STYLE_ACTIVE); |
| 156 shadow_->SetContentBounds(gfx::Rect(window->bounds().size())); |
| 157 shadow_->layer()->SetVisible(true); |
| 158 |
| 159 ui::Layer* layer = window->layer(); |
| 160 layer->Add(shadow_->layer()); |
| 161 } |
| 162 } |
| 163 |
144 virtual views::View* GetContentsView() OVERRIDE { | 164 virtual views::View* GetContentsView() OVERRIDE { |
145 return this; | 165 return this; |
146 } | 166 } |
147 | 167 |
148 app_list::AppListMainView* main_view_; | 168 app_list::AppListMainView* main_view_; |
149 BottomHomeView* bottom_view_; | 169 BottomHomeView* bottom_view_; |
150 views::View* minimized_view_; | 170 views::View* minimized_view_; |
| 171 scoped_ptr<wm::Shadow> shadow_; |
151 | 172 |
152 DISALLOW_COPY_AND_ASSIGN(HomeCardView); | 173 DISALLOW_COPY_AND_ASSIGN(HomeCardView); |
153 }; | 174 }; |
154 | 175 |
155 class HomeCardImpl : public HomeCard, | 176 class HomeCardImpl : public HomeCard, |
156 public AcceleratorHandler, | 177 public AcceleratorHandler, |
157 public HomeCardLayoutManager::Delegate, | 178 public HomeCardLayoutManager::Delegate, |
158 public MinimizedHomeDragDelegate, | 179 public MinimizedHomeDragDelegate, |
159 public WindowManagerObserver, | 180 public WindowManagerObserver, |
160 public aura::client::ActivationChangeObserver { | 181 public aura::client::ActivationChangeObserver { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 return kHomeCardMinimizedHeight; | 227 return kHomeCardMinimizedHeight; |
207 case HIDDEN: | 228 case HIDDEN: |
208 break; | 229 break; |
209 } | 230 } |
210 NOTREACHED(); | 231 NOTREACHED(); |
211 return -1; | 232 return -1; |
212 } | 233 } |
213 | 234 |
214 virtual int GetHorizontalMargin() const OVERRIDE { | 235 virtual int GetHorizontalMargin() const OVERRIDE { |
215 CHECK_NE(HIDDEN, state_); | 236 CHECK_NE(HIDDEN, state_); |
216 const int kHomeCardHorizontalMargin = 50; | 237 const int kHomeCardHorizontalMargin = 100; |
217 return state_ == VISIBLE_BOTTOM ? kHomeCardHorizontalMargin : 0; | 238 return state_ == VISIBLE_BOTTOM ? kHomeCardHorizontalMargin : 0; |
218 } | 239 } |
219 | 240 |
220 virtual aura::Window* GetNativeWindow() OVERRIDE { | 241 virtual aura::Window* GetNativeWindow() OVERRIDE { |
221 if (state_ == HIDDEN) | 242 if (state_ == HIDDEN) |
222 return NULL; | 243 return NULL; |
223 | 244 |
224 return home_card_widget_ ? home_card_widget_->GetNativeWindow() : NULL; | 245 return home_card_widget_ ? home_card_widget_->GetNativeWindow() : NULL; |
225 } | 246 } |
226 | 247 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 instance = NULL; | 409 instance = NULL; |
389 } | 410 } |
390 | 411 |
391 // static | 412 // static |
392 HomeCard* HomeCard::Get() { | 413 HomeCard* HomeCard::Get() { |
393 DCHECK(instance); | 414 DCHECK(instance); |
394 return instance; | 415 return instance; |
395 } | 416 } |
396 | 417 |
397 } // namespace athena | 418 } // namespace athena |
OLD | NEW |