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/common/shelf/shelf_view.h" | 5 #include "ash/common/shelf/shelf_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "ash/common/ash_constants.h" | 10 #include "ash/common/ash_constants.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "ash/common/wm_window.h" | 28 #include "ash/common/wm_window.h" |
29 #include "base/auto_reset.h" | 29 #include "base/auto_reset.h" |
30 #include "base/metrics/histogram.h" | 30 #include "base/metrics/histogram.h" |
31 #include "grit/ash_strings.h" | 31 #include "grit/ash_strings.h" |
32 #include "ui/accessibility/ax_node_data.h" | 32 #include "ui/accessibility/ax_node_data.h" |
33 #include "ui/base/l10n/l10n_util.h" | 33 #include "ui/base/l10n/l10n_util.h" |
34 #include "ui/base/models/simple_menu_model.h" | 34 #include "ui/base/models/simple_menu_model.h" |
35 #include "ui/base/resource/resource_bundle.h" | 35 #include "ui/base/resource/resource_bundle.h" |
36 #include "ui/compositor/layer.h" | 36 #include "ui/compositor/layer.h" |
37 #include "ui/compositor/layer_animator.h" | 37 #include "ui/compositor/layer_animator.h" |
| 38 #include "ui/compositor/layer_type.h" |
38 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 39 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
39 #include "ui/events/event_utils.h" | 40 #include "ui/events/event_utils.h" |
40 #include "ui/gfx/canvas.h" | 41 #include "ui/gfx/canvas.h" |
41 #include "ui/gfx/geometry/point.h" | 42 #include "ui/gfx/geometry/point.h" |
42 #include "ui/views/animation/bounds_animator.h" | 43 #include "ui/views/animation/bounds_animator.h" |
43 #include "ui/views/border.h" | 44 #include "ui/views/border.h" |
44 #include "ui/views/controls/button/image_button.h" | 45 #include "ui/views/controls/button/image_button.h" |
45 #include "ui/views/controls/menu/menu_model_adapter.h" | 46 #include "ui/views/controls/menu/menu_model_adapter.h" |
46 #include "ui/views/controls/menu/menu_runner.h" | 47 #include "ui/views/controls/menu/menu_runner.h" |
47 #include "ui/views/focus/focus_search.h" | 48 #include "ui/views/focus/focus_search.h" |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 bounds_animator_->RemoveObserver(this); | 399 bounds_animator_->RemoveObserver(this); |
399 model_->RemoveObserver(this); | 400 model_->RemoveObserver(this); |
400 } | 401 } |
401 | 402 |
402 void ShelfView::Init() { | 403 void ShelfView::Init() { |
403 model_->AddObserver(this); | 404 model_->AddObserver(this); |
404 | 405 |
405 const ShelfItems& items(model_->items()); | 406 const ShelfItems& items(model_->items()); |
406 for (ShelfItems::const_iterator i = items.begin(); i != items.end(); ++i) { | 407 for (ShelfItems::const_iterator i = items.begin(); i != items.end(); ++i) { |
407 views::View* child = CreateViewForItem(*i); | 408 views::View* child = CreateViewForItem(*i); |
408 child->SetPaintToLayer(true); | 409 child->SetPaintToLayer(ui::LAYER_TEXTURED); |
409 view_model_->Add(child, static_cast<int>(i - items.begin())); | 410 view_model_->Add(child, static_cast<int>(i - items.begin())); |
410 AddChildView(child); | 411 AddChildView(child); |
411 } | 412 } |
412 overflow_button_ = new OverflowButton(this, wm_shelf_); | 413 overflow_button_ = new OverflowButton(this, wm_shelf_); |
413 overflow_button_->set_context_menu_controller(this); | 414 overflow_button_->set_context_menu_controller(this); |
414 ConfigureChildView(overflow_button_); | 415 ConfigureChildView(overflow_button_); |
415 AddChildView(overflow_button_); | 416 AddChildView(overflow_button_); |
416 | 417 |
417 // We'll layout when our bounds change. | 418 // We'll layout when our bounds change. |
418 } | 419 } |
(...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1385 if (SameDragType(model_->items()[i].type, type)) { | 1386 if (SameDragType(model_->items()[i].type, type)) { |
1386 if (min_index == -1) | 1387 if (min_index == -1) |
1387 min_index = i; | 1388 min_index = i; |
1388 max_index = i; | 1389 max_index = i; |
1389 } | 1390 } |
1390 } | 1391 } |
1391 return std::pair<int, int>(min_index, max_index); | 1392 return std::pair<int, int>(min_index, max_index); |
1392 } | 1393 } |
1393 | 1394 |
1394 void ShelfView::ConfigureChildView(views::View* view) { | 1395 void ShelfView::ConfigureChildView(views::View* view) { |
1395 view->SetPaintToLayer(true); | 1396 view->SetPaintToLayer(ui::LAYER_TEXTURED); |
1396 view->layer()->SetFillsBoundsOpaquely(false); | 1397 view->layer()->SetFillsBoundsOpaquely(false); |
1397 } | 1398 } |
1398 | 1399 |
1399 void ShelfView::ToggleOverflowBubble() { | 1400 void ShelfView::ToggleOverflowBubble() { |
1400 if (IsShowingOverflowBubble()) { | 1401 if (IsShowingOverflowBubble()) { |
1401 overflow_bubble_->Hide(); | 1402 overflow_bubble_->Hide(); |
1402 return; | 1403 return; |
1403 } | 1404 } |
1404 | 1405 |
1405 if (!overflow_bubble_) | 1406 if (!overflow_bubble_) |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1878 | 1879 |
1879 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { | 1880 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { |
1880 const gfx::Rect bounds = GetBoundsInScreen(); | 1881 const gfx::Rect bounds = GetBoundsInScreen(); |
1881 int distance = wm_shelf_->SelectValueForShelfAlignment( | 1882 int distance = wm_shelf_->SelectValueForShelfAlignment( |
1882 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), | 1883 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), |
1883 bounds.x() - coordinate.x()); | 1884 bounds.x() - coordinate.x()); |
1884 return distance > 0 ? distance : 0; | 1885 return distance > 0 ? distance : 0; |
1885 } | 1886 } |
1886 | 1887 |
1887 } // namespace ash | 1888 } // namespace ash |
OLD | NEW |