Chromium Code Reviews| 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/macros.h" | 10 #include "base/macros.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 // The view for the App List overlay, which appears as a white rounded | 79 // The view for the App List overlay, which appears as a white rounded |
| 80 // rectangle with the given radius. | 80 // rectangle with the given radius. |
| 81 class AppListOverlayView : public views::View { | 81 class AppListOverlayView : public views::View { |
| 82 public: | 82 public: |
| 83 explicit AppListOverlayView(int corner_radius) | 83 explicit AppListOverlayView(int corner_radius) |
| 84 : corner_radius_(corner_radius) { | 84 : corner_radius_(corner_radius) { |
| 85 SetPaintToLayer(); | 85 SetPaintToLayer(); |
| 86 SetVisible(false); | 86 SetVisible(false); |
| 87 layer()->SetOpacity(0.0f); | |
|
sky
2017/04/07 03:28:18
Why are you removing this?
newcomer
2017/04/10 16:34:53
That was a mistake! Fixed.
| |
| 88 } | 87 } |
| 89 | 88 |
| 90 ~AppListOverlayView() override {} | 89 ~AppListOverlayView() override {} |
| 91 | 90 |
| 92 // Overridden from views::View: | 91 // Overridden from views::View: |
| 93 void OnPaint(gfx::Canvas* canvas) override { | 92 void OnPaint(gfx::Canvas* canvas) override { |
| 94 cc::PaintFlags flags; | 93 cc::PaintFlags flags; |
| 95 flags.setStyle(cc::PaintFlags::kFill_Style); | 94 flags.setStyle(cc::PaintFlags::kFill_Style); |
| 96 flags.setColor(SK_ColorWHITE); | 95 flags.setColor(SK_ColorWHITE); |
| 97 canvas->DrawRoundRect(GetContentsBounds(), corner_radius_, flags); | 96 canvas->DrawRoundRect(GetContentsBounds(), corner_radius_, flags); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 | 161 |
| 163 views::BubbleFrameView* frame_; | 162 views::BubbleFrameView* frame_; |
| 164 views::View* target_; | 163 views::View* target_; |
| 165 | 164 |
| 166 DISALLOW_COPY_AND_ASSIGN(HideViewAnimationObserver); | 165 DISALLOW_COPY_AND_ASSIGN(HideViewAnimationObserver); |
| 167 }; | 166 }; |
| 168 | 167 |
| 169 //////////////////////////////////////////////////////////////////////////////// | 168 //////////////////////////////////////////////////////////////////////////////// |
| 170 // AppListView: | 169 // AppListView: |
| 171 | 170 |
| 171 const char* AppListView::GetClassName() const { | |
| 172 return "AppListView"; | |
| 173 } | |
| 174 | |
| 172 AppListView::AppListView(AppListViewDelegate* delegate) | 175 AppListView::AppListView(AppListViewDelegate* delegate) |
| 173 : delegate_(delegate), | 176 : delegate_(delegate), |
| 174 app_list_main_view_(nullptr), | 177 app_list_main_view_(nullptr), |
| 175 speech_view_(nullptr), | 178 speech_view_(nullptr), |
| 176 search_box_focus_host_(nullptr), | 179 search_box_focus_host_(nullptr), |
| 177 search_box_widget_(nullptr), | 180 search_box_widget_(nullptr), |
| 178 search_box_view_(nullptr), | 181 search_box_view_(nullptr), |
| 179 overlay_view_(nullptr), | 182 overlay_view_(nullptr), |
| 180 animation_observer_(new HideViewAnimationObserver()) { | 183 animation_observer_(new HideViewAnimationObserver()), |
| 184 blurred(false) { | |
|
sky
2017/04/07 03:28:19
Does this compile?
newcomer
2017/04/10 16:34:53
It didn't compile. I added that when doing researc
| |
| 181 CHECK(delegate); | 185 CHECK(delegate); |
| 182 | 186 |
| 183 delegate_->GetSpeechUI()->AddObserver(this); | 187 delegate_->GetSpeechUI()->AddObserver(this); |
| 184 } | 188 } |
| 185 | 189 |
| 186 AppListView::~AppListView() { | 190 AppListView::~AppListView() { |
| 187 delegate_->GetSpeechUI()->RemoveObserver(this); | 191 delegate_->GetSpeechUI()->RemoveObserver(this); |
| 188 animation_observer_.reset(); | 192 animation_observer_.reset(); |
| 189 // Remove child views first to ensure no remaining dependencies on delegate_. | 193 // Remove child views first to ensure no remaining dependencies on delegate_. |
| 190 RemoveAllChildViews(true); | 194 RemoveAllChildViews(true); |
| 191 } | 195 } |
| 192 | 196 |
| 197 void AppListView::InitAsFramelessWindow(gfx::NativeView parent, | |
|
sky
2017/04/07 03:28:18
Please refactor this and InitAsBubble to share cod
newcomer
2017/04/10 16:34:53
I refactored it, then noticed there was a function
| |
| 198 int initial_apps_page, | |
| 199 gfx::Rect bounds) { | |
| 200 set_color(kContentsBackgroundColor); | |
| 201 InitContents(parent, initial_apps_page); | |
| 202 | |
|
sky
2017/04/07 03:28:18
Only one newline is fine.
newcomer
2017/04/10 16:34:53
Acknowledged.
| |
| 203 | |
| 204 views::Widget *widget = new views::Widget; | |
| 205 views::Widget::InitParams app_list_overlay_view_params( | |
| 206 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | |
| 207 app_list_overlay_view_params.parent = parent; | |
| 208 app_list_overlay_view_params.delegate = this; | |
| 209 | |
| 210 widget->Init(app_list_overlay_view_params); | |
| 211 widget->SetBounds(bounds); | |
| 212 widget->GetLayer()->SetFillsBoundsOpaquely(false); | |
| 213 widget->GetLayer()->SetBackgroundBlur(20); | |
| 214 InitChildWidgets(); | |
| 215 overlay_view_ = new AppListOverlayView(0 /* no corners */); | |
| 216 AddChildView(overlay_view_); | |
| 217 } | |
| 193 void AppListView::InitAsBubble(gfx::NativeView parent, int initial_apps_page) { | 218 void AppListView::InitAsBubble(gfx::NativeView parent, int initial_apps_page) { |
|
sky
2017/04/07 03:28:18
newline between 217/218.
| |
| 194 base::Time start_time = base::Time::Now(); | 219 base::Time start_time = base::Time::Now(); |
| 195 | 220 |
| 196 InitContents(parent, initial_apps_page); | 221 InitContents(parent, initial_apps_page); |
| 197 | 222 |
| 198 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); | 223 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); |
| 199 set_margins(gfx::Insets()); | 224 set_margins(gfx::Insets()); |
| 200 set_parent_window(parent); | 225 set_parent_window(parent); |
| 201 set_close_on_deactivate(false); | 226 set_close_on_deactivate(false); |
| 202 set_shadow(views::BubbleBorder::NO_ASSETS); | 227 set_shadow(views::BubbleBorder::NO_ASSETS); |
| 203 set_color(kContentsBackgroundColor); | 228 set_color(kContentsBackgroundColor); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 336 // crbug.com/441028 are fixed. | 361 // crbug.com/441028 are fixed. |
| 337 tracked_objects::ScopedTracker tracking_profile( | 362 tracked_objects::ScopedTracker tracking_profile( |
| 338 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 363 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 339 "440224, 441028 AppListView::InitContents")); | 364 "440224, 441028 AppListView::InitContents")); |
| 340 | 365 |
| 341 app_list_main_view_ = new AppListMainView(delegate_); | 366 app_list_main_view_ = new AppListMainView(delegate_); |
| 342 AddChildView(app_list_main_view_); | 367 AddChildView(app_list_main_view_); |
| 343 app_list_main_view_->SetPaintToLayer(); | 368 app_list_main_view_->SetPaintToLayer(); |
| 344 app_list_main_view_->layer()->SetFillsBoundsOpaquely(false); | 369 app_list_main_view_->layer()->SetFillsBoundsOpaquely(false); |
| 345 app_list_main_view_->layer()->SetMasksToBounds(true); | 370 app_list_main_view_->layer()->SetMasksToBounds(true); |
| 346 | |
| 347 // This will be added to the |search_box_widget_| after the app list widget is | 371 // This will be added to the |search_box_widget_| after the app list widget is |
| 348 // initialized. | 372 // initialized. |
| 349 search_box_view_ = new SearchBoxView(app_list_main_view_, delegate_); | 373 search_box_view_ = new SearchBoxView(app_list_main_view_, delegate_); |
| 350 search_box_view_->SetPaintToLayer(); | 374 search_box_view_->SetPaintToLayer(); |
| 351 search_box_view_->layer()->SetFillsBoundsOpaquely(false); | 375 search_box_view_->layer()->SetFillsBoundsOpaquely(false); |
| 352 search_box_view_->layer()->SetMasksToBounds(true); | 376 search_box_view_->layer()->SetMasksToBounds(true); |
| 353 | 377 |
| 354 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440224 and | 378 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440224 and |
| 355 // crbug.com/441028 are fixed. | 379 // crbug.com/441028 are fixed. |
| 356 tracked_objects::ScopedTracker tracking_profile1( | 380 tracked_objects::ScopedTracker tracking_profile1( |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 567 app_list_main_view_->SetVisible(true); | 591 app_list_main_view_->SetVisible(true); |
| 568 // Refocus the search box. However, if the app list widget does not have | 592 // Refocus the search box. However, if the app list widget does not have |
| 569 // focus, it means another window has already taken focus, and we *must not* | 593 // focus, it means another window has already taken focus, and we *must not* |
| 570 // focus the search box (or we would steal focus back into the app list). | 594 // focus the search box (or we would steal focus back into the app list). |
| 571 if (GetWidget()->IsActive()) | 595 if (GetWidget()->IsActive()) |
| 572 search_box_view_->search_box()->RequestFocus(); | 596 search_box_view_->search_box()->RequestFocus(); |
| 573 } | 597 } |
| 574 } | 598 } |
| 575 | 599 |
| 576 } // namespace app_list | 600 } // namespace app_list |
| OLD | NEW |