diff options
author | glen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-09 01:07:42 +0000 |
---|---|---|
committer | glen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-09 01:07:42 +0000 |
commit | 4a19063d1459a4c9c8c4c50ed86eb9048f69ea3f (patch) | |
tree | 69a1e9f78b3a5fa8b909cfab336826b09c44235f /views | |
parent | 5085ee0b4bfbe4625e63ee6975bb95702e13e0aa (diff) | |
download | chromium_src-4a19063d1459a4c9c8c4c50ed86eb9048f69ea3f.zip chromium_src-4a19063d1459a4c9c8c4c50ed86eb9048f69ea3f.tar.gz chromium_src-4a19063d1459a4c9c8c4c50ed86eb9048f69ea3f.tar.bz2 |
This is the first pass at themes.
This CL is paired with http://codereview.chromium.org/67284
This CL (for commit purposes) includes http://codereview.chromium.org/67284
BUG=4463,11232,11233,11234,11235
Review URL: http://codereview.chromium.org/99030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15704 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/view.cc | 5 | ||||
-rw-r--r-- | views/view.h | 4 | ||||
-rw-r--r-- | views/views.vcproj | 30 | ||||
-rw-r--r-- | views/widget/default_theme_provider.cc | 20 | ||||
-rw-r--r-- | views/widget/default_theme_provider.h | 30 | ||||
-rw-r--r-- | views/widget/widget.h | 13 | ||||
-rw-r--r-- | views/widget/widget_win.cc | 18 | ||||
-rw-r--r-- | views/widget/widget_win.h | 5 | ||||
-rw-r--r-- | views/window/custom_frame_view.cc | 272 | ||||
-rw-r--r-- | views/window/custom_frame_view.h | 8 |
10 files changed, 207 insertions, 198 deletions
diff --git a/views/view.cc b/views/view.cc index b2951d9..f4ef13d 100644 --- a/views/view.cc +++ b/views/view.cc @@ -1568,6 +1568,11 @@ int View::GetLineScrollIncrement(ScrollView* scroll_view, return 0; } +ThemeProvider* View::GetThemeProvider() { + Widget* widget = GetWidget(); + return widget ? widget->GetThemeProvider() : NULL; +} + // static void View::RegisterChildrenForVisibleBoundsNotification( RootView* root, View* view) { diff --git a/views/view.h b/views/view.h index e3a78f7..561632d 100644 --- a/views/view.h +++ b/views/view.h @@ -33,6 +33,7 @@ class Path; class ChromeCanvas; class OSExchangeData; class ViewAccessibilityWrapper; +class ThemeProvider; namespace views { @@ -995,6 +996,9 @@ class View : public AcceleratorTarget { virtual int GetLineScrollIncrement(ScrollView* scroll_view, bool is_horizontal, bool is_positive); + // Get the theme provider from the parent widget. + ThemeProvider* GetThemeProvider(); + protected: // The id of this View. Used to find this View. int id_; diff --git a/views/views.vcproj b/views/views.vcproj index 2c98260..1d1c269 100644 --- a/views/views.vcproj +++ b/views/views.vcproj @@ -201,6 +201,36 @@ > </File> <File + RelativePath=".\widget\default_theme_provider.cc" + > + <FileConfiguration + Name="Debug|Win32" + > + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)\$(InputName)1.obj" + XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" + /> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + > + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)\$(InputName)1.obj" + XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" + /> + </FileConfiguration> + </File> + <File + RelativePath=".\widget\default_theme_provider.h" + > + </File> + <File + RelativePath=".\widget\hwnd_notification_source.h" + > + </File> + <File RelativePath=".\widget\root_view.cc" > <FileConfiguration diff --git a/views/widget/default_theme_provider.cc b/views/widget/default_theme_provider.cc new file mode 100644 index 0000000..be348a9 --- /dev/null +++ b/views/widget/default_theme_provider.cc @@ -0,0 +1,20 @@ +// Copyright (c) 2009 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. + +#include "views/widget/default_theme_provider.h" + +#include "app/resource_bundle.h" + +namespace views { + +SkBitmap* DefaultThemeProvider::GetBitmapNamed(int id) { + return ResourceBundle::GetSharedInstance().GetBitmapNamed(id); +} + +SkColor DefaultThemeProvider::GetColor(int id) { + // Return debugging-blue. + return 0xff0000ff; +} + +} // namespace views diff --git a/views/widget/default_theme_provider.h b/views/widget/default_theme_provider.h new file mode 100644 index 0000000..1060c8e --- /dev/null +++ b/views/widget/default_theme_provider.h @@ -0,0 +1,30 @@ +// Copyright (c) 2009 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. + +#ifndef VIEWS_DEFAULT_THEME_PROVIDER_H_ +#define VIEWS_DEFAULT_THEME_PROVIDER_H_ + +#include "app/theme_provider.h" +#include "base/basictypes.h" + +class ResourceBundle; + +namespace views { + +class DefaultThemeProvider : public ThemeProvider { + public: + DefaultThemeProvider() { }; + virtual ~DefaultThemeProvider() { }; + + // Overridden from ThemeProvider. + virtual SkBitmap* GetBitmapNamed(int id); + virtual SkColor GetColor(int id); + + private: + DISALLOW_COPY_AND_ASSIGN(DefaultThemeProvider); +}; + +} // namespace views + +#endif // VIEWS_DEFAULT_THEME_PROVIDER_H_ diff --git a/views/widget/widget.h b/views/widget/widget.h index 8dd3f2e..b2c3551 100644 --- a/views/widget/widget.h +++ b/views/widget/widget.h @@ -7,6 +7,8 @@ #include "base/gfx/native_widget_types.h" +class ThemeProvider; + namespace gfx { class Rect; } @@ -53,6 +55,9 @@ class Widget { // Returns the RootView contained by this Widget. virtual RootView* GetRootView() = 0; + // Returns the Widget associated with the root ancestor. + virtual Widget* GetRootWidget() const = 0; + // Returns whether the Widget is visible to the user. virtual bool IsVisible() const = 0; @@ -74,6 +79,14 @@ class Widget { // window. virtual Window* GetWindow() { return NULL; } virtual const Window* GetWindow() const { return NULL; } + + // Get the theme provider. + virtual ThemeProvider* GetThemeProvider() const { return NULL; } + + // Get the dialog theme provider; this is necessary for when a dialog has + // no profile (and ThemeProvider) associated with it. The dialog theme + // provider provides a default set of bitmaps that such dialogs can use. + virtual ThemeProvider* GetDialogThemeProvider() { return NULL; } }; } // namespace views diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc index c59f512..25f25da 100644 --- a/views/widget/widget_win.cc +++ b/views/widget/widget_win.cc @@ -15,6 +15,7 @@ #include "views/fill_layout.h" #include "views/focus/focus_util_win.h" #include "views/widget/aero_tooltip_manager.h" +#include "views/widget/default_theme_provider.h" #include "views/widget/root_view.h" #include "views/window/window_win.h" @@ -166,6 +167,8 @@ void WidgetWin::Init(HWND parent, const gfx::Rect& bounds, // Force creation of the RootView if it hasn't been created yet. GetRootView(); + default_theme_provider_.reset(new DefaultThemeProvider()); + // Ensures the parent we have been passed is valid, otherwise CreateWindowEx // will fail. if (parent && !::IsWindow(parent)) { @@ -293,6 +296,11 @@ RootView* WidgetWin::GetRootView() { return root_view_.get(); } +Widget* WidgetWin::GetRootWidget() const { + return reinterpret_cast<WidgetWin*>( + win_util::GetWindowUserData(GetAncestor(hwnd_, GA_ROOT))); +} + bool WidgetWin::IsVisible() const { return !!::IsWindowVisible(GetNativeView()); } @@ -305,6 +313,16 @@ TooltipManager* WidgetWin::GetTooltipManager() { return tooltip_manager_.get(); } +ThemeProvider* WidgetWin::GetThemeProvider() const { + Widget* widget = GetRootWidget(); + if (widget) { + ThemeProvider* provider = widget->GetDialogThemeProvider(); + if (provider) + return provider; + } + return default_theme_provider_.get(); +} + Window* WidgetWin::GetWindow() { return GetWindowImpl(hwnd_); } diff --git a/views/widget/widget_win.h b/views/widget/widget_win.h index 09efa21..d948e66 100644 --- a/views/widget/widget_win.h +++ b/views/widget/widget_win.h @@ -24,6 +24,7 @@ namespace views { class RootView; class TooltipManager; +class DefaultThemeProvider; class Window; bool SetRootViewForHWND(HWND hwnd, RootView* root_view); @@ -235,9 +236,11 @@ class WidgetWin : public Widget, virtual gfx::NativeView GetNativeView() const; virtual void PaintNow(const gfx::Rect& update_rect); virtual RootView* GetRootView(); + virtual Widget* GetRootWidget() const; virtual bool IsVisible() const; virtual bool IsActive() const; virtual TooltipManager* GetTooltipManager(); + virtual ThemeProvider* GetThemeProvider() const; virtual Window* GetWindow(); virtual const Window* GetWindow() const; @@ -627,6 +630,8 @@ class WidgetWin : public Widget, // Instance of accessibility information and handling for MSAA root CComPtr<IAccessible> accessibility_root_; + scoped_ptr<DefaultThemeProvider> default_theme_provider_; + // Our hwnd. HWND hwnd_; }; diff --git a/views/window/custom_frame_view.cc b/views/window/custom_frame_view.cc index 1816fdc..88251b8 100644 --- a/views/window/custom_frame_view.cc +++ b/views/window/custom_frame_view.cc @@ -8,6 +8,7 @@ #include "app/gfx/chrome_font.h" #include "app/gfx/path.h" #include "app/resource_bundle.h" +#include "app/theme_provider.h" #if defined(OS_WIN) #include "app/win_util.h" #include "base/win_util.h" @@ -21,157 +22,7 @@ namespace views { -// An enumeration of bitmap resources used by this window. -enum { - FRAME_PART_BITMAP_FIRST = 0, // Must be first. - - // Window Controls. - FRAME_CLOSE_BUTTON_ICON, - FRAME_CLOSE_BUTTON_ICON_H, - FRAME_CLOSE_BUTTON_ICON_P, - FRAME_CLOSE_BUTTON_ICON_SA, - FRAME_CLOSE_BUTTON_ICON_SA_H, - FRAME_CLOSE_BUTTON_ICON_SA_P, - FRAME_RESTORE_BUTTON_ICON, - FRAME_RESTORE_BUTTON_ICON_H, - FRAME_RESTORE_BUTTON_ICON_P, - FRAME_MAXIMIZE_BUTTON_ICON, - FRAME_MAXIMIZE_BUTTON_ICON_H, - FRAME_MAXIMIZE_BUTTON_ICON_P, - FRAME_MINIMIZE_BUTTON_ICON, - FRAME_MINIMIZE_BUTTON_ICON_H, - FRAME_MINIMIZE_BUTTON_ICON_P, - - // Window Frame Border. - FRAME_BOTTOM_EDGE, - FRAME_BOTTOM_LEFT_CORNER, - FRAME_BOTTOM_RIGHT_CORNER, - FRAME_LEFT_EDGE, - FRAME_RIGHT_EDGE, - FRAME_TOP_EDGE, - FRAME_TOP_LEFT_CORNER, - FRAME_TOP_RIGHT_CORNER, - - // Client Edge Border. - FRAME_CLIENT_EDGE_TOP_LEFT, - FRAME_CLIENT_EDGE_TOP, - FRAME_CLIENT_EDGE_TOP_RIGHT, - FRAME_CLIENT_EDGE_RIGHT, - FRAME_CLIENT_EDGE_BOTTOM_RIGHT, - FRAME_CLIENT_EDGE_BOTTOM, - FRAME_CLIENT_EDGE_BOTTOM_LEFT, - FRAME_CLIENT_EDGE_LEFT, - - FRAME_PART_BITMAP_COUNT // Must be last. -}; - -class ActiveWindowResources : public WindowResources { - public: - ActiveWindowResources() { - InitClass(); - } - virtual ~ActiveWindowResources() { - } - - // WindowResources implementation: - virtual SkBitmap* GetPartBitmap(FramePartBitmap part) const { - return standard_frame_bitmaps_[part]; - } - - private: - static void InitClass() { - static bool initialized = false; - if (!initialized) { - static const int kFramePartBitmapIds[] = { - 0, - IDR_CLOSE, IDR_CLOSE_H, IDR_CLOSE_P, - IDR_CLOSE_SA, IDR_CLOSE_SA_H, IDR_CLOSE_SA_P, - IDR_RESTORE, IDR_RESTORE_H, IDR_RESTORE_P, - IDR_MAXIMIZE, IDR_MAXIMIZE_H, IDR_MAXIMIZE_P, - IDR_MINIMIZE, IDR_MINIMIZE_H, IDR_MINIMIZE_P, - IDR_WINDOW_BOTTOM_CENTER, IDR_WINDOW_BOTTOM_LEFT_CORNER, - IDR_WINDOW_BOTTOM_RIGHT_CORNER, IDR_WINDOW_LEFT_SIDE, - IDR_WINDOW_RIGHT_SIDE, IDR_WINDOW_TOP_CENTER, - IDR_WINDOW_TOP_LEFT_CORNER, IDR_WINDOW_TOP_RIGHT_CORNER, - IDR_APP_TOP_LEFT, IDR_APP_TOP_CENTER, IDR_APP_TOP_RIGHT, - IDR_CONTENT_RIGHT_SIDE, IDR_CONTENT_BOTTOM_RIGHT_CORNER, - IDR_CONTENT_BOTTOM_CENTER, IDR_CONTENT_BOTTOM_LEFT_CORNER, - IDR_CONTENT_LEFT_SIDE, - 0 - }; - - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - for (int i = 0; i < FRAME_PART_BITMAP_COUNT; ++i) { - int id = kFramePartBitmapIds[i]; - if (id != 0) - standard_frame_bitmaps_[i] = rb.GetBitmapNamed(id); - } - initialized = true; - } - } - - static SkBitmap* standard_frame_bitmaps_[FRAME_PART_BITMAP_COUNT]; - - DISALLOW_EVIL_CONSTRUCTORS(ActiveWindowResources); -}; - -class InactiveWindowResources : public WindowResources { - public: - InactiveWindowResources() { - InitClass(); - } - virtual ~InactiveWindowResources() { - } - - // WindowResources implementation: - virtual SkBitmap* GetPartBitmap(FramePartBitmap part) const { - return standard_frame_bitmaps_[part]; - } - - private: - static void InitClass() { - static bool initialized = false; - if (!initialized) { - static const int kFramePartBitmapIds[] = { - 0, - IDR_CLOSE, IDR_CLOSE_H, IDR_CLOSE_P, - IDR_CLOSE_SA, IDR_CLOSE_SA_H, IDR_CLOSE_SA_P, - IDR_RESTORE, IDR_RESTORE_H, IDR_RESTORE_P, - IDR_MAXIMIZE, IDR_MAXIMIZE_H, IDR_MAXIMIZE_P, - IDR_MINIMIZE, IDR_MINIMIZE_H, IDR_MINIMIZE_P, - IDR_DEWINDOW_BOTTOM_CENTER, IDR_DEWINDOW_BOTTOM_LEFT_CORNER, - IDR_DEWINDOW_BOTTOM_RIGHT_CORNER, IDR_DEWINDOW_LEFT_SIDE, - IDR_DEWINDOW_RIGHT_SIDE, IDR_DEWINDOW_TOP_CENTER, - IDR_DEWINDOW_TOP_LEFT_CORNER, IDR_DEWINDOW_TOP_RIGHT_CORNER, - IDR_APP_TOP_LEFT, IDR_APP_TOP_CENTER, IDR_APP_TOP_RIGHT, - IDR_CONTENT_RIGHT_SIDE, IDR_CONTENT_BOTTOM_RIGHT_CORNER, - IDR_CONTENT_BOTTOM_CENTER, IDR_CONTENT_BOTTOM_LEFT_CORNER, - IDR_CONTENT_LEFT_SIDE, - 0 - }; - - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - for (int i = 0; i < FRAME_PART_BITMAP_COUNT; ++i) { - int id = kFramePartBitmapIds[i]; - if (id != 0) - standard_frame_bitmaps_[i] = rb.GetBitmapNamed(id); - } - initialized = true; - } - } - - static SkBitmap* standard_frame_bitmaps_[FRAME_PART_BITMAP_COUNT]; - - DISALLOW_EVIL_CONSTRUCTORS(InactiveWindowResources); -}; - -// static -SkBitmap* ActiveWindowResources::standard_frame_bitmaps_[]; -SkBitmap* InactiveWindowResources::standard_frame_bitmaps_[]; - // static -WindowResources* CustomFrameView::active_resources_ = NULL; -WindowResources* CustomFrameView::inactive_resources_ = NULL; ChromeFont* CustomFrameView::title_font_ = NULL; namespace { @@ -231,33 +82,34 @@ CustomFrameView::CustomFrameView(Window* frame) should_show_minmax_buttons_(false), frame_(frame) { InitClass(); - WindowResources* resources = active_resources_; + + ThemeProvider* tp = GetThemeProvider(); // Close button images will be set in LayoutWindowControls(). AddChildView(close_button_); restore_button_->SetImage(CustomButton::BS_NORMAL, - resources->GetPartBitmap(FRAME_RESTORE_BUTTON_ICON)); + tp->GetBitmapNamed(IDR_RESTORE)); restore_button_->SetImage(CustomButton::BS_HOT, - resources->GetPartBitmap(FRAME_RESTORE_BUTTON_ICON_H)); + tp->GetBitmapNamed(IDR_RESTORE_H)); restore_button_->SetImage(CustomButton::BS_PUSHED, - resources->GetPartBitmap(FRAME_RESTORE_BUTTON_ICON_P)); + tp->GetBitmapNamed(IDR_RESTORE_P)); AddChildView(restore_button_); maximize_button_->SetImage(CustomButton::BS_NORMAL, - resources->GetPartBitmap(FRAME_MAXIMIZE_BUTTON_ICON)); + tp->GetBitmapNamed(IDR_MAXIMIZE)); maximize_button_->SetImage(CustomButton::BS_HOT, - resources->GetPartBitmap(FRAME_MAXIMIZE_BUTTON_ICON_H)); + tp->GetBitmapNamed(IDR_MAXIMIZE_H)); maximize_button_->SetImage(CustomButton::BS_PUSHED, - resources->GetPartBitmap(FRAME_MAXIMIZE_BUTTON_ICON_P)); + tp->GetBitmapNamed(IDR_MAXIMIZE_P)); AddChildView(maximize_button_); minimize_button_->SetImage(CustomButton::BS_NORMAL, - resources->GetPartBitmap(FRAME_MINIMIZE_BUTTON_ICON)); + tp->GetBitmapNamed(IDR_MINIMIZE)); minimize_button_->SetImage(CustomButton::BS_HOT, - resources->GetPartBitmap(FRAME_MINIMIZE_BUTTON_ICON_H)); + tp->GetBitmapNamed(IDR_MINIMIZE_H)); minimize_button_->SetImage(CustomButton::BS_PUSHED, - resources->GetPartBitmap(FRAME_MINIMIZE_BUTTON_ICON_P)); + tp->GetBitmapNamed(IDR_MINIMIZE_P)); AddChildView(minimize_button_); should_show_minmax_buttons_ = frame_->GetDelegate()->CanMaximize(); @@ -443,17 +295,50 @@ int CustomFrameView::TitleCoordinates(int* title_top_spacing, } void CustomFrameView::PaintRestoredFrameBorder(ChromeCanvas* canvas) { - SkBitmap* top_left_corner = resources()->GetPartBitmap(FRAME_TOP_LEFT_CORNER); + // Window frame mode. + ThemeProvider* tp = GetThemeProvider(); + + SkBitmap* theme_frame; + SkColor frame_color; + + if (frame_->IsActive()) { + theme_frame = tp->GetBitmapNamed(IDR_THEME_FRAME); + frame_color = ResourceBundle::frame_color; + } else { + theme_frame = tp->GetBitmapNamed(IDR_THEME_FRAME_INACTIVE); + frame_color = ResourceBundle::frame_color_inactive; + } + + SkBitmap* top_left_corner = tp->GetBitmapNamed(IDR_WINDOW_TOP_LEFT_CORNER); SkBitmap* top_right_corner = - resources()->GetPartBitmap(FRAME_TOP_RIGHT_CORNER); - SkBitmap* top_edge = resources()->GetPartBitmap(FRAME_TOP_EDGE); - SkBitmap* right_edge = resources()->GetPartBitmap(FRAME_RIGHT_EDGE); - SkBitmap* left_edge = resources()->GetPartBitmap(FRAME_LEFT_EDGE); + tp->GetBitmapNamed(IDR_WINDOW_TOP_RIGHT_CORNER); + SkBitmap* top_edge = tp->GetBitmapNamed(IDR_WINDOW_TOP_CENTER); + SkBitmap* right_edge = tp->GetBitmapNamed(IDR_WINDOW_RIGHT_SIDE); + SkBitmap* left_edge = tp->GetBitmapNamed(IDR_WINDOW_LEFT_SIDE); SkBitmap* bottom_left_corner = - resources()->GetPartBitmap(FRAME_BOTTOM_LEFT_CORNER); + tp->GetBitmapNamed(IDR_WINDOW_BOTTOM_LEFT_CORNER); SkBitmap* bottom_right_corner = - resources()->GetPartBitmap(FRAME_BOTTOM_RIGHT_CORNER); - SkBitmap* bottom_edge = resources()->GetPartBitmap(FRAME_BOTTOM_EDGE); + tp->GetBitmapNamed(IDR_WINDOW_BOTTOM_RIGHT_CORNER); + SkBitmap* bottom_edge = tp->GetBitmapNamed(IDR_WINDOW_BOTTOM_CENTER); + + // Fill with the frame color first so we have a constant background for + // areas not covered by the theme image. + canvas->FillRectInt(frame_color, 0, 0, width(), theme_frame->height()); + // Now fill down the sides + canvas->FillRectInt(frame_color, + 0, theme_frame->height(), + left_edge->width(), height() - theme_frame->height()); + canvas->FillRectInt(frame_color, + width() - right_edge->width(), theme_frame->height(), + right_edge->width(), height() - theme_frame->height()); + // Now fill the bottom area. + canvas->FillRectInt(frame_color, + left_edge->width(), height() - bottom_edge->height(), + width() - left_edge->width() - right_edge->width(), + bottom_edge->height()); + + // Draw the theme frame. + canvas->TileImageInt(*theme_frame, 0, 0, width(), theme_frame->height()); // Top. canvas->DrawBitmapInt(*top_left_corner, 0, 0); @@ -488,13 +373,15 @@ void CustomFrameView::PaintRestoredFrameBorder(ChromeCanvas* canvas) { void CustomFrameView::PaintMaximizedFrameBorder( ChromeCanvas* canvas) { - SkBitmap* top_edge = resources()->GetPartBitmap(FRAME_TOP_EDGE); + ThemeProvider* tp = GetThemeProvider(); + + SkBitmap* top_edge = tp->GetBitmapNamed(IDR_WINDOW_TOP_CENTER); canvas->TileImageInt(*top_edge, 0, FrameBorderThickness(), width(), top_edge->height()); // The bottom of the titlebar actually comes from the top of the Client Edge // graphic, with the actual client edge clipped off the bottom. - SkBitmap* titlebar_bottom = resources()->GetPartBitmap(FRAME_CLIENT_EDGE_TOP); + SkBitmap* titlebar_bottom = tp->GetBitmapNamed(IDR_APP_TOP_CENTER); int edge_height = titlebar_bottom->height() - kClientEdgeThickness; canvas->TileImageInt(*titlebar_bottom, 0, frame_->GetClientView()->y() - edge_height, width(), edge_height); @@ -518,16 +405,17 @@ void CustomFrameView::PaintRestoredClientEdge(ChromeCanvas* canvas) { gfx::Rect client_area_bounds = frame_->GetClientView()->bounds(); int client_area_top = client_area_bounds.y(); - SkBitmap* top_left = resources()->GetPartBitmap(FRAME_CLIENT_EDGE_TOP_LEFT); - SkBitmap* top = resources()->GetPartBitmap(FRAME_CLIENT_EDGE_TOP); - SkBitmap* top_right = resources()->GetPartBitmap(FRAME_CLIENT_EDGE_TOP_RIGHT); - SkBitmap* right = resources()->GetPartBitmap(FRAME_CLIENT_EDGE_RIGHT); + ThemeProvider* tp = GetThemeProvider(); + SkBitmap* top_left = tp->GetBitmapNamed(IDR_APP_TOP_LEFT); + SkBitmap* top = tp->GetBitmapNamed(IDR_APP_TOP_CENTER); + SkBitmap* top_right = tp->GetBitmapNamed(IDR_APP_TOP_RIGHT); + SkBitmap* right = tp->GetBitmapNamed(IDR_CONTENT_RIGHT_SIDE); SkBitmap* bottom_right = - resources()->GetPartBitmap(FRAME_CLIENT_EDGE_BOTTOM_RIGHT); - SkBitmap* bottom = resources()->GetPartBitmap(FRAME_CLIENT_EDGE_BOTTOM); + tp->GetBitmapNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER); + SkBitmap* bottom = tp->GetBitmapNamed(IDR_CONTENT_BOTTOM_CENTER); SkBitmap* bottom_left = - resources()->GetPartBitmap(FRAME_CLIENT_EDGE_BOTTOM_LEFT); - SkBitmap* left = resources()->GetPartBitmap(FRAME_CLIENT_EDGE_LEFT); + tp->GetBitmapNamed(IDR_CONTENT_BOTTOM_LEFT_CORNER); + SkBitmap* left = tp->GetBitmapNamed(IDR_CONTENT_LEFT_SIDE); // Top. // This next calculation is necessary because the top center bitmap is shorter @@ -559,6 +447,11 @@ void CustomFrameView::PaintRestoredClientEdge(ChromeCanvas* canvas) { // Left. canvas->TileImageInt(*left, client_area_bounds.x() - left->width(), client_area_top, left->width(), client_area_height); + + // Draw the toolbar color to fill in the edges. + canvas->DrawRectInt(ResourceBundle::toolbar_color, + client_area_bounds.x() - 1, client_area_top - 2, + client_area_bounds.width() + 1, client_area_bottom - client_area_top + 2); } void CustomFrameView::LayoutWindowControls() { @@ -609,24 +502,26 @@ void CustomFrameView::LayoutWindowControls() { minimize_button_size.width(), minimize_button_size.height() + top_extra_height); - normal_part = FRAME_CLOSE_BUTTON_ICON; - hot_part = FRAME_CLOSE_BUTTON_ICON_H; - pushed_part = FRAME_CLOSE_BUTTON_ICON_P; + normal_part = IDR_CLOSE; + hot_part = IDR_CLOSE_H; + pushed_part = IDR_CLOSE_P; } else { visible_button->SetVisible(false); minimize_button_->SetVisible(false); - normal_part = FRAME_CLOSE_BUTTON_ICON_SA; - hot_part = FRAME_CLOSE_BUTTON_ICON_SA_H; - pushed_part = FRAME_CLOSE_BUTTON_ICON_SA_P; + normal_part = IDR_CLOSE_SA; + hot_part = IDR_CLOSE_SA_H; + pushed_part = IDR_CLOSE_SA_P; } + ThemeProvider* tp = GetThemeProvider(); + close_button_->SetImage(CustomButton::BS_NORMAL, - active_resources_->GetPartBitmap(normal_part)); + tp->GetBitmapNamed(normal_part)); close_button_->SetImage(CustomButton::BS_HOT, - active_resources_->GetPartBitmap(hot_part)); + tp->GetBitmapNamed(hot_part)); close_button_->SetImage(CustomButton::BS_PUSHED, - active_resources_->GetPartBitmap(pushed_part)); + tp->GetBitmapNamed(pushed_part)); } void CustomFrameView::LayoutTitleBar() { @@ -688,9 +583,6 @@ void CustomFrameView::LayoutClientView() { void CustomFrameView::InitClass() { static bool initialized = false; if (!initialized) { - active_resources_ = new ActiveWindowResources; - inactive_resources_ = new InactiveWindowResources; - #if defined(OS_WIN) title_font_ = new ChromeFont(win_util::GetWindowTitleFont()); #elif defined(OS_LINUX) diff --git a/views/window/custom_frame_view.h b/views/window/custom_frame_view.h index f071692..ac0b114 100644 --- a/views/window/custom_frame_view.h +++ b/views/window/custom_frame_view.h @@ -85,12 +85,6 @@ class CustomFrameView : public NonClientFrameView, void LayoutTitleBar(); void LayoutClientView(); - // Returns the resource collection to be used when rendering the window. - WindowResources* resources() const { - return frame_->IsActive() || paint_as_active() ? active_resources_ - : inactive_resources_; - } - // The bounds of the client view, in this view's coordinates. gfx::Rect client_view_bounds_; @@ -110,8 +104,6 @@ class CustomFrameView : public NonClientFrameView, // Initialize various static resources. static void InitClass(); - static WindowResources* active_resources_; - static WindowResources* inactive_resources_; static ChromeFont* title_font_; DISALLOW_EVIL_CONSTRUCTORS(CustomFrameView); |