| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/views/constrained_window_impl.h" | 5 #include "chrome/browser/views/constrained_window_impl.h" |
| 6 | 6 |
| 7 #include "base/gfx/rect.h" | 7 #include "base/gfx/rect.h" |
| 8 #include "chrome/app/chrome_dll_resource.h" | 8 #include "chrome/app/chrome_dll_resource.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/profile.h" | 10 #include "chrome/browser/profile.h" |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 gfx::Rect title_bounds_; | 260 gfx::Rect title_bounds_; |
| 261 | 261 |
| 262 views::ImageButton* close_button_; | 262 views::ImageButton* close_button_; |
| 263 | 263 |
| 264 // The bounds of the ClientView. | 264 // The bounds of the ClientView. |
| 265 gfx::Rect client_view_bounds_; | 265 gfx::Rect client_view_bounds_; |
| 266 | 266 |
| 267 static void InitClass(); | 267 static void InitClass(); |
| 268 | 268 |
| 269 // The font to be used to render the titlebar text. | 269 // The font to be used to render the titlebar text. |
| 270 static ChromeFont title_font_; | 270 static ChromeFont* title_font_; |
| 271 | 271 |
| 272 DISALLOW_EVIL_CONSTRUCTORS(ConstrainedWindowFrameView); | 272 DISALLOW_EVIL_CONSTRUCTORS(ConstrainedWindowFrameView); |
| 273 }; | 273 }; |
| 274 | 274 |
| 275 ChromeFont ConstrainedWindowFrameView::title_font_; | 275 ChromeFont* ConstrainedWindowFrameView::title_font_ = NULL; |
| 276 | 276 |
| 277 namespace { | 277 namespace { |
| 278 // The frame border is only visible in restored mode and is hardcoded to 4 px on | 278 // The frame border is only visible in restored mode and is hardcoded to 4 px on |
| 279 // each side regardless of the system window border size. | 279 // each side regardless of the system window border size. |
| 280 const int kFrameBorderThickness = 4; | 280 const int kFrameBorderThickness = 4; |
| 281 // Various edges of the frame border have a 1 px shadow along their edges; in a | 281 // Various edges of the frame border have a 1 px shadow along their edges; in a |
| 282 // few cases we shift elements based on this amount for visual appeal. | 282 // few cases we shift elements based on this amount for visual appeal. |
| 283 const int kFrameShadowThickness = 1; | 283 const int kFrameShadowThickness = 1; |
| 284 // In the window corners, the resize areas don't actually expand bigger, but the | 284 // In the window corners, the resize areas don't actually expand bigger, but the |
| 285 // 16 px at the end of each edge triggers diagonal resizing. | 285 // 16 px at the end of each edge triggers diagonal resizing. |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 | 454 |
| 455 int ConstrainedWindowFrameView::TitleCoordinates( | 455 int ConstrainedWindowFrameView::TitleCoordinates( |
| 456 int* title_top_spacing, | 456 int* title_top_spacing, |
| 457 int* title_thickness) const { | 457 int* title_thickness) const { |
| 458 int frame_thickness = FrameBorderThickness(); | 458 int frame_thickness = FrameBorderThickness(); |
| 459 int min_titlebar_height = kTitlebarMinimumHeight + frame_thickness; | 459 int min_titlebar_height = kTitlebarMinimumHeight + frame_thickness; |
| 460 *title_top_spacing = frame_thickness + kTitleTopSpacing; | 460 *title_top_spacing = frame_thickness + kTitleTopSpacing; |
| 461 // The bottom spacing should be the same apparent height as the top spacing, | 461 // The bottom spacing should be the same apparent height as the top spacing, |
| 462 // plus have the client edge tacked on. | 462 // plus have the client edge tacked on. |
| 463 int title_bottom_spacing = *title_top_spacing + kClientEdgeThickness; | 463 int title_bottom_spacing = *title_top_spacing + kClientEdgeThickness; |
| 464 *title_thickness = std::max(title_font_.height(), | 464 *title_thickness = std::max(title_font_->height(), |
| 465 min_titlebar_height - *title_top_spacing - title_bottom_spacing); | 465 min_titlebar_height - *title_top_spacing - title_bottom_spacing); |
| 466 return *title_top_spacing + *title_thickness + title_bottom_spacing; | 466 return *title_top_spacing + *title_thickness + title_bottom_spacing; |
| 467 } | 467 } |
| 468 | 468 |
| 469 void ConstrainedWindowFrameView::PaintFrameBorder(ChromeCanvas* canvas) { | 469 void ConstrainedWindowFrameView::PaintFrameBorder(ChromeCanvas* canvas) { |
| 470 SkBitmap* top_left_corner = resources_->GetPartBitmap(FRAME_TOP_LEFT_CORNER); | 470 SkBitmap* top_left_corner = resources_->GetPartBitmap(FRAME_TOP_LEFT_CORNER); |
| 471 SkBitmap* top_right_corner = | 471 SkBitmap* top_right_corner = |
| 472 resources_->GetPartBitmap(FRAME_TOP_RIGHT_CORNER); | 472 resources_->GetPartBitmap(FRAME_TOP_RIGHT_CORNER); |
| 473 SkBitmap* top_edge = resources_->GetPartBitmap(FRAME_TOP_EDGE); | 473 SkBitmap* top_edge = resources_->GetPartBitmap(FRAME_TOP_EDGE); |
| 474 SkBitmap* right_edge = resources_->GetPartBitmap(FRAME_RIGHT_EDGE); | 474 SkBitmap* right_edge = resources_->GetPartBitmap(FRAME_RIGHT_EDGE); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 504 canvas->DrawBitmapInt(*bottom_left_corner, 0, | 504 canvas->DrawBitmapInt(*bottom_left_corner, 0, |
| 505 height() - bottom_left_corner->height()); | 505 height() - bottom_left_corner->height()); |
| 506 | 506 |
| 507 // Left. | 507 // Left. |
| 508 canvas->TileImageInt(*left_edge, 0, top_left_corner->height(), | 508 canvas->TileImageInt(*left_edge, 0, top_left_corner->height(), |
| 509 left_edge->width(), | 509 left_edge->width(), |
| 510 height() - top_left_corner->height() - bottom_left_corner->height()); | 510 height() - top_left_corner->height() - bottom_left_corner->height()); |
| 511 } | 511 } |
| 512 | 512 |
| 513 void ConstrainedWindowFrameView::PaintTitleBar(ChromeCanvas* canvas) { | 513 void ConstrainedWindowFrameView::PaintTitleBar(ChromeCanvas* canvas) { |
| 514 canvas->DrawStringInt(container_->GetWindowTitle(), title_font_, | 514 canvas->DrawStringInt(container_->GetWindowTitle(), *title_font_, |
| 515 GetTitleColor(), MirroredLeftPointForRect(title_bounds_), | 515 GetTitleColor(), MirroredLeftPointForRect(title_bounds_), |
| 516 title_bounds_.y(), title_bounds_.width(), title_bounds_.height()); | 516 title_bounds_.y(), title_bounds_.width(), title_bounds_.height()); |
| 517 } | 517 } |
| 518 | 518 |
| 519 void ConstrainedWindowFrameView::PaintClientEdge(ChromeCanvas* canvas) { | 519 void ConstrainedWindowFrameView::PaintClientEdge(ChromeCanvas* canvas) { |
| 520 gfx::Rect client_edge_bounds(CalculateClientAreaBounds(width(), height())); | 520 gfx::Rect client_edge_bounds(CalculateClientAreaBounds(width(), height())); |
| 521 client_edge_bounds.Inset(-kClientEdgeThickness, -kClientEdgeThickness); | 521 client_edge_bounds.Inset(-kClientEdgeThickness, -kClientEdgeThickness); |
| 522 gfx::Rect frame_shadow_bounds(client_edge_bounds); | 522 gfx::Rect frame_shadow_bounds(client_edge_bounds); |
| 523 frame_shadow_bounds.Inset(-kFrameShadowThickness, -kFrameShadowThickness); | 523 frame_shadow_bounds.Inset(-kFrameShadowThickness, -kFrameShadowThickness); |
| 524 | 524 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 538 kCaptionTopSpacing, close_button_size.width(), | 538 kCaptionTopSpacing, close_button_size.width(), |
| 539 close_button_size.height()); | 539 close_button_size.height()); |
| 540 } | 540 } |
| 541 | 541 |
| 542 void ConstrainedWindowFrameView::LayoutTitleBar() { | 542 void ConstrainedWindowFrameView::LayoutTitleBar() { |
| 543 // Size the title. | 543 // Size the title. |
| 544 int title_x = FrameBorderThickness() + kIconLeftSpacing; | 544 int title_x = FrameBorderThickness() + kIconLeftSpacing; |
| 545 int title_top_spacing, title_thickness; | 545 int title_top_spacing, title_thickness; |
| 546 TitleCoordinates(&title_top_spacing, &title_thickness); | 546 TitleCoordinates(&title_top_spacing, &title_thickness); |
| 547 title_bounds_.SetRect(title_x, | 547 title_bounds_.SetRect(title_x, |
| 548 title_top_spacing + ((title_thickness - title_font_.height()) / 2), | 548 title_top_spacing + ((title_thickness - title_font_->height()) / 2), |
| 549 std::max(0, close_button_->x() - kTitleCaptionSpacing - title_x), | 549 std::max(0, close_button_->x() - kTitleCaptionSpacing - title_x), |
| 550 title_font_.height()); | 550 title_font_->height()); |
| 551 } | 551 } |
| 552 | 552 |
| 553 void ConstrainedWindowFrameView::LayoutClientView() { | 553 void ConstrainedWindowFrameView::LayoutClientView() { |
| 554 client_view_bounds_ = CalculateClientAreaBounds(width(), height()); | 554 client_view_bounds_ = CalculateClientAreaBounds(width(), height()); |
| 555 } | 555 } |
| 556 | 556 |
| 557 gfx::Rect ConstrainedWindowFrameView::CalculateClientAreaBounds( | 557 gfx::Rect ConstrainedWindowFrameView::CalculateClientAreaBounds( |
| 558 int width, | 558 int width, |
| 559 int height) const { | 559 int height) const { |
| 560 int top_height = NonClientTopBorderHeight(); | 560 int top_height = NonClientTopBorderHeight(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 573 } else { | 573 } else { |
| 574 resources_.reset(new XPWindowResources); | 574 resources_.reset(new XPWindowResources); |
| 575 } | 575 } |
| 576 } | 576 } |
| 577 } | 577 } |
| 578 | 578 |
| 579 // static | 579 // static |
| 580 void ConstrainedWindowFrameView::InitClass() { | 580 void ConstrainedWindowFrameView::InitClass() { |
| 581 static bool initialized = false; | 581 static bool initialized = false; |
| 582 if (!initialized) { | 582 if (!initialized) { |
| 583 title_font_ = win_util::GetWindowTitleFont(); | 583 title_font_ = new ChromeFont(win_util::GetWindowTitleFont()); |
| 584 | 584 |
| 585 initialized = true; | 585 initialized = true; |
| 586 } | 586 } |
| 587 } | 587 } |
| 588 | 588 |
| 589 //////////////////////////////////////////////////////////////////////////////// | 589 //////////////////////////////////////////////////////////////////////////////// |
| 590 // ConstrainedWindowImpl, public: | 590 // ConstrainedWindowImpl, public: |
| 591 | 591 |
| 592 // The space (in pixels) between minimized pop-ups stacked horizontally and | 592 // The space (in pixels) between minimized pop-ups stacked horizontally and |
| 593 // vertically. | 593 // vertically. |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 ConstrainedWindow* ConstrainedWindow::CreateConstrainedDialog( | 752 ConstrainedWindow* ConstrainedWindow::CreateConstrainedDialog( |
| 753 TabContents* parent, | 753 TabContents* parent, |
| 754 const gfx::Rect& initial_bounds, | 754 const gfx::Rect& initial_bounds, |
| 755 views::View* contents_view, | 755 views::View* contents_view, |
| 756 views::WindowDelegate* window_delegate) { | 756 views::WindowDelegate* window_delegate) { |
| 757 ConstrainedWindowImpl* window = new ConstrainedWindowImpl(parent, | 757 ConstrainedWindowImpl* window = new ConstrainedWindowImpl(parent, |
| 758 window_delegate); | 758 window_delegate); |
| 759 window->InitAsDialog(initial_bounds); | 759 window->InitAsDialog(initial_bounds); |
| 760 return window; | 760 return window; |
| 761 } | 761 } |
| OLD | NEW |