Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: chrome/browser/views/find_bar_view.cc

Issue 3167027: Merge 56737 - Fix numerous alignment problems, both horizontal and vertical, ... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/472/src/
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/views/find_bar_view.h" 5 #include "chrome/browser/views/find_bar_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "chrome/browser/browser_theme_provider.h" 12 #include "chrome/browser/browser_theme_provider.h"
13 #include "chrome/browser/find_bar_controller.h" 13 #include "chrome/browser/find_bar_controller.h"
14 #include "chrome/browser/find_bar_state.h" 14 #include "chrome/browser/find_bar_state.h"
15 #include "chrome/browser/profile.h" 15 #include "chrome/browser/profile.h"
16 #include "chrome/browser/tab_contents/tab_contents.h" 16 #include "chrome/browser/tab_contents/tab_contents.h"
17 #include "chrome/browser/views/find_bar_host.h" 17 #include "chrome/browser/views/find_bar_host.h"
18 #include "chrome/browser/views/frame/browser_view.h"
18 #include "chrome/browser/view_ids.h" 19 #include "chrome/browser/view_ids.h"
19 #include "gfx/canvas.h" 20 #include "gfx/canvas.h"
20 #include "grit/generated_resources.h" 21 #include "grit/generated_resources.h"
21 #include "grit/theme_resources.h" 22 #include "grit/theme_resources.h"
22 #include "third_party/skia/include/effects/SkGradientShader.h" 23 #include "third_party/skia/include/effects/SkGradientShader.h"
23 #include "views/background.h" 24 #include "views/background.h"
24 #include "views/controls/button/image_button.h" 25 #include "views/controls/button/image_button.h"
25 #include "views/controls/label.h" 26 #include "views/controls/label.h"
27 #include "views/widget/widget.h"
26 28
27 // The amount of whitespace to have before the find button. 29 // The amount of whitespace to have before the find button.
28 static const int kWhiteSpaceAfterMatchCountLabel = 1; 30 static const int kWhiteSpaceAfterMatchCountLabel = 1;
29 31
30 // The margins around the search field and the close button. 32 // The margins around the search field and the close button.
31 static const int kMarginLeftOfCloseButton = 3; 33 static const int kMarginLeftOfCloseButton = 3;
32 static const int kMarginRightOfCloseButton = 7; 34 static const int kMarginRightOfCloseButton = 7;
33 static const int kMarginLeftOfFindTextfield = 12; 35 static const int kMarginLeftOfFindTextfield = 12;
34 36
35 // The margins around the match count label (We add extra space so that the 37 // The margins around the match count label (We add extra space so that the
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 if (select_all && !find_text_->text().empty()) 225 if (select_all && !find_text_->text().empty())
224 find_text_->SelectAll(); 226 find_text_->SelectAll();
225 } 227 }
226 228
227 /////////////////////////////////////////////////////////////////////////////// 229 ///////////////////////////////////////////////////////////////////////////////
228 // FindBarView, views::View overrides: 230 // FindBarView, views::View overrides:
229 231
230 void FindBarView::Paint(gfx::Canvas* canvas) { 232 void FindBarView::Paint(gfx::Canvas* canvas) {
231 SkPaint paint; 233 SkPaint paint;
232 234
235 // Determine the find bar size as well as the offset from which to tile the
236 // toolbar background image. First, get the widget bounds.
237 gfx::Rect bounds;
238 GetWidget()->GetBounds(&bounds, true);
239 // Now convert from screen to parent coordinates.
240 gfx::Point origin(bounds.origin());
241 BrowserView* browser_view = host()->browser_view();
242 ConvertPointToView(NULL, browser_view, &origin);
243 bounds.set_origin(origin);
244 // Finally, calculate the background image tiling offset.
245 origin = browser_view->OffsetPointForToolbarBackgroundImage(origin);
246
233 // First, we draw the background image for the whole dialog (3 images: left, 247 // First, we draw the background image for the whole dialog (3 images: left,
234 // middle and right). Note, that the window region has been set by the 248 // middle and right). Note, that the window region has been set by the
235 // controller, so the whitespace in the left and right background images is 249 // controller, so the whitespace in the left and right background images is
236 // actually outside the window region and is therefore not drawn. See 250 // actually outside the window region and is therefore not drawn. See
237 // FindInPageWidgetWin::CreateRoundedWindowEdges() for details. 251 // FindInPageWidgetWin::CreateRoundedWindowEdges() for details.
238 ThemeProvider* tp = GetThemeProvider(); 252 ThemeProvider* tp = GetThemeProvider();
239 gfx::Rect bounds; 253 canvas->TileImageInt(*tp->GetBitmapNamed(IDR_THEME_TOOLBAR), origin.x(),
240 host()->GetThemePosition(&bounds); 254 origin.y(), 0, 0, bounds.width(), bounds.height());
241 canvas->TileImageInt(*tp->GetBitmapNamed(IDR_THEME_TOOLBAR), bounds.x(),
242 bounds.y(), 0, 0, bounds.width(), bounds.height());
243 255
244 // Now flip the canvas for the rest of the graphics if in RTL mode. 256 // Now flip the canvas for the rest of the graphics if in RTL mode.
245 canvas->Save(); 257 canvas->Save();
246 if (base::i18n::IsRTL()) { 258 if (base::i18n::IsRTL()) {
247 canvas->TranslateInt(width(), 0); 259 canvas->TranslateInt(width(), 0);
248 canvas->ScaleInt(-1, 1); 260 canvas->ScaleInt(-1, 1);
249 } 261 }
250 262
251 canvas->DrawBitmapInt(*kDialog_left, 0, 0); 263 canvas->DrawBitmapInt(*kDialog_left, 0, 0);
252 264
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 515
504 void FindBarView::OnThemeChanged() { 516 void FindBarView::OnThemeChanged() {
505 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 517 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
506 if (GetThemeProvider()) { 518 if (GetThemeProvider()) {
507 close_button_->SetBackground( 519 close_button_->SetBackground(
508 GetThemeProvider()->GetColor(BrowserThemeProvider::COLOR_TAB_TEXT), 520 GetThemeProvider()->GetColor(BrowserThemeProvider::COLOR_TAB_TEXT),
509 rb.GetBitmapNamed(IDR_CLOSE_BAR), 521 rb.GetBitmapNamed(IDR_CLOSE_BAR),
510 rb.GetBitmapNamed(IDR_CLOSE_BAR_MASK)); 522 rb.GetBitmapNamed(IDR_CLOSE_BAR_MASK));
511 } 523 }
512 } 524 }
OLDNEW
« no previous file with comments | « chrome/browser/views/dropdown_bar_host.cc ('k') | chrome/browser/views/frame/app_panel_browser_frame_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698