| 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/tabbed_pane/tabbed_pane.h" | 5 #include "ui/views/controls/tabbed_pane/tabbed_pane.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "cc/paint/paint_flags.h" | 9 #include "cc/paint/paint_flags.h" |
| 10 #include "third_party/skia/include/core/SkPath.h" | 10 #include "third_party/skia/include/core/SkPath.h" |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 | 333 |
| 334 TabStrip::~TabStrip() {} | 334 TabStrip::~TabStrip() {} |
| 335 | 335 |
| 336 void TabStrip::OnSelectedTabChanged(Tab* from_tab, Tab* to_tab) {} | 336 void TabStrip::OnSelectedTabChanged(Tab* from_tab, Tab* to_tab) {} |
| 337 | 337 |
| 338 const char* TabStrip::GetClassName() const { | 338 const char* TabStrip::GetClassName() const { |
| 339 return kViewClassName; | 339 return kViewClassName; |
| 340 } | 340 } |
| 341 | 341 |
| 342 void TabStrip::OnPaintBorder(gfx::Canvas* canvas) { | 342 void TabStrip::OnPaintBorder(gfx::Canvas* canvas) { |
| 343 cc::PaintFlags paint; | 343 cc::PaintFlags fill_flags; |
| 344 paint.setColor(kTabBorderColor); | 344 fill_flags.setColor(kTabBorderColor); |
| 345 paint.setStrokeWidth(kTabBorderThickness); | 345 fill_flags.setStrokeWidth(kTabBorderThickness); |
| 346 SkScalar line_y = SkIntToScalar(height()) - (kTabBorderThickness / 2); | 346 SkScalar line_y = SkIntToScalar(height()) - (kTabBorderThickness / 2); |
| 347 SkScalar line_end = SkIntToScalar(width()); | 347 SkScalar line_end = SkIntToScalar(width()); |
| 348 int selected_tab_index = GetSelectedTabIndex(); | 348 int selected_tab_index = GetSelectedTabIndex(); |
| 349 if (selected_tab_index >= 0) { | 349 if (selected_tab_index >= 0) { |
| 350 Tab* selected_tab = GetTabAtIndex(selected_tab_index); | 350 Tab* selected_tab = GetTabAtIndex(selected_tab_index); |
| 351 SkPath path; | 351 SkPath path; |
| 352 SkScalar tab_height = | 352 SkScalar tab_height = |
| 353 SkIntToScalar(selected_tab->height()) - kTabBorderThickness; | 353 SkIntToScalar(selected_tab->height()) - kTabBorderThickness; |
| 354 SkScalar tab_width = | 354 SkScalar tab_width = |
| 355 SkIntToScalar(selected_tab->width()) - kTabBorderThickness; | 355 SkIntToScalar(selected_tab->width()) - kTabBorderThickness; |
| 356 SkScalar tab_start = SkIntToScalar(selected_tab->GetMirroredX()); | 356 SkScalar tab_start = SkIntToScalar(selected_tab->GetMirroredX()); |
| 357 path.moveTo(0, line_y); | 357 path.moveTo(0, line_y); |
| 358 path.rLineTo(tab_start, 0); | 358 path.rLineTo(tab_start, 0); |
| 359 path.rLineTo(0, -tab_height); | 359 path.rLineTo(0, -tab_height); |
| 360 path.rLineTo(tab_width, 0); | 360 path.rLineTo(tab_width, 0); |
| 361 path.rLineTo(0, tab_height); | 361 path.rLineTo(0, tab_height); |
| 362 path.lineTo(line_end, line_y); | 362 path.lineTo(line_end, line_y); |
| 363 | 363 |
| 364 cc::PaintFlags paint; | 364 cc::PaintFlags fill_flags; |
| 365 paint.setStyle(cc::PaintFlags::kStroke_Style); | 365 fill_flags.setStyle(cc::PaintFlags::kStroke_Style); |
| 366 paint.setColor(kTabBorderColor); | 366 fill_flags.setColor(kTabBorderColor); |
| 367 paint.setStrokeWidth(kTabBorderThickness); | 367 fill_flags.setStrokeWidth(kTabBorderThickness); |
| 368 canvas->DrawPath(path, paint); | 368 canvas->DrawPath(path, fill_flags); |
| 369 } else { | 369 } else { |
| 370 canvas->sk_canvas()->drawLine(0, line_y, line_end, line_y, paint); | 370 canvas->sk_canvas()->drawLine(0, line_y, line_end, line_y, fill_flags); |
| 371 } | 371 } |
| 372 } | 372 } |
| 373 | 373 |
| 374 Tab* TabStrip::GetTabAtIndex(int index) const { | 374 Tab* TabStrip::GetTabAtIndex(int index) const { |
| 375 return static_cast<Tab*>(const_cast<View*>(child_at(index))); | 375 return static_cast<Tab*>(const_cast<View*>(child_at(index))); |
| 376 } | 376 } |
| 377 | 377 |
| 378 int TabStrip::GetSelectedTabIndex() const { | 378 int TabStrip::GetSelectedTabIndex() const { |
| 379 for (int i = 0; i < child_count(); ++i) | 379 for (int i = 0; i < child_count(); ++i) |
| 380 if (GetTabAtIndex(i)->selected()) | 380 if (GetTabAtIndex(i)->selected()) |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 | 628 |
| 629 View* TabbedPane::GetSelectedTabContentView() { | 629 View* TabbedPane::GetSelectedTabContentView() { |
| 630 return GetSelectedTab() ? GetSelectedTab()->contents() : nullptr; | 630 return GetSelectedTab() ? GetSelectedTab()->contents() : nullptr; |
| 631 } | 631 } |
| 632 | 632 |
| 633 void TabbedPane::GetAccessibleNodeData(ui::AXNodeData* node_data) { | 633 void TabbedPane::GetAccessibleNodeData(ui::AXNodeData* node_data) { |
| 634 node_data->role = ui::AX_ROLE_TAB_LIST; | 634 node_data->role = ui::AX_ROLE_TAB_LIST; |
| 635 } | 635 } |
| 636 | 636 |
| 637 } // namespace views | 637 } // namespace views |
| OLD | NEW |