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 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. | 5 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. |
6 | 6 |
7 #include "ui/views/view.h" | 7 #include "ui/views/view.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 View* View::GetPreviousFocusableView() { | 1194 View* View::GetPreviousFocusableView() { |
1195 return previous_focusable_view_; | 1195 return previous_focusable_view_; |
1196 } | 1196 } |
1197 | 1197 |
1198 void View::SetNextFocusableView(View* view) { | 1198 void View::SetNextFocusableView(View* view) { |
1199 if (view) | 1199 if (view) |
1200 view->previous_focusable_view_ = this; | 1200 view->previous_focusable_view_ = this; |
1201 next_focusable_view_ = view; | 1201 next_focusable_view_ = view; |
1202 } | 1202 } |
1203 | 1203 |
| 1204 void View::SetFocusBehavior(FocusBehavior focus_behavior) { |
| 1205 if (focus_behavior == FocusBehavior::CONTROL) { |
| 1206 #if defined(OS_MACOSX) |
| 1207 focus_behavior = FocusBehavior::ACCESSIBLE_ONLY; |
| 1208 #else |
| 1209 focus_behavior = FocusBehavior::ALWAYS; |
| 1210 #endif |
| 1211 } |
| 1212 |
| 1213 switch (focus_behavior) { |
| 1214 case FocusBehavior::ALWAYS: |
| 1215 SetFocusable(true); |
| 1216 SetAccessibilityFocusable(true); |
| 1217 break; |
| 1218 case FocusBehavior::NEVER: |
| 1219 SetFocusable(false); |
| 1220 SetAccessibilityFocusable(false); |
| 1221 break; |
| 1222 case FocusBehavior::ACCESSIBLE_ONLY: |
| 1223 SetFocusable(false); |
| 1224 SetAccessibilityFocusable(true); |
| 1225 break; |
| 1226 case FocusBehavior::CONTROL: |
| 1227 NOTREACHED(); |
| 1228 break; |
| 1229 } |
| 1230 } |
| 1231 |
1204 void View::SetFocusable(bool focusable) { | 1232 void View::SetFocusable(bool focusable) { |
1205 if (focusable_ == focusable) | 1233 if (focusable_ == focusable) |
1206 return; | 1234 return; |
1207 | 1235 |
1208 focusable_ = focusable; | 1236 focusable_ = focusable; |
1209 AdvanceFocusIfNecessary(); | 1237 AdvanceFocusIfNecessary(); |
1210 } | 1238 } |
1211 | 1239 |
1212 bool View::IsFocusable() const { | 1240 bool View::IsFocusable() const { |
1213 return focusable_ && enabled_ && IsDrawn(); | 1241 return focusable_ && enabled_ && IsDrawn(); |
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2428 // Message the RootView to do the drag and drop. That way if we're removed | 2456 // Message the RootView to do the drag and drop. That way if we're removed |
2429 // the RootView can detect it and avoid calling us back. | 2457 // the RootView can detect it and avoid calling us back. |
2430 gfx::Point widget_location(event.location()); | 2458 gfx::Point widget_location(event.location()); |
2431 ConvertPointToWidget(this, &widget_location); | 2459 ConvertPointToWidget(this, &widget_location); |
2432 widget->RunShellDrag(this, data, widget_location, drag_operations, source); | 2460 widget->RunShellDrag(this, data, widget_location, drag_operations, source); |
2433 // WARNING: we may have been deleted. | 2461 // WARNING: we may have been deleted. |
2434 return true; | 2462 return true; |
2435 } | 2463 } |
2436 | 2464 |
2437 } // namespace views | 2465 } // namespace views |
OLD | NEW |