| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/i18n/case_conversion.h" | 7 #include "base/i18n/case_conversion.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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 if (new_menu == submenu_ && is_scrolling_up_ == new_is_up) | 162 if (new_menu == submenu_ && is_scrolling_up_ == new_is_up) |
| 163 return; | 163 return; |
| 164 | 164 |
| 165 start_scroll_time_ = Time::Now(); | 165 start_scroll_time_ = Time::Now(); |
| 166 start_y_ = part.submenu->GetVisibleBounds().y(); | 166 start_y_ = part.submenu->GetVisibleBounds().y(); |
| 167 submenu_ = new_menu; | 167 submenu_ = new_menu; |
| 168 is_scrolling_up_ = new_is_up; | 168 is_scrolling_up_ = new_is_up; |
| 169 | 169 |
| 170 if (!scrolling_timer_.IsRunning()) { | 170 if (!scrolling_timer_.IsRunning()) { |
| 171 scrolling_timer_.Start(TimeDelta::FromMilliseconds(kScrollTimerMS), this, | 171 scrolling_timer_.Start(TimeDelta::FromMilliseconds(kScrollTimerMS), this, |
| 172 &MenuScrollTask::Run); | 172 &MenuScrollTask::Run, FROM_HERE); |
| 173 } | 173 } |
| 174 } | 174 } |
| 175 | 175 |
| 176 void StopScrolling() { | 176 void StopScrolling() { |
| 177 if (scrolling_timer_.IsRunning()) { | 177 if (scrolling_timer_.IsRunning()) { |
| 178 scrolling_timer_.Stop(); | 178 scrolling_timer_.Stop(); |
| 179 submenu_ = NULL; | 179 submenu_ = NULL; |
| 180 } | 180 } |
| 181 } | 181 } |
| 182 | 182 |
| (...skipping 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1431 void MenuController::BuildMenuItemPath(MenuItemView* item, | 1431 void MenuController::BuildMenuItemPath(MenuItemView* item, |
| 1432 std::vector<MenuItemView*>* path) { | 1432 std::vector<MenuItemView*>* path) { |
| 1433 if (!item) | 1433 if (!item) |
| 1434 return; | 1434 return; |
| 1435 BuildMenuItemPath(item->GetParentMenuItem(), path); | 1435 BuildMenuItemPath(item->GetParentMenuItem(), path); |
| 1436 path->push_back(item); | 1436 path->push_back(item); |
| 1437 } | 1437 } |
| 1438 | 1438 |
| 1439 void MenuController::StartShowTimer() { | 1439 void MenuController::StartShowTimer() { |
| 1440 show_timer_.Start(TimeDelta::FromMilliseconds(kShowDelay), this, | 1440 show_timer_.Start(TimeDelta::FromMilliseconds(kShowDelay), this, |
| 1441 &MenuController::CommitPendingSelection); | 1441 &MenuController::CommitPendingSelection, FROM_HERE); |
| 1442 } | 1442 } |
| 1443 | 1443 |
| 1444 void MenuController::StopShowTimer() { | 1444 void MenuController::StopShowTimer() { |
| 1445 show_timer_.Stop(); | 1445 show_timer_.Stop(); |
| 1446 } | 1446 } |
| 1447 | 1447 |
| 1448 void MenuController::StartCancelAllTimer() { | 1448 void MenuController::StartCancelAllTimer() { |
| 1449 cancel_all_timer_.Start(TimeDelta::FromMilliseconds(kCloseOnExitTime), | 1449 cancel_all_timer_.Start(TimeDelta::FromMilliseconds(kCloseOnExitTime), |
| 1450 this, &MenuController::CancelAll); | 1450 this, &MenuController::CancelAll, FROM_HERE); |
| 1451 } | 1451 } |
| 1452 | 1452 |
| 1453 void MenuController::StopCancelAllTimer() { | 1453 void MenuController::StopCancelAllTimer() { |
| 1454 cancel_all_timer_.Stop(); | 1454 cancel_all_timer_.Stop(); |
| 1455 } | 1455 } |
| 1456 | 1456 |
| 1457 gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item, | 1457 gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item, |
| 1458 bool prefer_leading, | 1458 bool prefer_leading, |
| 1459 bool* is_leading) { | 1459 bool* is_leading) { |
| 1460 DCHECK(item); | 1460 DCHECK(item); |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1928 return; | 1928 return; |
| 1929 | 1929 |
| 1930 // Reset the active_mouse_view_ before sending mouse capture lost. That way if | 1930 // Reset the active_mouse_view_ before sending mouse capture lost. That way if |
| 1931 // it calls back to us, we aren't in a weird state. | 1931 // it calls back to us, we aren't in a weird state. |
| 1932 View* active_view = active_mouse_view_; | 1932 View* active_view = active_mouse_view_; |
| 1933 active_mouse_view_ = NULL; | 1933 active_mouse_view_ = NULL; |
| 1934 active_view->OnMouseCaptureLost(); | 1934 active_view->OnMouseCaptureLost(); |
| 1935 } | 1935 } |
| 1936 | 1936 |
| 1937 } // namespace views | 1937 } // namespace views |
| OLD | NEW |