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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 #endif | 43 #endif |
44 #if !defined(OS_CHROMEOS) | 44 #if !defined(OS_CHROMEOS) |
45 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 45 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
46 #endif | 46 #endif |
47 #endif // defined(USE_AURA) | 47 #endif // defined(USE_AURA) |
48 | 48 |
49 namespace app_list { | 49 namespace app_list { |
50 | 50 |
51 namespace { | 51 namespace { |
52 | 52 |
53 // For UMA and testing. If non-null, triggered when the app list is painted. | 53 void (*g_next_paint_callback)(); |
54 base::Closure g_next_paint_callback; | |
55 | 54 |
56 // The margin from the edge to the speech UI. | 55 // The margin from the edge to the speech UI. |
57 const int kSpeechUIMargin = 12; | 56 const int kSpeechUIMargin = 12; |
58 | 57 |
59 // The vertical position for the appearing animation of the speech UI. | 58 // The vertical position for the appearing animation of the speech UI. |
60 const float kSpeechUIAppearingPosition = 12; | 59 const float kSpeechUIAppearingPosition = 12; |
61 | 60 |
62 // The distance between the arrow tip and edge of the anchor view. | 61 // The distance between the arrow tip and edge of the anchor view. |
63 const int kArrowOffset = 10; | 62 const int kArrowOffset = 10; |
64 | 63 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 void AppListView::UpdateBounds() { | 192 void AppListView::UpdateBounds() { |
194 SizeToContents(); | 193 SizeToContents(); |
195 } | 194 } |
196 | 195 |
197 gfx::Size AppListView::GetPreferredSize() { | 196 gfx::Size AppListView::GetPreferredSize() { |
198 return app_list_main_view_->GetPreferredSize(); | 197 return app_list_main_view_->GetPreferredSize(); |
199 } | 198 } |
200 | 199 |
201 void AppListView::Paint(gfx::Canvas* canvas) { | 200 void AppListView::Paint(gfx::Canvas* canvas) { |
202 views::BubbleDelegateView::Paint(canvas); | 201 views::BubbleDelegateView::Paint(canvas); |
203 if (!g_next_paint_callback.is_null()) { | 202 if (g_next_paint_callback) { |
204 g_next_paint_callback.Run(); | 203 g_next_paint_callback(); |
205 g_next_paint_callback.Reset(); | 204 g_next_paint_callback = NULL; |
206 } | 205 } |
207 } | 206 } |
208 | 207 |
209 void AppListView::OnThemeChanged() { | 208 void AppListView::OnThemeChanged() { |
210 #if defined(OS_WIN) | 209 #if defined(OS_WIN) |
211 GetWidget()->Close(); | 210 GetWidget()->Close(); |
212 #endif | 211 #endif |
213 } | 212 } |
214 | 213 |
215 bool AppListView::ShouldHandleSystemCommands() const { | 214 bool AppListView::ShouldHandleSystemCommands() const { |
(...skipping 21 matching lines...) Expand all Loading... |
237 | 236 |
238 void AppListView::AddObserver(AppListViewObserver* observer) { | 237 void AppListView::AddObserver(AppListViewObserver* observer) { |
239 observers_.AddObserver(observer); | 238 observers_.AddObserver(observer); |
240 } | 239 } |
241 | 240 |
242 void AppListView::RemoveObserver(AppListViewObserver* observer) { | 241 void AppListView::RemoveObserver(AppListViewObserver* observer) { |
243 observers_.RemoveObserver(observer); | 242 observers_.RemoveObserver(observer); |
244 } | 243 } |
245 | 244 |
246 // static | 245 // static |
247 void AppListView::SetNextPaintCallback(const base::Closure& callback) { | 246 void AppListView::SetNextPaintCallback(void (*callback)()) { |
248 g_next_paint_callback = callback; | 247 g_next_paint_callback = callback; |
249 } | 248 } |
250 | 249 |
251 #if defined(OS_WIN) | 250 #if defined(OS_WIN) |
252 HWND AppListView::GetHWND() const { | 251 HWND AppListView::GetHWND() const { |
253 #if defined(USE_AURA) | 252 #if defined(USE_AURA) |
254 gfx::NativeWindow window = | 253 gfx::NativeWindow window = |
255 GetWidget()->GetTopLevelWidget()->GetNativeWindow(); | 254 GetWidget()->GetTopLevelWidget()->GetNativeWindow(); |
256 return window->GetHost()->GetAcceleratedWidget(); | 255 return window->GetHost()->GetAcceleratedWidget(); |
257 #else | 256 #else |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 #else | 501 #else |
503 speech_view_->SetVisible(recognizing); | 502 speech_view_->SetVisible(recognizing); |
504 app_list_main_view_->SetVisible(!recognizing); | 503 app_list_main_view_->SetVisible(!recognizing); |
505 | 504 |
506 // Needs to schedule paint of AppListView itself, to repaint the background. | 505 // Needs to schedule paint of AppListView itself, to repaint the background. |
507 GetBubbleFrameView()->SchedulePaint(); | 506 GetBubbleFrameView()->SchedulePaint(); |
508 #endif | 507 #endif |
509 } | 508 } |
510 | 509 |
511 } // namespace app_list | 510 } // namespace app_list |
OLD | NEW |