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

Side by Side Diff: chrome/browser/ui/views/frame/app_panel_browser_frame_view.cc

Issue 9332006: ui/gfx: Make the first version of Canvas::TileImageInt take a gfx::Rect. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/frame/app_panel_browser_frame_view.h" 5 #include "chrome/browser/ui/views/frame/app_panel_browser_frame_view.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/ui/views/frame/browser_frame.h" 9 #include "chrome/browser/ui/views/frame/browser_frame.h"
10 #include "chrome/browser/ui/views/frame/browser_view.h" 10 #include "chrome/browser/ui/views/frame/browser_view.h"
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 int center_width = width() - left_edge->width() - right_edge->width(); 349 int center_width = width() - left_edge->width() - right_edge->width();
350 if (center_width > 0) { 350 if (center_width > 0) {
351 // Now fill the bottom area. 351 // Now fill the bottom area.
352 canvas->FillRect(gfx::Rect(left_edge->width(), 352 canvas->FillRect(gfx::Rect(left_edge->width(),
353 height() - bottom_edge->height(), center_width, 353 height() - bottom_edge->height(), center_width,
354 bottom_edge->height()), frame_color); 354 bottom_edge->height()), frame_color);
355 } 355 }
356 } 356 }
357 357
358 // Draw the theme frame. 358 // Draw the theme frame.
359 canvas->TileImageInt(*theme_frame, 0, 0, width(), theme_frame->height()); 359 canvas->TileImage(*theme_frame,
360 gfx::Rect(0, 0, width(), theme_frame->height()));
360 361
361 // Top. 362 // Top.
362 canvas->DrawBitmapInt(*top_left_corner, 0, 0); 363 canvas->DrawBitmapInt(*top_left_corner, 0, 0);
363 canvas->TileImageInt(*top_edge, top_left_corner->width(), 0, 364 canvas->TileImage(*top_edge, gfx::Rect(top_left_corner->width(), 0,
364 width() - top_right_corner->width(), top_edge->height()); 365 width() - top_right_corner->width(), top_edge->height()));
Peter Kasting 2012/02/06 22:32:39 Nit: While here, this has a bug; third arg should
tfarina 2012/02/06 23:12:16 Done.
365 canvas->DrawBitmapInt(*top_right_corner, 366 canvas->DrawBitmapInt(*top_right_corner,
366 width() - top_right_corner->width(), 0); 367 width() - top_right_corner->width(), 0);
367 368
368 // Right. 369 // Right.
369 canvas->TileImageInt(*right_edge, width() - right_edge->width(), 370 canvas->TileImage(*right_edge, gfx::Rect(width() - right_edge->width(),
370 top_right_corner->height(), right_edge->width(), 371 top_right_corner->height(), right_edge->width(),
371 height() - top_right_corner->height() - bottom_right_corner->height()); 372 height() - top_right_corner->height() - bottom_right_corner->height()));
372 373
373 // Bottom. 374 // Bottom.
374 canvas->DrawBitmapInt(*bottom_right_corner, 375 canvas->DrawBitmapInt(*bottom_right_corner,
375 width() - bottom_right_corner->width(), 376 width() - bottom_right_corner->width(),
376 height() - bottom_right_corner->height()); 377 height() - bottom_right_corner->height());
377 canvas->TileImageInt(*bottom_edge, bottom_left_corner->width(), 378 canvas->TileImage(*bottom_edge, gfx::Rect(bottom_left_corner->width(),
378 height() - bottom_edge->height(), 379 height() - bottom_edge->height(),
379 width() - bottom_left_corner->width() - bottom_right_corner->width(), 380 width() - bottom_left_corner->width() - bottom_right_corner->width(),
380 bottom_edge->height()); 381 bottom_edge->height()));
381 canvas->DrawBitmapInt(*bottom_left_corner, 0, 382 canvas->DrawBitmapInt(*bottom_left_corner, 0,
382 height() - bottom_left_corner->height()); 383 height() - bottom_left_corner->height());
383 384
384 // Left. 385 // Left.
385 canvas->TileImageInt(*left_edge, 0, top_left_corner->height(), 386 canvas->TileImage(*left_edge, gfx::Rect(0, top_left_corner->height(),
386 left_edge->width(), 387 left_edge->width(),
387 height() - top_left_corner->height() - bottom_left_corner->height()); 388 height() - top_left_corner->height() - bottom_left_corner->height()));
388 } 389 }
389 390
390 void AppPanelBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) { 391 void AppPanelBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {
391 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 392 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
Peter Kasting 2012/02/06 22:32:39 Nit: Same nit about qualifiers
392 393
393 SkBitmap* frame_image = rb.GetBitmapNamed(IDR_FRAME_APP_PANEL); 394 SkBitmap* frame_image = rb.GetBitmapNamed(IDR_FRAME_APP_PANEL);
394 canvas->TileImageInt(*frame_image, 0, FrameBorderThickness(), width(), 395 canvas->TileImage(*frame_image, gfx::Rect(0, FrameBorderThickness(), width(),
395 frame_image->height()); 396 frame_image->height()));
396 397
397 // The bottom of the titlebar actually comes from the top of the Client Edge 398 // The bottom of the titlebar actually comes from the top of the Client Edge
398 // graphic, with the actual client edge clipped off the bottom. 399 // graphic, with the actual client edge clipped off the bottom.
399 SkBitmap* titlebar_bottom = rb.GetBitmapNamed(IDR_APP_TOP_CENTER); 400 SkBitmap* titlebar_bottom = rb.GetBitmapNamed(IDR_APP_TOP_CENTER);
400 int edge_height = titlebar_bottom->height() - kClientEdgeThickness; 401 int edge_height = titlebar_bottom->height() - kClientEdgeThickness;
401 canvas->TileImageInt(*titlebar_bottom, 0, 402 canvas->TileImage(*titlebar_bottom, gfx::Rect(0,
402 frame()->client_view()->y() - edge_height, 403 frame()->client_view()->y() - edge_height, width(), edge_height));
403 width(), edge_height);
404 } 404 }
405 405
406 void AppPanelBrowserFrameView::PaintTitleBar(gfx::Canvas* canvas) { 406 void AppPanelBrowserFrameView::PaintTitleBar(gfx::Canvas* canvas) {
407 // The window icon is painted by the TabIconView. 407 // The window icon is painted by the TabIconView.
408 views::WidgetDelegate* d = frame()->widget_delegate(); 408 views::WidgetDelegate* d = frame()->widget_delegate();
409 canvas->DrawStringInt(d->GetWindowTitle(), BrowserFrame::GetTitleFont(), 409 canvas->DrawStringInt(d->GetWindowTitle(), BrowserFrame::GetTitleFont(),
410 SK_ColorBLACK, GetMirroredXForRect(title_bounds_), title_bounds_.y(), 410 SK_ColorBLACK, GetMirroredXForRect(title_bounds_), title_bounds_.y(),
411 title_bounds_.width(), title_bounds_.height()); 411 title_bounds_.width(), title_bounds_.height());
412 } 412 }
413 413
(...skipping 10 matching lines...) Expand all
424 rb.GetBitmapNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER); 424 rb.GetBitmapNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER);
425 SkBitmap* bottom = rb.GetBitmapNamed(IDR_CONTENT_BOTTOM_CENTER); 425 SkBitmap* bottom = rb.GetBitmapNamed(IDR_CONTENT_BOTTOM_CENTER);
426 SkBitmap* bottom_left = 426 SkBitmap* bottom_left =
427 rb.GetBitmapNamed(IDR_CONTENT_BOTTOM_LEFT_CORNER); 427 rb.GetBitmapNamed(IDR_CONTENT_BOTTOM_LEFT_CORNER);
428 SkBitmap* left = rb.GetBitmapNamed(IDR_CONTENT_LEFT_SIDE); 428 SkBitmap* left = rb.GetBitmapNamed(IDR_CONTENT_LEFT_SIDE);
429 429
430 // Top. 430 // Top.
431 int top_edge_y = client_area_top - top->height(); 431 int top_edge_y = client_area_top - top->height();
432 canvas->DrawBitmapInt(*top_left, client_area_bounds.x() - top_left->width(), 432 canvas->DrawBitmapInt(*top_left, client_area_bounds.x() - top_left->width(),
433 top_edge_y); 433 top_edge_y);
434 canvas->TileImageInt(*top, client_area_bounds.x(), top_edge_y, 434 canvas->TileImage(*top, gfx::Rect(client_area_bounds.x(), top_edge_y,
435 client_area_bounds.width(), top->height()); 435 client_area_bounds.width(), top->height()));
436 canvas->DrawBitmapInt(*top_right, client_area_bounds.right(), top_edge_y); 436 canvas->DrawBitmapInt(*top_right, client_area_bounds.right(), top_edge_y);
437 437
438 // Right. 438 // Right.
439 int client_area_bottom = 439 int client_area_bottom =
440 std::max(client_area_top, client_area_bounds.bottom()); 440 std::max(client_area_top, client_area_bounds.bottom());
441 int client_area_height = client_area_bottom - client_area_top; 441 int client_area_height = client_area_bottom - client_area_top;
442 canvas->TileImageInt(*right, client_area_bounds.right(), client_area_top, 442 canvas->TileImage(*right, gfx::Rect(client_area_bounds.right(),
443 right->width(), client_area_height); 443 client_area_top, right->width(), client_area_height));
444 444
445 // Bottom. 445 // Bottom.
446 canvas->DrawBitmapInt(*bottom_right, client_area_bounds.right(), 446 canvas->DrawBitmapInt(*bottom_right, client_area_bounds.right(),
447 client_area_bottom); 447 client_area_bottom);
448 canvas->TileImageInt(*bottom, client_area_bounds.x(), client_area_bottom, 448 canvas->TileImage(*bottom, gfx::Rect(client_area_bounds.x(),
449 client_area_bounds.width(), bottom_right->height()); 449 client_area_bottom, client_area_bounds.width(), bottom_right->height()));
450 canvas->DrawBitmapInt(*bottom_left, 450 canvas->DrawBitmapInt(*bottom_left,
451 client_area_bounds.x() - bottom_left->width(), client_area_bottom); 451 client_area_bounds.x() - bottom_left->width(), client_area_bottom);
452 452
453 // Left. 453 // Left.
454 canvas->TileImageInt(*left, client_area_bounds.x() - left->width(), 454 canvas->TileImage(*left, gfx::Rect(client_area_bounds.x() - left->width(),
455 client_area_top, left->width(), client_area_height); 455 client_area_top, left->width(), client_area_height));
456 456
457 // Draw the toolbar color to fill in the edges. 457 // Draw the toolbar color to fill in the edges.
458 canvas->DrawRect(gfx::Rect( 458 canvas->DrawRect(gfx::Rect(
459 client_area_bounds.x() - kClientEdgeThickness, 459 client_area_bounds.x() - kClientEdgeThickness,
460 client_area_top - kClientEdgeThickness, 460 client_area_top - kClientEdgeThickness,
461 client_area_bounds.width() + kClientEdgeThickness, 461 client_area_bounds.width() + kClientEdgeThickness,
462 client_area_bottom - client_area_top + kClientEdgeThickness), 462 client_area_bottom - client_area_top + kClientEdgeThickness),
463 ResourceBundle::toolbar_color); 463 ResourceBundle::toolbar_color);
464 } 464 }
465 465
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 } 502 }
503 503
504 gfx::Rect AppPanelBrowserFrameView::CalculateClientAreaBounds(int width, 504 gfx::Rect AppPanelBrowserFrameView::CalculateClientAreaBounds(int width,
505 int height) const { 505 int height) const {
506 int top_height = NonClientTopBorderHeight(); 506 int top_height = NonClientTopBorderHeight();
507 int border_thickness = NonClientBorderThickness(); 507 int border_thickness = NonClientBorderThickness();
508 return gfx::Rect(border_thickness, top_height, 508 return gfx::Rect(border_thickness, top_height,
509 std::max(0, width - (2 * border_thickness)), 509 std::max(0, width - (2 * border_thickness)),
510 std::max(0, height - top_height - border_thickness)); 510 std::max(0, height - top_height - border_thickness));
511 } 511 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698