diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-03 00:28:00 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-03 00:28:00 +0000 |
commit | 32670b07a6c42634f446e3d471f42a9fb40090f2 (patch) | |
tree | 77b15435f3a436d54fcaa5cb4c0d4371a007fad6 /chrome/browser/views/tabs | |
parent | a0e5688cc11f7f5e835b5c1a75c17ce4a28a1527 (diff) | |
download | chromium_src-32670b07a6c42634f446e3d471f42a9fb40090f2.zip chromium_src-32670b07a6c42634f446e3d471f42a9fb40090f2.tar.gz chromium_src-32670b07a6c42634f446e3d471f42a9fb40090f2.tar.bz2 |
Support DWM switching.
This completes the collapsing of window types and browser frames around a single class: views::Window. CustomFrameWindow is removed with this change.
The Browser window is represented by a single views::Window subclass: BrowserFrame, which replaces both AeroGlassFrame and OpaqueFrame.
NonClientView is now a container of two sibling classes - the Window's ClientView (in the Browser's case, BrowserView), and a NonClientFrameView subclass, which provides the rendering for the non-client portions of the window. These Views are siblings rather than the ClientView a child of the NonClientFrameView because when the DWM is toggled, the ClientView would have to be re-parented. Many Views make the assumption they are only inserted into a View hierarchy once, and so this is problematic. By having the views be siblings, this is avoided.
With this in mind, all of the former NonClientViews now become NonClientFrameView subclasses:
DefaultNonClientView -> CustomFrameView
(non-existent, NonClientView) -> NativeFrameView
AeroGlassNonClientView -> GlassBrowserFrameView
OpaqueNonClientView -> OpaqueBrowserFrameView
The latter two derive from NonClientFrameView via BrowserNonClientFrameView, which adds some extras.
I also had to modify the TabRenderer class to know how to drop its cache of tab background images when the theme changes since it uses different ones for Glass and non-Glass.
This change also fixes a few non-client flicker issues relating to window non-client activation by using more ScopedRedrawLocks. (Touches info_bubble.cc, window.cc)
Bugs fixed:
http://crbug.com/153
http://crbug.com/747
http://crbug.com/2371
http://crbug.com/3264
http://crbug.com/8234
Plumbing for http://crbug.com/8247
Design docs:
http://dev.chromium.org/developers/design-documents/views-windowing
http://dev.chromium.org/developers/design-documents/browser-window
Review URL: http://codereview.chromium.org/27317
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10757 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/tabs')
-rw-r--r-- | chrome/browser/views/tabs/tab_renderer.cc | 54 | ||||
-rw-r--r-- | chrome/browser/views/tabs/tab_renderer.h | 4 | ||||
-rw-r--r-- | chrome/browser/views/tabs/tab_strip.cc | 3 |
3 files changed, 40 insertions, 21 deletions
diff --git a/chrome/browser/views/tabs/tab_renderer.cc b/chrome/browser/views/tabs/tab_renderer.cc index cc7cf4c..1580d05 100644 --- a/chrome/browser/views/tabs/tab_renderer.cc +++ b/chrome/browser/views/tabs/tab_renderer.cc @@ -15,6 +15,7 @@ #include "chrome/common/l10n_util.h" #include "chrome/common/resource_bundle.h" #include "chrome/common/win_util.h" +#include "chrome/views/window.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" #include "skia/ext/image_operations.h" @@ -78,6 +79,31 @@ static int download_icon_height = 0; namespace { +// Loads the images to be used for the tab background. Uses the images for +// Vista if |use_vista_images| is true. +void LoadTabImages(bool use_vista_images) { + ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + if (use_vista_images) { + tab_inactive_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT_V); + tab_inactive_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER_V); + tab_inactive_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT_V); + + // Our Vista frame doesn't change background color to show OTR, + // so we continue to use the existing background tabs. + tab_inactive_otr_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT_V); + tab_inactive_otr_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER_V); + tab_inactive_otr_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT_V); + } else { + tab_inactive_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT); + tab_inactive_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER); + tab_inactive_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT); + + tab_inactive_otr_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT_OTR); + tab_inactive_otr_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER_OTR); + tab_inactive_otr_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT_OTR); + } +} + void InitResources() { static bool initialized = false; if (!initialized) { @@ -97,25 +123,7 @@ void InitResources() { tab_active_l_width = tab_active_l->width(); tab_active_r_width = tab_active_r->width(); - if (win_util::ShouldUseVistaFrame()) { - tab_inactive_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT_V); - tab_inactive_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER_V); - tab_inactive_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT_V); - - // Our Vista frame doesn't change background color to show OTR, - // so we continue to use the existing background tabs. - tab_inactive_otr_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT_V); - tab_inactive_otr_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER_V); - tab_inactive_otr_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT_V); - } else { - tab_inactive_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT); - tab_inactive_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER); - tab_inactive_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT); - - tab_inactive_otr_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT_OTR); - tab_inactive_otr_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER_OTR); - tab_inactive_otr_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT_OTR); - } + LoadTabImages(win_util::ShouldUseVistaFrame()); tab_hover_l = rb.GetBitmapNamed(IDR_TAB_HOVER_LEFT); tab_hover_c = rb.GetBitmapNamed(IDR_TAB_HOVER_CENTER); @@ -535,6 +543,12 @@ void TabRenderer::OnMouseExited(const views::MouseEvent& e) { hover_animation_->Hide(); } +void TabRenderer::ThemeChanged() { + if (GetWidget() && GetWidget()->AsWindow()) + LoadTabImages(GetWidget()->AsWindow()->UseNativeFrame()); + View::ThemeChanged(); +} + /////////////////////////////////////////////////////////////////////////////// // TabRenderer, AnimationDelegate implementation: @@ -566,7 +580,7 @@ void TabRenderer::PaintTabBackground(ChromeCanvas* canvas) { animation = pulse_animation_.get(); if (animation->GetCurrentValue() > 0) { PaintHoverTabBackground(canvas, animation->GetCurrentValue() * - (win_util::ShouldUseVistaFrame() ? + (GetWidget()->AsWindow()->UseNativeFrame() ? kHoverOpacityVista : kHoverOpacity)); } else { PaintInactiveTabBackground(canvas); diff --git a/chrome/browser/views/tabs/tab_renderer.h b/chrome/browser/views/tabs/tab_renderer.h index 9cad816..68df3e3 100644 --- a/chrome/browser/views/tabs/tab_renderer.h +++ b/chrome/browser/views/tabs/tab_renderer.h @@ -76,6 +76,7 @@ class TabRenderer : public views::View, virtual void Layout(); virtual void OnMouseEntered(const views::MouseEvent& event); virtual void OnMouseExited(const views::MouseEvent& event); + virtual void ThemeChanged(); // Overridden from AnimationDelegate: virtual void AnimationProgressed(const Animation* animation); @@ -166,6 +167,9 @@ class TabRenderer : public views::View, bool should_display_crashed_favicon_; + static void InitClass(); + static bool initialized_; + DISALLOW_EVIL_CONSTRUCTORS(TabRenderer); }; diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc index fceb5af..e3ec025 100644 --- a/chrome/browser/views/tabs/tab_strip.cc +++ b/chrome/browser/views/tabs/tab_strip.cc @@ -25,6 +25,7 @@ #include "chrome/common/win_util.h" #include "chrome/views/image_view.h" #include "chrome/views/painter.h" +#include "chrome/views/window.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" @@ -618,7 +619,7 @@ void TabStrip::PaintChildren(ChromeCanvas* canvas) { } } - if (win_util::ShouldUseVistaFrame()) { + if (GetWidget()->AsWindow()->UseNativeFrame()) { // Make sure unselected tabs are somewhat transparent. SkPaint paint; paint.setColor(SkColorSetARGB(200, 255, 255, 255)); |