| 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 bool new_is_up = (part.type == MenuController::MenuPart::SCROLL_UP); | 161 bool new_is_up = (part.type == MenuController::MenuPart::SCROLL_UP); |
| 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(FROM_HERE, | 171 scrolling_timer_.Start(TimeDelta::FromMilliseconds(kScrollTimerMS), this, |
| 172 TimeDelta::FromMilliseconds(kScrollTimerMS), | 172 &MenuScrollTask::Run); |
| 173 this, &MenuScrollTask::Run); | |
| 174 } | 173 } |
| 175 } | 174 } |
| 176 | 175 |
| 177 void StopScrolling() { | 176 void StopScrolling() { |
| 178 if (scrolling_timer_.IsRunning()) { | 177 if (scrolling_timer_.IsRunning()) { |
| 179 scrolling_timer_.Stop(); | 178 scrolling_timer_.Stop(); |
| 180 submenu_ = NULL; | 179 submenu_ = NULL; |
| 181 } | 180 } |
| 182 } | 181 } |
| 183 | 182 |
| (...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1431 | 1430 |
| 1432 void MenuController::BuildMenuItemPath(MenuItemView* item, | 1431 void MenuController::BuildMenuItemPath(MenuItemView* item, |
| 1433 std::vector<MenuItemView*>* path) { | 1432 std::vector<MenuItemView*>* path) { |
| 1434 if (!item) | 1433 if (!item) |
| 1435 return; | 1434 return; |
| 1436 BuildMenuItemPath(item->GetParentMenuItem(), path); | 1435 BuildMenuItemPath(item->GetParentMenuItem(), path); |
| 1437 path->push_back(item); | 1436 path->push_back(item); |
| 1438 } | 1437 } |
| 1439 | 1438 |
| 1440 void MenuController::StartShowTimer() { | 1439 void MenuController::StartShowTimer() { |
| 1441 show_timer_.Start(FROM_HERE, TimeDelta::FromMilliseconds(kShowDelay), this, | 1440 show_timer_.Start(TimeDelta::FromMilliseconds(kShowDelay), this, |
| 1442 &MenuController::CommitPendingSelection); | 1441 &MenuController::CommitPendingSelection); |
| 1443 } | 1442 } |
| 1444 | 1443 |
| 1445 void MenuController::StopShowTimer() { | 1444 void MenuController::StopShowTimer() { |
| 1446 show_timer_.Stop(); | 1445 show_timer_.Stop(); |
| 1447 } | 1446 } |
| 1448 | 1447 |
| 1449 void MenuController::StartCancelAllTimer() { | 1448 void MenuController::StartCancelAllTimer() { |
| 1450 cancel_all_timer_.Start(FROM_HERE, | 1449 cancel_all_timer_.Start(TimeDelta::FromMilliseconds(kCloseOnExitTime), |
| 1451 TimeDelta::FromMilliseconds(kCloseOnExitTime), | |
| 1452 this, &MenuController::CancelAll); | 1450 this, &MenuController::CancelAll); |
| 1453 } | 1451 } |
| 1454 | 1452 |
| 1455 void MenuController::StopCancelAllTimer() { | 1453 void MenuController::StopCancelAllTimer() { |
| 1456 cancel_all_timer_.Stop(); | 1454 cancel_all_timer_.Stop(); |
| 1457 } | 1455 } |
| 1458 | 1456 |
| 1459 gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item, | 1457 gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item, |
| 1460 bool prefer_leading, | 1458 bool prefer_leading, |
| 1461 bool* is_leading) { | 1459 bool* is_leading) { |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1930 return; | 1928 return; |
| 1931 | 1929 |
| 1932 // 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 |
| 1933 // 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. |
| 1934 View* active_view = active_mouse_view_; | 1932 View* active_view = active_mouse_view_; |
| 1935 active_mouse_view_ = NULL; | 1933 active_mouse_view_ = NULL; |
| 1936 active_view->OnMouseCaptureLost(); | 1934 active_view->OnMouseCaptureLost(); |
| 1937 } | 1935 } |
| 1938 | 1936 |
| 1939 } // namespace views | 1937 } // namespace views |
| OLD | NEW |