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_views.h" | 5 #include "ui/views/controls/table/table_view_views.h" |
6 | 6 |
7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
8 #include "third_party/skia/include/core/SkBitmap.h" | 8 #include "third_party/skia/include/core/SkBitmap.h" |
9 #include "ui/base/models/table_model.h" | 9 #include "ui/base/models/table_model.h" |
10 #include "ui/gfx/canvas_skia.h" | 10 #include "ui/gfx/canvas_skia.h" |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 } | 235 } |
236 | 236 |
237 int min_row = std::min(RowCount() - 1, std::max(0, min_y / row_height_)); | 237 int min_row = std::min(RowCount() - 1, std::max(0, min_y / row_height_)); |
238 int max_row = max_y / row_height_; | 238 int max_row = max_y / row_height_; |
239 if (max_y % row_height_ != 0) | 239 if (max_y % row_height_ != 0) |
240 max_row++; | 240 max_row++; |
241 max_row = std::min(max_row, RowCount()); | 241 max_row = std::min(max_row, RowCount()); |
242 for (int i = min_row; i < max_row; ++i) { | 242 for (int i = min_row; i < max_row; ++i) { |
243 gfx::Rect row_bounds(GetRowBounds(i)); | 243 gfx::Rect row_bounds(GetRowBounds(i)); |
244 if (i == selected_row_) { | 244 if (i == selected_row_) { |
245 canvas->FillRect(kSelectedBackgroundColor, row_bounds); | 245 canvas->FillRect(row_bounds, kSelectedBackgroundColor); |
246 if (HasFocus()) | 246 if (HasFocus()) |
247 canvas->DrawFocusRect(row_bounds); | 247 canvas->DrawFocusRect(row_bounds); |
248 } | 248 } |
249 int text_x = kTextHorizontalPadding; | 249 int text_x = kTextHorizontalPadding; |
250 if (table_type_ == ICON_AND_TEXT) { | 250 if (table_type_ == ICON_AND_TEXT) { |
251 SkBitmap image = model_->GetIcon(i); | 251 SkBitmap image = model_->GetIcon(i); |
252 if (!image.isNull()) { | 252 if (!image.isNull()) { |
253 int image_x = GetMirroredXWithWidthInView(text_x, image.width()); | 253 int image_x = GetMirroredXWithWidthInView(text_x, image.width()); |
254 canvas->DrawBitmapInt( | 254 canvas->DrawBitmapInt( |
255 image, 0, 0, image.width(), image.height(), | 255 image, 0, 0, image.width(), image.height(), |
(...skipping 24 matching lines...) Expand all Loading... |
280 void TableView::NumRowsChanged() { | 280 void TableView::NumRowsChanged() { |
281 PreferredSizeChanged(); | 281 PreferredSizeChanged(); |
282 SchedulePaint(); | 282 SchedulePaint(); |
283 } | 283 } |
284 | 284 |
285 gfx::Rect TableView::GetRowBounds(int row) { | 285 gfx::Rect TableView::GetRowBounds(int row) { |
286 return gfx::Rect(0, row * row_height_, width(), row_height_); | 286 return gfx::Rect(0, row * row_height_, width(), row_height_); |
287 } | 287 } |
288 | 288 |
289 } // namespace views | 289 } // namespace views |
OLD | NEW |