Chromium Code Reviews| Index: chrome/browser/ui/views/tabs/tab_strip.cc |
| =================================================================== |
| --- chrome/browser/ui/views/tabs/tab_strip.cc (revision 92539) |
| +++ chrome/browser/ui/views/tabs/tab_strip.cc (working copy) |
| @@ -11,7 +11,6 @@ |
| #include "base/compiler_specific.h" |
| #include "base/stl_util-inl.h" |
| #include "base/utf_string_conversions.h" |
| -#include "chrome/browser/defaults.h" |
| #include "chrome/browser/tabs/tab_strip_selection_model.h" |
| #include "chrome/browser/themes/theme_service.h" |
| #include "chrome/browser/ui/view_ids.h" |
| @@ -77,8 +76,8 @@ |
| class NewTabButton : public views::ImageButton { |
| public: |
| - explicit NewTabButton(views::ButtonListener* listener) |
| - : views::ImageButton(listener) { |
| + explicit NewTabButton(TabStrip* tab_strip, views::ButtonListener* listener) |
| + : views::ImageButton(listener), tab_strip_(tab_strip) { |
|
sky
2011/07/14 20:38:20
When you can't fit all the initializers on a singl
Roger Tawa OOO till Jul 10th
2011/07/14 21:09:28
Done.
|
| } |
| virtual ~NewTabButton() {} |
| @@ -88,7 +87,7 @@ |
| // When the button is sized to the top of the tab strip we want the user to |
| // be able to click on complete bounds, and so don't return a custom hit |
| // mask. |
| - return !browser_defaults::kSizeTabButtonToTopOfTabStrip; |
| + return !tab_strip_->SizeTabButtonToTopOfTabStrip(); |
| } |
| virtual void GetHitTestMask(gfx::Path* path) const { |
| DCHECK(path); |
| @@ -110,6 +109,9 @@ |
| } |
| private: |
| + // Tab strip that contains this button. |
| + TabStrip* tab_strip_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(NewTabButton); |
| }; |
| @@ -150,11 +152,7 @@ |
| } |
| void TabStrip::InitTabStripButtons() { |
| - newtab_button_ = new NewTabButton(this); |
| - if (browser_defaults::kSizeTabButtonToTopOfTabStrip) { |
| - newtab_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT, |
| - views::ImageButton::ALIGN_BOTTOM); |
| - } |
| + newtab_button_ = new NewTabButton(this, this); |
| LoadNewTabButtonImage(); |
| newtab_button_->SetAccessibleName( |
| l10n_util::GetStringUTF16(IDS_ACCNAME_NEWTAB)); |
| @@ -481,8 +479,19 @@ |
| BaseTabStrip::DoLayout(); |
| // It is possible we don't have a new tab button yet. |
| - if (newtab_button_) |
| + if (newtab_button_) { |
| + if (SizeTabButtonToTopOfTabStrip()) { |
| + newtab_button_bounds_.set_height( |
| + kNewTabButtonHeight + kNewTabButtonVOffset); |
| + newtab_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT, |
| + views::ImageButton::ALIGN_BOTTOM); |
| + } else { |
| + newtab_button_bounds_.set_height(kNewTabButtonHeight); |
| + newtab_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT, |
| + views::ImageButton::ALIGN_TOP); |
| + } |
| newtab_button_->SetBoundsRect(newtab_button_bounds_); |
| + } |
| } |
| void TabStrip::LayoutDraggedTabsAt(const std::vector<BaseTab*>& tabs, |
| @@ -562,10 +571,6 @@ |
| void TabStrip::Init() { |
| set_id(VIEW_ID_TAB_STRIP); |
| newtab_button_bounds_.SetRect(0, 0, kNewTabButtonWidth, kNewTabButtonHeight); |
| - if (browser_defaults::kSizeTabButtonToTopOfTabStrip) { |
| - newtab_button_bounds_.set_height( |
| - kNewTabButtonHeight + kNewTabButtonVOffset); |
| - } |
| if (drop_indicator_width == 0) { |
| // Direction doesn't matter, both images are the same size. |
| SkBitmap* drop_image = GetDropArrowImage(true); |
| @@ -574,6 +579,10 @@ |
| } |
| } |
| +bool TabStrip::SizeTabButtonToTopOfTabStrip() { |
|
sky
2011/07/14 20:38:20
Make position match position in header.
Roger Tawa OOO till Jul 10th
2011/07/14 21:09:28
Done.
|
| + return controller()->SizeTabButtonToTopOfTabStrip(); |
| +} |
| + |
| void TabStrip::LoadNewTabButtonImage() { |
| ui::ThemeProvider* tp = GetThemeProvider(); |
| @@ -938,8 +947,7 @@ |
| // Update bounds of new tab button. |
| int new_tab_x; |
| - int new_tab_y = browser_defaults::kSizeTabButtonToTopOfTabStrip ? |
| - 0 : kNewTabButtonVOffset; |
| + int new_tab_y = SizeTabButtonToTopOfTabStrip() ? 0 : kNewTabButtonVOffset; |
| if (abs(Round(unselected) - Tab::GetStandardSize().width()) > 1 && |
| !in_tab_close_) { |
| // We're shrinking tabs, so we need to anchor the New Tab button to the |