summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/tabs/tab_strip.cc
diff options
context:
space:
mode:
authorfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-27 02:35:12 +0000
committerfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-27 02:35:12 +0000
commitafa097fea45bb2a21a0a9c11af7a8942db045ef0 (patch)
treec2c86eca9fa9546a084bb0865910ec38c8b95f66 /chrome/browser/views/tabs/tab_strip.cc
parent007a0acb82560269c7921960e2fd8077ed1eb527 (diff)
downloadchromium_src-afa097fea45bb2a21a0a9c11af7a8942db045ef0.zip
chromium_src-afa097fea45bb2a21a0a9c11af7a8942db045ef0.tar.gz
chromium_src-afa097fea45bb2a21a0a9c11af7a8942db045ef0.tar.bz2
Two changes to extension app icons:
1) When one of the mini tabs is an app (nano) tab, we now increase the margin between the mini tabs and the regular tabs by a few pixels. This is because with the large icons for nano tabs, it looks a little squished against the regular tabs in the tabstrip. 2) When dragging a nano tab within the tab strip, the background "handle" would grow to be as large as a regular tab (while dragging) due to the fact that UpdateData (that DraggedTabView calls) was not transferring the app tab bit to the new Tab. BUG=None TEST=Visual inspection. Review URL: http://codereview.chromium.org/1700016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45664 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/tabs/tab_strip.cc')
-rw-r--r--chrome/browser/views/tabs/tab_strip.cc31
1 files changed, 28 insertions, 3 deletions
diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc
index f5a8756..4d61d99 100644
--- a/chrome/browser/views/tabs/tab_strip.cc
+++ b/chrome/browser/views/tabs/tab_strip.cc
@@ -238,6 +238,9 @@ class TabStrip::RemoveTabDelegate
// static
const int TabStrip::mini_to_non_mini_gap_ = 3;
+// static
+const int TabStrip::extra_gap_for_nano_ = 10;
+
TabStrip::TabStrip(TabStripModel* model)
: model_(model),
resize_layout_factory_(this),
@@ -1087,9 +1090,11 @@ void TabStrip::GetCurrentTabWidths(double* unselected_width,
void TabStrip::GetDesiredTabWidths(int tab_count,
int mini_tab_count,
+ int nano_tab_count,
double* unselected_width,
double* selected_width) const {
DCHECK(tab_count >= 0 && mini_tab_count >= 0 && mini_tab_count <= tab_count);
+ DCHECK(nano_tab_count >= 0 && nano_tab_count <= tab_count);
const double min_unselected_width = Tab::GetMinimumUnselectedSize().width();
const double min_selected_width = Tab::GetMinimumSelectedSize().width();
@@ -1128,6 +1133,9 @@ void TabStrip::GetDesiredTabWidths(int tab_count,
}
// Account for gap between the last mini-tab and first non-mini-tab.
available_width -= mini_to_non_mini_gap_;
+ // And add some extra space if you have nano tabs in the mix.
+ if (nano_tab_count > 0)
+ available_width -= extra_gap_for_nano_;
}
// Calculate the desired tab widths by dividing the available space into equal
@@ -1187,7 +1195,8 @@ void TabStrip::ResizeLayoutTabs() {
}
Tab* first_tab = GetTabAtTabDataIndex(mini_tab_count);
double unselected, selected;
- GetDesiredTabWidths(GetTabCount(), mini_tab_count, &unselected, &selected);
+ GetDesiredTabWidths(GetTabCount(), mini_tab_count, GetNanoTabCount(),
+ &unselected, &selected);
int w = Round(first_tab->IsSelected() ? selected : selected);
// We only want to run the animation if we're not already at the desired
@@ -1396,17 +1405,20 @@ void TabStrip::GenerateIdealBounds() {
int tab_count = GetTabCount();
int non_closing_tab_count = 0;
int mini_tab_count = 0;
+ int nano_tab_count = 0;
for (int i = 0; i < tab_count; ++i) {
if (!tab_data_[i].tab->closing()) {
++non_closing_tab_count;
if (tab_data_[i].tab->mini())
mini_tab_count++;
+ if (tab_data_[i].tab->app())
+ nano_tab_count++;
}
}
double unselected, selected;
- GetDesiredTabWidths(non_closing_tab_count, mini_tab_count, &unselected,
- &selected);
+ GetDesiredTabWidths(non_closing_tab_count, mini_tab_count, nano_tab_count,
+ &unselected, &selected);
current_unselected_width_ = unselected;
current_selected_width_ = selected;
@@ -1426,6 +1438,8 @@ void TabStrip::GenerateIdealBounds() {
if (last_was_mini) {
// Give a bigger gap between mini and non-mini tabs.
tab_x += mini_to_non_mini_gap_;
+ if (nano_tab_count > 0)
+ tab_x += extra_gap_for_nano_;
}
if (tab->IsSelected())
tab_width = selected;
@@ -1680,6 +1694,17 @@ int TabStrip::GetMiniTabCount() const {
return mini_count;
}
+int TabStrip::GetNanoTabCount() const {
+ int nano_count = 0;
+ for (size_t i = 0; i < tab_data_.size(); ++i) {
+ if (tab_data_[i].tab->app())
+ nano_count++;
+ else
+ return nano_count;
+ }
+ return nano_count;
+}
+
int TabStrip::GetAvailableWidthForTabs(Tab* last_tab) const {
return last_tab->x() + last_tab->width();
}