| 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/table/table_view.h" | 5 #include "ui/views/controls/table/table_view.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 text_background_color_id(HasFocus())); | 539 text_background_color_id(HasFocus())); |
| 540 const SkColor fg_color = GetNativeTheme()->GetSystemColor( | 540 const SkColor fg_color = GetNativeTheme()->GetSystemColor( |
| 541 ui::NativeTheme::kColorId_TableText); | 541 ui::NativeTheme::kColorId_TableText); |
| 542 const SkColor selected_fg_color = GetNativeTheme()->GetSystemColor( | 542 const SkColor selected_fg_color = GetNativeTheme()->GetSystemColor( |
| 543 selected_text_color_id(HasFocus())); | 543 selected_text_color_id(HasFocus())); |
| 544 for (int i = region.min_row; i < region.max_row; ++i) { | 544 for (int i = region.min_row; i < region.max_row; ++i) { |
| 545 const int model_index = ViewToModel(i); | 545 const int model_index = ViewToModel(i); |
| 546 const bool is_selected = selection_model_.IsSelected(model_index); | 546 const bool is_selected = selection_model_.IsSelected(model_index); |
| 547 if (is_selected) | 547 if (is_selected) |
| 548 canvas->FillRect(GetRowBounds(i), selected_bg_color); | 548 canvas->FillRect(GetRowBounds(i), selected_bg_color); |
| 549 if (selection_model_.active() == model_index && HasFocus()) |
| 550 canvas->DrawFocusRect(GetRowBounds(i)); |
| 549 for (int j = region.min_column; j < region.max_column; ++j) { | 551 for (int j = region.min_column; j < region.max_column; ++j) { |
| 550 const gfx::Rect cell_bounds(GetCellBounds(i, j)); | 552 const gfx::Rect cell_bounds(GetCellBounds(i, j)); |
| 551 int text_x = kTextHorizontalPadding + cell_bounds.x(); | 553 int text_x = kTextHorizontalPadding + cell_bounds.x(); |
| 552 | 554 |
| 553 // Provide space for the grouping indicator, but draw it separately. | 555 // Provide space for the grouping indicator, but draw it separately. |
| 554 if (j == 0 && grouper_) | 556 if (j == 0 && grouper_) |
| 555 text_x += kGroupingIndicatorSize + kTextHorizontalPadding; | 557 text_x += kGroupingIndicatorSize + kTextHorizontalPadding; |
| 556 | 558 |
| 557 // Always paint the icon in the first visible column. | 559 // Always paint the icon in the first visible column. |
| 558 if (j == 0 && table_type_ == ICON_AND_TEXT) { | 560 if (j == 0 && table_type_ == ICON_AND_TEXT) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 kGroupingIndicatorSize / 2, grouping_flags); | 618 kGroupingIndicatorSize / 2, grouping_flags); |
| 617 } | 619 } |
| 618 canvas->DrawCircle( | 620 canvas->DrawCircle( |
| 619 gfx::Point(group_indicator_x, start_cell_bounds.CenterPoint().y()), | 621 gfx::Point(group_indicator_x, start_cell_bounds.CenterPoint().y()), |
| 620 kGroupingIndicatorSize / 2, grouping_flags); | 622 kGroupingIndicatorSize / 2, grouping_flags); |
| 621 i = last + 1; | 623 i = last + 1; |
| 622 } | 624 } |
| 623 } | 625 } |
| 624 | 626 |
| 625 void TableView::OnFocus() { | 627 void TableView::OnFocus() { |
| 626 ScrollView* scroll_view = ScrollView::GetScrollViewForContents(this); | |
| 627 if (scroll_view) | |
| 628 scroll_view->SetHasFocusIndicator(true); | |
| 629 SchedulePaintForSelection(); | 628 SchedulePaintForSelection(); |
| 630 | |
| 631 NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, true); | 629 NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, true); |
| 632 } | 630 } |
| 633 | 631 |
| 634 void TableView::OnBlur() { | 632 void TableView::OnBlur() { |
| 635 ScrollView* scroll_view = ScrollView::GetScrollViewForContents(this); | |
| 636 if (scroll_view) | |
| 637 scroll_view->SetHasFocusIndicator(false); | |
| 638 SchedulePaintForSelection(); | 633 SchedulePaintForSelection(); |
| 639 } | 634 } |
| 640 | 635 |
| 641 void TableView::NumRowsChanged() { | 636 void TableView::NumRowsChanged() { |
| 642 SortItemsAndUpdateMapping(); | 637 SortItemsAndUpdateMapping(); |
| 643 PreferredSizeChanged(); | 638 PreferredSizeChanged(); |
| 644 SchedulePaint(); | 639 SchedulePaint(); |
| 645 } | 640 } |
| 646 | 641 |
| 647 void TableView::SortItemsAndUpdateMapping() { | 642 void TableView::SortItemsAndUpdateMapping() { |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 if (tooltip) | 944 if (tooltip) |
| 950 *tooltip = text; | 945 *tooltip = text; |
| 951 if (tooltip_origin) { | 946 if (tooltip_origin) { |
| 952 tooltip_origin->SetPoint(cell_bounds.x(), | 947 tooltip_origin->SetPoint(cell_bounds.x(), |
| 953 cell_bounds.y() + kTextVerticalPadding); | 948 cell_bounds.y() + kTextVerticalPadding); |
| 954 } | 949 } |
| 955 return true; | 950 return true; |
| 956 } | 951 } |
| 957 | 952 |
| 958 } // namespace views | 953 } // namespace views |
| OLD | NEW |