| 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 "skia/ext/cdl_paint.h" |
| 9 #include "third_party/skia/include/core/SkPaint.h" | 10 #include "third_party/skia/include/core/SkPaint.h" |
| 10 #include "third_party/skia/include/core/SkPath.h" | 11 #include "third_party/skia/include/core/SkPath.h" |
| 11 #include "ui/accessibility/ax_node_data.h" | 12 #include "ui/accessibility/ax_node_data.h" |
| 12 #include "ui/base/default_style.h" | 13 #include "ui/base/default_style.h" |
| 13 #include "ui/base/material_design/material_design_controller.h" | 14 #include "ui/base/material_design/material_design_controller.h" |
| 14 #include "ui/base/resource/resource_bundle.h" | 15 #include "ui/base/resource/resource_bundle.h" |
| 15 #include "ui/events/keycodes/keyboard_codes.h" | 16 #include "ui/events/keycodes/keyboard_codes.h" |
| 16 #include "ui/gfx/animation/animation_delegate.h" | 17 #include "ui/gfx/animation/animation_delegate.h" |
| 17 #include "ui/gfx/animation/linear_animation.h" | 18 #include "ui/gfx/animation/linear_animation.h" |
| 18 #include "ui/gfx/animation/tween.h" | 19 #include "ui/gfx/animation/tween.h" |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 | 325 |
| 325 TabStrip::~TabStrip() {} | 326 TabStrip::~TabStrip() {} |
| 326 | 327 |
| 327 void TabStrip::OnSelectedTabChanged(Tab* from_tab, Tab* to_tab) {} | 328 void TabStrip::OnSelectedTabChanged(Tab* from_tab, Tab* to_tab) {} |
| 328 | 329 |
| 329 const char* TabStrip::GetClassName() const { | 330 const char* TabStrip::GetClassName() const { |
| 330 return kViewClassName; | 331 return kViewClassName; |
| 331 } | 332 } |
| 332 | 333 |
| 333 void TabStrip::OnPaintBorder(gfx::Canvas* canvas) { | 334 void TabStrip::OnPaintBorder(gfx::Canvas* canvas) { |
| 334 SkPaint paint; | 335 CdlPaint paint; |
| 335 paint.setColor(kTabBorderColor); | 336 paint.setColor(kTabBorderColor); |
| 336 paint.setStrokeWidth(kTabBorderThickness); | 337 paint.setStrokeWidth(kTabBorderThickness); |
| 337 SkScalar line_y = SkIntToScalar(height()) - (kTabBorderThickness / 2); | 338 SkScalar line_y = SkIntToScalar(height()) - (kTabBorderThickness / 2); |
| 338 SkScalar line_end = SkIntToScalar(width()); | 339 SkScalar line_end = SkIntToScalar(width()); |
| 339 int selected_tab_index = GetSelectedTabIndex(); | 340 int selected_tab_index = GetSelectedTabIndex(); |
| 340 if (selected_tab_index >= 0) { | 341 if (selected_tab_index >= 0) { |
| 341 Tab* selected_tab = GetTabAtIndex(selected_tab_index); | 342 Tab* selected_tab = GetTabAtIndex(selected_tab_index); |
| 342 SkPath path; | 343 SkPath path; |
| 343 SkScalar tab_height = | 344 SkScalar tab_height = |
| 344 SkIntToScalar(selected_tab->height()) - kTabBorderThickness; | 345 SkIntToScalar(selected_tab->height()) - kTabBorderThickness; |
| 345 SkScalar tab_width = | 346 SkScalar tab_width = |
| 346 SkIntToScalar(selected_tab->width()) - kTabBorderThickness; | 347 SkIntToScalar(selected_tab->width()) - kTabBorderThickness; |
| 347 SkScalar tab_start = SkIntToScalar(selected_tab->GetMirroredX()); | 348 SkScalar tab_start = SkIntToScalar(selected_tab->GetMirroredX()); |
| 348 path.moveTo(0, line_y); | 349 path.moveTo(0, line_y); |
| 349 path.rLineTo(tab_start, 0); | 350 path.rLineTo(tab_start, 0); |
| 350 path.rLineTo(0, -tab_height); | 351 path.rLineTo(0, -tab_height); |
| 351 path.rLineTo(tab_width, 0); | 352 path.rLineTo(tab_width, 0); |
| 352 path.rLineTo(0, tab_height); | 353 path.rLineTo(0, tab_height); |
| 353 path.lineTo(line_end, line_y); | 354 path.lineTo(line_end, line_y); |
| 354 | 355 |
| 355 SkPaint paint; | 356 CdlPaint paint; |
| 356 paint.setStyle(SkPaint::kStroke_Style); | 357 paint.setStyle(CdlPaint::kStroke_Style); |
| 357 paint.setColor(kTabBorderColor); | 358 paint.setColor(kTabBorderColor); |
| 358 paint.setStrokeWidth(kTabBorderThickness); | 359 paint.setStrokeWidth(kTabBorderThickness); |
| 359 canvas->DrawPath(path, paint); | 360 canvas->DrawPath(path, paint); |
| 360 } else { | 361 } else { |
| 361 canvas->sk_canvas()->drawLine(0, line_y, line_end, line_y, paint); | 362 canvas->sk_canvas()->drawLine(0, line_y, line_end, line_y, paint); |
| 362 } | 363 } |
| 363 } | 364 } |
| 364 | 365 |
| 365 Tab* TabStrip::GetTabAtIndex(int index) const { | 366 Tab* TabStrip::GetTabAtIndex(int index) const { |
| 366 return static_cast<Tab*>(const_cast<View*>(child_at(index))); | 367 return static_cast<Tab*>(const_cast<View*>(child_at(index))); |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 | 620 |
| 620 View* TabbedPane::GetSelectedTabContentView() { | 621 View* TabbedPane::GetSelectedTabContentView() { |
| 621 return GetSelectedTab() ? GetSelectedTab()->contents() : nullptr; | 622 return GetSelectedTab() ? GetSelectedTab()->contents() : nullptr; |
| 622 } | 623 } |
| 623 | 624 |
| 624 void TabbedPane::GetAccessibleNodeData(ui::AXNodeData* node_data) { | 625 void TabbedPane::GetAccessibleNodeData(ui::AXNodeData* node_data) { |
| 625 node_data->role = ui::AX_ROLE_TAB_LIST; | 626 node_data->role = ui::AX_ROLE_TAB_LIST; |
| 626 } | 627 } |
| 627 | 628 |
| 628 } // namespace views | 629 } // namespace views |
| OLD | NEW |