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 #include "ui/views/controls/tree/tree_view.h" | 5 #include "ui/views/controls/tree/tree_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 return selector_.get(); | 373 return selector_.get(); |
374 } | 374 } |
375 | 375 |
376 void TreeView::OnGestureEvent(ui::GestureEvent* event) { | 376 void TreeView::OnGestureEvent(ui::GestureEvent* event) { |
377 if (event->type() == ui::ET_GESTURE_TAP) { | 377 if (event->type() == ui::ET_GESTURE_TAP) { |
378 if (OnClickOrTap(*event)) | 378 if (OnClickOrTap(*event)) |
379 event->SetHandled(); | 379 event->SetHandled(); |
380 } | 380 } |
381 } | 381 } |
382 | 382 |
383 void TreeView::ShowContextMenu(const gfx::Point& p, bool is_mouse_gesture) { | 383 void TreeView::ShowContextMenu(const gfx::Point& p, |
| 384 ui::ContextMenuSourceType source_type) { |
384 if (!model_) | 385 if (!model_) |
385 return; | 386 return; |
386 if (is_mouse_gesture) { | 387 if (source_type == ui::CONTEXT_MENU_SOURCE_MOUSE) { |
387 // Only invoke View's implementation (which notifies the | 388 // Only invoke View's implementation (which notifies the |
388 // ContextMenuController) if over a node. | 389 // ContextMenuController) if over a node. |
389 gfx::Point local_point(p); | 390 gfx::Point local_point(p); |
390 ConvertPointToTarget(NULL, this, &local_point); | 391 ConvertPointToTarget(NULL, this, &local_point); |
391 int row = (local_point.y() - kVerticalInset) / row_height_; | 392 int row = (local_point.y() - kVerticalInset) / row_height_; |
392 int depth = 0; | 393 int depth = 0; |
393 InternalNode* node = GetNodeByRow(row, &depth); | 394 InternalNode* node = GetNodeByRow(row, &depth); |
394 if (!node) | 395 if (!node) |
395 return; | 396 return; |
396 gfx::Rect bounds(GetBoundsForNodeImpl(node, row, depth)); | 397 gfx::Rect bounds(GetBoundsForNodeImpl(node, row, depth)); |
397 if (!bounds.Contains(local_point)) | 398 if (!bounds.Contains(local_point)) |
398 return; | 399 return; |
399 } | 400 } |
400 View::ShowContextMenu(p, is_mouse_gesture); | 401 View::ShowContextMenu(p, source_type); |
401 } | 402 } |
402 | 403 |
403 void TreeView::GetAccessibleState(ui::AccessibleViewState* state) { | 404 void TreeView::GetAccessibleState(ui::AccessibleViewState* state) { |
404 state->role = ui::AccessibilityTypes::ROLE_OUTLINE; | 405 state->role = ui::AccessibilityTypes::ROLE_OUTLINE; |
405 state->state = ui::AccessibilityTypes::STATE_READONLY; | 406 state->state = ui::AccessibilityTypes::STATE_READONLY; |
406 } | 407 } |
407 | 408 |
408 void TreeView::TreeNodesAdded(TreeModel* model, | 409 void TreeView::TreeNodesAdded(TreeModel* model, |
409 TreeModelNode* parent, | 410 TreeModelNode* parent, |
410 int start, | 411 int start, |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 if (!is_expanded_) | 999 if (!is_expanded_) |
999 return max_width; | 1000 return max_width; |
1000 for (int i = 0; i < child_count(); ++i) { | 1001 for (int i = 0; i < child_count(); ++i) { |
1001 max_width = std::max(max_width, | 1002 max_width = std::max(max_width, |
1002 GetChild(i)->GetMaxWidth(indent, depth + 1)); | 1003 GetChild(i)->GetMaxWidth(indent, depth + 1)); |
1003 } | 1004 } |
1004 return max_width; | 1005 return max_width; |
1005 } | 1006 } |
1006 | 1007 |
1007 } // namespace views | 1008 } // namespace views |
OLD | NEW |