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

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

Issue 6913026: Compact Navigation prototype (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Clang build fix. After commit/revert. Created 9 years, 7 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
« no previous file with comments | « chrome/browser/ui/views/find_bar_host.cc ('k') | chrome/browser/ui/views/frame/browser_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ui/views/find_bar_view.h" 5 #include "chrome/browser/ui/views/find_bar_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 static const SkColor kBackgroundColorNoMatch = SkColorSetRGB(255, 102, 102); 60 static const SkColor kBackgroundColorNoMatch = SkColorSetRGB(255, 102, 102);
61 61
62 // The background images for the dialog. They are split into a left, a middle 62 // The background images for the dialog. They are split into a left, a middle
63 // and a right part. The middle part determines the height of the dialog. The 63 // and a right part. The middle part determines the height of the dialog. The
64 // middle part is stretched to fill any remaining part between the left and the 64 // middle part is stretched to fill any remaining part between the left and the
65 // right image, after sizing the dialog to kWindowWidth. 65 // right image, after sizing the dialog to kWindowWidth.
66 static const SkBitmap* kDialog_left = NULL; 66 static const SkBitmap* kDialog_left = NULL;
67 static const SkBitmap* kDialog_middle = NULL; 67 static const SkBitmap* kDialog_middle = NULL;
68 static const SkBitmap* kDialog_right = NULL; 68 static const SkBitmap* kDialog_right = NULL;
69 69
70 // When we are animating, we draw only the top part of the left and right
71 // edges to give the illusion that the find dialog is attached to the
72 // window during this animation; this is the height of the items we draw.
73 static const int kAnimatingEdgeHeight = 5;
74
75 // The background image for the Find text box, which we draw behind the Find box 70 // The background image for the Find text box, which we draw behind the Find box
76 // to provide the Chrome look to the edge of the text box. 71 // to provide the Chrome look to the edge of the text box.
77 static const SkBitmap* kBackground = NULL; 72 static const SkBitmap* kBackground = NULL;
78 73
79 // The rounded edge on the left side of the Find text box. 74 // The rounded edge on the left side of the Find text box.
80 static const SkBitmap* kBackground_left = NULL; 75 static const SkBitmap* kBackground_left = NULL;
81 76
82 // The default number of average characters that the text box will be. This 77 // The default number of average characters that the text box will be. This
83 // number brings the width on a "regular fonts" system to about 300px. 78 // number brings the width on a "regular fonts" system to about 300px.
84 static const int kDefaultCharWidth = 43; 79 static const int kDefaultCharWidth = 43;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 if (kDialog_left == NULL) { 158 if (kDialog_left == NULL) {
164 // Background images for the dialog. 159 // Background images for the dialog.
165 kDialog_left = rb.GetBitmapNamed(IDR_FIND_DIALOG_LEFT); 160 kDialog_left = rb.GetBitmapNamed(IDR_FIND_DIALOG_LEFT);
166 kDialog_middle = rb.GetBitmapNamed(IDR_FIND_DIALOG_MIDDLE); 161 kDialog_middle = rb.GetBitmapNamed(IDR_FIND_DIALOG_MIDDLE);
167 kDialog_right = rb.GetBitmapNamed(IDR_FIND_DIALOG_RIGHT); 162 kDialog_right = rb.GetBitmapNamed(IDR_FIND_DIALOG_RIGHT);
168 163
169 // Background images for the Find edit box. 164 // Background images for the Find edit box.
170 kBackground = rb.GetBitmapNamed(IDR_FIND_BOX_BACKGROUND); 165 kBackground = rb.GetBitmapNamed(IDR_FIND_BOX_BACKGROUND);
171 kBackground_left = rb.GetBitmapNamed(IDR_FIND_BOX_BACKGROUND_LEFT); 166 kBackground_left = rb.GetBitmapNamed(IDR_FIND_BOX_BACKGROUND_LEFT);
172 } 167 }
168 SetDialogBorderBitmaps(kDialog_left, kDialog_middle, kDialog_right);
173 } 169 }
174 170
175 FindBarView::~FindBarView() { 171 FindBarView::~FindBarView() {
176 } 172 }
177 173
178 void FindBarView::SetFindText(const string16& find_text) { 174 void FindBarView::SetFindText(const string16& find_text) {
179 find_text_->SetText(find_text); 175 find_text_->SetText(find_text);
180 } 176 }
181 177
182 string16 FindBarView::GetFindText() const { 178 string16 FindBarView::GetFindText() const {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 if (select_all && !find_text_->text().empty()) 235 if (select_all && !find_text_->text().empty())
240 find_text_->SelectAll(); 236 find_text_->SelectAll();
241 } 237 }
242 238
243 /////////////////////////////////////////////////////////////////////////////// 239 ///////////////////////////////////////////////////////////////////////////////
244 // FindBarView, views::View overrides: 240 // FindBarView, views::View overrides:
245 241
246 void FindBarView::OnPaint(gfx::Canvas* canvas) { 242 void FindBarView::OnPaint(gfx::Canvas* canvas) {
247 SkPaint paint; 243 SkPaint paint;
248 244
249 // Determine the find bar size as well as the offset from which to tile the 245 gfx::Rect bounds = PaintOffsetToolbarBackground(canvas);
250 // toolbar background image. First, get the widget bounds.
251 gfx::Rect bounds = GetWidget()->GetWindowScreenBounds();
252 // Now convert from screen to parent coordinates.
253 gfx::Point origin(bounds.origin());
254 BrowserView* browser_view = host()->browser_view();
255 ConvertPointToView(NULL, browser_view, &origin);
256 bounds.set_origin(origin);
257 // Finally, calculate the background image tiling offset.
258 origin = browser_view->OffsetPointForToolbarBackgroundImage(origin);
259
260 // First, we draw the background image for the whole dialog (3 images: left,
261 // middle and right). Note, that the window region has been set by the
262 // controller, so the whitespace in the left and right background images is
263 // actually outside the window region and is therefore not drawn. See
264 // FindInPageWidgetWin::CreateRoundedWindowEdges() for details.
265 ui::ThemeProvider* tp = GetThemeProvider();
266 canvas->TileImageInt(*tp->GetBitmapNamed(IDR_THEME_TOOLBAR), origin.x(),
267 origin.y(), 0, 0, bounds.width(), bounds.height());
268 246
269 // Now flip the canvas for the rest of the graphics if in RTL mode. 247 // Now flip the canvas for the rest of the graphics if in RTL mode.
270 canvas->Save(); 248 canvas->Save();
271 if (base::i18n::IsRTL()) { 249 if (base::i18n::IsRTL()) {
272 canvas->TranslateInt(width(), 0); 250 canvas->TranslateInt(width(), 0);
273 canvas->ScaleInt(-1, 1); 251 canvas->ScaleInt(-1, 1);
274 } 252 }
275 253
276 canvas->DrawBitmapInt(*kDialog_left, 0, 0); 254 PaintDialogBorder(canvas, bounds);
277
278 // Stretch the middle background to cover all of the area between the two
279 // other images.
280 canvas->TileImageInt(*kDialog_middle, kDialog_left->width(), 0,
281 bounds.width() - kDialog_left->width() - kDialog_right->width(),
282 kDialog_middle->height());
283
284 canvas->DrawBitmapInt(*kDialog_right, bounds.width() - kDialog_right->width(),
285 0);
286 255
287 // Then we draw the background image for the Find Textfield. We start by 256 // Then we draw the background image for the Find Textfield. We start by
288 // calculating the position of background images for the Find text box. 257 // calculating the position of background images for the Find text box.
289 int find_text_x = find_text_->x(); 258 int find_text_x = find_text_->x();
290 gfx::Point back_button_origin = find_previous_button_->bounds().origin(); 259 gfx::Point back_button_origin = find_previous_button_->bounds().origin();
291 260
292 // Draw the image to the left that creates a curved left edge for the box. 261 // Draw the image to the left that creates a curved left edge for the box.
293 canvas->TileImageInt(*kBackground_left, 262 canvas->TileImageInt(*kBackground_left,
294 find_text_x - kBackground_left->width(), back_button_origin.y(), 263 find_text_x - kBackground_left->width(), back_button_origin.y(),
295 kBackground_left->width(), kBackground_left->height()); 264 kBackground_left->width(), kBackground_left->height());
296 265
297 // Draw the top and bottom border for whole text box (encompasses both the 266 // Draw the top and bottom border for whole text box (encompasses both the
298 // find_text_ edit box and the match_count_text_ label). 267 // find_text_ edit box and the match_count_text_ label).
299 canvas->TileImageInt(*kBackground, find_text_x, back_button_origin.y(), 268 canvas->TileImageInt(*kBackground, find_text_x, back_button_origin.y(),
300 back_button_origin.x() - find_text_x, 269 back_button_origin.x() - find_text_x,
301 kBackground->height()); 270 kBackground->height());
302 271
303 if (animation_offset() > 0) { 272 PaintAnimatingEdges(canvas, bounds);
304 // While animating we draw the curved edges at the point where the
305 // controller told us the top of the window is: |animation_offset()|.
306 canvas->TileImageInt(*kDialog_left, bounds.x(), animation_offset(),
307 kDialog_left->width(), kAnimatingEdgeHeight);
308 canvas->TileImageInt(*kDialog_right,
309 bounds.width() - kDialog_right->width(), animation_offset(),
310 kDialog_right->width(), kAnimatingEdgeHeight);
311 }
312 273
313 canvas->Restore(); 274 canvas->Restore();
314 } 275 }
315 276
316 void FindBarView::Layout() { 277 void FindBarView::Layout() {
317 gfx::Size panel_size = GetPreferredSize(); 278 gfx::Size panel_size = GetPreferredSize();
318 279
319 // First we draw the close button on the far right. 280 // First we draw the close button on the far right.
320 gfx::Size sz = close_button_->GetPreferredSize(); 281 gfx::Size sz = close_button_->GetPreferredSize();
321 close_button_->SetBounds(panel_size.width() - sz.width() - 282 close_button_->SetBounds(panel_size.width() - sz.width() -
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 501
541 void FindBarView::OnThemeChanged() { 502 void FindBarView::OnThemeChanged() {
542 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 503 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
543 if (GetThemeProvider()) { 504 if (GetThemeProvider()) {
544 close_button_->SetBackground( 505 close_button_->SetBackground(
545 GetThemeProvider()->GetColor(ThemeService::COLOR_TAB_TEXT), 506 GetThemeProvider()->GetColor(ThemeService::COLOR_TAB_TEXT),
546 rb.GetBitmapNamed(IDR_CLOSE_BAR), 507 rb.GetBitmapNamed(IDR_CLOSE_BAR),
547 rb.GetBitmapNamed(IDR_CLOSE_BAR_MASK)); 508 rb.GetBitmapNamed(IDR_CLOSE_BAR_MASK));
548 } 509 }
549 } 510 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/find_bar_host.cc ('k') | chrome/browser/ui/views/frame/browser_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698