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