diff options
author | sail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-25 06:09:03 +0000 |
---|---|---|
committer | sail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-25 06:09:03 +0000 |
commit | 510ea77c92ad9b9c8b897b412254ccdede2b635f (patch) | |
tree | c50a05586d1f08f16816742bfed6008b6ac30580 | |
parent | d4a0e2c7445cec440e8ff542cdefaa7555c94f16 (diff) | |
download | chromium_src-510ea77c92ad9b9c8b897b412254ccdede2b635f.zip chromium_src-510ea77c92ad9b9c8b897b412254ccdede2b635f.tar.gz chromium_src-510ea77c92ad9b9c8b897b412254ccdede2b635f.tar.bz2 |
Revert 119018 - Draw new tab button with tab background
Currently the new tab button is drawn with a semi-transparent image blended with the window background color.
This CL changes the drawing code so that we now use the inactive tab background image as the button's background. I've removed the fill from the newtab button images so that they just contain the border and shadow.
The main benefit of this approach is that the button now matches the look of inactive tabs.
Note, I'm only implementing this on views for now. Once this is implemented on all platforms we can remove the old button images.
Screenshots: http://imgur.com/a/iez8r
BUG=100775
TEST=
Review URL: https://chromiumcodereview.appspot.com/9252026
TBR=sail@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9288015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119020 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/theme/large_newtab_p_views.png | bin | 854 -> 0 bytes | |||
-rw-r--r-- | chrome/app/theme/large_newtab_views.png | bin | 939 -> 0 bytes | |||
-rw-r--r-- | chrome/app/theme/newtab_p_views.png | bin | 1272 -> 0 bytes | |||
-rw-r--r-- | chrome/app/theme/newtab_views.png | bin | 1446 -> 0 bytes | |||
-rw-r--r-- | chrome/app/theme/theme_resources_large.grd | 12 | ||||
-rw-r--r-- | chrome/app/theme/theme_resources_standard.grd | 12 | ||||
-rw-r--r-- | chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc | 6 | ||||
-rw-r--r-- | chrome/browser/ui/views/tabs/browser_tab_strip_controller.h | 3 | ||||
-rw-r--r-- | chrome/browser/ui/views/tabs/tab_strip.cc | 356 | ||||
-rw-r--r-- | chrome/browser/ui/views/tabs/tab_strip.h | 7 | ||||
-rw-r--r-- | chrome/browser/ui/views/tabs/tab_strip_controller.h | 5 | ||||
-rw-r--r-- | ui/gfx/skbitmap_operations.cc | 5 |
12 files changed, 145 insertions, 261 deletions
diff --git a/chrome/app/theme/large_newtab_p_views.png b/chrome/app/theme/large_newtab_p_views.png Binary files differdeleted file mode 100644 index c812bd2..0000000 --- a/chrome/app/theme/large_newtab_p_views.png +++ /dev/null diff --git a/chrome/app/theme/large_newtab_views.png b/chrome/app/theme/large_newtab_views.png Binary files differdeleted file mode 100644 index fa84f5b..0000000 --- a/chrome/app/theme/large_newtab_views.png +++ /dev/null diff --git a/chrome/app/theme/newtab_p_views.png b/chrome/app/theme/newtab_p_views.png Binary files differdeleted file mode 100644 index 311be28..0000000 --- a/chrome/app/theme/newtab_p_views.png +++ /dev/null diff --git a/chrome/app/theme/newtab_views.png b/chrome/app/theme/newtab_views.png Binary files differdeleted file mode 100644 index 3e18d43..0000000 --- a/chrome/app/theme/newtab_views.png +++ /dev/null diff --git a/chrome/app/theme/theme_resources_large.grd b/chrome/app/theme/theme_resources_large.grd index 7ebd2ee..3371bfb 100644 --- a/chrome/app/theme/theme_resources_large.grd +++ b/chrome/app/theme/theme_resources_large.grd @@ -87,16 +87,10 @@ <include name="IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_C" file="large_keyword_search_bubble_c.png" type="BINDATA" /> <include name="IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_L" file="large_keyword_search_bubble_l.png" type="BINDATA" /> <include name="IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_R" file="large_keyword_search_bubble_r.png" type="BINDATA" /> - <if expr="pp_ifdef('toolkit_views')"> - <include name="IDR_NEWTAB_BUTTON" file="large_newtab_views.png" type="BINDATA" /> - <include name="IDR_NEWTAB_BUTTON_P" file="large_newtab_p_views.png" type="BINDATA" /> - </if> - <if expr="not pp_ifdef('toolkit_views')"> - <include name="IDR_NEWTAB_BUTTON" file="large_newtab.png" type="BINDATA" /> - <include name="IDR_NEWTAB_BUTTON_H" file="large_newtab_h.png" type="BINDATA" /> - <include name="IDR_NEWTAB_BUTTON_P" file="large_newtab_p.png" type="BINDATA" /> - </if> + <include name="IDR_NEWTAB_BUTTON" file="large_newtab.png" type="BINDATA" /> + <include name="IDR_NEWTAB_BUTTON_H" file="large_newtab_h.png" type="BINDATA" /> <include name="IDR_NEWTAB_BUTTON_MASK" file="large_newtab_button_mask.png" type="BINDATA" /> + <include name="IDR_NEWTAB_BUTTON_P" file="large_newtab_p.png" type="BINDATA" /> <include name="IDR_SETTINGS_FAVICON" file="large_settings_favicon.png" type="BINDATA" /> <include name="IDR_OMNIBOX_EV_BUBBLE_BACKGROUND_C" file="large_ev_bubble_c.png" type="BINDATA" /> <include name="IDR_OMNIBOX_EV_BUBBLE_BACKGROUND_L" file="large_ev_bubble_l.png" type="BINDATA" /> diff --git a/chrome/app/theme/theme_resources_standard.grd b/chrome/app/theme/theme_resources_standard.grd index 4d4df5d..ebd0cc6 100644 --- a/chrome/app/theme/theme_resources_standard.grd +++ b/chrome/app/theme/theme_resources_standard.grd @@ -90,16 +90,10 @@ <include name="IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_C" file="keyword_search_bubble_c.png" type="BINDATA" /> <include name="IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_L" file="keyword_search_bubble_l.png" type="BINDATA" /> <include name="IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_R" file="keyword_search_bubble_r.png" type="BINDATA" /> - <if expr="pp_ifdef('toolkit_views')"> - <include name="IDR_NEWTAB_BUTTON" file="newtab_views.png" type="BINDATA" /> - <include name="IDR_NEWTAB_BUTTON_P" file="newtab_p_views.png" type="BINDATA" /> - </if> - <if expr="not pp_ifdef('toolkit_views')"> - <include name="IDR_NEWTAB_BUTTON" file="newtab.png" type="BINDATA" /> - <include name="IDR_NEWTAB_BUTTON_H" file="newtab_h.png" type="BINDATA" /> - <include name="IDR_NEWTAB_BUTTON_P" file="newtab_p.png" type="BINDATA" /> - </if> + <include name="IDR_NEWTAB_BUTTON" file="newtab.png" type="BINDATA" /> + <include name="IDR_NEWTAB_BUTTON_H" file="newtab_h.png" type="BINDATA" /> <include name="IDR_NEWTAB_BUTTON_MASK" file="newtab_button_mask.png" type="BINDATA" /> + <include name="IDR_NEWTAB_BUTTON_P" file="newtab_p.png" type="BINDATA" /> <include name="IDR_SETTINGS_FAVICON" file="settings_favicon.png" type="BINDATA" /> <include name="IDR_OMNIBOX_EV_BUBBLE_BACKGROUND_C" file="ev_bubble_c.png" type="BINDATA" /> <include name="IDR_OMNIBOX_EV_BUBBLE_BACKGROUND_L" file="ev_bubble_l.png" type="BINDATA" /> diff --git a/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc b/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc index 82b3b81..8b5d4c8 100644 --- a/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc +++ b/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -315,10 +315,6 @@ void BrowserTabStripController::ClickActiveTab(int index) { model_->ActiveTabClicked(index); } -bool BrowserTabStripController::IsIncognito() { - return browser_->profile()->IsOffTheRecord(); -} - //////////////////////////////////////////////////////////////////////////////// // BrowserTabStripController, TabStripModelObserver implementation: diff --git a/chrome/browser/ui/views/tabs/browser_tab_strip_controller.h b/chrome/browser/ui/views/tabs/browser_tab_strip_controller.h index e758d3b..6d1d31b 100644 --- a/chrome/browser/ui/views/tabs/browser_tab_strip_controller.h +++ b/chrome/browser/ui/views/tabs/browser_tab_strip_controller.h @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -68,7 +68,6 @@ class BrowserTabStripController : public TabStripController, virtual bool IsCompatibleWith(TabStrip* other) const OVERRIDE; virtual void CreateNewTab() OVERRIDE; virtual void ClickActiveTab(int index) OVERRIDE; - virtual bool IsIncognito() OVERRIDE; // TabStripModelObserver implementation: virtual void TabInsertedAt(TabContentsWrapper* contents, diff --git a/chrome/browser/ui/views/tabs/tab_strip.cc b/chrome/browser/ui/views/tabs/tab_strip.cc index 4266b37..6e4d1cb 100644 --- a/chrome/browser/ui/views/tabs/tab_strip.cc +++ b/chrome/browser/ui/views/tabs/tab_strip.cc @@ -27,13 +27,11 @@ #include "grit/theme_resources_standard.h" #include "ui/base/accessibility/accessible_view_state.h" #include "ui/base/animation/animation_container.h" -#include "ui/base/animation/throb_animation.h" #include "ui/base/dragdrop/drag_drop_types.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/canvas_skia.h" #include "ui/gfx/path.h" -#include "ui/gfx/skbitmap_operations.h" #include "ui/gfx/size.h" #include "ui/views/controls/image_view.h" #include "ui/views/widget/default_theme_provider.h" @@ -53,11 +51,6 @@ static const int kNewTabButtonVOffset = 5; static const int kSuspendAnimationsTimeMs = 200; static const int kTabHOffset = -16; static const int kTabStripAnimationVSlop = 40; -// Inactive tabs in a native frame are slightly transparent. -static const int kNativeFrameInactiveTabAlpha = 200; -// If there are multiple tabs selected then make non-selected inactive tabs -// even more transparent. -static const int kNativeFrameInactiveTabAlphaMultiSelection = 150; // Inverse ratio of the width of a tab edge to the width of the tab. When // hovering over the left or right edge of a tab, the drop indicator will @@ -97,260 +90,140 @@ class ResetDraggingStateDelegate DISALLOW_COPY_AND_ASSIGN(ResetDraggingStateDelegate); }; -} // namespace - /////////////////////////////////////////////////////////////////////////////// // NewTabButton // -// A subclass of button that hit-tests to the shape of the new tab button and -// does custom drawing. +// A subclass of button that hit-tests to the shape of the new tab button. class NewTabButton : public views::ImageButton { public: - NewTabButton(TabStrip* tab_strip, views::ButtonListener* listener); - virtual ~NewTabButton(); - - // Set the background offset used to match the background image to the frame - // image. - void set_background_offset(const gfx::Point& offset) { - background_offset_ = offset; + NewTabButton(TabStrip* tab_strip, views::ButtonListener* listener) + : views::ImageButton(listener), + tab_strip_(tab_strip) { } + virtual ~NewTabButton() {} protected: // Overridden from views::View: - virtual bool HasHitTestMask() const OVERRIDE; - virtual void GetHitTestMask(gfx::Path* path) const OVERRIDE; + virtual bool HasHitTestMask() const { + // 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 !tab_strip_->SizeTabButtonToTopOfTabStrip(); + } + virtual void GetHitTestMask(gfx::Path* path) const { + DCHECK(path); + + SkScalar w = SkIntToScalar(width()); + + // These values are defined by the shape of the new tab bitmap. Should that + // bitmap ever change, these values will need to be updated. They're so + // custom it's not really worth defining constants for. + path->moveTo(0, 1); + path->lineTo(w - 7, 1); + path->lineTo(w - 4, 4); + path->lineTo(w, 16); + path->lineTo(w - 1, 17); + path->lineTo(7, 17); + path->lineTo(4, 13); + path->lineTo(0, 1); + path->close(); + } + #if defined(OS_WIN) && !defined(USE_AURA) - void OnMouseReleased(const views::MouseEvent& event) OVERRIDE; + void OnMouseReleased(const views::MouseEvent& event) OVERRIDE { + if (event.IsOnlyRightMouseButton()) { + gfx::Point point(event.x(), event.y()); + views::View::ConvertPointToScreen(this, &point); + ui::ShowSystemMenu(GetWidget()->GetNativeView(), point.x(), point.y()); + SetState(BS_NORMAL); + return; + } + views::ImageButton::OnMouseReleased(event); + } #endif - void OnPaint(gfx::Canvas* canvas) OVERRIDE; private: - SkBitmap GetBitmapForState(views::CustomButton::ButtonState state) const; - SkBitmap GetBitmap() const; - // Tab strip that contains this button. TabStrip* tab_strip_; - // The offset used to paint the background image. - gfx::Point background_offset_; - DISALLOW_COPY_AND_ASSIGN(NewTabButton); }; -NewTabButton::NewTabButton(TabStrip* tab_strip, views::ButtonListener* listener) - : views::ImageButton(listener), - tab_strip_(tab_strip) { -} - -NewTabButton::~NewTabButton() { -} - -bool NewTabButton::HasHitTestMask() const { - // 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 !tab_strip_->SizeTabButtonToTopOfTabStrip(); -} - -void NewTabButton::GetHitTestMask(gfx::Path* path) const { - DCHECK(path); - - SkScalar w = SkIntToScalar(width()); - - // These values are defined by the shape of the new tab bitmap. Should that - // bitmap ever change, these values will need to be updated. They're so - // custom it's not really worth defining constants for. - path->moveTo(0, 1); - path->lineTo(w - 7, 1); - path->lineTo(w - 4, 4); - path->lineTo(w, 16); - path->lineTo(w - 1, 17); - path->lineTo(7, 17); - path->lineTo(4, 13); - path->lineTo(0, 1); - path->close(); -} - -#if defined(OS_WIN) && !defined(USE_AURA) -void NewTabButton::OnMouseReleased(const views::MouseEvent& event) { - if (event.IsOnlyRightMouseButton()) { - gfx::Point point(event.x(), event.y()); - views::View::ConvertPointToScreen(this, &point); - ui::ShowSystemMenu(GetWidget()->GetNativeView(), point.x(), point.y()); - SetState(BS_NORMAL); - return; - } - views::ImageButton::OnMouseReleased(event); -} -#endif - -void NewTabButton::OnPaint(gfx::Canvas* canvas) { - SkBitmap bitmap = GetBitmap(); - canvas->DrawBitmapInt(bitmap, 0, height() - bitmap.height()); -} - -SkBitmap NewTabButton::GetBitmapForState( - views::CustomButton::ButtonState state) const { - bool use_native_frame = - GetWidget() && GetWidget()->GetTopLevelWidget()->ShouldUseNativeFrame(); - int background_id = 0; - if (use_native_frame) { - background_id = IDR_THEME_TAB_BACKGROUND_V; - } else { - background_id = tab_strip_->controller()->IsIncognito() ? - IDR_THEME_TAB_BACKGROUND_INCOGNITO : IDR_THEME_TAB_BACKGROUND; - } - - int overlay_id = 0; - int alpha = 0; - switch (state) { - case views::CustomButton::BS_NORMAL: - overlay_id = IDR_NEWTAB_BUTTON; - alpha = use_native_frame ? kNativeFrameInactiveTabAlpha : 255; - break; - case views::CustomButton::BS_HOT: - overlay_id = IDR_NEWTAB_BUTTON; - alpha = use_native_frame ? kNativeFrameInactiveTabAlpha : 255; - break; - case views::CustomButton::BS_PUSHED: - overlay_id = IDR_NEWTAB_BUTTON_P; - alpha = 145; - break; - default: - NOTREACHED(); - break; - } - - ui::ThemeProvider* tp = GetThemeProvider(); - SkBitmap* background = tp->GetBitmapNamed(background_id); - SkBitmap* overlay = tp->GetBitmapNamed(overlay_id); - int height = overlay->height(); - int width = overlay->width(); - - gfx::CanvasSkia canvas(gfx::Size(width, height), false); - - // For custom images the background starts at the top of the tab strip. - // Otherwise the background starts at the top of the frame. - int offset_y = GetThemeProvider()->HasCustomImage(background_id) ? - 0 : background_offset_.y(); - canvas.TileImageInt(*background, GetMirroredX() + background_offset_.x(), - kNewTabButtonVOffset + offset_y, 0, 0, width, height); - - if (alpha != 255) { - SkPaint paint; - paint.setColor(SkColorSetARGB(alpha, 255, 255, 255)); - paint.setXfermodeMode(SkXfermode::kDstIn_Mode); - paint.setStyle(SkPaint::kFill_Style); - canvas.DrawRect(gfx::Rect(0, 0, width, height), paint); - } - - if (state == views::CustomButton::BS_HOT) { - canvas.FillRect(SkColorSetARGB(72, 255, 255, 255), - gfx::Rect(gfx::Size(size()))); - } - - canvas.DrawBitmapInt(*overlay, 0, 0); - SkBitmap* mask = tp->GetBitmapNamed(IDR_NEWTAB_BUTTON_MASK); - return SkBitmapOperations::CreateMaskedBitmap(canvas.ExtractBitmap(), *mask); -} - -SkBitmap NewTabButton::GetBitmap() const { - if (!hover_animation_->is_animating()) - return GetBitmapForState(state()); - return SkBitmapOperations::CreateBlendedBitmap( - GetBitmapForState(views::CustomButton::BS_NORMAL), - GetBitmapForState(views::CustomButton::BS_HOT), - hover_animation_->GetCurrentValue()); -} +} // namespace -/////////////////////////////////////////////////////////////////////////////// -// TabStrip::RemoveTabDelegate -// // AnimationDelegate used when removing a tab. Does the necessary cleanup when // done. class TabStrip::RemoveTabDelegate : public views::BoundsAnimator::OwnedAnimationDelegate { public: - RemoveTabDelegate(TabStrip* tab_strip, BaseTab* tab); + RemoveTabDelegate(TabStrip* tab_strip, BaseTab* tab) + : tabstrip_(tab_strip), + tab_(tab) { + } + + virtual void AnimationEnded(const ui::Animation* animation) { + CompleteRemove(); + } - virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; - virtual void AnimationCanceled(const ui::Animation* animation) OVERRIDE; + virtual void AnimationCanceled(const ui::Animation* animation) { + // We can be canceled for two interesting reasons: + // . The tab we reference was dragged back into the tab strip. In this case + // we don't want to remove the tab (closing is false). + // . The drag was completed before the animation completed + // (DestroyDraggedSourceTab). In this case we need to remove the tab + // (closing is true). + if (tab_->closing()) + CompleteRemove(); + } private: - void CompleteRemove(); + void CompleteRemove() { + if (!tab_->closing()) { + // The tab was added back yet we weren't canceled. This shouldn't happen. + NOTREACHED(); + return; + } + tabstrip_->RemoveAndDeleteTab(tab_); + HighlightCloseButton(); + } // When the animation completes, we send the Container a message to simulate // a mouse moved event at the current mouse position. This tickles the Tab // the mouse is currently over to show the "hot" state of the close button. - void HighlightCloseButton(); - - TabStrip* tabstrip_; - BaseTab* tab_; - - DISALLOW_COPY_AND_ASSIGN(RemoveTabDelegate); -}; - -TabStrip::RemoveTabDelegate::RemoveTabDelegate(TabStrip* tab_strip, - BaseTab* tab) - : tabstrip_(tab_strip), - tab_(tab) { -} - -void TabStrip::RemoveTabDelegate::AnimationEnded( - const ui::Animation* animation) { - CompleteRemove(); -} - -void TabStrip::RemoveTabDelegate::AnimationCanceled( - const ui::Animation* animation) { - // We can be canceled for two interesting reasons: - // . The tab we reference was dragged back into the tab strip. In this case - // we don't want to remove the tab (closing is false). - // . The drag was completed before the animation completed - // (DestroyDraggedSourceTab). In this case we need to remove the tab - // (closing is true). - if (tab_->closing()) - CompleteRemove(); -} - -void TabStrip::RemoveTabDelegate::CompleteRemove() { - if (!tab_->closing()) { - // The tab was added back yet we weren't canceled. This shouldn't happen. - NOTREACHED(); - return; - } - tabstrip_->RemoveAndDeleteTab(tab_); - HighlightCloseButton(); -} - -void TabStrip::RemoveTabDelegate::HighlightCloseButton() { - if (tabstrip_->IsDragSessionActive() || - !tabstrip_->ShouldHighlightCloseButtonAfterRemove()) { - // This function is not required (and indeed may crash!) for removes - // spawned by non-mouse closes and drag-detaches. - return; - } + void HighlightCloseButton() { + if (tabstrip_->IsDragSessionActive() || + !tabstrip_->ShouldHighlightCloseButtonAfterRemove()) { + // This function is not required (and indeed may crash!) for removes + // spawned by non-mouse closes and drag-detaches. + return; + } #if defined(OS_WIN) && !defined(USE_AURA) - views::Widget* widget = tabstrip_->GetWidget(); - // This can be null during shutdown. See http://crbug.com/42737. - if (!widget) - return; + views::Widget* widget = tabstrip_->GetWidget(); + // This can be null during shutdown. See http://crbug.com/42737. + if (!widget) + return; - widget->ResetLastMouseMoveFlag(); + widget->ResetLastMouseMoveFlag(); - // Force the close button (that slides under the mouse) to highlight by - // saying the mouse just moved, but sending the same coordinates. - DWORD pos = GetMessagePos(); - POINT cursor_point = {GET_X_LPARAM(pos), GET_Y_LPARAM(pos)}; - MapWindowPoints(NULL, widget->GetNativeView(), &cursor_point, 1); - SendMessage(widget->GetNativeView(), WM_MOUSEMOVE, 0, - MAKELPARAM(cursor_point.x, cursor_point.y)); + // Force the close button (that slides under the mouse) to highlight by + // saying the mouse just moved, but sending the same coordinates. + DWORD pos = GetMessagePos(); + POINT cursor_point = {GET_X_LPARAM(pos), GET_Y_LPARAM(pos)}; + MapWindowPoints(NULL, widget->GetNativeView(), &cursor_point, 1); + SendMessage(widget->GetNativeView(), WM_MOUSEMOVE, 0, + MAKELPARAM(cursor_point.x, cursor_point.y)); #else - NOTIMPLEMENTED(); + NOTIMPLEMENTED(); #endif -} + } + + TabStrip* tabstrip_; + BaseTab* tab_; + + DISALLOW_COPY_AND_ASSIGN(RemoveTabDelegate); +}; /////////////////////////////////////////////////////////////////////////////// // TabStrip, public: @@ -776,7 +649,6 @@ bool TabStrip::IsPositionInWindowCaption(const gfx::Point& point) { void TabStrip::SetBackgroundOffset(const gfx::Point& offset) { for (int i = 0; i < tab_count(); ++i) GetTabAtTabDataIndex(i)->set_background_offset(offset); - newtab_button_->set_background_offset(offset); } views::View* TabStrip::GetNewTabButton() { @@ -830,10 +702,8 @@ void TabStrip::PaintChildren(gfx::Canvas* canvas) { SkPaint paint; // If there are multiple tabs selected, fade non-selected tabs more to make // the selected tabs more noticable. - int alpha = multiple_tabs_selected ? - kNativeFrameInactiveTabAlphaMultiSelection : - kNativeFrameInactiveTabAlpha; - paint.setColor(SkColorSetARGB(alpha, 255, 255, 255)); + paint.setColor(SkColorSetARGB( + multiple_tabs_selected ? 150 : 200, 255, 255, 255)); paint.setXfermodeMode(SkXfermode::kDstIn_Mode); paint.setStyle(SkPaint::kFill_Style); // The tabstrip area overlaps the toolbar area by 2 px. @@ -936,6 +806,10 @@ views::View* TabStrip::GetEventHandlerForPoint(const gfx::Point& point) { return this; } +void TabStrip::OnThemeChanged() { + LoadNewTabButtonImage(); +} + int TabStrip::TabIndexOfTab(BaseTab* tab) const { for (int i = 0; i < tab_count(); ++i) { if (base_tab_at_tab_index(i) == tab) @@ -1035,11 +909,39 @@ void TabStrip::Init() { void TabStrip::InitTabStripButtons() { newtab_button_ = new NewTabButton(this, this); + LoadNewTabButtonImage(); newtab_button_->SetAccessibleName( l10n_util::GetStringUTF16(IDS_ACCNAME_NEWTAB)); AddChildView(newtab_button_); } +void TabStrip::LoadNewTabButtonImage() { + ui::ThemeProvider* tp = GetThemeProvider(); + + // If we don't have a theme provider yet, it means we do not have a + // root view, and are therefore in a test. + bool in_test = false; + if (tp == NULL) { + tp = new views::DefaultThemeProvider(); + in_test = true; + } + + SkBitmap* bitmap = tp->GetBitmapNamed(IDR_NEWTAB_BUTTON); + SkColor color = tp->GetColor(ThemeService::COLOR_BUTTON_BACKGROUND); + SkBitmap* background = tp->GetBitmapNamed( + IDR_THEME_WINDOW_CONTROL_BACKGROUND); + + newtab_button_->SetImage(views::CustomButton::BS_NORMAL, bitmap); + newtab_button_->SetImage(views::CustomButton::BS_PUSHED, + tp->GetBitmapNamed(IDR_NEWTAB_BUTTON_P)); + newtab_button_->SetImage(views::CustomButton::BS_HOT, + tp->GetBitmapNamed(IDR_NEWTAB_BUTTON_H)); + newtab_button_->SetBackground(color, background, + tp->GetBitmapNamed(IDR_NEWTAB_BUTTON_MASK)); + if (in_test) + delete tp; +} + BaseTab* TabStrip::CreateTab() { Tab* tab = new Tab(this); tab->set_animation_container(animation_container_.get()); diff --git a/chrome/browser/ui/views/tabs/tab_strip.h b/chrome/browser/ui/views/tabs/tab_strip.h index 338d733..f6fdd17 100644 --- a/chrome/browser/ui/views/tabs/tab_strip.h +++ b/chrome/browser/ui/views/tabs/tab_strip.h @@ -22,7 +22,6 @@ #include "ui/views/mouse_watcher.h" class BaseTab; -class NewTabButton; class Tab; class TabDragController; class TabStripController; @@ -185,6 +184,7 @@ class TabStrip : public AbstractTabStripView, virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; virtual views::View* GetEventHandlerForPoint( const gfx::Point& point) OVERRIDE; + virtual void OnThemeChanged() OVERRIDE; protected: // Horizontal gap between mini and non-mini-tabs. @@ -271,6 +271,9 @@ class TabStrip : public AbstractTabStripView, // Creates the new tab button. void InitTabStripButtons(); + // Set the images for the new tab button. + void LoadNewTabButtonImage(); + // Creates and returns a new tab. The caller owners the returned tab. BaseTab* CreateTab(); @@ -428,7 +431,7 @@ class TabStrip : public AbstractTabStripView, std::vector<TabData> tab_data_; // The "New Tab" button. - NewTabButton* newtab_button_; + views::ImageButton* newtab_button_; // Ideal bounds of the new tab button. gfx::Rect newtab_button_bounds_; diff --git a/chrome/browser/ui/views/tabs/tab_strip_controller.h b/chrome/browser/ui/views/tabs/tab_strip_controller.h index 2d093361..8dcfd83 100644 --- a/chrome/browser/ui/views/tabs/tab_strip_controller.h +++ b/chrome/browser/ui/views/tabs/tab_strip_controller.h @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -89,9 +89,6 @@ class TabStripController { // Informs that an active tab is selected when already active (ie - clicked // when already active/foreground). virtual void ClickActiveTab(int index) = 0; - - // Returns true if the tab strip is in an incognito window. - virtual bool IsIncognito() = 0; }; #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_STRIP_CONTROLLER_H_ diff --git a/ui/gfx/skbitmap_operations.cc b/ui/gfx/skbitmap_operations.cc index 3af3948..760bd60 100644 --- a/ui/gfx/skbitmap_operations.cc +++ b/ui/gfx/skbitmap_operations.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -149,8 +149,7 @@ SkBitmap SkBitmapOperations::CreateMaskedBitmap(const SkBitmap& rgb, for (int x = 0; x < masked.width(); ++x) { SkColor rgb_pixel = SkUnPreMultiply::PMColorToColor(rgb_row[x]); - SkColor alpha_pixel = SkUnPreMultiply::PMColorToColor(alpha_row[x]); - int alpha = SkAlphaMul(SkColorGetA(rgb_pixel), SkColorGetA(alpha_pixel)); + int alpha = SkAlphaMul(SkColorGetA(rgb_pixel), SkColorGetA(alpha_row[x])); dst_row[x] = SkColorSetARGB(alpha, SkAlphaMul(SkColorGetR(rgb_pixel), alpha), SkAlphaMul(SkColorGetG(rgb_pixel), alpha), |