diff options
Diffstat (limited to 'chrome/browser/views')
-rw-r--r-- | chrome/browser/views/tabs/dragged_tab_controller.cc | 11 | ||||
-rw-r--r-- | chrome/browser/views/tabs/tab_renderer.cc | 7 | ||||
-rw-r--r-- | chrome/browser/views/tabs/tab_strip.cc | 31 | ||||
-rw-r--r-- | chrome/browser/views/tabs/tab_strip.h | 14 |
4 files changed, 50 insertions, 13 deletions
diff --git a/chrome/browser/views/tabs/dragged_tab_controller.cc b/chrome/browser/views/tabs/dragged_tab_controller.cc index 262154f..1fda3b3 100644 --- a/chrome/browser/views/tabs/dragged_tab_controller.cc +++ b/chrome/browser/views/tabs/dragged_tab_controller.cc @@ -23,7 +23,6 @@ #include "chrome/browser/views/tabs/native_view_photobooth.h" #include "chrome/browser/views/tabs/tab.h" #include "chrome/browser/views/tabs/tab_strip.h" -#include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/common/notification_service.h" #include "gfx/canvas.h" #include "grit/theme_resources.h" @@ -42,7 +41,7 @@ #include <gdk/gdkkeysyms.h> #endif -static const int kHorizontalMoveThreshold = 16; // pixels +static const int kHorizontalMoveThreshold = 16; // Pixels. namespace { @@ -338,7 +337,7 @@ DraggedTabController::~DraggedTabController() { // bounds, it won't be able to clean up properly since its cleanup routine // uses GetIndexForDraggedContents, which will be invalid. view_.reset(NULL); - SetDraggedContents(NULL); // This removes our observer. + SetDraggedContents(NULL); // This removes our observer. } void DraggedTabController::CaptureDragInfo(const gfx::Point& mouse_offset) { @@ -766,11 +765,13 @@ void DraggedTabController::Attach(TabStrip* attached_tabstrip, // TabStrip. int tab_count = attached_tabstrip_->GetTabCount(); int mini_tab_count = attached_tabstrip_->GetMiniTabCount(); + int nano_tab_count = attached_tabstrip_->GetNanoTabCount(); if (!tab) ++tab_count; double unselected_width, selected_width = 0; attached_tabstrip_->GetDesiredTabWidths(tab_count, mini_tab_count, - &unselected_width, &selected_width); + nano_tab_count, &unselected_width, + &selected_width); EnsureDraggedView(); int dragged_tab_width = mini_ ? Tab::GetMiniWidth() : static_cast<int>(selected_width); @@ -809,7 +810,7 @@ void DraggedTabController::Attach(TabStrip* attached_tabstrip, tab = GetTabMatchingDraggedContents(attached_tabstrip_); } - DCHECK(tab); // We should now have a tab. + DCHECK(tab); // We should now have a tab. tab->SetVisible(false); // Move the corresponding window to the front. diff --git a/chrome/browser/views/tabs/tab_renderer.cc b/chrome/browser/views/tabs/tab_renderer.cc index f089393..9f22248 100644 --- a/chrome/browser/views/tabs/tab_renderer.cc +++ b/chrome/browser/views/tabs/tab_renderer.cc @@ -323,6 +323,7 @@ void TabRenderer::UpdateData(TabContents* contents, else data_.favicon = contents->GetFavIcon(); data_.phantom = phantom; + data_.app = contents->is_app(); // Sets the accessible name for the tab. SetAccessibleName(UTF16ToWide(data_.title)); @@ -978,9 +979,9 @@ void TabRenderer::LoadTabImages() { tab_active.l_width = tab_active.image_l->width(); tab_active.r_width = tab_active.image_r->width(); - // This is high much taller *visually* the regular tab is compared to the - // nano tabs. The images are the same height, this is really just the - // difference in whitespace above the tab image. + // The regular tab is high much taller *visually* than the nano tabs. + // The images are the same height, this is really just the difference + // in whitespace above the tab image (regular vs nano). const int kMiniTabDiffHeight = 14; tab_active_nano.image_l = rb.GetBitmapNamed(IDR_TAB_ACTIVE_NANO_LEFT); 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(); } diff --git a/chrome/browser/views/tabs/tab_strip.h b/chrome/browser/views/tabs/tab_strip.h index 2af7f93..95ccfdb 100644 --- a/chrome/browser/views/tabs/tab_strip.h +++ b/chrome/browser/views/tabs/tab_strip.h @@ -5,6 +5,8 @@ #ifndef CHROME_BROWSER_VIEWS_TABS_TAB_STRIP_H_ #define CHROME_BROWSER_VIEWS_TABS_TAB_STRIP_H_ +#include <vector> + #include "app/animation_container.h" #include "base/message_loop.h" #include "base/ref_counted.h" @@ -186,6 +188,10 @@ class TabStrip : public BaseTabStrip, // Horizontal gap between mini and non-mini-tabs. static const int mini_to_non_mini_gap_; + // Extra horizontal gap (on top of mini_to_non_mini_gap_) when one of the + // mini tabs is a nano tab. + static const int extra_gap_for_nano_; + private: class RemoveTabDelegate; @@ -280,6 +286,9 @@ class TabStrip : public BaseTabStrip, // Returns the number of mini-tabs. int GetMiniTabCount() const; + // Returns the number of nano-tabs. + int GetNanoTabCount() const; + // -- Tab Resize Layout ----------------------------------------------------- // Returns the exact (unrounded) current width of each tab. @@ -290,10 +299,11 @@ class TabStrip : public BaseTabStrip, // desired strip width and number of tabs. If // |width_of_tabs_for_mouse_close_| is nonnegative we use that value in // calculating the desired strip width; otherwise we use the current width. - // |mini_tab_count| gives the number of mini-tabs, and |tab_count| the - // number of mini and non-mini-tabs. + // |mini_tab_count| gives the number of mini-tabs, |nano_tab_count| the + // number of mini-tabs and |tab_count| the number of mini and non-mini-tabs. void GetDesiredTabWidths(int tab_count, int mini_tab_count, + int nano_tab_count, double* unselected_width, double* selected_width) const; |