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

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: Peter review 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_left_corner->width() - top_right_corner->width(),
366 top_edge->height()));
365 canvas->DrawBitmapInt(*top_right_corner, 367 canvas->DrawBitmapInt(*top_right_corner,
366 width() - top_right_corner->width(), 0); 368 width() - top_right_corner->width(), 0);
367 369
368 // Right. 370 // Right.
369 canvas->TileImageInt(*right_edge, width() - right_edge->width(), 371 canvas->TileImage(*right_edge, gfx::Rect(width() - right_edge->width(),
370 top_right_corner->height(), right_edge->width(), 372 top_right_corner->height(), right_edge->width(),
371 height() - top_right_corner->height() - bottom_right_corner->height()); 373 height() - top_right_corner->height() - bottom_right_corner->height()));
372 374
373 // Bottom. 375 // Bottom.
374 canvas->DrawBitmapInt(*bottom_right_corner, 376 canvas->DrawBitmapInt(*bottom_right_corner,
375 width() - bottom_right_corner->width(), 377 width() - bottom_right_corner->width(),
376 height() - bottom_right_corner->height()); 378 height() - bottom_right_corner->height());
377 canvas->TileImageInt(*bottom_edge, bottom_left_corner->width(), 379 canvas->TileImage(*bottom_edge, gfx::Rect(bottom_left_corner->width(),
378 height() - bottom_edge->height(), 380 height() - bottom_edge->height(),
379 width() - bottom_left_corner->width() - bottom_right_corner->width(), 381 width() - bottom_left_corner->width() - bottom_right_corner->width(),
380 bottom_edge->height()); 382 bottom_edge->height()));
381 canvas->DrawBitmapInt(*bottom_left_corner, 0, 383 canvas->DrawBitmapInt(*bottom_left_corner, 0,
382 height() - bottom_left_corner->height()); 384 height() - bottom_left_corner->height());
383 385
384 // Left. 386 // Left.
385 canvas->TileImageInt(*left_edge, 0, top_left_corner->height(), 387 canvas->TileImage(*left_edge, gfx::Rect(0, top_left_corner->height(),
386 left_edge->width(), 388 left_edge->width(),
387 height() - top_left_corner->height() - bottom_left_corner->height()); 389 height() - top_left_corner->height() - bottom_left_corner->height()));
388 } 390 }
389 391
390 void AppPanelBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) { 392 void AppPanelBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {
391 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 393 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
392 394
393 SkBitmap* frame_image = rb.GetBitmapNamed(IDR_FRAME_APP_PANEL); 395 SkBitmap* frame_image = rb.GetBitmapNamed(IDR_FRAME_APP_PANEL);
394 canvas->TileImageInt(*frame_image, 0, FrameBorderThickness(), width(), 396 canvas->TileImage(*frame_image, gfx::Rect(0, FrameBorderThickness(), width(),
395 frame_image->height()); 397 frame_image->height()));
396 398
397 // The bottom of the titlebar actually comes from the top of the Client Edge 399 // 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. 400 // graphic, with the actual client edge clipped off the bottom.
399 SkBitmap* titlebar_bottom = rb.GetBitmapNamed(IDR_APP_TOP_CENTER); 401 SkBitmap* titlebar_bottom = rb.GetBitmapNamed(IDR_APP_TOP_CENTER);
400 int edge_height = titlebar_bottom->height() - kClientEdgeThickness; 402 int edge_height = titlebar_bottom->height() - kClientEdgeThickness;
401 canvas->TileImageInt(*titlebar_bottom, 0, 403 canvas->TileImage(*titlebar_bottom, gfx::Rect(0,
402 frame()->client_view()->y() - edge_height, 404 frame()->client_view()->y() - edge_height, width(), edge_height));
403 width(), edge_height);
404 } 405 }
405 406
406 void AppPanelBrowserFrameView::PaintTitleBar(gfx::Canvas* canvas) { 407 void AppPanelBrowserFrameView::PaintTitleBar(gfx::Canvas* canvas) {
407 // The window icon is painted by the TabIconView. 408 // The window icon is painted by the TabIconView.
408 views::WidgetDelegate* d = frame()->widget_delegate(); 409 views::WidgetDelegate* d = frame()->widget_delegate();
409 canvas->DrawStringInt(d->GetWindowTitle(), BrowserFrame::GetTitleFont(), 410 canvas->DrawStringInt(d->GetWindowTitle(), BrowserFrame::GetTitleFont(),
410 SK_ColorBLACK, GetMirroredXForRect(title_bounds_), title_bounds_.y(), 411 SK_ColorBLACK, GetMirroredXForRect(title_bounds_), title_bounds_.y(),
411 title_bounds_.width(), title_bounds_.height()); 412 title_bounds_.width(), title_bounds_.height());
412 } 413 }
413 414
(...skipping 10 matching lines...) Expand all
424 rb.GetBitmapNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER); 425 rb.GetBitmapNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER);
425 SkBitmap* bottom = rb.GetBitmapNamed(IDR_CONTENT_BOTTOM_CENTER); 426 SkBitmap* bottom = rb.GetBitmapNamed(IDR_CONTENT_BOTTOM_CENTER);
426 SkBitmap* bottom_left = 427 SkBitmap* bottom_left =
427 rb.GetBitmapNamed(IDR_CONTENT_BOTTOM_LEFT_CORNER); 428 rb.GetBitmapNamed(IDR_CONTENT_BOTTOM_LEFT_CORNER);
428 SkBitmap* left = rb.GetBitmapNamed(IDR_CONTENT_LEFT_SIDE); 429 SkBitmap* left = rb.GetBitmapNamed(IDR_CONTENT_LEFT_SIDE);
429 430
430 // Top. 431 // Top.
431 int top_edge_y = client_area_top - top->height(); 432 int top_edge_y = client_area_top - top->height();
432 canvas->DrawBitmapInt(*top_left, client_area_bounds.x() - top_left->width(), 433 canvas->DrawBitmapInt(*top_left, client_area_bounds.x() - top_left->width(),
433 top_edge_y); 434 top_edge_y);
434 canvas->TileImageInt(*top, client_area_bounds.x(), top_edge_y, 435 canvas->TileImage(*top, gfx::Rect(client_area_bounds.x(), top_edge_y,
435 client_area_bounds.width(), top->height()); 436 client_area_bounds.width(), top->height()));
436 canvas->DrawBitmapInt(*top_right, client_area_bounds.right(), top_edge_y); 437 canvas->DrawBitmapInt(*top_right, client_area_bounds.right(), top_edge_y);
437 438
438 // Right. 439 // Right.
439 int client_area_bottom = 440 int client_area_bottom =
440 std::max(client_area_top, client_area_bounds.bottom()); 441 std::max(client_area_top, client_area_bounds.bottom());
441 int client_area_height = client_area_bottom - client_area_top; 442 int client_area_height = client_area_bottom - client_area_top;
442 canvas->TileImageInt(*right, client_area_bounds.right(), client_area_top, 443 canvas->TileImage(*right, gfx::Rect(client_area_bounds.right(),
443 right->width(), client_area_height); 444 client_area_top, right->width(), client_area_height));
444 445
445 // Bottom. 446 // Bottom.
446 canvas->DrawBitmapInt(*bottom_right, client_area_bounds.right(), 447 canvas->DrawBitmapInt(*bottom_right, client_area_bounds.right(),
447 client_area_bottom); 448 client_area_bottom);
448 canvas->TileImageInt(*bottom, client_area_bounds.x(), client_area_bottom, 449 canvas->TileImage(*bottom, gfx::Rect(client_area_bounds.x(),
449 client_area_bounds.width(), bottom_right->height()); 450 client_area_bottom, client_area_bounds.width(), bottom_right->height()));
450 canvas->DrawBitmapInt(*bottom_left, 451 canvas->DrawBitmapInt(*bottom_left,
451 client_area_bounds.x() - bottom_left->width(), client_area_bottom); 452 client_area_bounds.x() - bottom_left->width(), client_area_bottom);
452 453
453 // Left. 454 // Left.
454 canvas->TileImageInt(*left, client_area_bounds.x() - left->width(), 455 canvas->TileImage(*left, gfx::Rect(client_area_bounds.x() - left->width(),
455 client_area_top, left->width(), client_area_height); 456 client_area_top, left->width(), client_area_height));
456 457
457 // Draw the toolbar color to fill in the edges. 458 // Draw the toolbar color to fill in the edges.
458 canvas->DrawRect(gfx::Rect( 459 canvas->DrawRect(gfx::Rect(
459 client_area_bounds.x() - kClientEdgeThickness, 460 client_area_bounds.x() - kClientEdgeThickness,
460 client_area_top - kClientEdgeThickness, 461 client_area_top - kClientEdgeThickness,
461 client_area_bounds.width() + kClientEdgeThickness, 462 client_area_bounds.width() + kClientEdgeThickness,
462 client_area_bottom - client_area_top + kClientEdgeThickness), 463 client_area_bottom - client_area_top + kClientEdgeThickness),
463 ResourceBundle::toolbar_color); 464 ResourceBundle::toolbar_color);
464 } 465 }
465 466
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 } 503 }
503 504
504 gfx::Rect AppPanelBrowserFrameView::CalculateClientAreaBounds(int width, 505 gfx::Rect AppPanelBrowserFrameView::CalculateClientAreaBounds(int width,
505 int height) const { 506 int height) const {
506 int top_height = NonClientTopBorderHeight(); 507 int top_height = NonClientTopBorderHeight();
507 int border_thickness = NonClientBorderThickness(); 508 int border_thickness = NonClientBorderThickness();
508 return gfx::Rect(border_thickness, top_height, 509 return gfx::Rect(border_thickness, top_height,
509 std::max(0, width - (2 * border_thickness)), 510 std::max(0, width - (2 * border_thickness)),
510 std::max(0, height - top_height - border_thickness)); 511 std::max(0, height - top_height - border_thickness));
511 } 512 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698