Chromium Code Reviews| 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 "third_party/skia/include/core/SkPaint.h" | 9 #include "third_party/skia/include/core/SkPaint.h" |
| 10 #include "third_party/skia/include/core/SkPath.h" | 10 #include "third_party/skia/include/core/SkPath.h" |
| 11 #include "ui/accessibility/ax_view_state.h" | 11 #include "ui/accessibility/ax_view_state.h" |
| 12 #include "ui/base/default_style.h" | 12 #include "ui/base/default_style.h" |
| 13 #include "ui/base/material_design/material_design_controller.h" | 13 #include "ui/base/material_design/material_design_controller.h" |
| 14 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
| 15 #include "ui/events/keycodes/keyboard_codes.h" | 15 #include "ui/events/keycodes/keyboard_codes.h" |
| 16 #include "ui/gfx/canvas.h" | 16 #include "ui/gfx/canvas.h" |
| 17 #include "ui/gfx/font_list.h" | 17 #include "ui/gfx/font_list.h" |
| 18 #include "ui/native_theme/native_theme.h" | |
| 18 #include "ui/views/border.h" | 19 #include "ui/views/border.h" |
| 19 #include "ui/views/controls/label.h" | 20 #include "ui/views/controls/label.h" |
| 20 #include "ui/views/controls/tabbed_pane/tabbed_pane_listener.h" | 21 #include "ui/views/controls/tabbed_pane/tabbed_pane_listener.h" |
| 21 #include "ui/views/layout/box_layout.h" | 22 #include "ui/views/layout/box_layout.h" |
| 22 #include "ui/views/layout/layout_manager.h" | 23 #include "ui/views/layout/layout_manager.h" |
| 23 #include "ui/views/widget/widget.h" | 24 #include "ui/views/widget/widget.h" |
| 24 | 25 |
| 25 namespace { | 26 namespace { |
| 26 | 27 |
| 27 // TODO(markusheintz|msw): Use NativeTheme colors. | 28 // TODO(markusheintz|msw): Use NativeTheme colors. |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 254 MdTab::MdTab(TabbedPane* tabbed_pane, | 255 MdTab::MdTab(TabbedPane* tabbed_pane, |
| 255 const base::string16& title, | 256 const base::string16& title, |
| 256 View* contents) | 257 View* contents) |
| 257 : Tab(tabbed_pane, title, contents) { | 258 : Tab(tabbed_pane, title, contents) { |
| 258 OnStateChanged(); | 259 OnStateChanged(); |
| 259 } | 260 } |
| 260 | 261 |
| 261 MdTab::~MdTab() {} | 262 MdTab::~MdTab() {} |
| 262 | 263 |
| 263 void MdTab::OnStateChanged() { | 264 void MdTab::OnStateChanged() { |
| 264 // These values are directly from the Harmony specs for tabbed panes. | 265 ui::NativeTheme* theme = GetNativeTheme(); |
| 265 const SkColor kSelectedBorderColor = SkColorSetRGB(0x42, 0x85, 0xF4); | 266 SkColor border_color = selected() |
| 266 const SkColor kNormalBorderColor = SkColorSetARGB(0x23, 0x00, 0x00, 0x00); | 267 ? theme->GetSystemColor(ui::NativeTheme::kColorId_FocusedBorderColor) |
|
Evan Stade
2016/09/06 17:04:28
nit: move ternary inside GetSystemColor
| |
| 267 const SkColor kSelectedFontColor = SkColorSetRGB(0x42, 0x85, 0xF4); | 268 : theme->GetSystemColor(ui::NativeTheme::kColorId_UnfocusedBorderColor); |
| 268 const SkColor kNormalFontColor = SkColorSetRGB(0x5A, 0x5A, 0x5A); | |
| 269 | |
| 270 SkColor border_color = selected() ? kSelectedBorderColor : kNormalBorderColor; | |
| 271 int border_thickness = selected() ? 2 : 1; | 269 int border_thickness = selected() ? 2 : 1; |
| 272 SetBorder( | 270 SetBorder( |
| 273 Border::CreateSolidSidedBorder(0, 0, border_thickness, 0, border_color)); | 271 Border::CreateSolidSidedBorder(0, 0, border_thickness, 0, border_color)); |
| 274 | 272 |
| 275 SkColor font_color = selected() ? kSelectedFontColor : kNormalFontColor; | 273 SkColor font_color = selected() |
| 274 ? theme->GetSystemColor(ui::NativeTheme::kColorId_CallToActionColor) | |
| 275 : theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonEnabledColor); | |
| 276 title()->SetEnabledColor(font_color); | 276 title()->SetEnabledColor(font_color); |
| 277 | 277 |
| 278 gfx::Font::Weight font_weight = gfx::Font::Weight::NORMAL; | 278 gfx::Font::Weight font_weight = gfx::Font::Weight::NORMAL; |
| 279 #if defined(OS_WIN) | 279 #if defined(OS_WIN) |
| 280 if (selected()) | 280 if (selected()) |
| 281 font_weight = gfx::Font::Weight::BOLD; | 281 font_weight = gfx::Font::Weight::BOLD; |
| 282 #endif | 282 #endif |
| 283 | 283 |
| 284 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 284 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 285 title()->SetFontList(rb.GetFontListWithDelta(ui::kLabelFontSizeDelta, | 285 title()->SetFontList(rb.GetFontListWithDelta(ui::kLabelFontSizeDelta, |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 519 selected_tab->NotifyAccessibilityEvent( | 519 selected_tab->NotifyAccessibilityEvent( |
| 520 ui::AX_EVENT_FOCUS, true); | 520 ui::AX_EVENT_FOCUS, true); |
| 521 } | 521 } |
| 522 } | 522 } |
| 523 | 523 |
| 524 void TabbedPane::GetAccessibleState(ui::AXViewState* state) { | 524 void TabbedPane::GetAccessibleState(ui::AXViewState* state) { |
| 525 state->role = ui::AX_ROLE_TAB_LIST; | 525 state->role = ui::AX_ROLE_TAB_LIST; |
| 526 } | 526 } |
| 527 | 527 |
| 528 } // namespace views | 528 } // namespace views |
| OLD | NEW |