| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/gtk/tabs/tab_strip_gtk.h" | 5 #include "chrome/browser/gtk/tabs/tab_strip_gtk.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "app/gtk_dnd_util.h" | 9 #include "app/gtk_dnd_util.h" |
| 10 #include "app/gfx/canvas_paint.h" | 10 #include "app/gfx/canvas_paint.h" |
| (...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 int tab_right = 0; | 766 int tab_right = 0; |
| 767 for (int i = 0; i < tab_count; ++i) { | 767 for (int i = 0; i < tab_count; ++i) { |
| 768 const gfx::Rect& bounds = tab_data_.at(i).ideal_bounds; | 768 const gfx::Rect& bounds = tab_data_.at(i).ideal_bounds; |
| 769 TabGtk* tab = GetTabAt(i); | 769 TabGtk* tab = GetTabAt(i); |
| 770 SetTabBounds(tab, bounds); | 770 SetTabBounds(tab, bounds); |
| 771 tab_right = bounds.right(); | 771 tab_right = bounds.right(); |
| 772 tab_right += GetTabHOffset(i + 1); | 772 tab_right += GetTabHOffset(i + 1); |
| 773 } | 773 } |
| 774 | 774 |
| 775 LayoutNewTabButton(static_cast<double>(tab_right), current_unselected_width_); | 775 LayoutNewTabButton(static_cast<double>(tab_right), current_unselected_width_); |
| 776 gtk_widget_queue_draw(tabstrip_.get()); | |
| 777 } | 776 } |
| 778 | 777 |
| 779 void TabStripGtk::SchedulePaint() { | 778 void TabStripGtk::SchedulePaint() { |
| 780 gtk_widget_queue_draw(tabstrip_.get()); | 779 gtk_widget_queue_draw(tabstrip_.get()); |
| 781 } | 780 } |
| 782 | 781 |
| 783 void TabStripGtk::SetBounds(const gfx::Rect& bounds) { | 782 void TabStripGtk::SetBounds(const gfx::Rect& bounds) { |
| 784 bounds_ = bounds; | 783 bounds_ = bounds; |
| 785 } | 784 } |
| 786 | 785 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 974 void TabStripGtk::TabSelectedAt(TabContents* old_contents, | 973 void TabStripGtk::TabSelectedAt(TabContents* old_contents, |
| 975 TabContents* new_contents, | 974 TabContents* new_contents, |
| 976 int index, | 975 int index, |
| 977 bool user_gesture) { | 976 bool user_gesture) { |
| 978 DCHECK(index >= 0 && index < static_cast<int>(GetTabCount())); | 977 DCHECK(index >= 0 && index < static_cast<int>(GetTabCount())); |
| 979 | 978 |
| 980 if (CanUpdateDisplay()) { | 979 if (CanUpdateDisplay()) { |
| 981 // We have "tiny tabs" if the tabs are so tiny that the unselected ones are | 980 // We have "tiny tabs" if the tabs are so tiny that the unselected ones are |
| 982 // a different size to the selected ones. | 981 // a different size to the selected ones. |
| 983 bool tiny_tabs = current_unselected_width_ != current_selected_width_; | 982 bool tiny_tabs = current_unselected_width_ != current_selected_width_; |
| 984 if (!IsAnimating() && (!resize_layout_scheduled_ || tiny_tabs)) { | 983 if (!IsAnimating() && (!resize_layout_scheduled_ || tiny_tabs)) |
| 985 Layout(); | 984 Layout(); |
| 986 } else { | |
| 987 gtk_widget_queue_draw(tabstrip_.get()); | |
| 988 } | |
| 989 } | 985 } |
| 990 } | 986 } |
| 991 | 987 |
| 992 void TabStripGtk::TabMoved(TabContents* contents, | 988 void TabStripGtk::TabMoved(TabContents* contents, |
| 993 int from_index, | 989 int from_index, |
| 994 int to_index, | 990 int to_index, |
| 995 bool pinned_state_changed) { | 991 bool pinned_state_changed) { |
| 996 gfx::Rect start_bounds = GetIdealBounds(from_index); | 992 gfx::Rect start_bounds = GetIdealBounds(from_index); |
| 997 TabGtk* tab = GetTabAt(from_index); | 993 TabGtk* tab = GetTabAt(from_index); |
| 998 tab_data_.erase(tab_data_.begin() + from_index); | 994 tab_data_.erase(tab_data_.begin() + from_index); |
| (...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1690 double tab_width = TabAnimation::GetCurrentTabWidth(this, animation, i); | 1686 double tab_width = TabAnimation::GetCurrentTabWidth(this, animation, i); |
| 1691 double end_of_tab = tab_x + tab_width; | 1687 double end_of_tab = tab_x + tab_width; |
| 1692 int rounded_tab_x = Round(tab_x); | 1688 int rounded_tab_x = Round(tab_x); |
| 1693 TabGtk* tab = GetTabAt(i); | 1689 TabGtk* tab = GetTabAt(i); |
| 1694 gfx::Rect bounds(rounded_tab_x, 0, Round(end_of_tab) - rounded_tab_x, | 1690 gfx::Rect bounds(rounded_tab_x, 0, Round(end_of_tab) - rounded_tab_x, |
| 1695 tab_height); | 1691 tab_height); |
| 1696 SetTabBounds(tab, bounds); | 1692 SetTabBounds(tab, bounds); |
| 1697 tab_x = end_of_tab + GetTabHOffset(i + 1); | 1693 tab_x = end_of_tab + GetTabHOffset(i + 1); |
| 1698 } | 1694 } |
| 1699 LayoutNewTabButton(tab_x, unselected_width); | 1695 LayoutNewTabButton(tab_x, unselected_width); |
| 1700 gtk_widget_queue_draw(tabstrip_.get()); | |
| 1701 } | 1696 } |
| 1702 | 1697 |
| 1703 void TabStripGtk::StartInsertTabAnimation(int index) { | 1698 void TabStripGtk::StartInsertTabAnimation(int index) { |
| 1704 // The TabStrip can now use its entire width to lay out Tabs. | 1699 // The TabStrip can now use its entire width to lay out Tabs. |
| 1705 available_width_for_tabs_ = -1; | 1700 available_width_for_tabs_ = -1; |
| 1706 if (active_animation_.get()) | 1701 if (active_animation_.get()) |
| 1707 active_animation_->Stop(); | 1702 active_animation_->Stop(); |
| 1708 active_animation_.reset(new InsertTabAnimation(this, index)); | 1703 active_animation_.reset(new InsertTabAnimation(this, index)); |
| 1709 active_animation_->Start(); | 1704 active_animation_->Start(); |
| 1710 } | 1705 } |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2011 | 2006 |
| 2012 // Let the middle mouse button initiate clicks as well. | 2007 // Let the middle mouse button initiate clicks as well. |
| 2013 gtk_util::SetButtonTriggersNavigation(button->widget()); | 2008 gtk_util::SetButtonTriggersNavigation(button->widget()); |
| 2014 g_signal_connect(G_OBJECT(button->widget()), "clicked", | 2009 g_signal_connect(G_OBJECT(button->widget()), "clicked", |
| 2015 G_CALLBACK(OnNewTabClicked), this); | 2010 G_CALLBACK(OnNewTabClicked), this); |
| 2016 GTK_WIDGET_UNSET_FLAGS(button->widget(), GTK_CAN_FOCUS); | 2011 GTK_WIDGET_UNSET_FLAGS(button->widget(), GTK_CAN_FOCUS); |
| 2017 gtk_fixed_put(GTK_FIXED(tabstrip_.get()), button->widget(), 0, 0); | 2012 gtk_fixed_put(GTK_FIXED(tabstrip_.get()), button->widget(), 0, 0); |
| 2018 | 2013 |
| 2019 return button; | 2014 return button; |
| 2020 } | 2015 } |
| OLD | NEW |