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/shelf/shelf_view.h" | 5 #include "ash/shelf/shelf_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "ash/aura/wm_window_aura.h" | 10 #include "ash/aura/wm_window_aura.h" |
11 #include "ash/common/ash_constants.h" | 11 #include "ash/common/ash_constants.h" |
12 #include "ash/common/ash_switches.h" | 12 #include "ash/common/ash_switches.h" |
| 13 #include "ash/common/shelf/overflow_bubble.h" |
| 14 #include "ash/common/shelf/overflow_bubble_view.h" |
| 15 #include "ash/common/shelf/overflow_button.h" |
13 #include "ash/common/shelf/shelf_constants.h" | 16 #include "ash/common/shelf/shelf_constants.h" |
14 #include "ash/common/shelf/shelf_item_delegate_manager.h" | 17 #include "ash/common/shelf/shelf_item_delegate_manager.h" |
15 #include "ash/common/shelf/shelf_menu_model.h" | 18 #include "ash/common/shelf/shelf_menu_model.h" |
16 #include "ash/common/shelf/shelf_model.h" | 19 #include "ash/common/shelf/shelf_model.h" |
17 #include "ash/common/shell_delegate.h" | 20 #include "ash/common/shell_delegate.h" |
18 #include "ash/common/wm/root_window_finder.h" | 21 #include "ash/common/wm/root_window_finder.h" |
19 #include "ash/common/wm_shell.h" | 22 #include "ash/common/wm_shell.h" |
20 #include "ash/drag_drop/drag_image_view.h" | 23 #include "ash/drag_drop/drag_image_view.h" |
21 #include "ash/scoped_target_root_window.h" | 24 #include "ash/scoped_target_root_window.h" |
22 #include "ash/shelf/app_list_button.h" | 25 #include "ash/shelf/app_list_button.h" |
23 #include "ash/shelf/overflow_bubble.h" | |
24 #include "ash/shelf/overflow_bubble_view.h" | |
25 #include "ash/shelf/overflow_button.h" | |
26 #include "ash/shelf/shelf.h" | 26 #include "ash/shelf/shelf.h" |
27 #include "ash/shelf/shelf_button.h" | 27 #include "ash/shelf/shelf_button.h" |
28 #include "ash/shelf/shelf_delegate.h" | 28 #include "ash/shelf/shelf_delegate.h" |
29 #include "ash/shelf/shelf_icon_observer.h" | 29 #include "ash/shelf/shelf_icon_observer.h" |
30 #include "ash/shelf/shelf_widget.h" | 30 #include "ash/shelf/shelf_widget.h" |
31 #include "ash/shell.h" | 31 #include "ash/shell.h" |
32 #include "base/auto_reset.h" | 32 #include "base/auto_reset.h" |
33 #include "base/metrics/histogram.h" | 33 #include "base/metrics/histogram.h" |
34 #include "grit/ash_strings.h" | 34 #include "grit/ash_strings.h" |
35 #include "ui/accessibility/ax_view_state.h" | 35 #include "ui/accessibility/ax_view_state.h" |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 void ShelfView::Init() { | 407 void ShelfView::Init() { |
408 model_->AddObserver(this); | 408 model_->AddObserver(this); |
409 | 409 |
410 const ShelfItems& items(model_->items()); | 410 const ShelfItems& items(model_->items()); |
411 for (ShelfItems::const_iterator i = items.begin(); i != items.end(); ++i) { | 411 for (ShelfItems::const_iterator i = items.begin(); i != items.end(); ++i) { |
412 views::View* child = CreateViewForItem(*i); | 412 views::View* child = CreateViewForItem(*i); |
413 child->SetPaintToLayer(true); | 413 child->SetPaintToLayer(true); |
414 view_model_->Add(child, static_cast<int>(i - items.begin())); | 414 view_model_->Add(child, static_cast<int>(i - items.begin())); |
415 AddChildView(child); | 415 AddChildView(child); |
416 } | 416 } |
417 overflow_button_ = new OverflowButton(this, shelf_); | 417 overflow_button_ = new OverflowButton(this, wm_shelf_); |
418 overflow_button_->set_context_menu_controller(this); | 418 overflow_button_->set_context_menu_controller(this); |
419 ConfigureChildView(overflow_button_); | 419 ConfigureChildView(overflow_button_); |
420 AddChildView(overflow_button_); | 420 AddChildView(overflow_button_); |
421 | 421 |
422 // We'll layout when our bounds change. | 422 // We'll layout when our bounds change. |
423 } | 423 } |
424 | 424 |
425 void ShelfView::OnShelfAlignmentChanged() { | 425 void ShelfView::OnShelfAlignmentChanged() { |
426 overflow_button_->OnShelfAlignmentChanged(); | 426 overflow_button_->OnShelfAlignmentChanged(); |
427 LayoutToIdealBounds(); | 427 LayoutToIdealBounds(); |
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1362 view->layer()->SetFillsBoundsOpaquely(false); | 1362 view->layer()->SetFillsBoundsOpaquely(false); |
1363 } | 1363 } |
1364 | 1364 |
1365 void ShelfView::ToggleOverflowBubble() { | 1365 void ShelfView::ToggleOverflowBubble() { |
1366 if (IsShowingOverflowBubble()) { | 1366 if (IsShowingOverflowBubble()) { |
1367 overflow_bubble_->Hide(); | 1367 overflow_bubble_->Hide(); |
1368 return; | 1368 return; |
1369 } | 1369 } |
1370 | 1370 |
1371 if (!overflow_bubble_) | 1371 if (!overflow_bubble_) |
1372 overflow_bubble_.reset(new OverflowBubble()); | 1372 overflow_bubble_.reset(new OverflowBubble(wm_shelf_)); |
1373 | 1373 |
1374 ShelfView* overflow_view = | 1374 ShelfView* overflow_view = |
1375 new ShelfView(model_, delegate_, wm_shelf_, shelf_); | 1375 new ShelfView(model_, delegate_, wm_shelf_, shelf_); |
1376 overflow_view->overflow_mode_ = true; | 1376 overflow_view->overflow_mode_ = true; |
1377 overflow_view->Init(); | 1377 overflow_view->Init(); |
1378 overflow_view->set_owner_overflow_bubble(overflow_bubble_.get()); | 1378 overflow_view->set_owner_overflow_bubble(overflow_bubble_.get()); |
1379 overflow_view->OnShelfAlignmentChanged(); | 1379 overflow_view->OnShelfAlignmentChanged(); |
1380 overflow_view->main_shelf_ = this; | 1380 overflow_view->main_shelf_ = this; |
1381 UpdateOverflowRange(overflow_view); | 1381 UpdateOverflowRange(overflow_view); |
1382 | 1382 |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1908 | 1908 |
1909 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { | 1909 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { |
1910 const gfx::Rect bounds = GetBoundsInScreen(); | 1910 const gfx::Rect bounds = GetBoundsInScreen(); |
1911 int distance = shelf_->SelectValueForShelfAlignment( | 1911 int distance = shelf_->SelectValueForShelfAlignment( |
1912 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), | 1912 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), |
1913 bounds.x() - coordinate.x()); | 1913 bounds.x() - coordinate.x()); |
1914 return distance > 0 ? distance : 0; | 1914 return distance > 0 ? distance : 0; |
1915 } | 1915 } |
1916 | 1916 |
1917 } // namespace ash | 1917 } // namespace ash |
OLD | NEW |