diff options
author | sail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-25 05:52:41 +0000 |
---|---|---|
committer | sail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-25 05:52:41 +0000 |
commit | f903709594e37edff8dced5addf98815e81ef2ab (patch) | |
tree | 4920f9b1f4993b6ba677d57825c2ce6a547d763b | |
parent | aa44d3dc180c0b0446f05e3c6299d58703edaa7d (diff) | |
download | chromium_src-f903709594e37edff8dced5addf98815e81ef2ab.zip chromium_src-f903709594e37edff8dced5addf98815e81ef2ab.tar.gz chromium_src-f903709594e37edff8dced5addf98815e81ef2ab.tar.bz2 |
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
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119018 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/theme/large_newtab_p_views.png | bin | 0 -> 854 bytes | |||
-rw-r--r-- | chrome/app/theme/large_newtab_views.png | bin | 0 -> 939 bytes | |||
-rw-r--r-- | chrome/app/theme/newtab_p_views.png | bin | 0 -> 1272 bytes | |||
-rw-r--r-- | chrome/app/theme/newtab_views.png | bin | 0 -> 1446 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, 261 insertions, 145 deletions
diff --git a/chrome/app/theme/large_newtab_p_views.png b/chrome/app/theme/large_newtab_p_views.png Binary files differnew file mode 100644 index 0000000..c812bd2 --- /dev/null +++ b/chrome/app/theme/large_newtab_p_views.png diff --git a/chrome/app/theme/large_newtab_views.png b/chrome/app/theme/large_newtab_views.png Binary files differnew file mode 100644 index 0000000..fa84f5b --- /dev/null +++ b/chrome/app/theme/large_newtab_views.png diff --git a/chrome/app/theme/newtab_p_views.png b/chrome/app/theme/newtab_p_views.png Binary files differnew file mode 100644 index 0000000..311be28 --- /dev/null +++ b/chrome/app/theme/newtab_p_views.png diff --git a/chrome/app/theme/newtab_views.png b/chrome/app/theme/newtab_views.png Binary files differnew file mode 100644 index 0000000..3e18d43 --- /dev/null +++ b/chrome/app/theme/newtab_views.png diff --git a/chrome/app/theme/theme_resources_large.grd b/chrome/app/theme/theme_resources_large.grd index 3371bfb..7ebd2ee 100644 --- a/chrome/app/theme/theme_resources_large.grd +++ b/chrome/app/theme/theme_resources_large.grd @@ -87,10 +87,16 @@ <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" /> - <include name="IDR_NEWTAB_BUTTON" file="large_newtab.png" type="BINDATA" /> - <include name="IDR_NEWTAB_BUTTON_H" file="large_newtab_h.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_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 ebd0cc6..4d4df5d 100644 --- a/chrome/app/theme/theme_resources_standard.grd +++ b/chrome/app/theme/theme_resources_standard.grd @@ -90,10 +90,16 @@ <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" /> - <include name="IDR_NEWTAB_BUTTON" file="newtab.png" type="BINDATA" /> - <include name="IDR_NEWTAB_BUTTON_H" file="newtab_h.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_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 8b5d4c8..82b3b81 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) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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,6 +315,10 @@ 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 6d1d31b..e758d3b 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) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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,6 +68,7 @@ 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 6e4d1cb..4266b37 100644 --- a/chrome/browser/ui/views/tabs/tab_strip.cc +++ b/chrome/browser/ui/views/tabs/tab_strip.cc @@ -27,11 +27,13 @@ #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" @@ -51,6 +53,11 @@ 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 @@ -90,141 +97,261 @@ class ResetDraggingStateDelegate DISALLOW_COPY_AND_ASSIGN(ResetDraggingStateDelegate); }; +} // namespace + /////////////////////////////////////////////////////////////////////////////// // NewTabButton // -// A subclass of button that hit-tests to the shape of the new tab button. +// A subclass of button that hit-tests to the shape of the new tab button and +// does custom drawing. class NewTabButton : public views::ImageButton { public: - NewTabButton(TabStrip* tab_strip, views::ButtonListener* listener) - : views::ImageButton(listener), - tab_strip_(tab_strip) { + 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; } - virtual ~NewTabButton() {} protected: // Overridden from views::View: - 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(); - } - + virtual bool HasHitTestMask() const OVERRIDE; + virtual void GetHitTestMask(gfx::Path* path) const OVERRIDE; #if defined(OS_WIN) && !defined(USE_AURA) - 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); - } + void OnMouseReleased(const views::MouseEvent& event) OVERRIDE; #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); }; -} // namespace +NewTabButton::NewTabButton(TabStrip* tab_strip, views::ButtonListener* listener) + : views::ImageButton(listener), + tab_strip_(tab_strip) { +} -// 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) - : tabstrip_(tab_strip), - tab_(tab) { - } +NewTabButton::~NewTabButton() { +} - virtual void AnimationEnded(const ui::Animation* animation) { - CompleteRemove(); +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 - 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(); +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; } - private: - void CompleteRemove() { - if (!tab_->closing()) { - // The tab was added back yet we weren't canceled. This shouldn't happen. + 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(); - return; - } - tabstrip_->RemoveAndDeleteTab(tab_); - HighlightCloseButton(); + break; } - // 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() { - 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; - } + ui::ThemeProvider* tp = GetThemeProvider(); + SkBitmap* background = tp->GetBitmapNamed(background_id); + SkBitmap* overlay = tp->GetBitmapNamed(overlay_id); + int height = overlay->height(); + int width = overlay->width(); -#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; + gfx::CanvasSkia canvas(gfx::Size(width, height), false); - widget->ResetLastMouseMoveFlag(); + // 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); - // 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(); -#endif + 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()); +} + +/////////////////////////////////////////////////////////////////////////////// +// 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); + + virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; + virtual void AnimationCanceled(const ui::Animation* animation) OVERRIDE; + + private: + void CompleteRemove(); + + // 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; + } + +#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; + + 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)); +#else + NOTIMPLEMENTED(); +#endif +} + /////////////////////////////////////////////////////////////////////////////// // TabStrip, public: @@ -649,6 +776,7 @@ 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() { @@ -702,8 +830,10 @@ 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. - paint.setColor(SkColorSetARGB( - multiple_tabs_selected ? 150 : 200, 255, 255, 255)); + int alpha = multiple_tabs_selected ? + kNativeFrameInactiveTabAlphaMultiSelection : + kNativeFrameInactiveTabAlpha; + paint.setColor(SkColorSetARGB(alpha, 255, 255, 255)); paint.setXfermodeMode(SkXfermode::kDstIn_Mode); paint.setStyle(SkPaint::kFill_Style); // The tabstrip area overlaps the toolbar area by 2 px. @@ -806,10 +936,6 @@ 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) @@ -909,39 +1035,11 @@ 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 f6fdd17..338d733 100644 --- a/chrome/browser/ui/views/tabs/tab_strip.h +++ b/chrome/browser/ui/views/tabs/tab_strip.h @@ -22,6 +22,7 @@ #include "ui/views/mouse_watcher.h" class BaseTab; +class NewTabButton; class Tab; class TabDragController; class TabStripController; @@ -184,7 +185,6 @@ 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,9 +271,6 @@ 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(); @@ -431,7 +428,7 @@ class TabStrip : public AbstractTabStripView, std::vector<TabData> tab_data_; // The "New Tab" button. - views::ImageButton* newtab_button_; + NewTabButton* 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 8dcfd83..2d093361 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) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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,6 +89,9 @@ 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 760bd60..3af3948 100644 --- a/ui/gfx/skbitmap_operations.cc +++ b/ui/gfx/skbitmap_operations.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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,7 +149,8 @@ SkBitmap SkBitmapOperations::CreateMaskedBitmap(const SkBitmap& rgb, for (int x = 0; x < masked.width(); ++x) { SkColor rgb_pixel = SkUnPreMultiply::PMColorToColor(rgb_row[x]); - int alpha = SkAlphaMul(SkColorGetA(rgb_pixel), SkColorGetA(alpha_row[x])); + SkColor alpha_pixel = SkUnPreMultiply::PMColorToColor(alpha_row[x]); + int alpha = SkAlphaMul(SkColorGetA(rgb_pixel), SkColorGetA(alpha_pixel)); dst_row[x] = SkColorSetARGB(alpha, SkAlphaMul(SkColorGetR(rgb_pixel), alpha), SkAlphaMul(SkColorGetG(rgb_pixel), alpha), |