| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h" | 5 #include "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 static double GetCurrentTabWidth(TabStripGtk* tabstrip, | 161 static double GetCurrentTabWidth(TabStripGtk* tabstrip, |
| 162 TabStripGtk::TabAnimation* animation, | 162 TabStripGtk::TabAnimation* animation, |
| 163 int index) { | 163 int index) { |
| 164 TabGtk* tab = tabstrip->GetTabAt(index); | 164 TabGtk* tab = tabstrip->GetTabAt(index); |
| 165 double tab_width; | 165 double tab_width; |
| 166 if (tab->mini()) { | 166 if (tab->mini()) { |
| 167 tab_width = TabGtk::GetMiniWidth(); | 167 tab_width = TabGtk::GetMiniWidth(); |
| 168 } else { | 168 } else { |
| 169 double unselected, selected; | 169 double unselected, selected; |
| 170 tabstrip->GetCurrentTabWidths(&unselected, &selected); | 170 tabstrip->GetCurrentTabWidths(&unselected, &selected); |
| 171 tab_width = tab->IsSelected() ? selected : unselected; | 171 tab_width = tab->IsActive() ? selected : unselected; |
| 172 } | 172 } |
| 173 | 173 |
| 174 if (animation) { | 174 if (animation) { |
| 175 double specified_tab_width = animation->GetWidthForTab(index); | 175 double specified_tab_width = animation->GetWidthForTab(index); |
| 176 if (specified_tab_width != -1) | 176 if (specified_tab_width != -1) |
| 177 tab_width = specified_tab_width; | 177 tab_width = specified_tab_width; |
| 178 } | 178 } |
| 179 | 179 |
| 180 return tab_width; | 180 return tab_width; |
| 181 } | 181 } |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 double delta = target_width - start_width; | 295 double delta = target_width - start_width; |
| 296 if (delta > 0) | 296 if (delta > 0) |
| 297 return start_width + (delta * animation_.GetCurrentValue()); | 297 return start_width + (delta * animation_.GetCurrentValue()); |
| 298 | 298 |
| 299 return start_width; | 299 return start_width; |
| 300 } | 300 } |
| 301 | 301 |
| 302 if (tabstrip_->GetTabAt(index)->mini()) | 302 if (tabstrip_->GetTabAt(index)->mini()) |
| 303 return TabGtk::GetMiniWidth(); | 303 return TabGtk::GetMiniWidth(); |
| 304 | 304 |
| 305 if (tabstrip_->GetTabAt(index)->IsSelected()) { | 305 if (tabstrip_->GetTabAt(index)->IsActive()) { |
| 306 double delta = end_selected_width_ - start_selected_width_; | 306 double delta = end_selected_width_ - start_selected_width_; |
| 307 return start_selected_width_ + (delta * animation_.GetCurrentValue()); | 307 return start_selected_width_ + (delta * animation_.GetCurrentValue()); |
| 308 } | 308 } |
| 309 | 309 |
| 310 double delta = end_unselected_width_ - start_unselected_width_; | 310 double delta = end_unselected_width_ - start_unselected_width_; |
| 311 return start_unselected_width_ + (delta * animation_.GetCurrentValue()); | 311 return start_unselected_width_ + (delta * animation_.GetCurrentValue()); |
| 312 } | 312 } |
| 313 | 313 |
| 314 private: | 314 private: |
| 315 int index_; | 315 int index_; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 if (tab->mini()) | 376 if (tab->mini()) |
| 377 return TabGtk::GetMiniWidth(); | 377 return TabGtk::GetMiniWidth(); |
| 378 | 378 |
| 379 if (tabstrip_->available_width_for_tabs_ != -1 && | 379 if (tabstrip_->available_width_for_tabs_ != -1 && |
| 380 index_ != tabstrip_->GetTabCount() - 1) { | 380 index_ != tabstrip_->GetTabCount() - 1) { |
| 381 return TabStripGtk::TabAnimation::GetWidthForTab(index); | 381 return TabStripGtk::TabAnimation::GetWidthForTab(index); |
| 382 } | 382 } |
| 383 | 383 |
| 384 // All other tabs are sized according to the start/end widths specified at | 384 // All other tabs are sized according to the start/end widths specified at |
| 385 // the start of the animation. | 385 // the start of the animation. |
| 386 if (tab->IsSelected()) { | 386 if (tab->IsActive()) { |
| 387 double delta = end_selected_width_ - start_selected_width_; | 387 double delta = end_selected_width_ - start_selected_width_; |
| 388 return start_selected_width_ + (delta * animation_.GetCurrentValue()); | 388 return start_selected_width_ + (delta * animation_.GetCurrentValue()); |
| 389 } | 389 } |
| 390 | 390 |
| 391 double delta = end_unselected_width_ - start_unselected_width_; | 391 double delta = end_unselected_width_ - start_unselected_width_; |
| 392 return start_unselected_width_ + (delta * animation_.GetCurrentValue()); | 392 return start_unselected_width_ + (delta * animation_.GetCurrentValue()); |
| 393 } | 393 } |
| 394 | 394 |
| 395 virtual void AnimationEnded(const ui::Animation* animation) { | 395 virtual void AnimationEnded(const ui::Animation* animation) { |
| 396 tabstrip_->RemoveTabAt(index_); | 396 tabstrip_->RemoveTabAt(index_); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 virtual int GetDuration() const { | 484 virtual int GetDuration() const { |
| 485 return kResizeLayoutAnimationDurationMs; | 485 return kResizeLayoutAnimationDurationMs; |
| 486 } | 486 } |
| 487 | 487 |
| 488 virtual double GetWidthForTab(int index) const { | 488 virtual double GetWidthForTab(int index) const { |
| 489 TabGtk* tab = tabstrip_->GetTabAt(index); | 489 TabGtk* tab = tabstrip_->GetTabAt(index); |
| 490 | 490 |
| 491 if (tab->mini()) | 491 if (tab->mini()) |
| 492 return TabGtk::GetMiniWidth(); | 492 return TabGtk::GetMiniWidth(); |
| 493 | 493 |
| 494 if (tab->IsSelected()) { | 494 if (tab->IsActive()) { |
| 495 return animation_.CurrentValueBetween(start_selected_width_, | 495 return animation_.CurrentValueBetween(start_selected_width_, |
| 496 end_selected_width_); | 496 end_selected_width_); |
| 497 } | 497 } |
| 498 | 498 |
| 499 return animation_.CurrentValueBetween(start_unselected_width_, | 499 return animation_.CurrentValueBetween(start_unselected_width_, |
| 500 end_unselected_width_); | 500 end_unselected_width_); |
| 501 } | 501 } |
| 502 | 502 |
| 503 private: | 503 private: |
| 504 // We need to start from the current widths of the Tabs as they were last | 504 // We need to start from the current widths of the Tabs as they were last |
| 505 // laid out, _not_ the last known good state, which is what'll be done if we | 505 // laid out, _not_ the last known good state, which is what'll be done if we |
| 506 // don't measure the Tab sizes here and just go with the default TabAnimation | 506 // don't measure the Tab sizes here and just go with the default TabAnimation |
| 507 // behavior... | 507 // behavior... |
| 508 void InitStartState() { | 508 void InitStartState() { |
| 509 for (int i = 0; i < tabstrip_->GetTabCount(); ++i) { | 509 for (int i = 0; i < tabstrip_->GetTabCount(); ++i) { |
| 510 TabGtk* current_tab = tabstrip_->GetTabAt(i); | 510 TabGtk* current_tab = tabstrip_->GetTabAt(i); |
| 511 if (!current_tab->mini()) { | 511 if (!current_tab->mini()) { |
| 512 if (current_tab->IsSelected()) { | 512 if (current_tab->IsActive()) { |
| 513 start_selected_width_ = current_tab->width(); | 513 start_selected_width_ = current_tab->width(); |
| 514 } else { | 514 } else { |
| 515 start_unselected_width_ = current_tab->width(); | 515 start_unselected_width_ = current_tab->width(); |
| 516 } | 516 } |
| 517 } | 517 } |
| 518 } | 518 } |
| 519 } | 519 } |
| 520 | 520 |
| 521 DISALLOW_COPY_AND_ASSIGN(ResizeLayoutAnimation); | 521 DISALLOW_COPY_AND_ASSIGN(ResizeLayoutAnimation); |
| 522 }; | 522 }; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 static_cast<double>(TabGtk::GetMiniWidth())); | 556 static_cast<double>(TabGtk::GetMiniWidth())); |
| 557 } else { | 557 } else { |
| 558 return animation_.CurrentValueBetween( | 558 return animation_.CurrentValueBetween( |
| 559 static_cast<double>(TabGtk::GetMiniWidth()), | 559 static_cast<double>(TabGtk::GetMiniWidth()), |
| 560 end_selected_width_); | 560 end_selected_width_); |
| 561 } | 561 } |
| 562 } else if (tab->mini()) { | 562 } else if (tab->mini()) { |
| 563 return TabGtk::GetMiniWidth(); | 563 return TabGtk::GetMiniWidth(); |
| 564 } | 564 } |
| 565 | 565 |
| 566 if (tab->IsSelected()) { | 566 if (tab->IsActive()) { |
| 567 return animation_.CurrentValueBetween(start_selected_width_, | 567 return animation_.CurrentValueBetween(start_selected_width_, |
| 568 end_selected_width_); | 568 end_selected_width_); |
| 569 } | 569 } |
| 570 | 570 |
| 571 return animation_.CurrentValueBetween(start_unselected_width_, | 571 return animation_.CurrentValueBetween(start_unselected_width_, |
| 572 end_unselected_width_); | 572 end_unselected_width_); |
| 573 } | 573 } |
| 574 | 574 |
| 575 private: | 575 private: |
| 576 // Index of the tab whose mini-state changed. | 576 // Index of the tab whose mini-state changed. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 | 654 |
| 655 virtual double GetWidthForTab(int index) const { | 655 virtual double GetWidthForTab(int index) const { |
| 656 TabGtk* tab = tabstrip_->GetTabAt(index); | 656 TabGtk* tab = tabstrip_->GetTabAt(index); |
| 657 | 657 |
| 658 if (index == to_index_) | 658 if (index == to_index_) |
| 659 return animation_.CurrentValueBetween(0, target_bounds_.width()); | 659 return animation_.CurrentValueBetween(0, target_bounds_.width()); |
| 660 | 660 |
| 661 if (tab->mini()) | 661 if (tab->mini()) |
| 662 return TabGtk::GetMiniWidth(); | 662 return TabGtk::GetMiniWidth(); |
| 663 | 663 |
| 664 if (tab->IsSelected()) { | 664 if (tab->IsActive()) { |
| 665 return animation_.CurrentValueBetween(start_selected_width_, | 665 return animation_.CurrentValueBetween(start_selected_width_, |
| 666 end_selected_width_); | 666 end_selected_width_); |
| 667 } | 667 } |
| 668 | 668 |
| 669 return animation_.CurrentValueBetween(start_unselected_width_, | 669 return animation_.CurrentValueBetween(start_unselected_width_, |
| 670 end_unselected_width_); | 670 end_unselected_width_); |
| 671 } | 671 } |
| 672 | 672 |
| 673 private: | 673 private: |
| 674 // The tab being moved. | 674 // The tab being moved. |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1048 GenerateIdealBounds(); | 1048 GenerateIdealBounds(); |
| 1049 StartMoveTabAnimation(from_index, to_index); | 1049 StartMoveTabAnimation(from_index, to_index); |
| 1050 } | 1050 } |
| 1051 | 1051 |
| 1052 void TabStripGtk::TabChangedAt(TabContentsWrapper* contents, int index, | 1052 void TabStripGtk::TabChangedAt(TabContentsWrapper* contents, int index, |
| 1053 TabChangeType change_type) { | 1053 TabChangeType change_type) { |
| 1054 // Index is in terms of the model. Need to make sure we adjust that index in | 1054 // Index is in terms of the model. Need to make sure we adjust that index in |
| 1055 // case we have an animation going. | 1055 // case we have an animation going. |
| 1056 TabGtk* tab = GetTabAtAdjustForAnimation(index); | 1056 TabGtk* tab = GetTabAtAdjustForAnimation(index); |
| 1057 if (change_type == TITLE_NOT_LOADING) { | 1057 if (change_type == TITLE_NOT_LOADING) { |
| 1058 if (tab->mini() && !tab->IsSelected()) | 1058 if (tab->mini() && !tab->IsActive()) |
| 1059 tab->StartMiniTabTitleAnimation(); | 1059 tab->StartMiniTabTitleAnimation(); |
| 1060 // We'll receive another notification of the change asynchronously. | 1060 // We'll receive another notification of the change asynchronously. |
| 1061 return; | 1061 return; |
| 1062 } | 1062 } |
| 1063 tab->UpdateData(contents->tab_contents(), | 1063 tab->UpdateData(contents->tab_contents(), |
| 1064 model_->IsAppTab(index), | 1064 model_->IsAppTab(index), |
| 1065 change_type == LOADING_ONLY); | 1065 change_type == LOADING_ONLY); |
| 1066 tab->UpdateFromModel(); | 1066 tab->UpdateFromModel(); |
| 1067 } | 1067 } |
| 1068 | 1068 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1090 } | 1090 } |
| 1091 | 1091 |
| 1092 void TabStripGtk::TabBlockedStateChanged(TabContentsWrapper* contents, | 1092 void TabStripGtk::TabBlockedStateChanged(TabContentsWrapper* contents, |
| 1093 int index) { | 1093 int index) { |
| 1094 GetTabAt(index)->SetBlocked(model_->IsTabBlocked(index)); | 1094 GetTabAt(index)->SetBlocked(model_->IsTabBlocked(index)); |
| 1095 } | 1095 } |
| 1096 | 1096 |
| 1097 //////////////////////////////////////////////////////////////////////////////// | 1097 //////////////////////////////////////////////////////////////////////////////// |
| 1098 // TabStripGtk, TabGtk::TabDelegate implementation: | 1098 // TabStripGtk, TabGtk::TabDelegate implementation: |
| 1099 | 1099 |
| 1100 bool TabStripGtk::IsTabSelected(const TabGtk* tab) const { | 1100 bool TabStripGtk::IsTabActive(const TabGtk* tab) const { |
| 1101 if (tab->closing()) | 1101 if (tab->closing()) |
| 1102 return false; | 1102 return false; |
| 1103 | 1103 |
| 1104 return GetIndexOfTab(tab) == model_->active_index(); | 1104 return GetIndexOfTab(tab) == model_->active_index(); |
| 1105 } | 1105 } |
| 1106 | 1106 |
| 1107 bool TabStripGtk::IsTabSelected(const TabGtk* tab) const { |
| 1108 if (tab->closing()) |
| 1109 return false; |
| 1110 |
| 1111 return model_->IsTabSelected(GetIndexOfTab(tab)); |
| 1112 } |
| 1113 |
| 1107 bool TabStripGtk::IsTabDetached(const TabGtk* tab) const { | 1114 bool TabStripGtk::IsTabDetached(const TabGtk* tab) const { |
| 1108 if (drag_controller_.get()) | 1115 if (drag_controller_.get()) |
| 1109 return drag_controller_->IsTabDetached(tab); | 1116 return drag_controller_->IsTabDetached(tab); |
| 1110 return false; | 1117 return false; |
| 1111 } | 1118 } |
| 1112 | 1119 |
| 1113 void TabStripGtk::GetCurrentTabWidths(double* unselected_width, | 1120 void TabStripGtk::GetCurrentTabWidths(double* unselected_width, |
| 1114 double* selected_width) const { | 1121 double* selected_width) const { |
| 1115 *unselected_width = current_unselected_width_; | 1122 *unselected_width = current_unselected_width_; |
| 1116 *selected_width = current_selected_width_; | 1123 *selected_width = current_selected_width_; |
| 1117 } | 1124 } |
| 1118 | 1125 |
| 1119 bool TabStripGtk::IsTabPinned(const TabGtk* tab) const { | 1126 bool TabStripGtk::IsTabPinned(const TabGtk* tab) const { |
| 1120 if (tab->closing()) | 1127 if (tab->closing()) |
| 1121 return false; | 1128 return false; |
| 1122 | 1129 |
| 1123 return model_->IsTabPinned(GetIndexOfTab(tab)); | 1130 return model_->IsTabPinned(GetIndexOfTab(tab)); |
| 1124 } | 1131 } |
| 1125 | 1132 |
| 1126 void TabStripGtk::SelectTab(TabGtk* tab) { | 1133 void TabStripGtk::ActivateTab(TabGtk* tab) { |
| 1127 int index = GetIndexOfTab(tab); | 1134 int index = GetIndexOfTab(tab); |
| 1128 if (model_->ContainsIndex(index)) | 1135 if (model_->ContainsIndex(index)) |
| 1129 model_->ActivateTabAt(index, true); | 1136 model_->ActivateTabAt(index, true); |
| 1130 } | 1137 } |
| 1131 | 1138 |
| 1139 void TabStripGtk::ToggleTabSelection(TabGtk* tab) { |
| 1140 int index = GetIndexOfTab(tab); |
| 1141 if (model_->ContainsIndex(index)) |
| 1142 model_->ToggleSelectionAt(index); |
| 1143 } |
| 1144 |
| 1145 void TabStripGtk::ExtendTabSelection(TabGtk* tab) { |
| 1146 int index = GetIndexOfTab(tab); |
| 1147 if (model_->ContainsIndex(index)) |
| 1148 model_->ExtendSelectionTo(index); |
| 1149 } |
| 1150 |
| 1132 void TabStripGtk::CloseTab(TabGtk* tab) { | 1151 void TabStripGtk::CloseTab(TabGtk* tab) { |
| 1133 int tab_index = GetIndexOfTab(tab); | 1152 int tab_index = GetIndexOfTab(tab); |
| 1134 if (model_->ContainsIndex(tab_index)) { | 1153 if (model_->ContainsIndex(tab_index)) { |
| 1135 TabGtk* last_tab = GetTabAt(GetTabCount() - 1); | 1154 TabGtk* last_tab = GetTabAt(GetTabCount() - 1); |
| 1136 // Limit the width available to the TabStrip for laying out Tabs, so that | 1155 // Limit the width available to the TabStrip for laying out Tabs, so that |
| 1137 // Tabs are not resized until a later time (when the mouse pointer leaves | 1156 // Tabs are not resized until a later time (when the mouse pointer leaves |
| 1138 // the TabStrip). | 1157 // the TabStrip). |
| 1139 available_width_for_tabs_ = GetAvailableWidthForTabs(last_tab); | 1158 available_width_for_tabs_ = GetAvailableWidthForTabs(last_tab); |
| 1140 needs_resize_layout_ = true; | 1159 needs_resize_layout_ = true; |
| 1141 // We hook into the message loop in order to receive mouse move events when | 1160 // We hook into the message loop in order to receive mouse move events when |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1340 | 1359 |
| 1341 // NOTE: This currently assumes a tab's height doesn't differ based on | 1360 // NOTE: This currently assumes a tab's height doesn't differ based on |
| 1342 // selected state or the number of tabs in the strip! | 1361 // selected state or the number of tabs in the strip! |
| 1343 int tab_height = TabGtk::GetStandardSize().height(); | 1362 int tab_height = TabGtk::GetStandardSize().height(); |
| 1344 double tab_x = tab_start_x(); | 1363 double tab_x = tab_start_x(); |
| 1345 for (int i = 0; i < tab_count; ++i) { | 1364 for (int i = 0; i < tab_count; ++i) { |
| 1346 TabGtk* tab = GetTabAt(i); | 1365 TabGtk* tab = GetTabAt(i); |
| 1347 double tab_width = unselected; | 1366 double tab_width = unselected; |
| 1348 if (tab->mini()) | 1367 if (tab->mini()) |
| 1349 tab_width = TabGtk::GetMiniWidth(); | 1368 tab_width = TabGtk::GetMiniWidth(); |
| 1350 else if (tab->IsSelected()) | 1369 else if (tab->IsActive()) |
| 1351 tab_width = selected; | 1370 tab_width = selected; |
| 1352 double end_of_tab = tab_x + tab_width; | 1371 double end_of_tab = tab_x + tab_width; |
| 1353 int rounded_tab_x = Round(tab_x); | 1372 int rounded_tab_x = Round(tab_x); |
| 1354 gfx::Rect state(rounded_tab_x, 0, Round(end_of_tab) - rounded_tab_x, | 1373 gfx::Rect state(rounded_tab_x, 0, Round(end_of_tab) - rounded_tab_x, |
| 1355 tab_height); | 1374 tab_height); |
| 1356 tab_data_.at(i).ideal_bounds = state; | 1375 tab_data_.at(i).ideal_bounds = state; |
| 1357 tab_x = end_of_tab + GetTabHOffset(i + 1); | 1376 tab_x = end_of_tab + GetTabHOffset(i + 1); |
| 1358 } | 1377 } |
| 1359 } | 1378 } |
| 1360 | 1379 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1484 available_width_for_tabs_ = -1; | 1503 available_width_for_tabs_ = -1; |
| 1485 int mini_tab_count = GetMiniTabCount(); | 1504 int mini_tab_count = GetMiniTabCount(); |
| 1486 if (mini_tab_count == GetTabCount()) { | 1505 if (mini_tab_count == GetTabCount()) { |
| 1487 // Only mini tabs, we know the tab widths won't have changed (all mini-tabs | 1506 // Only mini tabs, we know the tab widths won't have changed (all mini-tabs |
| 1488 // have the same width), so there is nothing to do. | 1507 // have the same width), so there is nothing to do. |
| 1489 return false; | 1508 return false; |
| 1490 } | 1509 } |
| 1491 TabGtk* first_tab = GetTabAt(mini_tab_count); | 1510 TabGtk* first_tab = GetTabAt(mini_tab_count); |
| 1492 double unselected, selected; | 1511 double unselected, selected; |
| 1493 GetDesiredTabWidths(GetTabCount(), mini_tab_count, &unselected, &selected); | 1512 GetDesiredTabWidths(GetTabCount(), mini_tab_count, &unselected, &selected); |
| 1494 int w = Round(first_tab->IsSelected() ? selected : unselected); | 1513 int w = Round(first_tab->IsActive() ? selected : unselected); |
| 1495 | 1514 |
| 1496 // We only want to run the animation if we're not already at the desired | 1515 // We only want to run the animation if we're not already at the desired |
| 1497 // size. | 1516 // size. |
| 1498 if (abs(first_tab->width() - w) > 1) { | 1517 if (abs(first_tab->width() - w) > 1) { |
| 1499 StartResizeLayoutAnimation(); | 1518 StartResizeLayoutAnimation(); |
| 1500 return true; | 1519 return true; |
| 1501 } | 1520 } |
| 1502 | 1521 |
| 1503 return false; | 1522 return false; |
| 1504 } | 1523 } |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1913 newtab_button_->widget(), event); | 1932 newtab_button_->widget(), event); |
| 1914 | 1933 |
| 1915 // Paint the tabs in reverse order, so they stack to the left. | 1934 // Paint the tabs in reverse order, so they stack to the left. |
| 1916 TabGtk* selected_tab = NULL; | 1935 TabGtk* selected_tab = NULL; |
| 1917 int tab_count = GetTabCount(); | 1936 int tab_count = GetTabCount(); |
| 1918 for (int i = tab_count - 1; i >= 0; --i) { | 1937 for (int i = tab_count - 1; i >= 0; --i) { |
| 1919 TabGtk* tab = GetTabAt(i); | 1938 TabGtk* tab = GetTabAt(i); |
| 1920 // We must ask the _Tab's_ model, not ourselves, because in some situations | 1939 // We must ask the _Tab's_ model, not ourselves, because in some situations |
| 1921 // the model will be different to this object, e.g. when a Tab is being | 1940 // the model will be different to this object, e.g. when a Tab is being |
| 1922 // removed after its TabContents has been destroyed. | 1941 // removed after its TabContents has been destroyed. |
| 1923 if (!tab->IsSelected()) { | 1942 if (!tab->IsActive()) { |
| 1924 gtk_container_propagate_expose(GTK_CONTAINER(tabstrip_.get()), | 1943 gtk_container_propagate_expose(GTK_CONTAINER(tabstrip_.get()), |
| 1925 tab->widget(), event); | 1944 tab->widget(), event); |
| 1926 } else { | 1945 } else { |
| 1927 selected_tab = tab; | 1946 selected_tab = tab; |
| 1928 } | 1947 } |
| 1929 } | 1948 } |
| 1930 | 1949 |
| 1931 // Paint the selected tab last, so it overlaps all the others. | 1950 // Paint the selected tab last, so it overlaps all the others. |
| 1932 if (selected_tab) { | 1951 if (selected_tab) { |
| 1933 gtk_container_propagate_expose(GTK_CONTAINER(tabstrip_.get()), | 1952 gtk_container_propagate_expose(GTK_CONTAINER(tabstrip_.get()), |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2076 | 2095 |
| 2077 // Let the middle mouse button initiate clicks as well. | 2096 // Let the middle mouse button initiate clicks as well. |
| 2078 gtk_util::SetButtonTriggersNavigation(button->widget()); | 2097 gtk_util::SetButtonTriggersNavigation(button->widget()); |
| 2079 g_signal_connect(button->widget(), "clicked", | 2098 g_signal_connect(button->widget(), "clicked", |
| 2080 G_CALLBACK(OnNewTabClickedThunk), this); | 2099 G_CALLBACK(OnNewTabClickedThunk), this); |
| 2081 GTK_WIDGET_UNSET_FLAGS(button->widget(), GTK_CAN_FOCUS); | 2100 GTK_WIDGET_UNSET_FLAGS(button->widget(), GTK_CAN_FOCUS); |
| 2082 gtk_fixed_put(GTK_FIXED(tabstrip_.get()), button->widget(), 0, 0); | 2101 gtk_fixed_put(GTK_FIXED(tabstrip_.get()), button->widget(), 0, 0); |
| 2083 | 2102 |
| 2084 return button; | 2103 return button; |
| 2085 } | 2104 } |
| OLD | NEW |