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/animation/animation_delegate.h" | |
| 17 #include "ui/gfx/animation/linear_animation.h" | |
| 18 #include "ui/gfx/animation/tween.h" | |
| 16 #include "ui/gfx/canvas.h" | 19 #include "ui/gfx/canvas.h" |
| 17 #include "ui/gfx/font_list.h" | 20 #include "ui/gfx/font_list.h" |
| 18 #include "ui/native_theme/native_theme.h" | 21 #include "ui/native_theme/native_theme.h" |
| 19 #include "ui/views/border.h" | 22 #include "ui/views/border.h" |
| 20 #include "ui/views/controls/label.h" | 23 #include "ui/views/controls/label.h" |
| 21 #include "ui/views/controls/tabbed_pane/tabbed_pane_listener.h" | 24 #include "ui/views/controls/tabbed_pane/tabbed_pane_listener.h" |
| 22 #include "ui/views/layout/box_layout.h" | 25 #include "ui/views/layout/box_layout.h" |
| 23 #include "ui/views/layout/fill_layout.h" | 26 #include "ui/views/layout/fill_layout.h" |
| 24 #include "ui/views/layout/layout_manager.h" | 27 #include "ui/views/layout/layout_manager.h" |
| 25 #include "ui/views/widget/widget.h" | 28 #include "ui/views/widget/widget.h" |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 51 class MdTab : public Tab { | 54 class MdTab : public Tab { |
| 52 public: | 55 public: |
| 53 MdTab(TabbedPane* tabbed_pane, const base::string16& title, View* contents); | 56 MdTab(TabbedPane* tabbed_pane, const base::string16& title, View* contents); |
| 54 ~MdTab() override; | 57 ~MdTab() override; |
| 55 | 58 |
| 56 // Overridden from Tab: | 59 // Overridden from Tab: |
| 57 void OnStateChanged() override; | 60 void OnStateChanged() override; |
| 58 | 61 |
| 59 // Overridden from View: | 62 // Overridden from View: |
| 60 gfx::Size GetPreferredSize() const override; | 63 gfx::Size GetPreferredSize() const override; |
| 61 void OnPaintBorder(gfx::Canvas* canvas) override; | 64 void OnFocus() override; |
| 65 void OnBlur() override; | |
| 62 | 66 |
| 63 private: | 67 private: |
| 64 DISALLOW_COPY_AND_ASSIGN(MdTab); | 68 DISALLOW_COPY_AND_ASSIGN(MdTab); |
| 65 }; | 69 }; |
| 66 | 70 |
| 67 // The tab strip shown above the tab contents. | 71 // The tab strip shown above the tab contents. |
| 68 class TabStrip : public View { | 72 class TabStrip : public View { |
| 69 public: | 73 public: |
| 70 // Internal class name. | 74 // Internal class name. |
| 71 static const char kViewClassName[]; | 75 static const char kViewClassName[]; |
| 72 | 76 |
| 73 TabStrip(); | 77 TabStrip(); |
| 74 ~TabStrip() override; | 78 ~TabStrip() override; |
| 75 | 79 |
| 80 // Called by TabStrip when the selected tab changes. This function is only | |
| 81 // called if |from_tab| is not null, i.e., there was a previously selected | |
| 82 // tab. | |
| 83 virtual void OnSelectedTabChanged(Tab* from_tab, Tab* to_tab); | |
| 84 | |
| 76 // Overridden from View: | 85 // Overridden from View: |
| 77 const char* GetClassName() const override; | 86 const char* GetClassName() const override; |
| 78 void OnPaintBorder(gfx::Canvas* canvas) override; | 87 void OnPaintBorder(gfx::Canvas* canvas) override; |
| 79 | 88 |
| 80 Tab* GetSelectedTab() const; | 89 Tab* GetSelectedTab() const; |
| 81 Tab* GetTabAtDeltaFromSelected(int delta) const; | 90 Tab* GetTabAtDeltaFromSelected(int delta) const; |
| 82 Tab* GetTabAtIndex(int index) const; | 91 Tab* GetTabAtIndex(int index) const; |
| 83 int GetSelectedTabIndex() const; | 92 int GetSelectedTabIndex() const; |
| 84 | 93 |
| 85 private: | 94 private: |
| 86 DISALLOW_COPY_AND_ASSIGN(TabStrip); | 95 DISALLOW_COPY_AND_ASSIGN(TabStrip); |
| 87 }; | 96 }; |
| 88 | 97 |
| 89 // A subclass of TabStrip that implements the Harmony visual styling. This | 98 // A subclass of TabStrip that implements the Harmony visual styling. This |
| 90 // class uses a BoxLayout to position tabs. | 99 // class uses a BoxLayout to position tabs. |
| 91 class MdTabStrip : public TabStrip { | 100 class MdTabStrip : public TabStrip, public gfx::AnimationDelegate { |
| 92 public: | 101 public: |
| 93 MdTabStrip(); | 102 MdTabStrip(); |
| 94 ~MdTabStrip() override; | 103 ~MdTabStrip() override; |
| 95 | 104 |
| 105 // Overridden from TabStrip: | |
| 106 void OnSelectedTabChanged(Tab* from_tab, Tab* to_tab) override; | |
| 107 | |
| 96 // Overridden from View: | 108 // Overridden from View: |
| 97 void OnPaintBorder(gfx::Canvas* canvas) override; | 109 void OnPaintBorder(gfx::Canvas* canvas) override; |
| 98 | 110 |
| 111 // Overridden from AnimationDelegate: | |
| 112 void AnimationProgressed(const gfx::Animation* animation) override; | |
| 113 void AnimationEnded(const gfx::Animation* animation) override; | |
| 114 | |
| 99 private: | 115 private: |
| 116 // Animations for expanding and contracting the selection bar. When changing | |
| 117 // selections, the selection bar first grows to encompass both the old and new | |
| 118 // selections, then shrinks to encompass only the new selection. The rates of | |
| 119 // expansion and contraction each follow the cubic bezier curves used in | |
| 120 // gfx::Tween; see MdTabStrip::OnPaintBorder for details. | |
| 121 std::unique_ptr<gfx::LinearAnimation> expand_animation_; | |
| 122 std::unique_ptr<gfx::LinearAnimation> contract_animation_; | |
| 123 | |
| 124 // The x-coordinate ranges of the old selection and the new selection. | |
| 125 gfx::Range animating_from_; | |
| 126 gfx::Range animating_to_; | |
| 127 | |
| 100 DISALLOW_COPY_AND_ASSIGN(MdTabStrip); | 128 DISALLOW_COPY_AND_ASSIGN(MdTabStrip); |
| 101 }; | 129 }; |
| 102 | 130 |
| 103 // static | 131 // static |
| 104 const char Tab::kViewClassName[] = "Tab"; | 132 const char Tab::kViewClassName[] = "Tab"; |
| 105 | 133 |
| 106 Tab::Tab(TabbedPane* tabbed_pane, const base::string16& title, View* contents) | 134 Tab::Tab(TabbedPane* tabbed_pane, const base::string16& title, View* contents) |
| 107 : tabbed_pane_(tabbed_pane), | 135 : tabbed_pane_(tabbed_pane), |
| 108 title_(new Label( | 136 title_(new Label( |
| 109 title, | 137 title, |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 231 ui::KeyboardCode key = event.key_code(); | 259 ui::KeyboardCode key = event.key_code(); |
| 232 if (key != ui::VKEY_LEFT && key != ui::VKEY_RIGHT) | 260 if (key != ui::VKEY_LEFT && key != ui::VKEY_RIGHT) |
| 233 return false; | 261 return false; |
| 234 return tabbed_pane_->MoveSelectionBy(key == ui::VKEY_RIGHT ? 1 : -1); | 262 return tabbed_pane_->MoveSelectionBy(key == ui::VKEY_RIGHT ? 1 : -1); |
| 235 } | 263 } |
| 236 | 264 |
| 237 MdTab::MdTab(TabbedPane* tabbed_pane, | 265 MdTab::MdTab(TabbedPane* tabbed_pane, |
| 238 const base::string16& title, | 266 const base::string16& title, |
| 239 View* contents) | 267 View* contents) |
| 240 : Tab(tabbed_pane, title, contents) { | 268 : Tab(tabbed_pane, title, contents) { |
| 269 const int kBorderThickness = 2; | |
| 270 SetBorder(Border::CreateEmptyBorder(gfx::Insets(kBorderThickness))); | |
| 241 OnStateChanged(); | 271 OnStateChanged(); |
| 242 } | 272 } |
| 243 | 273 |
| 244 MdTab::~MdTab() {} | 274 MdTab::~MdTab() {} |
| 245 | 275 |
| 246 void MdTab::OnStateChanged() { | 276 void MdTab::OnStateChanged() { |
| 247 ui::NativeTheme* theme = GetNativeTheme(); | 277 ui::NativeTheme* theme = GetNativeTheme(); |
| 248 | 278 |
| 249 SkColor font_color = selected() | 279 SkColor font_color = selected() |
| 250 ? theme->GetSystemColor(ui::NativeTheme::kColorId_ProminentButtonColor) | 280 ? theme->GetSystemColor(ui::NativeTheme::kColorId_ProminentButtonColor) |
| 251 : theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonEnabledColor); | 281 : theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonEnabledColor); |
| 252 title()->SetEnabledColor(font_color); | 282 title()->SetEnabledColor(font_color); |
| 253 | 283 |
| 254 gfx::Font::Weight font_weight = gfx::Font::Weight::MEDIUM; | 284 gfx::Font::Weight font_weight = gfx::Font::Weight::MEDIUM; |
| 255 #if defined(OS_WIN) | 285 #if defined(OS_WIN) |
| 256 if (selected()) | 286 if (selected()) |
| 257 font_weight = gfx::Font::Weight::BOLD; | 287 font_weight = gfx::Font::Weight::BOLD; |
| 258 #endif | 288 #endif |
| 259 | 289 |
| 260 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 290 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 261 title()->SetFontList(rb.GetFontListWithDelta(ui::kLabelFontSizeDelta, | 291 title()->SetFontList(rb.GetFontListWithDelta(ui::kLabelFontSizeDelta, |
| 262 gfx::Font::NORMAL, font_weight)); | 292 gfx::Font::NORMAL, font_weight)); |
| 263 } | 293 } |
| 264 | 294 |
| 265 void MdTab::OnPaintBorder(gfx::Canvas* canvas) { | |
| 266 const int kBorderStrokeWidth = 2; | |
| 267 if (!HasFocus()) { | |
| 268 SkColor color = GetNativeTheme()->GetSystemColor( | |
| 269 selected() ? ui::NativeTheme::kColorId_FocusedBorderColor | |
| 270 : ui::NativeTheme::kColorId_UnfocusedBorderColor); | |
| 271 int thickness = selected() ? kBorderStrokeWidth : kBorderStrokeWidth / 2; | |
| 272 canvas->FillRect(gfx::Rect(0, height() - thickness, width(), thickness), | |
| 273 color); | |
| 274 return; | |
| 275 } | |
| 276 | |
| 277 // TODO(ellyjones): should this 0x66 be part of NativeTheme somehow? | |
| 278 SkColor base_color = GetNativeTheme()->GetSystemColor( | |
| 279 ui::NativeTheme::kColorId_FocusedBorderColor); | |
| 280 SkColor light_color = SkColorSetA(base_color, 0x66); | |
| 281 | |
| 282 SkPaint paint; | |
| 283 paint.setColor(light_color); | |
| 284 paint.setStyle(SkPaint::kStroke_Style); | |
| 285 paint.setStrokeWidth(kBorderStrokeWidth); | |
| 286 | |
| 287 gfx::RectF bounds = gfx::RectF(GetLocalBounds()); | |
| 288 bounds.Inset(gfx::Insets(kBorderStrokeWidth / 2.f)); | |
| 289 | |
| 290 // Draw the lighter-colored stroke first, then draw the heavier stroke over | |
| 291 // the bottom of it. This is fine because the heavier stroke has 1.0 alpha, so | |
| 292 // the lighter stroke won't show through. | |
| 293 canvas->DrawRect(bounds, paint); | |
| 294 canvas->FillRect( | |
| 295 gfx::Rect(0, height() - kBorderStrokeWidth, width(), kBorderStrokeWidth), | |
| 296 base_color); | |
| 297 } | |
| 298 | |
| 299 gfx::Size MdTab::GetPreferredSize() const { | 295 gfx::Size MdTab::GetPreferredSize() const { |
| 300 return gfx::Size(Tab::GetPreferredSize().width(), kHarmonyTabStripTabHeight); | 296 return gfx::Size(Tab::GetPreferredSize().width(), kHarmonyTabStripTabHeight); |
| 301 } | 297 } |
| 302 | 298 |
| 299 void MdTab::OnFocus() { | |
| 300 SetBorder(Border::CreateSolidBorder( | |
| 301 GetInsets().top(), | |
| 302 SkColorSetA(GetNativeTheme()->GetSystemColor( | |
| 303 ui::NativeTheme::kColorId_FocusedBorderColor), | |
| 304 0x66))); | |
| 305 SchedulePaint(); | |
| 306 } | |
| 307 | |
| 308 void MdTab::OnBlur() { | |
| 309 SetBorder(Border::CreateEmptyBorder(GetInsets())); | |
| 310 SchedulePaint(); | |
| 311 } | |
| 312 | |
| 303 // static | 313 // static |
| 304 const char TabStrip::kViewClassName[] = "TabStrip"; | 314 const char TabStrip::kViewClassName[] = "TabStrip"; |
| 305 | 315 |
| 306 TabStrip::TabStrip() { | 316 TabStrip::TabStrip() { |
| 307 const int kTabStripLeadingEdgePadding = 9; | 317 const int kTabStripLeadingEdgePadding = 9; |
| 308 BoxLayout* layout = | 318 BoxLayout* layout = |
| 309 new BoxLayout(BoxLayout::kHorizontal, kTabStripLeadingEdgePadding, 0, 0); | 319 new BoxLayout(BoxLayout::kHorizontal, kTabStripLeadingEdgePadding, 0, 0); |
| 310 layout->set_main_axis_alignment(BoxLayout::MAIN_AXIS_ALIGNMENT_START); | 320 layout->set_main_axis_alignment(BoxLayout::MAIN_AXIS_ALIGNMENT_START); |
| 311 layout->set_cross_axis_alignment(BoxLayout::CROSS_AXIS_ALIGNMENT_END); | 321 layout->set_cross_axis_alignment(BoxLayout::CROSS_AXIS_ALIGNMENT_END); |
| 312 layout->SetDefaultFlex(0); | 322 layout->SetDefaultFlex(0); |
| 313 SetLayoutManager(layout); | 323 SetLayoutManager(layout); |
| 314 } | 324 } |
| 315 | 325 |
| 316 TabStrip::~TabStrip() {} | 326 TabStrip::~TabStrip() {} |
| 317 | 327 |
| 328 void TabStrip::OnSelectedTabChanged(Tab* from_tab, Tab* to_tab) {} | |
| 329 | |
| 318 const char* TabStrip::GetClassName() const { | 330 const char* TabStrip::GetClassName() const { |
| 319 return kViewClassName; | 331 return kViewClassName; |
| 320 } | 332 } |
| 321 | 333 |
| 322 void TabStrip::OnPaintBorder(gfx::Canvas* canvas) { | 334 void TabStrip::OnPaintBorder(gfx::Canvas* canvas) { |
| 323 SkPaint paint; | 335 SkPaint paint; |
| 324 paint.setColor(kTabBorderColor); | 336 paint.setColor(kTabBorderColor); |
| 325 paint.setStrokeWidth(kTabBorderThickness); | 337 paint.setStrokeWidth(kTabBorderThickness); |
| 326 SkScalar line_y = SkIntToScalar(height()) - (kTabBorderThickness / 2); | 338 SkScalar line_y = SkIntToScalar(height()) - (kTabBorderThickness / 2); |
| 327 SkScalar line_end = SkIntToScalar(width()); | 339 SkScalar line_end = SkIntToScalar(width()); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 return GetTabAtIndex(index); | 386 return GetTabAtIndex(index); |
| 375 } | 387 } |
| 376 | 388 |
| 377 MdTabStrip::MdTabStrip() { | 389 MdTabStrip::MdTabStrip() { |
| 378 BoxLayout* layout = | 390 BoxLayout* layout = |
| 379 new BoxLayout(BoxLayout::kHorizontal, 0, kHarmonyTabStripVerticalPad, 0); | 391 new BoxLayout(BoxLayout::kHorizontal, 0, kHarmonyTabStripVerticalPad, 0); |
| 380 layout->set_main_axis_alignment(BoxLayout::MAIN_AXIS_ALIGNMENT_CENTER); | 392 layout->set_main_axis_alignment(BoxLayout::MAIN_AXIS_ALIGNMENT_CENTER); |
| 381 layout->set_cross_axis_alignment(BoxLayout::CROSS_AXIS_ALIGNMENT_STRETCH); | 393 layout->set_cross_axis_alignment(BoxLayout::CROSS_AXIS_ALIGNMENT_STRETCH); |
| 382 layout->SetDefaultFlex(1); | 394 layout->SetDefaultFlex(1); |
| 383 SetLayoutManager(layout); | 395 SetLayoutManager(layout); |
| 396 | |
| 397 // These durations are ripped off from the Paper Tabs source: | |
|
msw
2016/10/13 17:08:26
nit: s/ripped off/taken/
Elly Fong-Jones
2016/10/13 17:12:50
Done.
| |
| 398 // https://github.com/PolymerElements/paper-tabs/blob/master/paper-tabs.html#L 197 | |
|
msw
2016/10/13 17:08:26
nit: maybe mention selectionBar.expand and selecti
Elly Fong-Jones
2016/10/13 17:12:50
Done.
| |
| 399 const int kExpandAnimationDurationMs = 150; | |
| 400 expand_animation_.reset(new gfx::LinearAnimation(this)); | |
| 401 expand_animation_->SetDuration(kExpandAnimationDurationMs); | |
| 402 | |
| 403 const int kContractAnimationDurationMs = 180; | |
| 404 contract_animation_.reset(new gfx::LinearAnimation(this)); | |
| 405 contract_animation_->SetDuration(kContractAnimationDurationMs); | |
| 384 } | 406 } |
| 385 | 407 |
| 386 MdTabStrip::~MdTabStrip() {} | 408 MdTabStrip::~MdTabStrip() {} |
| 387 | 409 |
| 388 // The tab strip "border" is drawn as part of the tabs. | 410 void MdTabStrip::OnSelectedTabChanged(Tab* from_tab, Tab* to_tab) { |
| 389 void MdTabStrip::OnPaintBorder(gfx::Canvas* canvas) {} | 411 DCHECK(!from_tab->selected()); |
| 412 DCHECK(to_tab->selected()); | |
| 413 | |
| 414 animating_from_ = | |
| 415 gfx::Range(from_tab->x(), from_tab->x() + from_tab->width()); | |
| 416 animating_to_ = gfx::Range(to_tab->x(), to_tab->x() + to_tab->width()); | |
| 417 | |
| 418 contract_animation_->Stop(); | |
| 419 expand_animation_->Start(); | |
| 420 } | |
| 421 | |
| 422 void MdTabStrip::OnPaintBorder(gfx::Canvas* canvas) { | |
| 423 int max_y = child_at(0)->y() + child_at(0)->height(); | |
| 424 const int kUnselectedBorderThickness = 1; | |
| 425 const int kSelectedBorderThickness = 2; | |
| 426 | |
| 427 // First, draw the unselected border across the TabStrip's entire width. The | |
| 428 // area underneath the selected tab will be overdrawn later. | |
| 429 canvas->FillRect(gfx::Rect(0, max_y - kUnselectedBorderThickness, width(), | |
| 430 kUnselectedBorderThickness), | |
| 431 GetNativeTheme()->GetSystemColor( | |
| 432 ui::NativeTheme::kColorId_UnfocusedBorderColor)); | |
| 433 | |
| 434 int min_x = 0; | |
| 435 int max_x = 0; | |
| 436 | |
| 437 // Now, figure out the range to draw the selection marker underneath. There | |
| 438 // are three states here: | |
| 439 // 1) Expand animation is running: use FAST_OUT_LINEAR_IN to grow the | |
| 440 // selection marker until it encompasses both the previously selected tab | |
| 441 // and the currently selected tab; | |
| 442 // 2) Contract animation is running: use LINEAR_OUT_SLOW_IN to shrink the | |
| 443 // selection marker until it encompasses only the currently selected tab; | |
| 444 // 3) No animations running: the selection marker is only under the currently | |
| 445 // selected tab. | |
| 446 Tab* tab = GetSelectedTab(); | |
| 447 if (expand_animation_->is_animating()) { | |
| 448 bool animating_left = animating_to_.start() < animating_from_.start(); | |
| 449 double anim_value = gfx::Tween::CalculateValue( | |
| 450 gfx::Tween::FAST_OUT_LINEAR_IN, expand_animation_->GetCurrentValue()); | |
| 451 | |
| 452 if (animating_left) { | |
| 453 min_x = gfx::Tween::IntValueBetween(anim_value, animating_from_.start(), | |
| 454 animating_to_.start()); | |
| 455 max_x = animating_from_.end(); | |
| 456 } else { | |
| 457 min_x = animating_from_.start(); | |
| 458 max_x = gfx::Tween::IntValueBetween(anim_value, animating_from_.end(), | |
| 459 animating_to_.end()); | |
| 460 } | |
| 461 } else if (contract_animation_->is_animating()) { | |
| 462 bool animating_left = animating_to_.start() < animating_from_.start(); | |
| 463 double anim_value = gfx::Tween::CalculateValue( | |
| 464 gfx::Tween::LINEAR_OUT_SLOW_IN, contract_animation_->GetCurrentValue()); | |
| 465 if (animating_left) { | |
| 466 min_x = animating_to_.start(); | |
| 467 max_x = gfx::Tween::IntValueBetween(anim_value, animating_from_.end(), | |
| 468 animating_to_.end()); | |
| 469 } else { | |
| 470 min_x = gfx::Tween::IntValueBetween(anim_value, animating_from_.start(), | |
| 471 animating_to_.start()); | |
| 472 max_x = animating_to_.end(); | |
| 473 } | |
| 474 } else if (tab) { | |
| 475 min_x = tab->x(); | |
| 476 max_x = tab->x() + tab->width(); | |
| 477 } | |
| 478 | |
| 479 if (min_x != max_x) { | |
|
msw
2016/10/13 17:08:26
q: When would this ever be the case? DCHECK instea
Elly Fong-Jones
2016/10/13 17:12:50
Only if there's no selected tab, which is rare but
| |
| 480 // Draw over the unselected border from above. | |
| 481 canvas->FillRect(gfx::Rect(min_x, max_y - kSelectedBorderThickness, | |
| 482 max_x - min_x, kSelectedBorderThickness), | |
| 483 GetNativeTheme()->GetSystemColor( | |
| 484 ui::NativeTheme::kColorId_FocusedBorderColor)); | |
| 485 } | |
| 486 } | |
| 487 | |
| 488 void MdTabStrip::AnimationProgressed(const gfx::Animation* animation) { | |
| 489 SchedulePaint(); | |
| 490 } | |
| 491 | |
| 492 void MdTabStrip::AnimationEnded(const gfx::Animation* animation) { | |
| 493 if (animation == expand_animation_.get()) | |
| 494 contract_animation_->Start(); | |
| 495 } | |
| 390 | 496 |
| 391 TabbedPane::TabbedPane() | 497 TabbedPane::TabbedPane() |
| 392 : listener_(NULL), | 498 : listener_(NULL), |
| 393 tab_strip_(ui::MaterialDesignController::IsSecondaryUiMaterial() | 499 tab_strip_(ui::MaterialDesignController::IsSecondaryUiMaterial() |
| 394 ? new MdTabStrip | 500 ? new MdTabStrip |
| 395 : new TabStrip), | 501 : new TabStrip), |
| 396 contents_(new View()) { | 502 contents_(new View()) { |
| 397 AddChildView(tab_strip_); | 503 AddChildView(tab_strip_); |
| 398 AddChildView(contents_); | 504 AddChildView(contents_); |
| 399 } | 505 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 434 void TabbedPane::SelectTab(Tab* new_selected_tab) { | 540 void TabbedPane::SelectTab(Tab* new_selected_tab) { |
| 435 Tab* old_selected_tab = tab_strip_->GetSelectedTab(); | 541 Tab* old_selected_tab = tab_strip_->GetSelectedTab(); |
| 436 if (old_selected_tab == new_selected_tab) | 542 if (old_selected_tab == new_selected_tab) |
| 437 return; | 543 return; |
| 438 | 544 |
| 439 new_selected_tab->SetSelected(true); | 545 new_selected_tab->SetSelected(true); |
| 440 if (old_selected_tab) { | 546 if (old_selected_tab) { |
| 441 if (old_selected_tab->HasFocus()) | 547 if (old_selected_tab->HasFocus()) |
| 442 new_selected_tab->RequestFocus(); | 548 new_selected_tab->RequestFocus(); |
| 443 old_selected_tab->SetSelected(false); | 549 old_selected_tab->SetSelected(false); |
| 550 tab_strip_->OnSelectedTabChanged(old_selected_tab, new_selected_tab); | |
| 444 } | 551 } |
| 445 tab_strip_->SchedulePaint(); | 552 tab_strip_->SchedulePaint(); |
| 446 | 553 |
| 447 FocusManager* focus_manager = new_selected_tab->contents()->GetFocusManager(); | 554 FocusManager* focus_manager = new_selected_tab->contents()->GetFocusManager(); |
| 448 if (focus_manager) { | 555 if (focus_manager) { |
| 449 const View* focused_view = focus_manager->GetFocusedView(); | 556 const View* focused_view = focus_manager->GetFocusedView(); |
| 450 if (focused_view && contents_->Contains(focused_view) && | 557 if (focused_view && contents_->Contains(focused_view) && |
| 451 !new_selected_tab->contents()->Contains(focused_view)) | 558 !new_selected_tab->contents()->Contains(focused_view)) |
| 452 focus_manager->SetFocusedView(new_selected_tab->contents()); | 559 focus_manager->SetFocusedView(new_selected_tab->contents()); |
| 453 } | 560 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 512 | 619 |
| 513 View* TabbedPane::GetSelectedTabContentView() { | 620 View* TabbedPane::GetSelectedTabContentView() { |
| 514 return GetSelectedTab() ? GetSelectedTab()->contents() : nullptr; | 621 return GetSelectedTab() ? GetSelectedTab()->contents() : nullptr; |
| 515 } | 622 } |
| 516 | 623 |
| 517 void TabbedPane::GetAccessibleState(ui::AXViewState* state) { | 624 void TabbedPane::GetAccessibleState(ui::AXViewState* state) { |
| 518 state->role = ui::AX_ROLE_TAB_LIST; | 625 state->role = ui::AX_ROLE_TAB_LIST; |
| 519 } | 626 } |
| 520 | 627 |
| 521 } // namespace views | 628 } // namespace views |
| OLD | NEW |