From 677c8e35386e63fa00e87a03ef5b6e05326dcdbc Mon Sep 17 00:00:00 2001 From: "glen@chromium.org" Date: Thu, 21 May 2009 20:22:48 +0000 Subject: Theme the find bar. The image resources are additional, as we don't want to mess with Linux. BUG=11702 Review URL: http://codereview.chromium.org/115613 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16647 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/app/theme/find_dialog_left.png | Bin 0 -> 198 bytes chrome/app/theme/find_dialog_middle.png | Bin 0 -> 183 bytes chrome/app/theme/find_dialog_right.png | Bin 0 -> 195 bytes chrome/app/theme/theme_resources.grd | 11 +++-- chrome/browser/views/find_bar_view.cc | 67 ++++++++++++----------------- chrome/browser/views/find_bar_view.h | 7 --- chrome/browser/views/find_bar_win.cc | 8 +++- chrome/browser/views/find_bar_win.h | 4 ++ chrome/browser/views/frame/browser_view.cc | 4 ++ chrome/browser/views/frame/browser_view.h | 4 ++ 10 files changed, 53 insertions(+), 52 deletions(-) create mode 100644 chrome/app/theme/find_dialog_left.png create mode 100644 chrome/app/theme/find_dialog_middle.png create mode 100644 chrome/app/theme/find_dialog_right.png (limited to 'chrome') diff --git a/chrome/app/theme/find_dialog_left.png b/chrome/app/theme/find_dialog_left.png new file mode 100644 index 0000000..cb1c4a1 Binary files /dev/null and b/chrome/app/theme/find_dialog_left.png differ diff --git a/chrome/app/theme/find_dialog_middle.png b/chrome/app/theme/find_dialog_middle.png new file mode 100644 index 0000000..fda9c71 Binary files /dev/null and b/chrome/app/theme/find_dialog_middle.png differ diff --git a/chrome/app/theme/find_dialog_right.png b/chrome/app/theme/find_dialog_right.png new file mode 100644 index 0000000..ccd101b Binary files /dev/null and b/chrome/app/theme/find_dialog_right.png differ diff --git a/chrome/app/theme/theme_resources.grd b/chrome/app/theme/theme_resources.grd index b0080d5..58949ea 100644 --- a/chrome/app/theme/theme_resources.grd +++ b/chrome/app/theme/theme_resources.grd @@ -167,9 +167,17 @@ + + + + + + + + @@ -262,9 +270,6 @@ - - - diff --git a/chrome/browser/views/find_bar_view.cc b/chrome/browser/views/find_bar_view.cc index 063ea63..2c62a27 100644 --- a/chrome/browser/views/find_bar_view.cc +++ b/chrome/browser/views/find_bar_view.cc @@ -10,6 +10,7 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/string_util.h" +#include "chrome/browser/browser_theme_provider.h" #include "chrome/browser/find_bar_controller.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/views/find_bar_win.h" @@ -52,15 +53,9 @@ static const SkColor kBackgroundColorNoMatch = SkColorSetRGB(255, 102, 102); // and a right part. The middle part determines the height of the dialog. The // middle part is stretched to fill any remaining part between the left and the // right image, after sizing the dialog to kWindowWidth. -static const SkBitmap* kDlgBackground_left = NULL; -static const SkBitmap* kDlgBackground_middle = NULL; -static const SkBitmap* kDlgBackground_right = NULL; - -// These are versions of the above images but for use when the bookmarks bar -// is extended (when toolbar_blend_ = false). -static const SkBitmap* kDlgBackground_bb_left = NULL; -static const SkBitmap* kDlgBackground_bb_middle = NULL; -static const SkBitmap* kDlgBackground_bb_right = NULL; +static const SkBitmap* kDialog_left = NULL; +static const SkBitmap* kDialog_middle = NULL; +static const SkBitmap* kDialog_right = NULL; // When we are animating, we draw only the top part of the left and right // edges to give the illusion that the find dialog is attached to the @@ -89,8 +84,7 @@ FindBarView::FindBarView(FindBarWin* container) find_previous_button_(NULL), find_next_button_(NULL), close_button_(NULL), - animation_offset_(0), - toolbar_blend_(true) { + animation_offset_(0) { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); find_text_ = new views::TextField(); @@ -150,17 +144,11 @@ FindBarView::FindBarView(FindBarWin* container) l10n_util::GetString(IDS_FIND_IN_PAGE_CLOSE_TOOLTIP)); AddChildView(close_button_); - if (kDlgBackground_left == NULL) { + if (kDialog_left == NULL) { // Background images for the dialog. - kDlgBackground_left = rb.GetBitmapNamed(IDR_FIND_DLG_LEFT_BACKGROUND); - kDlgBackground_middle = rb.GetBitmapNamed(IDR_FIND_DLG_MIDDLE_BACKGROUND); - kDlgBackground_right = rb.GetBitmapNamed(IDR_FIND_DLG_RIGHT_BACKGROUND); - kDlgBackground_bb_left = - rb.GetBitmapNamed(IDR_FIND_DLG_LEFT_BB_BACKGROUND); - kDlgBackground_bb_middle = - rb.GetBitmapNamed(IDR_FIND_DLG_MIDDLE_BB_BACKGROUND); - kDlgBackground_bb_right = - rb.GetBitmapNamed(IDR_FIND_DLG_RIGHT_BB_BACKGROUND); + kDialog_left = rb.GetBitmapNamed(IDR_FIND_DIALOG_LEFT); + kDialog_middle = rb.GetBitmapNamed(IDR_FIND_DIALOG_MIDDLE); + kDialog_right = rb.GetBitmapNamed(IDR_FIND_DIALOG_RIGHT); // Background images for the Find edit box. kBackground = rb.GetBitmapNamed(IDR_FIND_BOX_BACKGROUND); @@ -248,26 +236,25 @@ void FindBarView::Paint(gfx::Canvas* canvas) { // controller, so the whitespace in the left and right background images is // actually outside the window region and is therefore not drawn. See // FindInPageWidgetWin::CreateRoundedWindowEdges() for details. - const SkBitmap *bg_left = - toolbar_blend_ ? kDlgBackground_left : kDlgBackground_bb_left; - const SkBitmap *bg_middle = - toolbar_blend_ ? kDlgBackground_middle : kDlgBackground_bb_middle; - const SkBitmap *bg_right = - toolbar_blend_ ? kDlgBackground_right : kDlgBackground_bb_right; + ThemeProvider* tp = GetThemeProvider(); + gfx::Rect bounds; + container_->GetThemePosition(&bounds); + canvas->TileImageInt(*tp->GetBitmapNamed(IDR_THEME_TOOLBAR), + bounds.x(), bounds.y(), 0, 0, lb.width(), lb.height()); - canvas->DrawBitmapInt(*bg_left, 0, 0); + canvas->DrawBitmapInt(*kDialog_left, 0, 0); // Stretch the middle background to cover all of the area between the two // other images. - canvas->TileImageInt(*bg_middle, - bg_left->width(), + canvas->TileImageInt(*kDialog_middle, + kDialog_left->width(), 0, lb.width() - - bg_left->width() - - bg_right->width(), - bg_middle->height()); + kDialog_left->width() - + kDialog_right->width(), + kDialog_middle->height()); - canvas->DrawBitmapInt(*bg_right, lb.right() - bg_right->width(), 0); + canvas->DrawBitmapInt(*kDialog_right, lb.right() - kDialog_right->width(), 0); // Then we draw the background image for the Find TextField. We start by // calculating the position of background images for the Find text box. @@ -309,15 +296,15 @@ void FindBarView::Paint(gfx::Canvas* canvas) { if (animation_offset_ > 0) { // While animating we draw the curved edges at the point where the // controller told us the top of the window is: |animation_offset_|. - canvas->TileImageInt(*bg_left, + canvas->TileImageInt(*kDialog_left, lb.x(), animation_offset_, - bg_left->width(), + kDialog_left->width(), kAnimatingEdgeHeight); - canvas->TileImageInt(*bg_right, - lb.right() - bg_right->width(), + canvas->TileImageInt(*kDialog_right, + lb.right() - kDialog_right->width(), animation_offset_, - bg_right->width(), + kDialog_right->width(), kAnimatingEdgeHeight); } } @@ -392,7 +379,7 @@ void FindBarView::ViewHierarchyChanged(bool is_add, View *parent, View *child) { gfx::Size FindBarView::GetPreferredSize() { gfx::Size prefsize = find_text_->GetPreferredSize(); - prefsize.set_height(kDlgBackground_middle->height()); + prefsize.set_height(kDialog_middle->height()); // Add up all the preferred sizes and margins of the rest of the controls. prefsize.Enlarge(kMarginLeftOfCloseButton + kMarginRightOfCloseButton + diff --git a/chrome/browser/views/find_bar_view.h b/chrome/browser/views/find_bar_view.h index 00ba8fe1..2a07dff 100644 --- a/chrome/browser/views/find_bar_view.h +++ b/chrome/browser/views/find_bar_view.h @@ -70,9 +70,6 @@ class FindBarView : public views::View, virtual bool HandleKeystroke(views::TextField* sender, const views::TextField::Keystroke& key); - // Set whether or not we're attempting to blend with the toolbar. - void set_toolbar_blend(bool toolbar_blend) { toolbar_blend_ = toolbar_blend; } - private: // Resets the background for the match count label. void ResetMatchCountBackground(); @@ -109,10 +106,6 @@ class FindBarView : public views::View, views::ImageButton* find_next_button_; views::ImageButton* close_button_; - // Whether or not we're attempting to blend with the toolbar (this is - // false if the bookmarks bar is visible). - bool toolbar_blend_; - // While animating, the controller clips the window and draws only the bottom // part of it. The view needs to know the pixel offset at which we are drawing // the window so that we can draw the curved edges that attach to the toolbar diff --git a/chrome/browser/views/find_bar_win.cc b/chrome/browser/views/find_bar_win.cc index 0a56f61..007dcc0 100644 --- a/chrome/browser/views/find_bar_win.cc +++ b/chrome/browser/views/find_bar_win.cc @@ -358,6 +358,12 @@ void FindBarWin::AnimationEnded(const Animation* animation) { } } +void FindBarWin::GetThemePosition(gfx::Rect* bounds) { + *bounds = GetDialogPosition(gfx::Rect()); + gfx::Rect tab_strip_bounds = browser_view_->GetTabStripBounds(); + bounds->Offset(-tab_strip_bounds.x(), -tab_strip_bounds.y()); +} + //////////////////////////////////////////////////////////////////////////////// // FindBarTesting implementation: @@ -382,8 +388,6 @@ void FindBarWin::GetDialogBounds(gfx::Rect* bounds) { // The BrowserView does Layout for the components that we care about // positioning relative to, so we ask it to tell us where we should go. *bounds = browser_view_->GetFindBarBoundingBox(); - view_->set_toolbar_blend( - !browser_view_->ShouldFindBarBlendWithBookmarksBar()); } gfx::Rect FindBarWin::GetDialogPosition(gfx::Rect avoid_overlapping_rect) { diff --git a/chrome/browser/views/find_bar_win.h b/chrome/browser/views/find_bar_win.h index 182f65e..c97d6cf 100644 --- a/chrome/browser/views/find_bar_win.h +++ b/chrome/browser/views/find_bar_win.h @@ -106,6 +106,10 @@ class FindBarWin : public views::FocusChangeListener, // FindBarTesting implementation: virtual bool GetFindBarWindowInfo(gfx::Point* position, bool* fully_visible); + + // Get the offset with which to paint the theme image. + void GetThemePosition(gfx::Rect* bounds); + private: // Retrieves the boundaries that the find bar has to work with within the // Chrome frame window. The resulting rectangle will be a rectangle that diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index ce0197d..d34e151 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -407,6 +407,10 @@ int BrowserView::GetTabStripHeight() const { return IsTabStripVisible() ? tabstrip_->GetPreferredSize().height() : 0; } +gfx::Rect BrowserView::GetTabStripBounds() const { + return frame_->GetBoundsForTabStrip(tabstrip_); +} + bool BrowserView::IsToolbarVisible() const { return browser_->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) || browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR); diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h index e1f71f6..2bbbc5c 100644 --- a/chrome/browser/views/frame/browser_view.h +++ b/chrome/browser/views/frame/browser_view.h @@ -107,6 +107,10 @@ class BrowserView : public BrowserWindow, // avatar icon. int GetTabStripHeight() const; + // Returns the bounds of the TabStrip. Used by themed views to determine the + // offset of IDR_THEME_TOOLBAR. + gfx::Rect GetTabStripBounds() const; + // Accessor for the TabStrip. TabStrip* tabstrip() const { return tabstrip_; } -- cgit v1.1