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

Side by Side Diff: ui/views/window/custom_frame_view.cc

Issue 97633002: views: Cleanup PaintRestoredClientEdge() function. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: revert some changes Created 7 years 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 | « no previous file | no next file » | 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) 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 "ui/views/window/custom_frame_view.h" 5 #include "ui/views/window/custom_frame_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "grit/ui_resources.h" 10 #include "grit/ui_resources.h"
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 SK_ColorWHITE, GetMirroredXForRect(title_bounds_), 381 SK_ColorWHITE, GetMirroredXForRect(title_bounds_),
382 title_bounds_.y(), title_bounds_.width(), 382 title_bounds_.y(), title_bounds_.width(),
383 title_bounds_.height()); 383 title_bounds_.height());
384 } 384 }
385 385
386 void CustomFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { 386 void CustomFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
387 gfx::Rect client_area_bounds = frame_->client_view()->bounds(); 387 gfx::Rect client_area_bounds = frame_->client_view()->bounds();
388 int client_area_top = client_area_bounds.y(); 388 int client_area_top = client_area_bounds.y();
389 389
390 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 390 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
391 const gfx::ImageSkia* top_left = rb.GetImageNamed(
392 IDR_APP_TOP_LEFT).ToImageSkia();
393 const gfx::ImageSkia* top = rb.GetImageNamed(
394 IDR_APP_TOP_CENTER).ToImageSkia();
395 const gfx::ImageSkia* top_right = rb.GetImageNamed(
396 IDR_APP_TOP_RIGHT).ToImageSkia();
397 const gfx::ImageSkia* right = rb.GetImageNamed(
398 IDR_CONTENT_RIGHT_SIDE).ToImageSkia();
399 const gfx::ImageSkia* bottom_right = rb.GetImageNamed(
400 IDR_CONTENT_BOTTOM_RIGHT_CORNER).ToImageSkia();
401 const gfx::ImageSkia* bottom = rb.GetImageNamed(
402 IDR_CONTENT_BOTTOM_CENTER).ToImageSkia();
403 const gfx::ImageSkia* bottom_left = rb.GetImageNamed(
404 IDR_CONTENT_BOTTOM_LEFT_CORNER).ToImageSkia();
405 const gfx::ImageSkia* left = rb.GetImageNamed(
406 IDR_CONTENT_LEFT_SIDE).ToImageSkia();
407 391
408 // Top. 392 // Top: left, center, right sides.
409 int top_edge_y = client_area_top - top->height(); 393 const gfx::ImageSkia* top_left = rb.GetImageSkiaNamed(IDR_APP_TOP_LEFT);
410 canvas->DrawImageInt(*top_left, client_area_bounds.x() - top_left->width(), 394 const gfx::ImageSkia* top_center = rb.GetImageSkiaNamed(IDR_APP_TOP_CENTER);
395 const gfx::ImageSkia* top_right = rb.GetImageSkiaNamed(IDR_APP_TOP_RIGHT);
396 int top_edge_y = client_area_top - top_center->height();
397 canvas->DrawImageInt(*top_left,
398 client_area_bounds.x() - top_left->width(),
411 top_edge_y); 399 top_edge_y);
412 canvas->TileImageInt(*top, client_area_bounds.x(), top_edge_y, 400 canvas->TileImageInt(*top_center,
413 client_area_bounds.width(), top->height()); 401 client_area_bounds.x(),
402 top_edge_y,
403 client_area_bounds.width(),
404 top_center->height());
414 canvas->DrawImageInt(*top_right, client_area_bounds.right(), top_edge_y); 405 canvas->DrawImageInt(*top_right, client_area_bounds.right(), top_edge_y);
415 406
416 // Right. 407 // Right side.
408 const gfx::ImageSkia* right = rb.GetImageSkiaNamed(IDR_CONTENT_RIGHT_SIDE);
417 int client_area_bottom = 409 int client_area_bottom =
418 std::max(client_area_top, client_area_bounds.bottom()); 410 std::max(client_area_top, client_area_bounds.bottom());
419 int client_area_height = client_area_bottom - client_area_top; 411 int client_area_height = client_area_bottom - client_area_top;
420 canvas->TileImageInt(*right, client_area_bounds.right(), client_area_top, 412 canvas->TileImageInt(*right,
421 right->width(), client_area_height); 413 client_area_bounds.right(),
414 client_area_top,
415 right->width(),
416 client_area_height);
422 417
423 // Bottom. 418 // Bottom: left, center, right sides.
424 canvas->DrawImageInt(*bottom_right, client_area_bounds.right(), 419 const gfx::ImageSkia* bottom_left =
420 rb.GetImageSkiaNamed(IDR_CONTENT_BOTTOM_LEFT_CORNER);
421 const gfx::ImageSkia* bottom_center =
422 rb.GetImageSkiaNamed(IDR_CONTENT_BOTTOM_CENTER);
423 const gfx::ImageSkia* bottom_right =
424 rb.GetImageSkiaNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER);
425
426 canvas->DrawImageInt(*bottom_left,
427 client_area_bounds.x() - bottom_left->width(),
425 client_area_bottom); 428 client_area_bottom);
426 canvas->TileImageInt(*bottom, client_area_bounds.x(), client_area_bottom,
427 client_area_bounds.width(), bottom_right->height());
428 canvas->DrawImageInt(*bottom_left,
429 client_area_bounds.x() - bottom_left->width(), client_area_bottom);
430 429
431 // Left. 430 canvas->TileImageInt(*bottom_center,
432 canvas->TileImageInt(*left, client_area_bounds.x() - left->width(), 431 client_area_bounds.x(),
433 client_area_top, left->width(), client_area_height); 432 client_area_bottom,
433 client_area_bounds.width(),
434 bottom_right->height());
435
436 canvas->DrawImageInt(*bottom_right,
437 client_area_bounds.right(),
438 client_area_bottom);
439 // Left side.
440 const gfx::ImageSkia* left = rb.GetImageSkiaNamed(IDR_CONTENT_LEFT_SIDE);
441 canvas->TileImageInt(*left,
442 client_area_bounds.x() - left->width(),
443 client_area_top,
444 left->width(),
445 client_area_height);
434 446
435 // Draw the color to fill in the edges. 447 // Draw the color to fill in the edges.
436 canvas->FillRect(gfx::Rect(client_area_bounds.x() - 1, client_area_top - 1, 448 canvas->FillRect(gfx::Rect(client_area_bounds.x() - 1,
437 client_area_bounds.width() + 1, client_area_bottom - client_area_top + 1), 449 client_area_top - 1,
438 kClientEdgeColor); 450 client_area_bounds.width() + 1,
451 client_area_bottom - client_area_top + 1),
452 kClientEdgeColor);
439 } 453 }
440 454
441 SkColor CustomFrameView::GetFrameColor() const { 455 SkColor CustomFrameView::GetFrameColor() const {
442 return frame_->IsActive() ? kDefaultColorFrame : kDefaultColorFrameInactive; 456 return frame_->IsActive() ? kDefaultColorFrame : kDefaultColorFrameInactive;
443 } 457 }
444 458
445 const gfx::ImageSkia* CustomFrameView::GetFrameImage() const { 459 const gfx::ImageSkia* CustomFrameView::GetFrameImage() const {
446 return ui::ResourceBundle::GetSharedInstance().GetImageNamed( 460 return ui::ResourceBundle::GetSharedInstance().GetImageNamed(
447 frame_->IsActive() ? IDR_FRAME : IDR_FRAME_INACTIVE).ToImageSkia(); 461 frame_->IsActive() ? IDR_FRAME : IDR_FRAME_INACTIVE).ToImageSkia();
448 } 462 }
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 rb.GetImageNamed(normal_image_id).ToImageSkia()); 571 rb.GetImageNamed(normal_image_id).ToImageSkia());
558 button->SetImage(CustomButton::STATE_HOVERED, 572 button->SetImage(CustomButton::STATE_HOVERED,
559 rb.GetImageNamed(hot_image_id).ToImageSkia()); 573 rb.GetImageNamed(hot_image_id).ToImageSkia());
560 button->SetImage(CustomButton::STATE_PRESSED, 574 button->SetImage(CustomButton::STATE_PRESSED,
561 rb.GetImageNamed(pushed_image_id).ToImageSkia()); 575 rb.GetImageNamed(pushed_image_id).ToImageSkia());
562 AddChildView(button); 576 AddChildView(button);
563 return button; 577 return button;
564 } 578 }
565 579
566 } // namespace views 580 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698