| 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 | 8 |
| 9 #include "ash/ash_constants.h" | 9 #include "ash/ash_constants.h" |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| 11 #include "ash/drag_drop/drag_image_view.h" | 11 #include "ash/drag_drop/drag_image_view.h" |
| 12 #include "ash/metrics/user_metrics_recorder.h" | 12 #include "ash/metrics/user_metrics_recorder.h" |
| 13 #include "ash/root_window_controller.h" | |
| 14 #include "ash/scoped_target_root_window.h" | 13 #include "ash/scoped_target_root_window.h" |
| 15 #include "ash/shelf/app_list_button.h" | 14 #include "ash/shelf/app_list_button.h" |
| 16 #include "ash/shelf/overflow_bubble.h" | 15 #include "ash/shelf/overflow_bubble.h" |
| 17 #include "ash/shelf/overflow_bubble_view.h" | 16 #include "ash/shelf/overflow_bubble_view.h" |
| 18 #include "ash/shelf/overflow_button.h" | 17 #include "ash/shelf/overflow_button.h" |
| 18 #include "ash/shelf/shelf.h" |
| 19 #include "ash/shelf/shelf_button.h" | 19 #include "ash/shelf/shelf_button.h" |
| 20 #include "ash/shelf/shelf_constants.h" | 20 #include "ash/shelf/shelf_constants.h" |
| 21 #include "ash/shelf/shelf_delegate.h" | 21 #include "ash/shelf/shelf_delegate.h" |
| 22 #include "ash/shelf/shelf_icon_observer.h" | 22 #include "ash/shelf/shelf_icon_observer.h" |
| 23 #include "ash/shelf/shelf_item_delegate_manager.h" | 23 #include "ash/shelf/shelf_item_delegate_manager.h" |
| 24 #include "ash/shelf/shelf_layout_manager.h" | |
| 25 #include "ash/shelf/shelf_menu_model.h" | 24 #include "ash/shelf/shelf_menu_model.h" |
| 26 #include "ash/shelf/shelf_model.h" | 25 #include "ash/shelf/shelf_model.h" |
| 27 #include "ash/shelf/shelf_tooltip_manager.h" | 26 #include "ash/shelf/shelf_tooltip_manager.h" |
| 28 #include "ash/shelf/shelf_widget.h" | 27 #include "ash/shelf/shelf_widget.h" |
| 29 #include "ash/shell.h" | 28 #include "ash/shell.h" |
| 30 #include "ash/wm/coordinate_conversion.h" | 29 #include "ash/wm/coordinate_conversion.h" |
| 31 #include "base/auto_reset.h" | 30 #include "base/auto_reset.h" |
| 32 #include "base/memory/scoped_ptr.h" | 31 #include "base/memory/scoped_ptr.h" |
| 33 #include "base/metrics/histogram.h" | 32 #include "base/metrics/histogram.h" |
| 34 #include "grit/ash_strings.h" | 33 #include "grit/ash_strings.h" |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 view_->layer()->SetOpacity(1.0f); | 355 view_->layer()->SetOpacity(1.0f); |
| 357 } | 356 } |
| 358 | 357 |
| 359 private: | 358 private: |
| 360 ShelfView* shelf_view_; | 359 ShelfView* shelf_view_; |
| 361 views::View* view_; | 360 views::View* view_; |
| 362 | 361 |
| 363 DISALLOW_COPY_AND_ASSIGN(StartFadeAnimationDelegate); | 362 DISALLOW_COPY_AND_ASSIGN(StartFadeAnimationDelegate); |
| 364 }; | 363 }; |
| 365 | 364 |
| 366 ShelfView::ShelfView(ShelfModel* model, | 365 ShelfView::ShelfView(ShelfModel* model, ShelfDelegate* delegate, Shelf* shelf) |
| 367 ShelfDelegate* delegate, | |
| 368 ShelfLayoutManager* manager) | |
| 369 : model_(model), | 366 : model_(model), |
| 370 delegate_(delegate), | 367 delegate_(delegate), |
| 368 shelf_(shelf), |
| 371 view_model_(new views::ViewModel), | 369 view_model_(new views::ViewModel), |
| 372 first_visible_index_(0), | 370 first_visible_index_(0), |
| 373 last_visible_index_(-1), | 371 last_visible_index_(-1), |
| 374 overflow_button_(NULL), | 372 overflow_button_(NULL), |
| 375 owner_overflow_bubble_(NULL), | 373 owner_overflow_bubble_(NULL), |
| 376 drag_pointer_(NONE), | 374 drag_pointer_(NONE), |
| 377 drag_view_(NULL), | 375 drag_view_(NULL), |
| 378 start_drag_index_(-1), | 376 start_drag_index_(-1), |
| 379 context_menu_id_(0), | 377 context_menu_id_(0), |
| 380 leading_inset_(kDefaultLeadingInset), | 378 leading_inset_(kDefaultLeadingInset), |
| 381 cancelling_drag_model_changed_(false), | 379 cancelling_drag_model_changed_(false), |
| 382 last_hidden_index_(0), | 380 last_hidden_index_(0), |
| 383 closing_event_time_(base::TimeDelta()), | 381 closing_event_time_(base::TimeDelta()), |
| 384 got_deleted_(NULL), | 382 got_deleted_(NULL), |
| 385 drag_and_drop_item_pinned_(false), | 383 drag_and_drop_item_pinned_(false), |
| 386 drag_and_drop_shelf_id_(0), | 384 drag_and_drop_shelf_id_(0), |
| 387 drag_replaced_view_(nullptr), | 385 drag_replaced_view_(nullptr), |
| 388 dragged_off_shelf_(false), | 386 dragged_off_shelf_(false), |
| 389 snap_back_from_rip_off_view_(NULL), | 387 snap_back_from_rip_off_view_(NULL), |
| 390 item_manager_(Shell::GetInstance()->shelf_item_delegate_manager()), | 388 item_manager_(Shell::GetInstance()->shelf_item_delegate_manager()), |
| 391 layout_manager_(manager), | |
| 392 overflow_mode_(false), | 389 overflow_mode_(false), |
| 393 main_shelf_(NULL), | 390 main_shelf_(NULL), |
| 394 dragged_off_from_overflow_to_shelf_(false), | 391 dragged_off_from_overflow_to_shelf_(false), |
| 395 is_repost_event_(false), | 392 is_repost_event_(false), |
| 396 last_pressed_index_(-1) { | 393 last_pressed_index_(-1) { |
| 397 DCHECK(model_); | 394 DCHECK(model_); |
| 398 bounds_animator_.reset(new views::BoundsAnimator(this)); | 395 bounds_animator_.reset(new views::BoundsAnimator(this)); |
| 399 bounds_animator_->AddObserver(this); | 396 bounds_animator_->AddObserver(this); |
| 400 set_context_menu_controller(this); | 397 set_context_menu_controller(this); |
| 401 focus_search_.reset(new ShelfFocusSearch(view_model_.get())); | 398 focus_search_.reset(new ShelfFocusSearch(view_model_.get())); |
| 402 tooltip_.reset(new ShelfTooltipManager(manager, this)); | 399 tooltip_.reset(new ShelfTooltipManager(shelf->shelf_layout_manager(), this)); |
| 403 } | 400 } |
| 404 | 401 |
| 405 ShelfView::~ShelfView() { | 402 ShelfView::~ShelfView() { |
| 406 bounds_animator_->RemoveObserver(this); | 403 bounds_animator_->RemoveObserver(this); |
| 407 model_->RemoveObserver(this); | 404 model_->RemoveObserver(this); |
| 408 // If we are inside the MenuRunner, we need to know if we were getting | 405 // If we are inside the MenuRunner, we need to know if we were getting |
| 409 // deleted while it was running. | 406 // deleted while it was running. |
| 410 if (got_deleted_) | 407 if (got_deleted_) |
| 411 *got_deleted_ = true; | 408 *got_deleted_ = true; |
| 412 } | 409 } |
| 413 | 410 |
| 414 void ShelfView::Init() { | 411 void ShelfView::Init() { |
| 415 model_->AddObserver(this); | 412 model_->AddObserver(this); |
| 416 | 413 |
| 417 const ShelfItems& items(model_->items()); | 414 const ShelfItems& items(model_->items()); |
| 418 for (ShelfItems::const_iterator i = items.begin(); i != items.end(); ++i) { | 415 for (ShelfItems::const_iterator i = items.begin(); i != items.end(); ++i) { |
| 419 views::View* child = CreateViewForItem(*i); | 416 views::View* child = CreateViewForItem(*i); |
| 420 child->SetPaintToLayer(true); | 417 child->SetPaintToLayer(true); |
| 421 view_model_->Add(child, static_cast<int>(i - items.begin())); | 418 view_model_->Add(child, static_cast<int>(i - items.begin())); |
| 422 AddChildView(child); | 419 AddChildView(child); |
| 423 } | 420 } |
| 424 overflow_button_ = new OverflowButton(this, shelf_layout_manager()); | 421 overflow_button_ = new OverflowButton(this, shelf_); |
| 425 overflow_button_->set_context_menu_controller(this); | 422 overflow_button_->set_context_menu_controller(this); |
| 426 ConfigureChildView(overflow_button_); | 423 ConfigureChildView(overflow_button_); |
| 427 AddChildView(overflow_button_); | 424 AddChildView(overflow_button_); |
| 428 | 425 |
| 429 // We'll layout when our bounds change. | 426 // We'll layout when our bounds change. |
| 430 } | 427 } |
| 431 | 428 |
| 432 void ShelfView::OnShelfAlignmentChanged() { | 429 void ShelfView::OnShelfAlignmentChanged() { |
| 433 overflow_button_->OnShelfAlignmentChanged(); | 430 overflow_button_->OnShelfAlignmentChanged(); |
| 434 LayoutToIdealBounds(); | 431 LayoutToIdealBounds(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 const gfx::Point& midpoint) { | 476 const gfx::Point& midpoint) { |
| 480 int current_index = model_->ItemIndexByID(id); | 477 int current_index = model_->ItemIndexByID(id); |
| 481 int first_panel_index = model_->FirstPanelIndex(); | 478 int first_panel_index = model_->FirstPanelIndex(); |
| 482 if (current_index < first_panel_index) | 479 if (current_index < first_panel_index) |
| 483 return; | 480 return; |
| 484 | 481 |
| 485 gfx::Point midpoint_in_view(GetMirroredXInView(midpoint.x()), | 482 gfx::Point midpoint_in_view(GetMirroredXInView(midpoint.x()), |
| 486 midpoint.y()); | 483 midpoint.y()); |
| 487 int target_index = current_index; | 484 int target_index = current_index; |
| 488 while (target_index > first_panel_index && | 485 while (target_index > first_panel_index && |
| 489 layout_manager_->PrimaryAxisValue( | 486 shelf_->PrimaryAxisValue(view_model_->ideal_bounds(target_index).x(), |
| 490 view_model_->ideal_bounds(target_index).x(), | 487 view_model_->ideal_bounds(target_index).y()) > |
| 491 view_model_->ideal_bounds(target_index).y()) > | 488 shelf_->PrimaryAxisValue(midpoint_in_view.x(), |
| 492 layout_manager_->PrimaryAxisValue(midpoint_in_view.x(), | 489 midpoint_in_view.y())) { |
| 493 midpoint_in_view.y())) { | |
| 494 --target_index; | 490 --target_index; |
| 495 } | 491 } |
| 496 while (target_index < view_model_->view_size() - 1 && | 492 while (target_index < view_model_->view_size() - 1 && |
| 497 layout_manager_->PrimaryAxisValue( | 493 shelf_->PrimaryAxisValue( |
| 498 view_model_->ideal_bounds(target_index).right(), | 494 view_model_->ideal_bounds(target_index).right(), |
| 499 view_model_->ideal_bounds(target_index).bottom()) < | 495 view_model_->ideal_bounds(target_index).bottom()) < |
| 500 layout_manager_->PrimaryAxisValue(midpoint_in_view.x(), | 496 shelf_->PrimaryAxisValue(midpoint_in_view.x(), |
| 501 midpoint_in_view.y())) { | 497 midpoint_in_view.y())) { |
| 502 ++target_index; | 498 ++target_index; |
| 503 } | 499 } |
| 504 if (current_index != target_index) | 500 if (current_index != target_index) |
| 505 model_->Move(current_index, target_index); | 501 model_->Move(current_index, target_index); |
| 506 } | 502 } |
| 507 | 503 |
| 508 bool ShelfView::IsShowingMenu() const { | 504 bool ShelfView::IsShowingMenu() const { |
| 509 return (launcher_menu_runner_.get() && | 505 return (launcher_menu_runner_.get() && |
| 510 launcher_menu_runner_->IsRunning()); | 506 launcher_menu_runner_->IsRunning()); |
| 511 } | 507 } |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 // should be always true regardless of its position. | 699 // should be always true regardless of its position. |
| 704 if (dragged_off_from_overflow_to_shelf_ && | 700 if (dragged_off_from_overflow_to_shelf_ && |
| 705 view_model_->view_at(i) == drag_view_) | 701 view_model_->view_at(i) == drag_view_) |
| 706 view_model_->view_at(i)->SetVisible(true); | 702 view_model_->view_at(i)->SetVisible(true); |
| 707 else | 703 else |
| 708 view_model_->view_at(i)->SetVisible(visible); | 704 view_model_->view_at(i)->SetVisible(visible); |
| 709 } | 705 } |
| 710 } | 706 } |
| 711 | 707 |
| 712 void ShelfView::CalculateIdealBounds(IdealBounds* bounds) const { | 708 void ShelfView::CalculateIdealBounds(IdealBounds* bounds) const { |
| 713 int available_size = layout_manager_->PrimaryAxisValue(width(), height()); | 709 int available_size = shelf_->PrimaryAxisValue(width(), height()); |
| 714 DCHECK(model_->item_count() == view_model_->view_size()); | 710 DCHECK(model_->item_count() == view_model_->view_size()); |
| 715 if (!available_size) | 711 if (!available_size) |
| 716 return; | 712 return; |
| 717 | 713 |
| 718 int first_panel_index = model_->FirstPanelIndex(); | 714 int first_panel_index = model_->FirstPanelIndex(); |
| 719 int last_button_index = first_panel_index - 1; | 715 int last_button_index = first_panel_index - 1; |
| 720 | 716 |
| 721 int x = 0; | 717 int x = 0; |
| 722 int y = 0; | 718 int y = 0; |
| 723 int button_size = kShelfButtonSize; | 719 int button_size = kShelfButtonSize; |
| 724 int button_spacing = kShelfButtonSpacing; | 720 int button_spacing = kShelfButtonSpacing; |
| 725 | 721 |
| 726 int w = layout_manager_->PrimaryAxisValue(button_size, width()); | 722 int w = shelf_->PrimaryAxisValue(button_size, width()); |
| 727 int h = layout_manager_->PrimaryAxisValue(height(), button_size); | 723 int h = shelf_->PrimaryAxisValue(height(), button_size); |
| 728 for (int i = 0; i < view_model_->view_size(); ++i) { | 724 for (int i = 0; i < view_model_->view_size(); ++i) { |
| 729 if (i < first_visible_index_) { | 725 if (i < first_visible_index_) { |
| 730 view_model_->set_ideal_bounds(i, gfx::Rect(x, y, 0, 0)); | 726 view_model_->set_ideal_bounds(i, gfx::Rect(x, y, 0, 0)); |
| 731 continue; | 727 continue; |
| 732 } | 728 } |
| 733 | 729 |
| 734 view_model_->set_ideal_bounds(i, gfx::Rect(x, y, w, h)); | 730 view_model_->set_ideal_bounds(i, gfx::Rect(x, y, w, h)); |
| 735 x = layout_manager_->PrimaryAxisValue(x + w + button_spacing, x); | 731 x = shelf_->PrimaryAxisValue(x + w + button_spacing, x); |
| 736 y = layout_manager_->PrimaryAxisValue(y, y + h + button_spacing); | 732 y = shelf_->PrimaryAxisValue(y, y + h + button_spacing); |
| 737 } | 733 } |
| 738 | 734 |
| 739 if (is_overflow_mode()) { | 735 if (is_overflow_mode()) { |
| 740 const_cast<ShelfView*>(this)->UpdateAllButtonsVisibilityInOverflowMode(); | 736 const_cast<ShelfView*>(this)->UpdateAllButtonsVisibilityInOverflowMode(); |
| 741 return; | 737 return; |
| 742 } | 738 } |
| 743 | 739 |
| 744 // Right aligned icons. | 740 // Right aligned icons. |
| 745 int end_position = available_size - button_spacing; | 741 int end_position = available_size - button_spacing; |
| 746 x = layout_manager_->PrimaryAxisValue(end_position, 0); | 742 x = shelf_->PrimaryAxisValue(end_position, 0); |
| 747 y = layout_manager_->PrimaryAxisValue(0, end_position); | 743 y = shelf_->PrimaryAxisValue(0, end_position); |
| 748 for (int i = view_model_->view_size() - 1; | 744 for (int i = view_model_->view_size() - 1; |
| 749 i >= first_panel_index; --i) { | 745 i >= first_panel_index; --i) { |
| 750 x = layout_manager_->PrimaryAxisValue(x - w - button_spacing, x); | 746 x = shelf_->PrimaryAxisValue(x - w - button_spacing, x); |
| 751 y = layout_manager_->PrimaryAxisValue(y, y - h - button_spacing); | 747 y = shelf_->PrimaryAxisValue(y, y - h - button_spacing); |
| 752 view_model_->set_ideal_bounds(i, gfx::Rect(x, y, w, h)); | 748 view_model_->set_ideal_bounds(i, gfx::Rect(x, y, w, h)); |
| 753 end_position = layout_manager_->PrimaryAxisValue(x, y); | 749 end_position = shelf_->PrimaryAxisValue(x, y); |
| 754 } | 750 } |
| 755 | 751 |
| 756 // Icons on the left / top are guaranteed up to kLeftIconProportion of | 752 // Icons on the left / top are guaranteed up to kLeftIconProportion of |
| 757 // the available space. | 753 // the available space. |
| 758 int last_icon_position = layout_manager_->PrimaryAxisValue( | 754 int last_icon_position = |
| 759 view_model_->ideal_bounds(last_button_index).right(), | 755 shelf_->PrimaryAxisValue( |
| 760 view_model_->ideal_bounds(last_button_index).bottom()) + button_size; | 756 view_model_->ideal_bounds(last_button_index).right(), |
| 757 view_model_->ideal_bounds(last_button_index).bottom()) + |
| 758 button_size; |
| 761 int reserved_icon_space = available_size * kReservedNonPanelIconProportion; | 759 int reserved_icon_space = available_size * kReservedNonPanelIconProportion; |
| 762 if (last_icon_position < reserved_icon_space) | 760 if (last_icon_position < reserved_icon_space) |
| 763 end_position = last_icon_position; | 761 end_position = last_icon_position; |
| 764 else | 762 else |
| 765 end_position = std::max(end_position, reserved_icon_space); | 763 end_position = std::max(end_position, reserved_icon_space); |
| 766 | 764 |
| 767 bounds->overflow_bounds.set_size( | 765 bounds->overflow_bounds.set_size( |
| 768 gfx::Size(layout_manager_->PrimaryAxisValue(w, width()), | 766 gfx::Size(shelf_->PrimaryAxisValue(w, width()), |
| 769 layout_manager_->PrimaryAxisValue(height(), h))); | 767 shelf_->PrimaryAxisValue(height(), h))); |
| 770 | 768 |
| 771 last_visible_index_ = DetermineLastVisibleIndex( | 769 last_visible_index_ = DetermineLastVisibleIndex( |
| 772 end_position - button_size); | 770 end_position - button_size); |
| 773 last_hidden_index_ = DetermineFirstVisiblePanelIndex(end_position) - 1; | 771 last_hidden_index_ = DetermineFirstVisiblePanelIndex(end_position) - 1; |
| 774 bool show_overflow = last_visible_index_ < last_button_index || | 772 bool show_overflow = last_visible_index_ < last_button_index || |
| 775 last_hidden_index_ >= first_panel_index; | 773 last_hidden_index_ >= first_panel_index; |
| 776 | 774 |
| 777 // Create Space for the overflow button | 775 // Create Space for the overflow button |
| 778 if (show_overflow) { | 776 if (show_overflow) { |
| 779 // The following code makes sure that platform apps icons (aligned to left / | 777 // The following code makes sure that platform apps icons (aligned to left / |
| (...skipping 27 matching lines...) Expand all Loading... |
| 807 view_model_->view_at(i)->SetVisible(visible); | 805 view_model_->view_at(i)->SetVisible(visible); |
| 808 } | 806 } |
| 809 | 807 |
| 810 overflow_button_->SetVisible(show_overflow); | 808 overflow_button_->SetVisible(show_overflow); |
| 811 if (show_overflow) { | 809 if (show_overflow) { |
| 812 DCHECK_NE(0, view_model_->view_size()); | 810 DCHECK_NE(0, view_model_->view_size()); |
| 813 if (last_visible_index_ == -1) { | 811 if (last_visible_index_ == -1) { |
| 814 x = 0; | 812 x = 0; |
| 815 y = 0; | 813 y = 0; |
| 816 } else { | 814 } else { |
| 817 x = layout_manager_->PrimaryAxisValue( | 815 x = shelf_->PrimaryAxisValue( |
| 818 view_model_->ideal_bounds(last_visible_index_).right(), | 816 view_model_->ideal_bounds(last_visible_index_).right(), |
| 819 view_model_->ideal_bounds(last_visible_index_).x()); | 817 view_model_->ideal_bounds(last_visible_index_).x()); |
| 820 y = layout_manager_->PrimaryAxisValue( | 818 y = shelf_->PrimaryAxisValue( |
| 821 view_model_->ideal_bounds(last_visible_index_).y(), | 819 view_model_->ideal_bounds(last_visible_index_).y(), |
| 822 view_model_->ideal_bounds(last_visible_index_).bottom()); | 820 view_model_->ideal_bounds(last_visible_index_).bottom()); |
| 823 } | 821 } |
| 824 // Set all hidden panel icon positions to be on the overflow button. | 822 // Set all hidden panel icon positions to be on the overflow button. |
| 825 for (int i = first_panel_index; i <= last_hidden_index_; ++i) | 823 for (int i = first_panel_index; i <= last_hidden_index_; ++i) |
| 826 view_model_->set_ideal_bounds(i, gfx::Rect(x, y, w, h)); | 824 view_model_->set_ideal_bounds(i, gfx::Rect(x, y, w, h)); |
| 827 | 825 |
| 828 // Add more space between last visible item and overflow button. | 826 // Add more space between last visible item and overflow button. |
| 829 // Without this, two buttons look too close compared with other items. | 827 // Without this, two buttons look too close compared with other items. |
| 830 x = layout_manager_->PrimaryAxisValue(x + button_spacing, x); | 828 x = shelf_->PrimaryAxisValue(x + button_spacing, x); |
| 831 y = layout_manager_->PrimaryAxisValue(y, y + button_spacing); | 829 y = shelf_->PrimaryAxisValue(y, y + button_spacing); |
| 832 | 830 |
| 833 bounds->overflow_bounds.set_x(x); | 831 bounds->overflow_bounds.set_x(x); |
| 834 bounds->overflow_bounds.set_y(y); | 832 bounds->overflow_bounds.set_y(y); |
| 835 if (overflow_bubble_.get() && overflow_bubble_->IsShowing()) | 833 if (overflow_bubble_.get() && overflow_bubble_->IsShowing()) |
| 836 UpdateOverflowRange(overflow_bubble_->shelf_view()); | 834 UpdateOverflowRange(overflow_bubble_->shelf_view()); |
| 837 } else { | 835 } else { |
| 838 if (overflow_bubble_) | 836 if (overflow_bubble_) |
| 839 overflow_bubble_->Hide(); | 837 overflow_bubble_->Hide(); |
| 840 } | 838 } |
| 841 } | 839 } |
| 842 | 840 |
| 843 int ShelfView::DetermineLastVisibleIndex(int max_value) const { | 841 int ShelfView::DetermineLastVisibleIndex(int max_value) const { |
| 844 int index = model_->FirstPanelIndex() - 1; | 842 int index = model_->FirstPanelIndex() - 1; |
| 845 while (index >= 0 && | 843 while (index >= 0 && |
| 846 layout_manager_->PrimaryAxisValue( | 844 shelf_->PrimaryAxisValue(view_model_->ideal_bounds(index).right(), |
| 847 view_model_->ideal_bounds(index).right(), | 845 view_model_->ideal_bounds(index).bottom()) > |
| 848 view_model_->ideal_bounds(index).bottom()) > max_value) { | 846 max_value) { |
| 849 index--; | 847 index--; |
| 850 } | 848 } |
| 851 return index; | 849 return index; |
| 852 } | 850 } |
| 853 | 851 |
| 854 int ShelfView::DetermineFirstVisiblePanelIndex(int min_value) const { | 852 int ShelfView::DetermineFirstVisiblePanelIndex(int min_value) const { |
| 855 int index = model_->FirstPanelIndex(); | 853 int index = model_->FirstPanelIndex(); |
| 856 while (index < view_model_->view_size() && | 854 while (index < view_model_->view_size() && |
| 857 layout_manager_->PrimaryAxisValue( | 855 shelf_->PrimaryAxisValue(view_model_->ideal_bounds(index).right(), |
| 858 view_model_->ideal_bounds(index).right(), | 856 view_model_->ideal_bounds(index).bottom()) < |
| 859 view_model_->ideal_bounds(index).bottom()) < min_value) { | 857 min_value) { |
| 860 ++index; | 858 ++index; |
| 861 } | 859 } |
| 862 return index; | 860 return index; |
| 863 } | 861 } |
| 864 | 862 |
| 865 void ShelfView::AddIconObserver(ShelfIconObserver* observer) { | 863 void ShelfView::AddIconObserver(ShelfIconObserver* observer) { |
| 866 observers_.AddObserver(observer); | 864 observers_.AddObserver(observer); |
| 867 } | 865 } |
| 868 | 866 |
| 869 void ShelfView::RemoveIconObserver(ShelfIconObserver* observer) { | 867 void ShelfView::RemoveIconObserver(ShelfIconObserver* observer) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 886 | 884 |
| 887 views::View* ShelfView::CreateViewForItem(const ShelfItem& item) { | 885 views::View* ShelfView::CreateViewForItem(const ShelfItem& item) { |
| 888 views::View* view = NULL; | 886 views::View* view = NULL; |
| 889 switch (item.type) { | 887 switch (item.type) { |
| 890 case TYPE_BROWSER_SHORTCUT: | 888 case TYPE_BROWSER_SHORTCUT: |
| 891 case TYPE_APP_SHORTCUT: | 889 case TYPE_APP_SHORTCUT: |
| 892 case TYPE_WINDOWED_APP: | 890 case TYPE_WINDOWED_APP: |
| 893 case TYPE_PLATFORM_APP: | 891 case TYPE_PLATFORM_APP: |
| 894 case TYPE_DIALOG: | 892 case TYPE_DIALOG: |
| 895 case TYPE_APP_PANEL: { | 893 case TYPE_APP_PANEL: { |
| 896 ShelfButton* button = ShelfButton::Create(this, this, layout_manager_); | 894 ShelfButton* button = ShelfButton::Create(this, this, shelf_); |
| 897 button->SetImage(item.image); | 895 button->SetImage(item.image); |
| 898 ReflectItemStatus(item, button); | 896 ReflectItemStatus(item, button); |
| 899 view = button; | 897 view = button; |
| 900 break; | 898 break; |
| 901 } | 899 } |
| 902 | 900 |
| 903 case TYPE_APP_LIST: { | 901 case TYPE_APP_LIST: { |
| 904 view = new AppListButton(this, this, layout_manager_->shelf_widget()); | 902 view = new AppListButton(this, this, shelf_->shelf_widget()); |
| 905 break; | 903 break; |
| 906 } | 904 } |
| 907 | 905 |
| 908 default: | 906 default: |
| 909 break; | 907 break; |
| 910 } | 908 } |
| 911 view->set_context_menu_controller(this); | 909 view->set_context_menu_controller(this); |
| 912 | 910 |
| 913 DCHECK(view); | 911 DCHECK(view); |
| 914 ConfigureChildView(view); | 912 ConfigureChildView(view); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 978 // Constrain the location to the range of valid indices for the type. | 976 // Constrain the location to the range of valid indices for the type. |
| 979 std::pair<int, int> indices(GetDragRange(current_index)); | 977 std::pair<int, int> indices(GetDragRange(current_index)); |
| 980 int first_drag_index = indices.first; | 978 int first_drag_index = indices.first; |
| 981 int last_drag_index = indices.second; | 979 int last_drag_index = indices.second; |
| 982 // If the last index isn't valid, we're overflowing. Constrain to the app list | 980 // If the last index isn't valid, we're overflowing. Constrain to the app list |
| 983 // (which is the last visible item). | 981 // (which is the last visible item). |
| 984 if (first_drag_index < model_->FirstPanelIndex() && | 982 if (first_drag_index < model_->FirstPanelIndex() && |
| 985 last_drag_index > last_visible_index_) | 983 last_drag_index > last_visible_index_) |
| 986 last_drag_index = last_visible_index_; | 984 last_drag_index = last_visible_index_; |
| 987 int x = 0, y = 0; | 985 int x = 0, y = 0; |
| 988 if (layout_manager_->IsHorizontalAlignment()) { | 986 if (shelf_->IsHorizontalAlignment()) { |
| 989 x = std::max(view_model_->ideal_bounds(indices.first).x(), | 987 x = std::max(view_model_->ideal_bounds(indices.first).x(), |
| 990 drag_point.x() - drag_origin_.x()); | 988 drag_point.x() - drag_origin_.x()); |
| 991 x = std::min(view_model_->ideal_bounds(last_drag_index).right() - | 989 x = std::min(view_model_->ideal_bounds(last_drag_index).right() - |
| 992 view_model_->ideal_bounds(current_index).width(), | 990 view_model_->ideal_bounds(current_index).width(), |
| 993 x); | 991 x); |
| 994 if (drag_view_->x() == x) | 992 if (drag_view_->x() == x) |
| 995 return; | 993 return; |
| 996 drag_view_->SetX(x); | 994 drag_view_->SetX(x); |
| 997 } else { | 995 } else { |
| 998 y = std::max(view_model_->ideal_bounds(indices.first).y(), | 996 y = std::max(view_model_->ideal_bounds(indices.first).y(), |
| 999 drag_point.y() - drag_origin_.y()); | 997 drag_point.y() - drag_origin_.y()); |
| 1000 y = std::min(view_model_->ideal_bounds(last_drag_index).bottom() - | 998 y = std::min(view_model_->ideal_bounds(last_drag_index).bottom() - |
| 1001 view_model_->ideal_bounds(current_index).height(), | 999 view_model_->ideal_bounds(current_index).height(), |
| 1002 y); | 1000 y); |
| 1003 if (drag_view_->y() == y) | 1001 if (drag_view_->y() == y) |
| 1004 return; | 1002 return; |
| 1005 drag_view_->SetY(y); | 1003 drag_view_->SetY(y); |
| 1006 } | 1004 } |
| 1007 | 1005 |
| 1008 int target_index = | 1006 int target_index = views::ViewModelUtils::DetermineMoveIndex( |
| 1009 views::ViewModelUtils::DetermineMoveIndex( | 1007 *view_model_, drag_view_, |
| 1010 *view_model_, drag_view_, | 1008 shelf_->IsHorizontalAlignment() ? views::ViewModelUtils::HORIZONTAL |
| 1011 layout_manager_->IsHorizontalAlignment() ? | 1009 : views::ViewModelUtils::VERTICAL, |
| 1012 views::ViewModelUtils::HORIZONTAL : | 1010 x, y); |
| 1013 views::ViewModelUtils::VERTICAL, | |
| 1014 x, y); | |
| 1015 target_index = | 1011 target_index = |
| 1016 std::min(indices.second, std::max(target_index, indices.first)); | 1012 std::min(indices.second, std::max(target_index, indices.first)); |
| 1017 | 1013 |
| 1018 int first_draggable_item = 0; | 1014 int first_draggable_item = 0; |
| 1019 while (first_draggable_item < static_cast<int>(model_->items().size()) && | 1015 while (first_draggable_item < static_cast<int>(model_->items().size()) && |
| 1020 !item_manager_->GetShelfItemDelegate( | 1016 !item_manager_->GetShelfItemDelegate( |
| 1021 model_->items()[first_draggable_item].id) | 1017 model_->items()[first_draggable_item].id) |
| 1022 ->IsDraggable()) { | 1018 ->IsDraggable()) { |
| 1023 first_draggable_item++; | 1019 first_draggable_item++; |
| 1024 } | 1020 } |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1251 | 1247 |
| 1252 void ShelfView::ToggleOverflowBubble() { | 1248 void ShelfView::ToggleOverflowBubble() { |
| 1253 if (IsShowingOverflowBubble()) { | 1249 if (IsShowingOverflowBubble()) { |
| 1254 overflow_bubble_->Hide(); | 1250 overflow_bubble_->Hide(); |
| 1255 return; | 1251 return; |
| 1256 } | 1252 } |
| 1257 | 1253 |
| 1258 if (!overflow_bubble_) | 1254 if (!overflow_bubble_) |
| 1259 overflow_bubble_.reset(new OverflowBubble()); | 1255 overflow_bubble_.reset(new OverflowBubble()); |
| 1260 | 1256 |
| 1261 ShelfView* overflow_view = | 1257 ShelfView* overflow_view = new ShelfView(model_, delegate_, shelf_); |
| 1262 new ShelfView(model_, delegate_, layout_manager_); | |
| 1263 overflow_view->overflow_mode_ = true; | 1258 overflow_view->overflow_mode_ = true; |
| 1264 overflow_view->Init(); | 1259 overflow_view->Init(); |
| 1265 overflow_view->set_owner_overflow_bubble(overflow_bubble_.get()); | 1260 overflow_view->set_owner_overflow_bubble(overflow_bubble_.get()); |
| 1266 overflow_view->OnShelfAlignmentChanged(); | 1261 overflow_view->OnShelfAlignmentChanged(); |
| 1267 overflow_view->main_shelf_ = this; | 1262 overflow_view->main_shelf_ = this; |
| 1268 UpdateOverflowRange(overflow_view); | 1263 UpdateOverflowRange(overflow_view); |
| 1269 | 1264 |
| 1270 overflow_bubble_->Show(overflow_button_, overflow_view); | 1265 overflow_bubble_->Show(overflow_button_, overflow_view); |
| 1271 | 1266 |
| 1272 Shell::GetInstance()->UpdateShelfVisibility(); | 1267 Shell::GetInstance()->UpdateShelfVisibility(); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1335 const int last_button_index = view_model_->view_size() - 1; | 1330 const int last_button_index = view_model_->view_size() - 1; |
| 1336 gfx::Rect last_button_bounds = | 1331 gfx::Rect last_button_bounds = |
| 1337 view_model_->view_at(last_button_index)->bounds(); | 1332 view_model_->view_at(last_button_index)->bounds(); |
| 1338 if (overflow_button_->visible() && | 1333 if (overflow_button_->visible() && |
| 1339 model_->GetItemIndexForType(TYPE_APP_PANEL) == -1) { | 1334 model_->GetItemIndexForType(TYPE_APP_PANEL) == -1) { |
| 1340 // When overflow button is visible and shelf has no panel items, | 1335 // When overflow button is visible and shelf has no panel items, |
| 1341 // last_button_bounds should be overflow button's bounds. | 1336 // last_button_bounds should be overflow button's bounds. |
| 1342 last_button_bounds = overflow_button_->bounds(); | 1337 last_button_bounds = overflow_button_->bounds(); |
| 1343 } | 1338 } |
| 1344 | 1339 |
| 1345 if (layout_manager_->IsHorizontalAlignment()) { | 1340 if (shelf_->IsHorizontalAlignment()) { |
| 1346 preferred_size = gfx::Size(last_button_bounds.right() + leading_inset_, | 1341 preferred_size = gfx::Size(last_button_bounds.right() + leading_inset_, |
| 1347 kShelfSize); | 1342 kShelfSize); |
| 1348 } else { | 1343 } else { |
| 1349 preferred_size = gfx::Size(kShelfSize, | 1344 preferred_size = gfx::Size(kShelfSize, |
| 1350 last_button_bounds.bottom() + leading_inset_); | 1345 last_button_bounds.bottom() + leading_inset_); |
| 1351 } | 1346 } |
| 1352 } | 1347 } |
| 1353 gfx::Point origin(GetMirroredXWithWidthInView(0, preferred_size.width()), 0); | 1348 gfx::Point origin(GetMirroredXWithWidthInView(0, preferred_size.width()), 0); |
| 1354 | 1349 |
| 1355 // In overflow mode, we should use OverflowBubbleView as a source for | 1350 // In overflow mode, we should use OverflowBubbleView as a source for |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1409 dragged_off_shelf_ && | 1404 dragged_off_shelf_ && |
| 1410 !dragged_off_from_overflow_to_shelf_ && | 1405 !dragged_off_from_overflow_to_shelf_ && |
| 1411 RemovableByRipOff(view_model_->GetIndexOfView(drag_view_)) == REMOVABLE) | 1406 RemovableByRipOff(view_model_->GetIndexOfView(drag_view_)) == REMOVABLE) |
| 1412 last_button_index--; | 1407 last_button_index--; |
| 1413 | 1408 |
| 1414 const gfx::Rect last_button_bounds = | 1409 const gfx::Rect last_button_bounds = |
| 1415 last_button_index >= first_visible_index_ ? | 1410 last_button_index >= first_visible_index_ ? |
| 1416 view_model_->ideal_bounds(last_button_index) : | 1411 view_model_->ideal_bounds(last_button_index) : |
| 1417 gfx::Rect(gfx::Size(kShelfSize, kShelfSize)); | 1412 gfx::Rect(gfx::Size(kShelfSize, kShelfSize)); |
| 1418 | 1413 |
| 1419 if (layout_manager_->IsHorizontalAlignment()) { | 1414 if (shelf_->IsHorizontalAlignment()) |
| 1420 return gfx::Size(last_button_bounds.right() + leading_inset_, kShelfSize); | 1415 return gfx::Size(last_button_bounds.right() + leading_inset_, kShelfSize); |
| 1421 } | |
| 1422 | 1416 |
| 1423 return gfx::Size(kShelfSize, | 1417 return gfx::Size(kShelfSize, |
| 1424 last_button_bounds.bottom() + leading_inset_); | 1418 last_button_bounds.bottom() + leading_inset_); |
| 1425 } | 1419 } |
| 1426 | 1420 |
| 1427 void ShelfView::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 1421 void ShelfView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
| 1428 // This bounds change is produced by the shelf movement and all content has | 1422 // This bounds change is produced by the shelf movement and all content has |
| 1429 // to follow. Using an animation at that time would produce a time lag since | 1423 // to follow. Using an animation at that time would produce a time lag since |
| 1430 // the animation of the BoundsAnimator has itself a delay before it arrives | 1424 // the animation of the BoundsAnimator has itself a delay before it arrives |
| 1431 // at the required location. As such we tell the animator to go there | 1425 // at the required location. As such we tell the animator to go there |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1612 return; // View is being deleted or not draggable, ignore request. | 1606 return; // View is being deleted or not draggable, ignore request. |
| 1613 | 1607 |
| 1614 // Only when the repost event occurs on the same shelf item, we should ignore | 1608 // Only when the repost event occurs on the same shelf item, we should ignore |
| 1615 // the call in ShelfView::ButtonPressed(...). | 1609 // the call in ShelfView::ButtonPressed(...). |
| 1616 is_repost_event_ = IsRepostEvent(event) && (last_pressed_index_ == index); | 1610 is_repost_event_ = IsRepostEvent(event) && (last_pressed_index_ == index); |
| 1617 | 1611 |
| 1618 CHECK_EQ(ShelfButton::kViewClassName, view->GetClassName()); | 1612 CHECK_EQ(ShelfButton::kViewClassName, view->GetClassName()); |
| 1619 drag_view_ = static_cast<ShelfButton*>(view); | 1613 drag_view_ = static_cast<ShelfButton*>(view); |
| 1620 drag_origin_ = gfx::Point(event.x(), event.y()); | 1614 drag_origin_ = gfx::Point(event.x(), event.y()); |
| 1621 UMA_HISTOGRAM_ENUMERATION("Ash.ShelfAlignmentUsage", | 1615 UMA_HISTOGRAM_ENUMERATION("Ash.ShelfAlignmentUsage", |
| 1622 layout_manager_->SelectValueForShelfAlignment( | 1616 shelf_->SelectValueForShelfAlignment( |
| 1623 SHELF_ALIGNMENT_UMA_ENUM_VALUE_BOTTOM, | 1617 SHELF_ALIGNMENT_UMA_ENUM_VALUE_BOTTOM, |
| 1624 SHELF_ALIGNMENT_UMA_ENUM_VALUE_LEFT, | 1618 SHELF_ALIGNMENT_UMA_ENUM_VALUE_LEFT, |
| 1625 SHELF_ALIGNMENT_UMA_ENUM_VALUE_RIGHT, | 1619 SHELF_ALIGNMENT_UMA_ENUM_VALUE_RIGHT, -1), |
| 1626 -1), | 1620 SHELF_ALIGNMENT_UMA_ENUM_VALUE_COUNT); |
| 1627 SHELF_ALIGNMENT_UMA_ENUM_VALUE_COUNT); | |
| 1628 } | 1621 } |
| 1629 | 1622 |
| 1630 void ShelfView::PointerDraggedOnButton(views::View* view, | 1623 void ShelfView::PointerDraggedOnButton(views::View* view, |
| 1631 Pointer pointer, | 1624 Pointer pointer, |
| 1632 const ui::LocatedEvent& event) { | 1625 const ui::LocatedEvent& event) { |
| 1633 // To prepare all drag types (moving an item in the shelf and dragging off), | 1626 // To prepare all drag types (moving an item in the shelf and dragging off), |
| 1634 // we should check the x-axis and y-axis offset. | 1627 // we should check the x-axis and y-axis offset. |
| 1635 if (!dragging() && drag_view_ && | 1628 if (!dragging() && drag_view_ && |
| 1636 ((std::abs(event.x() - drag_origin_.x()) >= kMinimumDragDistance) || | 1629 ((std::abs(event.x() - drag_origin_.x()) >= kMinimumDragDistance) || |
| 1637 (std::abs(event.y() - drag_origin_.y()) >= kMinimumDragDistance))) { | 1630 (std::abs(event.y() - drag_origin_.y()) >= kMinimumDragDistance))) { |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1831 launcher_menu_runner_.reset(new views::MenuRunner( | 1824 launcher_menu_runner_.reset(new views::MenuRunner( |
| 1832 menu_model, context_menu ? views::MenuRunner::CONTEXT_MENU : 0)); | 1825 menu_model, context_menu ? views::MenuRunner::CONTEXT_MENU : 0)); |
| 1833 | 1826 |
| 1834 ScopedTargetRootWindow scoped_target( | 1827 ScopedTargetRootWindow scoped_target( |
| 1835 source->GetWidget()->GetNativeView()->GetRootWindow()); | 1828 source->GetWidget()->GetNativeView()->GetRootWindow()); |
| 1836 | 1829 |
| 1837 // Determine the menu alignment dependent on the shelf. | 1830 // Determine the menu alignment dependent on the shelf. |
| 1838 views::MenuAnchorPosition menu_alignment = views::MENU_ANCHOR_TOPLEFT; | 1831 views::MenuAnchorPosition menu_alignment = views::MENU_ANCHOR_TOPLEFT; |
| 1839 gfx::Rect anchor_point = gfx::Rect(click_point, gfx::Size()); | 1832 gfx::Rect anchor_point = gfx::Rect(click_point, gfx::Size()); |
| 1840 | 1833 |
| 1841 ShelfWidget* shelf = RootWindowController::ForShelf( | |
| 1842 GetWidget()->GetNativeView())->shelf(); | |
| 1843 if (!context_menu) { | 1834 if (!context_menu) { |
| 1844 // Application lists use a bubble. | 1835 // Application lists use a bubble. |
| 1845 ShelfAlignment align = shelf->GetAlignment(); | 1836 ShelfAlignment align = shelf_->alignment(); |
| 1846 anchor_point = source->GetBoundsInScreen(); | 1837 anchor_point = source->GetBoundsInScreen(); |
| 1847 | 1838 |
| 1848 // It is possible to invoke the menu while it is sliding into view. To cover | 1839 // It is possible to invoke the menu while it is sliding into view. To cover |
| 1849 // that case, the screen coordinates are offsetted by the animation delta. | 1840 // that case, the screen coordinates are offsetted by the animation delta. |
| 1850 gfx::Vector2d offset = | 1841 gfx::Vector2d offset = |
| 1851 source->GetWidget()->GetNativeWindow()->bounds().origin() - | 1842 source->GetWidget()->GetNativeWindow()->bounds().origin() - |
| 1852 source->GetWidget()->GetNativeWindow()->GetTargetBounds().origin(); | 1843 source->GetWidget()->GetNativeWindow()->GetTargetBounds().origin(); |
| 1853 anchor_point.set_x(anchor_point.x() - offset.x()); | 1844 anchor_point.set_x(anchor_point.x() - offset.x()); |
| 1854 anchor_point.set_y(anchor_point.y() - offset.y()); | 1845 anchor_point.set_y(anchor_point.y() - offset.y()); |
| 1855 | 1846 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1871 case SHELF_ALIGNMENT_TOP: | 1862 case SHELF_ALIGNMENT_TOP: |
| 1872 menu_alignment = views::MENU_ANCHOR_BUBBLE_BELOW; | 1863 menu_alignment = views::MENU_ANCHOR_BUBBLE_BELOW; |
| 1873 break; | 1864 break; |
| 1874 } | 1865 } |
| 1875 } | 1866 } |
| 1876 // If this gets deleted while we are in the menu, the shelf will be gone | 1867 // If this gets deleted while we are in the menu, the shelf will be gone |
| 1877 // as well. | 1868 // as well. |
| 1878 bool got_deleted = false; | 1869 bool got_deleted = false; |
| 1879 got_deleted_ = &got_deleted; | 1870 got_deleted_ = &got_deleted; |
| 1880 | 1871 |
| 1881 shelf->ForceUndimming(true); | 1872 ShelfWidget* shelf_widget = shelf_->shelf_widget(); |
| 1873 shelf_widget->ForceUndimming(true); |
| 1882 // NOTE: if you convert to HAS_MNEMONICS be sure and update menu building | 1874 // NOTE: if you convert to HAS_MNEMONICS be sure and update menu building |
| 1883 // code. | 1875 // code. |
| 1884 if (launcher_menu_runner_->RunMenuAt(source->GetWidget(), | 1876 if (launcher_menu_runner_->RunMenuAt(source->GetWidget(), |
| 1885 NULL, | 1877 NULL, |
| 1886 anchor_point, | 1878 anchor_point, |
| 1887 menu_alignment, | 1879 menu_alignment, |
| 1888 source_type) == | 1880 source_type) == |
| 1889 views::MenuRunner::MENU_DELETED) { | 1881 views::MenuRunner::MENU_DELETED) { |
| 1890 if (!got_deleted) { | 1882 if (!got_deleted) { |
| 1891 got_deleted_ = NULL; | 1883 got_deleted_ = NULL; |
| 1892 shelf->ForceUndimming(false); | 1884 shelf_widget->ForceUndimming(false); |
| 1893 } | 1885 } |
| 1894 return; | 1886 return; |
| 1895 } | 1887 } |
| 1896 got_deleted_ = NULL; | 1888 got_deleted_ = NULL; |
| 1897 shelf->ForceUndimming(false); | 1889 shelf_widget->ForceUndimming(false); |
| 1898 | 1890 |
| 1899 // If it is a context menu and we are showing overflow bubble | 1891 // If it is a context menu and we are showing overflow bubble |
| 1900 // we want to hide overflow bubble. | 1892 // we want to hide overflow bubble. |
| 1901 if (owner_overflow_bubble_) | 1893 if (owner_overflow_bubble_) |
| 1902 owner_overflow_bubble_->HideBubbleAndRefreshButton(); | 1894 owner_overflow_bubble_->HideBubbleAndRefreshButton(); |
| 1903 | 1895 |
| 1904 // Unpinning an item will reset the |launcher_menu_runner_| before coming | 1896 // Unpinning an item will reset the |launcher_menu_runner_| before coming |
| 1905 // here. | 1897 // here. |
| 1906 if (launcher_menu_runner_) | 1898 if (launcher_menu_runner_) |
| 1907 closing_event_time_ = launcher_menu_runner_->closing_event_time(); | 1899 closing_event_time_ = launcher_menu_runner_->closing_event_time(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1960 return false; | 1952 return false; |
| 1961 const ShelfItem* item = ShelfItemForView(view); | 1953 const ShelfItem* item = ShelfItemForView(view); |
| 1962 if (!item) | 1954 if (!item) |
| 1963 return true; | 1955 return true; |
| 1964 ShelfItemDelegate* item_delegate = | 1956 ShelfItemDelegate* item_delegate = |
| 1965 item_manager_->GetShelfItemDelegate(item->id); | 1957 item_manager_->GetShelfItemDelegate(item->id); |
| 1966 return item_delegate->ShouldShowTooltip(); | 1958 return item_delegate->ShouldShowTooltip(); |
| 1967 } | 1959 } |
| 1968 | 1960 |
| 1969 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { | 1961 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { |
| 1970 ShelfWidget* shelf = RootWindowController::ForShelf( | |
| 1971 GetWidget()->GetNativeView())->shelf(); | |
| 1972 ShelfAlignment align = shelf->GetAlignment(); | |
| 1973 const gfx::Rect bounds = GetBoundsInScreen(); | 1962 const gfx::Rect bounds = GetBoundsInScreen(); |
| 1974 int distance = 0; | 1963 int distance = shelf_->SelectValueForShelfAlignment( |
| 1975 switch (align) { | 1964 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), |
| 1976 case SHELF_ALIGNMENT_BOTTOM: | 1965 bounds.x() - coordinate.x(), coordinate.y() - bounds.bottom()); |
| 1977 distance = bounds.y() - coordinate.y(); | |
| 1978 break; | |
| 1979 case SHELF_ALIGNMENT_LEFT: | |
| 1980 distance = coordinate.x() - bounds.right(); | |
| 1981 break; | |
| 1982 case SHELF_ALIGNMENT_RIGHT: | |
| 1983 distance = bounds.x() - coordinate.x(); | |
| 1984 break; | |
| 1985 case SHELF_ALIGNMENT_TOP: | |
| 1986 distance = coordinate.y() - bounds.bottom(); | |
| 1987 break; | |
| 1988 } | |
| 1989 return distance > 0 ? distance : 0; | 1966 return distance > 0 ? distance : 0; |
| 1990 } | 1967 } |
| 1991 | 1968 |
| 1992 } // namespace ash | 1969 } // namespace ash |
| OLD | NEW |