| OLD | NEW |
| 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/constrained_window_views.h" | 5 #include "chrome/browser/ui/views/constrained_window_views.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 SkBitmap* bottom_right_corner = | 443 SkBitmap* bottom_right_corner = |
| 444 resources_->GetPartBitmap(FRAME_BOTTOM_RIGHT_CORNER); | 444 resources_->GetPartBitmap(FRAME_BOTTOM_RIGHT_CORNER); |
| 445 SkBitmap* bottom_edge = resources_->GetPartBitmap(FRAME_BOTTOM_EDGE); | 445 SkBitmap* bottom_edge = resources_->GetPartBitmap(FRAME_BOTTOM_EDGE); |
| 446 | 446 |
| 447 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 447 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 448 SkBitmap* theme_frame = rb.GetBitmapNamed(IDR_THEME_FRAME); | 448 SkBitmap* theme_frame = rb.GetBitmapNamed(IDR_THEME_FRAME); |
| 449 SkColor frame_color = ResourceBundle::frame_color; | 449 SkColor frame_color = ResourceBundle::frame_color; |
| 450 | 450 |
| 451 // Fill with the frame color first so we have a constant background for | 451 // Fill with the frame color first so we have a constant background for |
| 452 // areas not covered by the theme image. | 452 // areas not covered by the theme image. |
| 453 canvas->FillRectInt(frame_color, 0, 0, width(), theme_frame->height()); | 453 canvas->FillRect(frame_color, |
| 454 // Now fill down the sides. | 454 gfx::Rect(0, 0, width(), theme_frame->height())); |
| 455 canvas->FillRectInt(frame_color, 0, theme_frame->height(), left_edge->width(), | 455 |
| 456 height() - theme_frame->height()); | 456 int remaining_height = height() - theme_frame->height(); |
| 457 canvas->FillRectInt(frame_color, width() - right_edge->width(), | 457 if (remaining_height > 0) { |
| 458 theme_frame->height(), right_edge->width(), | 458 // Now fill down the sides. |
| 459 height() - theme_frame->height()); | 459 canvas->FillRect(frame_color, gfx::Rect(0, theme_frame->height(), |
| 460 // Now fill the bottom area. | 460 left_edge->width(), |
| 461 canvas->FillRectInt(frame_color, | 461 remaining_height)); |
| 462 left_edge->width(), height() - bottom_edge->height(), | 462 canvas->FillRect(frame_color, gfx::Rect(width() - right_edge->width(), |
| 463 width() - left_edge->width() - right_edge->width(), | 463 theme_frame->height(), |
| 464 bottom_edge->height()); | 464 right_edge->width(), |
| 465 remaining_height)); |
| 466 int center_width = width() - left_edge->width() - right_edge->width(); |
| 467 if (center_width > 0) { |
| 468 // Now fill the bottom area. |
| 469 canvas->FillRect(frame_color, |
| 470 gfx::Rect(left_edge->width(), |
| 471 height() - bottom_edge->height(), |
| 472 center_width, bottom_edge->height())); |
| 473 } |
| 474 } |
| 465 | 475 |
| 466 // Draw the theme frame. | 476 // Draw the theme frame. |
| 467 canvas->TileImageInt(*theme_frame, 0, 0, width(), theme_frame->height()); | 477 canvas->TileImageInt(*theme_frame, 0, 0, width(), theme_frame->height()); |
| 468 | 478 |
| 469 // Top. | 479 // Top. |
| 470 canvas->DrawBitmapInt(*top_left_corner, 0, 0); | 480 canvas->DrawBitmapInt(*top_left_corner, 0, 0); |
| 471 canvas->TileImageInt(*top_edge, top_left_corner->width(), 0, | 481 canvas->TileImageInt(*top_edge, top_left_corner->width(), 0, |
| 472 width() - top_right_corner->width(), top_edge->height()); | 482 width() - top_right_corner->width(), top_edge->height()); |
| 473 canvas->DrawBitmapInt(*top_right_corner, | 483 canvas->DrawBitmapInt(*top_right_corner, |
| 474 width() - top_right_corner->width(), 0); | 484 width() - top_right_corner->width(), 0); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 501 *title_font_, GetTitleColor(), GetMirroredXForRect(title_bounds_), | 511 *title_font_, GetTitleColor(), GetMirroredXForRect(title_bounds_), |
| 502 title_bounds_.y(), title_bounds_.width(), title_bounds_.height()); | 512 title_bounds_.y(), title_bounds_.width(), title_bounds_.height()); |
| 503 } | 513 } |
| 504 | 514 |
| 505 void ConstrainedWindowFrameView::PaintClientEdge(gfx::Canvas* canvas) { | 515 void ConstrainedWindowFrameView::PaintClientEdge(gfx::Canvas* canvas) { |
| 506 gfx::Rect client_edge_bounds(CalculateClientAreaBounds(width(), height())); | 516 gfx::Rect client_edge_bounds(CalculateClientAreaBounds(width(), height())); |
| 507 client_edge_bounds.Inset(-kClientEdgeThickness, -kClientEdgeThickness); | 517 client_edge_bounds.Inset(-kClientEdgeThickness, -kClientEdgeThickness); |
| 508 gfx::Rect frame_shadow_bounds(client_edge_bounds); | 518 gfx::Rect frame_shadow_bounds(client_edge_bounds); |
| 509 frame_shadow_bounds.Inset(-kFrameShadowThickness, -kFrameShadowThickness); | 519 frame_shadow_bounds.Inset(-kFrameShadowThickness, -kFrameShadowThickness); |
| 510 | 520 |
| 511 canvas->FillRectInt(kContentsBorderShadow, frame_shadow_bounds.x(), | 521 canvas->FillRect(kContentsBorderShadow, frame_shadow_bounds); |
| 512 frame_shadow_bounds.y(), frame_shadow_bounds.width(), | 522 canvas->FillRect(ResourceBundle::toolbar_color, client_edge_bounds); |
| 513 frame_shadow_bounds.height()); | |
| 514 | |
| 515 canvas->FillRectInt(ResourceBundle::toolbar_color, client_edge_bounds.x(), | |
| 516 client_edge_bounds.y(), client_edge_bounds.width(), | |
| 517 client_edge_bounds.height()); | |
| 518 } | 523 } |
| 519 | 524 |
| 520 void ConstrainedWindowFrameView::LayoutWindowControls() { | 525 void ConstrainedWindowFrameView::LayoutWindowControls() { |
| 521 gfx::Size close_button_size = close_button_->GetPreferredSize(); | 526 gfx::Size close_button_size = close_button_->GetPreferredSize(); |
| 522 close_button_->SetBounds( | 527 close_button_->SetBounds( |
| 523 width() - kFrameBorderThickness - close_button_size.width(), | 528 width() - kFrameBorderThickness - close_button_size.width(), |
| 524 kFrameShadowThickness, close_button_size.width(), | 529 kFrameShadowThickness, close_button_size.width(), |
| 525 close_button_size.height()); | 530 close_button_size.height()); |
| 526 } | 531 } |
| 527 | 532 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 } | 662 } |
| 658 | 663 |
| 659 void ConstrainedWindowViews::OnNativeConstrainedWindowMouseActivate() { | 664 void ConstrainedWindowViews::OnNativeConstrainedWindowMouseActivate() { |
| 660 Activate(); | 665 Activate(); |
| 661 } | 666 } |
| 662 | 667 |
| 663 views::internal::NativeWidgetDelegate* | 668 views::internal::NativeWidgetDelegate* |
| 664 ConstrainedWindowViews::AsNativeWidgetDelegate() { | 669 ConstrainedWindowViews::AsNativeWidgetDelegate() { |
| 665 return this; | 670 return this; |
| 666 } | 671 } |
| OLD | NEW |