| 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/resource/resource_bundle.h" | 13 #include "ui/base/resource/resource_bundle.h" |
| 13 #include "ui/events/keycodes/keyboard_codes.h" | 14 #include "ui/events/keycodes/keyboard_codes.h" |
| 14 #include "ui/gfx/canvas.h" | 15 #include "ui/gfx/canvas.h" |
| 15 #include "ui/gfx/font_list.h" | 16 #include "ui/gfx/font_list.h" |
| 16 #include "ui/views/controls/label.h" | 17 #include "ui/views/controls/label.h" |
| 17 #include "ui/views/controls/tabbed_pane/tabbed_pane_listener.h" | 18 #include "ui/views/controls/tabbed_pane/tabbed_pane_listener.h" |
| 18 #include "ui/views/layout/layout_manager.h" | 19 #include "ui/views/layout/layout_manager.h" |
| 19 #include "ui/views/widget/widget.h" | 20 #include "ui/views/widget/widget.h" |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 // TODO(markusheintz|msw): Use NativeTheme colors. | 24 // TODO(markusheintz|msw): Use NativeTheme colors. |
| 24 const SkColor kTabTitleColor_Inactive = SkColorSetRGB(0x64, 0x64, 0x64); | 25 const SkColor kTabTitleColor_Inactive = SkColorSetRGB(0x64, 0x64, 0x64); |
| 25 const SkColor kTabTitleColor_Active = SK_ColorBLACK; | 26 const SkColor kTabTitleColor_Active = SK_ColorBLACK; |
| 26 const SkColor kTabTitleColor_Hovered = SK_ColorBLACK; | 27 const SkColor kTabTitleColor_Hovered = SK_ColorBLACK; |
| 27 const SkColor kTabBorderColor = SkColorSetRGB(0xC8, 0xC8, 0xC8); | 28 const SkColor kTabBorderColor = SkColorSetRGB(0xC8, 0xC8, 0xC8); |
| 28 const SkScalar kTabBorderThickness = 1.0f; | 29 const SkScalar kTabBorderThickness = 1.0f; |
| 29 | 30 |
| 31 const gfx::Font::FontStyle kHoverStyle = gfx::Font::NORMAL; |
| 32 const gfx::Font::FontStyle kActiveStyle = gfx::Font::BOLD; |
| 33 const gfx::Font::FontStyle kInactiveStyle = gfx::Font::NORMAL; |
| 34 |
| 30 } // namespace | 35 } // namespace |
| 31 | 36 |
| 32 namespace views { | 37 namespace views { |
| 33 | 38 |
| 34 // static | 39 // static |
| 35 const char TabbedPane::kViewClassName[] = "TabbedPane"; | 40 const char TabbedPane::kViewClassName[] = "TabbedPane"; |
| 36 | 41 |
| 37 // The tab view shown in the tab strip. | 42 // The tab view shown in the tab strip. |
| 38 class Tab : public View { | 43 class Tab : public View { |
| 39 public: | 44 public: |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 TabbedPane* tabbed_pane_; | 100 TabbedPane* tabbed_pane_; |
| 96 | 101 |
| 97 DISALLOW_COPY_AND_ASSIGN(TabStrip); | 102 DISALLOW_COPY_AND_ASSIGN(TabStrip); |
| 98 }; | 103 }; |
| 99 | 104 |
| 100 // static | 105 // static |
| 101 const char Tab::kViewClassName[] = "Tab"; | 106 const char Tab::kViewClassName[] = "Tab"; |
| 102 | 107 |
| 103 Tab::Tab(TabbedPane* tabbed_pane, const base::string16& title, View* contents) | 108 Tab::Tab(TabbedPane* tabbed_pane, const base::string16& title, View* contents) |
| 104 : tabbed_pane_(tabbed_pane), | 109 : tabbed_pane_(tabbed_pane), |
| 105 title_(new Label(title, | 110 title_(new Label( |
| 106 ui::ResourceBundle::GetSharedInstance().GetFontList( | 111 title, |
| 107 ui::ResourceBundle::BoldFont))), | 112 ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta( |
| 113 ui::kLabelFontSizeDelta, |
| 114 kActiveStyle))), |
| 108 tab_state_(TAB_ACTIVE), | 115 tab_state_(TAB_ACTIVE), |
| 109 contents_(contents) { | 116 contents_(contents) { |
| 110 // Calculate this now while the font list is guaranteed to be bold. | 117 // Calculate this now while the font list is guaranteed to be bold. |
| 111 preferred_title_size_ = title_->GetPreferredSize(); | 118 preferred_title_size_ = title_->GetPreferredSize(); |
| 112 | 119 |
| 113 SetState(TAB_INACTIVE); | 120 SetState(TAB_INACTIVE); |
| 114 AddChildView(title_); | 121 AddChildView(title_); |
| 115 } | 122 } |
| 116 | 123 |
| 117 Tab::~Tab() {} | 124 Tab::~Tab() {} |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 | 182 |
| 176 void Tab::SetState(TabState tab_state) { | 183 void Tab::SetState(TabState tab_state) { |
| 177 if (tab_state == tab_state_) | 184 if (tab_state == tab_state_) |
| 178 return; | 185 return; |
| 179 tab_state_ = tab_state; | 186 tab_state_ = tab_state; |
| 180 | 187 |
| 181 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 188 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 182 switch (tab_state) { | 189 switch (tab_state) { |
| 183 case TAB_INACTIVE: | 190 case TAB_INACTIVE: |
| 184 title_->SetEnabledColor(kTabTitleColor_Inactive); | 191 title_->SetEnabledColor(kTabTitleColor_Inactive); |
| 185 title_->SetFontList(rb.GetFontList(ui::ResourceBundle::BaseFont)); | 192 title_->SetFontList( |
| 193 rb.GetFontListWithDelta(ui::kLabelFontSizeDelta, kInactiveStyle)); |
| 186 break; | 194 break; |
| 187 case TAB_ACTIVE: | 195 case TAB_ACTIVE: |
| 188 title_->SetEnabledColor(kTabTitleColor_Active); | 196 title_->SetEnabledColor(kTabTitleColor_Active); |
| 189 title_->SetFontList(rb.GetFontList(ui::ResourceBundle::BoldFont)); | 197 title_->SetFontList( |
| 198 rb.GetFontListWithDelta(ui::kLabelFontSizeDelta, kActiveStyle)); |
| 190 break; | 199 break; |
| 191 case TAB_HOVERED: | 200 case TAB_HOVERED: |
| 192 title_->SetEnabledColor(kTabTitleColor_Hovered); | 201 title_->SetEnabledColor(kTabTitleColor_Hovered); |
| 193 title_->SetFontList(rb.GetFontList(ui::ResourceBundle::BaseFont)); | 202 title_->SetFontList( |
| 203 rb.GetFontListWithDelta(ui::kLabelFontSizeDelta, kHoverStyle)); |
| 194 break; | 204 break; |
| 195 } | 205 } |
| 196 SchedulePaint(); | 206 SchedulePaint(); |
| 197 } | 207 } |
| 198 | 208 |
| 199 // static | 209 // static |
| 200 const char TabStrip::kViewClassName[] = "TabStrip"; | 210 const char TabStrip::kViewClassName[] = "TabStrip"; |
| 201 | 211 |
| 202 TabStrip::TabStrip(TabbedPane* tabbed_pane) : tabbed_pane_(tabbed_pane) {} | 212 TabStrip::TabStrip(TabbedPane* tabbed_pane) : tabbed_pane_(tabbed_pane) {} |
| 203 | 213 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 selected_tab->NotifyAccessibilityEvent( | 401 selected_tab->NotifyAccessibilityEvent( |
| 392 ui::AX_EVENT_FOCUS, true); | 402 ui::AX_EVENT_FOCUS, true); |
| 393 } | 403 } |
| 394 } | 404 } |
| 395 | 405 |
| 396 void TabbedPane::GetAccessibleState(ui::AXViewState* state) { | 406 void TabbedPane::GetAccessibleState(ui::AXViewState* state) { |
| 397 state->role = ui::AX_ROLE_TAB_LIST; | 407 state->role = ui::AX_ROLE_TAB_LIST; |
| 398 } | 408 } |
| 399 | 409 |
| 400 } // namespace views | 410 } // namespace views |
| OLD | NEW |