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" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 gfx::Font::NORMAL, | 140 gfx::Font::NORMAL, |
141 kActiveWeight))), | 141 kActiveWeight))), |
142 tab_state_(TAB_ACTIVE), | 142 tab_state_(TAB_ACTIVE), |
143 contents_(contents) { | 143 contents_(contents) { |
144 // Calculate this now while the font list is guaranteed to be bold. | 144 // Calculate this now while the font list is guaranteed to be bold. |
145 preferred_title_size_ = title_->GetPreferredSize(); | 145 preferred_title_size_ = title_->GetPreferredSize(); |
146 | 146 |
147 const int kTabVerticalPadding = 5; | 147 const int kTabVerticalPadding = 5; |
148 const int kTabHorizontalPadding = 10; | 148 const int kTabHorizontalPadding = 10; |
149 | 149 |
150 SetBorder(Border::CreateEmptyBorder( | 150 SetBorder(CreateEmptyBorder( |
151 gfx::Insets(kTabVerticalPadding, kTabHorizontalPadding))); | 151 gfx::Insets(kTabVerticalPadding, kTabHorizontalPadding))); |
152 SetLayoutManager(new FillLayout); | 152 SetLayoutManager(new FillLayout); |
153 | 153 |
154 SetState(TAB_INACTIVE); | 154 SetState(TAB_INACTIVE); |
155 AddChildView(title_); | 155 AddChildView(title_); |
156 } | 156 } |
157 | 157 |
158 Tab::~Tab() {} | 158 Tab::~Tab() {} |
159 | 159 |
160 void Tab::SetSelected(bool selected) { | 160 void Tab::SetSelected(bool selected) { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 if (key != ui::VKEY_LEFT && key != ui::VKEY_RIGHT) | 260 if (key != ui::VKEY_LEFT && key != ui::VKEY_RIGHT) |
261 return false; | 261 return false; |
262 return tabbed_pane_->MoveSelectionBy(key == ui::VKEY_RIGHT ? 1 : -1); | 262 return tabbed_pane_->MoveSelectionBy(key == ui::VKEY_RIGHT ? 1 : -1); |
263 } | 263 } |
264 | 264 |
265 MdTab::MdTab(TabbedPane* tabbed_pane, | 265 MdTab::MdTab(TabbedPane* tabbed_pane, |
266 const base::string16& title, | 266 const base::string16& title, |
267 View* contents) | 267 View* contents) |
268 : Tab(tabbed_pane, title, contents) { | 268 : Tab(tabbed_pane, title, contents) { |
269 const int kBorderThickness = 2; | 269 const int kBorderThickness = 2; |
270 SetBorder(Border::CreateEmptyBorder(gfx::Insets(kBorderThickness))); | 270 SetBorder(CreateEmptyBorder(gfx::Insets(kBorderThickness))); |
271 OnStateChanged(); | 271 OnStateChanged(); |
272 } | 272 } |
273 | 273 |
274 MdTab::~MdTab() {} | 274 MdTab::~MdTab() {} |
275 | 275 |
276 void MdTab::OnStateChanged() { | 276 void MdTab::OnStateChanged() { |
277 ui::NativeTheme* theme = GetNativeTheme(); | 277 ui::NativeTheme* theme = GetNativeTheme(); |
278 | 278 |
279 SkColor font_color = selected() | 279 SkColor font_color = selected() |
280 ? theme->GetSystemColor(ui::NativeTheme::kColorId_ProminentButtonColor) | 280 ? theme->GetSystemColor(ui::NativeTheme::kColorId_ProminentButtonColor) |
281 : theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonEnabledColor); | 281 : theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonEnabledColor); |
282 title()->SetEnabledColor(font_color); | 282 title()->SetEnabledColor(font_color); |
283 | 283 |
284 gfx::Font::Weight font_weight = gfx::Font::Weight::MEDIUM; | 284 gfx::Font::Weight font_weight = gfx::Font::Weight::MEDIUM; |
285 #if defined(OS_WIN) | 285 #if defined(OS_WIN) |
286 if (selected()) | 286 if (selected()) |
287 font_weight = gfx::Font::Weight::BOLD; | 287 font_weight = gfx::Font::Weight::BOLD; |
288 #endif | 288 #endif |
289 | 289 |
290 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 290 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
291 title()->SetFontList(rb.GetFontListWithDelta(ui::kLabelFontSizeDelta, | 291 title()->SetFontList(rb.GetFontListWithDelta(ui::kLabelFontSizeDelta, |
292 gfx::Font::NORMAL, font_weight)); | 292 gfx::Font::NORMAL, font_weight)); |
293 } | 293 } |
294 | 294 |
295 gfx::Size MdTab::GetPreferredSize() const { | 295 gfx::Size MdTab::GetPreferredSize() const { |
296 return gfx::Size(Tab::GetPreferredSize().width(), kHarmonyTabStripTabHeight); | 296 return gfx::Size(Tab::GetPreferredSize().width(), kHarmonyTabStripTabHeight); |
297 } | 297 } |
298 | 298 |
299 void MdTab::OnFocus() { | 299 void MdTab::OnFocus() { |
300 SetBorder(Border::CreateSolidBorder( | 300 SetBorder(CreateSolidBorder( |
301 GetInsets().top(), | 301 GetInsets().top(), |
302 SkColorSetA(GetNativeTheme()->GetSystemColor( | 302 SkColorSetA(GetNativeTheme()->GetSystemColor( |
303 ui::NativeTheme::kColorId_FocusedBorderColor), | 303 ui::NativeTheme::kColorId_FocusedBorderColor), |
304 0x66))); | 304 0x66))); |
305 SchedulePaint(); | 305 SchedulePaint(); |
306 } | 306 } |
307 | 307 |
308 void MdTab::OnBlur() { | 308 void MdTab::OnBlur() { |
309 SetBorder(Border::CreateEmptyBorder(GetInsets())); | 309 SetBorder(CreateEmptyBorder(GetInsets())); |
310 SchedulePaint(); | 310 SchedulePaint(); |
311 } | 311 } |
312 | 312 |
313 // static | 313 // static |
314 const char TabStrip::kViewClassName[] = "TabStrip"; | 314 const char TabStrip::kViewClassName[] = "TabStrip"; |
315 | 315 |
316 TabStrip::TabStrip() { | 316 TabStrip::TabStrip() { |
317 const int kTabStripLeadingEdgePadding = 9; | 317 const int kTabStripLeadingEdgePadding = 9; |
318 BoxLayout* layout = | 318 BoxLayout* layout = |
319 new BoxLayout(BoxLayout::kHorizontal, kTabStripLeadingEdgePadding, 0, 0); | 319 new BoxLayout(BoxLayout::kHorizontal, kTabStripLeadingEdgePadding, 0, 0); |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 | 621 |
622 View* TabbedPane::GetSelectedTabContentView() { | 622 View* TabbedPane::GetSelectedTabContentView() { |
623 return GetSelectedTab() ? GetSelectedTab()->contents() : nullptr; | 623 return GetSelectedTab() ? GetSelectedTab()->contents() : nullptr; |
624 } | 624 } |
625 | 625 |
626 void TabbedPane::GetAccessibleNodeData(ui::AXNodeData* node_data) { | 626 void TabbedPane::GetAccessibleNodeData(ui::AXNodeData* node_data) { |
627 node_data->role = ui::AX_ROLE_TAB_LIST; | 627 node_data->role = ui::AX_ROLE_TAB_LIST; |
628 } | 628 } |
629 | 629 |
630 } // namespace views | 630 } // namespace views |
OLD | NEW |