| 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)); | |
| 551 for (int j = region.min_column; j < region.max_column; ++j) { | 549 for (int j = region.min_column; j < region.max_column; ++j) { |
| 552 const gfx::Rect cell_bounds(GetCellBounds(i, j)); | 550 const gfx::Rect cell_bounds(GetCellBounds(i, j)); |
| 553 int text_x = kTextHorizontalPadding + cell_bounds.x(); | 551 int text_x = kTextHorizontalPadding + cell_bounds.x(); |
| 554 | 552 |
| 555 // Provide space for the grouping indicator, but draw it separately. | 553 // Provide space for the grouping indicator, but draw it separately. |
| 556 if (j == 0 && grouper_) | 554 if (j == 0 && grouper_) |
| 557 text_x += kGroupingIndicatorSize + kTextHorizontalPadding; | 555 text_x += kGroupingIndicatorSize + kTextHorizontalPadding; |
| 558 | 556 |
| 559 // Always paint the icon in the first visible column. | 557 // Always paint the icon in the first visible column. |
| 560 if (j == 0 && table_type_ == ICON_AND_TEXT) { | 558 if (j == 0 && table_type_ == ICON_AND_TEXT) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 kGroupingIndicatorSize / 2, grouping_flags); | 616 kGroupingIndicatorSize / 2, grouping_flags); |
| 619 } | 617 } |
| 620 canvas->DrawCircle( | 618 canvas->DrawCircle( |
| 621 gfx::Point(group_indicator_x, start_cell_bounds.CenterPoint().y()), | 619 gfx::Point(group_indicator_x, start_cell_bounds.CenterPoint().y()), |
| 622 kGroupingIndicatorSize / 2, grouping_flags); | 620 kGroupingIndicatorSize / 2, grouping_flags); |
| 623 i = last + 1; | 621 i = last + 1; |
| 624 } | 622 } |
| 625 } | 623 } |
| 626 | 624 |
| 627 void TableView::OnFocus() { | 625 void TableView::OnFocus() { |
| 626 ScrollView* scroll_view = ScrollView::GetScrollViewForContents(this); |
| 627 if (scroll_view) |
| 628 scroll_view->SetHasFocusIndicator(true); |
| 628 SchedulePaintForSelection(); | 629 SchedulePaintForSelection(); |
| 630 |
| 629 NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, true); | 631 NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, true); |
| 630 } | 632 } |
| 631 | 633 |
| 632 void TableView::OnBlur() { | 634 void TableView::OnBlur() { |
| 635 ScrollView* scroll_view = ScrollView::GetScrollViewForContents(this); |
| 636 if (scroll_view) |
| 637 scroll_view->SetHasFocusIndicator(false); |
| 633 SchedulePaintForSelection(); | 638 SchedulePaintForSelection(); |
| 634 } | 639 } |
| 635 | 640 |
| 636 void TableView::NumRowsChanged() { | 641 void TableView::NumRowsChanged() { |
| 637 SortItemsAndUpdateMapping(); | 642 SortItemsAndUpdateMapping(); |
| 638 PreferredSizeChanged(); | 643 PreferredSizeChanged(); |
| 639 SchedulePaint(); | 644 SchedulePaint(); |
| 640 } | 645 } |
| 641 | 646 |
| 642 void TableView::SortItemsAndUpdateMapping() { | 647 void TableView::SortItemsAndUpdateMapping() { |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 if (tooltip) | 949 if (tooltip) |
| 945 *tooltip = text; | 950 *tooltip = text; |
| 946 if (tooltip_origin) { | 951 if (tooltip_origin) { |
| 947 tooltip_origin->SetPoint(cell_bounds.x(), | 952 tooltip_origin->SetPoint(cell_bounds.x(), |
| 948 cell_bounds.y() + kTextVerticalPadding); | 953 cell_bounds.y() + kTextVerticalPadding); |
| 949 } | 954 } |
| 950 return true; | 955 return true; |
| 951 } | 956 } |
| 952 | 957 |
| 953 } // namespace views | 958 } // namespace views |
| OLD | NEW |