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 "ui/app_list/views/app_list_view.h" | 5 #include "ui/app_list/views/app_list_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 #endif | 46 #endif |
47 #if !defined(OS_CHROMEOS) | 47 #if !defined(OS_CHROMEOS) |
48 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 48 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
49 #endif | 49 #endif |
50 #endif // defined(USE_AURA) | 50 #endif // defined(USE_AURA) |
51 | 51 |
52 namespace app_list { | 52 namespace app_list { |
53 | 53 |
54 namespace { | 54 namespace { |
55 | 55 |
56 void (*g_next_paint_callback)(); | |
57 | |
58 // The margin from the edge to the speech UI. | 56 // The margin from the edge to the speech UI. |
59 const int kSpeechUIMargin = 12; | 57 const int kSpeechUIMargin = 12; |
60 | 58 |
61 // The vertical position for the appearing animation of the speech UI. | 59 // The vertical position for the appearing animation of the speech UI. |
62 const float kSpeechUIAppearingPosition = 12; | 60 const float kSpeechUIAppearingPosition = 12; |
63 | 61 |
64 // The distance between the arrow tip and edge of the anchor view. | 62 // The distance between the arrow tip and edge of the anchor view. |
65 const int kArrowOffset = 10; | 63 const int kArrowOffset = 10; |
66 | 64 |
67 // Determines whether the current environment supports shadows bubble borders. | 65 // Determines whether the current environment supports shadows bubble borders. |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 bool AppListView::ShouldCenterWindow() const { | 197 bool AppListView::ShouldCenterWindow() const { |
200 return delegate_->ShouldCenterWindow(); | 198 return delegate_->ShouldCenterWindow(); |
201 } | 199 } |
202 | 200 |
203 gfx::Size AppListView::GetPreferredSize() { | 201 gfx::Size AppListView::GetPreferredSize() { |
204 return app_list_main_view_->GetPreferredSize(); | 202 return app_list_main_view_->GetPreferredSize(); |
205 } | 203 } |
206 | 204 |
207 void AppListView::Paint(gfx::Canvas* canvas, const views::CullSet& cull_set) { | 205 void AppListView::Paint(gfx::Canvas* canvas, const views::CullSet& cull_set) { |
208 views::BubbleDelegateView::Paint(canvas, cull_set); | 206 views::BubbleDelegateView::Paint(canvas, cull_set); |
209 if (g_next_paint_callback) { | 207 if (!next_paint_callback_.is_null()) { |
210 g_next_paint_callback(); | 208 next_paint_callback_.Run(); |
211 g_next_paint_callback = NULL; | 209 next_paint_callback_.Reset(); |
212 } | 210 } |
213 } | 211 } |
214 | 212 |
215 void AppListView::OnThemeChanged() { | 213 void AppListView::OnThemeChanged() { |
216 #if defined(OS_WIN) | 214 #if defined(OS_WIN) |
217 GetWidget()->Close(); | 215 GetWidget()->Close(); |
218 #endif | 216 #endif |
219 } | 217 } |
220 | 218 |
221 bool AppListView::ShouldHandleSystemCommands() const { | 219 bool AppListView::ShouldHandleSystemCommands() const { |
(...skipping 21 matching lines...) Expand all Loading... |
243 | 241 |
244 void AppListView::AddObserver(AppListViewObserver* observer) { | 242 void AppListView::AddObserver(AppListViewObserver* observer) { |
245 observers_.AddObserver(observer); | 243 observers_.AddObserver(observer); |
246 } | 244 } |
247 | 245 |
248 void AppListView::RemoveObserver(AppListViewObserver* observer) { | 246 void AppListView::RemoveObserver(AppListViewObserver* observer) { |
249 observers_.RemoveObserver(observer); | 247 observers_.RemoveObserver(observer); |
250 } | 248 } |
251 | 249 |
252 // static | 250 // static |
253 void AppListView::SetNextPaintCallback(void (*callback)()) { | 251 void AppListView::SetNextPaintCallback(const base::Closure& callback) { |
254 g_next_paint_callback = callback; | 252 next_paint_callback_ = callback; |
255 } | 253 } |
256 | 254 |
257 #if defined(OS_WIN) | 255 #if defined(OS_WIN) |
258 HWND AppListView::GetHWND() const { | 256 HWND AppListView::GetHWND() const { |
259 #if defined(USE_AURA) | 257 #if defined(USE_AURA) |
260 gfx::NativeWindow window = | 258 gfx::NativeWindow window = |
261 GetWidget()->GetTopLevelWidget()->GetNativeWindow(); | 259 GetWidget()->GetTopLevelWidget()->GetNativeWindow(); |
262 return window->GetHost()->GetAcceleratedWidget(); | 260 return window->GetHost()->GetAcceleratedWidget(); |
263 #else | 261 #else |
264 return GetWidget()->GetTopLevelWidget()->GetNativeWindow(); | 262 return GetWidget()->GetTopLevelWidget()->GetNativeWindow(); |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 #else | 511 #else |
514 speech_view_->SetVisible(recognizing); | 512 speech_view_->SetVisible(recognizing); |
515 app_list_main_view_->SetVisible(!recognizing); | 513 app_list_main_view_->SetVisible(!recognizing); |
516 | 514 |
517 // Needs to schedule paint of AppListView itself, to repaint the background. | 515 // Needs to schedule paint of AppListView itself, to repaint the background. |
518 GetBubbleFrameView()->SchedulePaint(); | 516 GetBubbleFrameView()->SchedulePaint(); |
519 #endif | 517 #endif |
520 } | 518 } |
521 | 519 |
522 } // namespace app_list | 520 } // namespace app_list |
OLD | NEW |