From 5e9c8899e1c3d26cbf82024ff24559882a588194 Mon Sep 17 00:00:00 2001 From: "glen@google.com" Date: Fri, 1 Aug 2008 22:32:50 +0000 Subject: Let the logo display correctly on the History and Downloads pages in RTL. This really should be using our GridLayout, but GridLayout had trouble both handling our row-spanned images, and cropping the image correctly when the column got too small (it center-cropped it). In the interests of not adding complication for Beta, I just modified the existing code. BUG=1304459 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@267 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/native_ui_contents.cc | 49 +++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 17 deletions(-) (limited to 'chrome/browser/native_ui_contents.cc') diff --git a/chrome/browser/native_ui_contents.cc b/chrome/browser/native_ui_contents.cc index 977aae8..3988ae0 100644 --- a/chrome/browser/native_ui_contents.cc +++ b/chrome/browser/native_ui_contents.cc @@ -497,6 +497,16 @@ SearchableUIContainer::SearchableUIContainer( title_image_ = new ChromeViews::ImageView(); title_image_->SetVisible(false); + // Get the product logo + if (!kProductLogo) { + kProductLogo = resource_bundle.GetBitmapNamed(IDR_PRODUCT_LOGO); + } + + product_logo_ = new ChromeViews::ImageView(); + product_logo_->SetVisible(true); + product_logo_->SetImage(*kProductLogo); + AddChildView(product_logo_); + search_field_ = new ChromeViews::TextField; search_field_->SetFont(ResourceBundle::GetSharedInstance().GetFont( ResourceBundle::WebFont)); @@ -510,11 +520,6 @@ SearchableUIContainer::SearchableUIContainer( throbber_ = new ChromeViews::SmoothedThrobber(50); - // Get the product logo - if (!kProductLogo) { - kProductLogo = resource_bundle.GetBitmapNamed(IDR_PRODUCT_LOGO); - } - GridLayout* layout = new GridLayout(this); // View owns the LayoutManager and will delete it along with all the columns // we create here. @@ -601,6 +606,28 @@ ChromeViews::View* SearchableUIContainer::GetContents() { return scroll_view_->GetContents(); } +void SearchableUIContainer::Layout() { + View::Layout(); + + CSize search_button_size; + search_button_->GetPreferredSize(&search_button_size); + + CSize product_logo_size; + product_logo_->GetPreferredSize(&product_logo_size); + + int field_width = kDestinationSearchOffset + + kDestinationSearchWidth + + kDestinationSmallerMargin + + static_cast(search_button_size.cx) + + kDestinationSmallerMargin; + + product_logo_->SetBounds(std::max(GetWidth() - kProductLogo->width() - + kProductLogoPadding, + field_width), + kProductLogoPadding, + product_logo_size.cx, product_logo_size.cy); +} + void SearchableUIContainer::Paint(ChromeCanvas* canvas) { SkColor top_color(kBackground); canvas->FillRectInt(top_color, 0, 0, @@ -611,18 +638,6 @@ void SearchableUIContainer::Paint(ChromeCanvas* canvas) { canvas->FillRectInt(SkColorSetRGB(196, 196, 196), 0, scroll_view_->GetY() - 1, GetWidth(), 1); - - // Lay out the product logo. - CSize search_button_size; - search_button_->GetPreferredSize(&search_button_size); - - canvas->DrawBitmapInt(*kProductLogo, - std::max(GetWidth() - kProductLogo->width() - kProductLogoPadding, - kDestinationSearchOffset + kDestinationSearchWidth + - kDestinationSmallerMargin + - static_cast(search_button_size.cx) + - kDestinationSmallerMargin), - kProductLogoPadding); } ChromeViews::TextField* SearchableUIContainer::GetSearchField() const { -- cgit v1.1