OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "views/controls/menu/menu_controller.h" | 5 #include "views/controls/menu/menu_controller.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 | 610 |
611 MenuItemView* menu_item = GetMenuItemAt(source, event.x(), event.y()); | 611 MenuItemView* menu_item = GetMenuItemAt(source, event.x(), event.y()); |
612 bool over_empty_menu = false; | 612 bool over_empty_menu = false; |
613 if (!menu_item) { | 613 if (!menu_item) { |
614 // See if we're over an empty menu. | 614 // See if we're over an empty menu. |
615 menu_item = GetEmptyMenuItemAt(source, event.x(), event.y()); | 615 menu_item = GetEmptyMenuItemAt(source, event.x(), event.y()); |
616 if (menu_item) | 616 if (menu_item) |
617 over_empty_menu = true; | 617 over_empty_menu = true; |
618 } | 618 } |
619 MenuDelegate::DropPosition drop_position = MenuDelegate::DROP_NONE; | 619 MenuDelegate::DropPosition drop_position = MenuDelegate::DROP_NONE; |
620 int drop_operation = DragDropTypes::DRAG_NONE; | 620 int drop_operation = ui::DragDropTypes::DRAG_NONE; |
621 if (menu_item) { | 621 if (menu_item) { |
622 gfx::Point menu_item_loc(event.location()); | 622 gfx::Point menu_item_loc(event.location()); |
623 View::ConvertPointToView(source, menu_item, &menu_item_loc); | 623 View::ConvertPointToView(source, menu_item, &menu_item_loc); |
624 MenuItemView* query_menu_item; | 624 MenuItemView* query_menu_item; |
625 if (!over_empty_menu) { | 625 if (!over_empty_menu) { |
626 int menu_item_height = menu_item->height(); | 626 int menu_item_height = menu_item->height(); |
627 if (menu_item->HasSubmenu() && | 627 if (menu_item->HasSubmenu() && |
628 (menu_item_loc.y() > kDropBetweenPixels && | 628 (menu_item_loc.y() > kDropBetweenPixels && |
629 menu_item_loc.y() < (menu_item_height - kDropBetweenPixels))) { | 629 menu_item_loc.y() < (menu_item_height - kDropBetweenPixels))) { |
630 drop_position = MenuDelegate::DROP_ON; | 630 drop_position = MenuDelegate::DROP_ON; |
631 } else { | 631 } else { |
632 drop_position = (menu_item_loc.y() < menu_item_height / 2) ? | 632 drop_position = (menu_item_loc.y() < menu_item_height / 2) ? |
633 MenuDelegate::DROP_BEFORE : MenuDelegate::DROP_AFTER; | 633 MenuDelegate::DROP_BEFORE : MenuDelegate::DROP_AFTER; |
634 } | 634 } |
635 query_menu_item = menu_item; | 635 query_menu_item = menu_item; |
636 } else { | 636 } else { |
637 query_menu_item = menu_item->GetParentMenuItem(); | 637 query_menu_item = menu_item->GetParentMenuItem(); |
638 drop_position = MenuDelegate::DROP_ON; | 638 drop_position = MenuDelegate::DROP_ON; |
639 } | 639 } |
640 drop_operation = menu_item->GetDelegate()->GetDropOperation( | 640 drop_operation = menu_item->GetDelegate()->GetDropOperation( |
641 query_menu_item, event, &drop_position); | 641 query_menu_item, event, &drop_position); |
642 | 642 |
643 // If the menu has a submenu, schedule the submenu to open. | 643 // If the menu has a submenu, schedule the submenu to open. |
644 SetSelection(menu_item, menu_item->HasSubmenu() ? SELECTION_OPEN_SUBMENU : | 644 SetSelection(menu_item, menu_item->HasSubmenu() ? SELECTION_OPEN_SUBMENU : |
645 SELECTION_DEFAULT); | 645 SELECTION_DEFAULT); |
646 | 646 |
647 if (drop_position == MenuDelegate::DROP_NONE || | 647 if (drop_position == MenuDelegate::DROP_NONE || |
648 drop_operation == DragDropTypes::DRAG_NONE) | 648 drop_operation == ui::DragDropTypes::DRAG_NONE) |
649 menu_item = NULL; | 649 menu_item = NULL; |
650 } else { | 650 } else { |
651 SetSelection(source->GetMenuItem(), SELECTION_OPEN_SUBMENU); | 651 SetSelection(source->GetMenuItem(), SELECTION_OPEN_SUBMENU); |
652 } | 652 } |
653 SetDropMenuItem(menu_item, drop_position); | 653 SetDropMenuItem(menu_item, drop_position); |
654 last_drop_operation_ = drop_operation; | 654 last_drop_operation_ = drop_operation; |
655 return drop_operation; | 655 return drop_operation; |
656 } | 656 } |
657 | 657 |
658 void MenuController::OnDragExited(SubmenuView* source) { | 658 void MenuController::OnDragExited(SubmenuView* source) { |
(...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1835 | 1835 |
1836 MouseEvent release_event(Event::ET_MOUSE_RELEASED, -1, -1, 0); | 1836 MouseEvent release_event(Event::ET_MOUSE_RELEASED, -1, -1, 0); |
1837 // Reset the active_mouse_view_ before sending mouse released. That way if if | 1837 // Reset the active_mouse_view_ before sending mouse released. That way if if |
1838 // calls back to use we aren't in a weird state. | 1838 // calls back to use we aren't in a weird state. |
1839 View* active_view = active_mouse_view_; | 1839 View* active_view = active_mouse_view_; |
1840 active_mouse_view_ = NULL; | 1840 active_mouse_view_ = NULL; |
1841 active_view->OnMouseReleased(release_event, true); | 1841 active_view->OnMouseReleased(release_event, true); |
1842 } | 1842 } |
1843 | 1843 |
1844 } // namespace views | 1844 } // namespace views |
OLD | NEW |