| 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/frame/opaque_non_client_view.h" | 5 #include "chrome/browser/views/frame/opaque_browser_frame_view.h" |
| 6 | 6 |
| 7 #include "chrome/browser/views/frame/browser_frame.h" |
| 7 #include "chrome/browser/views/frame/browser_view.h" | 8 #include "chrome/browser/views/frame/browser_view.h" |
| 8 #include "chrome/browser/views/tabs/tab_strip.h" | 9 #include "chrome/browser/views/tabs/tab_strip.h" |
| 9 #include "chrome/common/gfx/chrome_font.h" | 10 #include "chrome/common/gfx/chrome_font.h" |
| 10 #include "chrome/common/gfx/path.h" | 11 #include "chrome/common/gfx/path.h" |
| 11 #include "chrome/common/l10n_util.h" | 12 #include "chrome/common/l10n_util.h" |
| 12 #include "chrome/common/resource_bundle.h" | 13 #include "chrome/common/resource_bundle.h" |
| 13 #include "chrome/common/win_util.h" | 14 #include "chrome/common/win_util.h" |
| 14 #include "chrome/views/root_view.h" | 15 #include "chrome/views/root_view.h" |
| 15 #include "chrome/views/window_resources.h" | 16 #include "chrome/views/window_resources.h" |
| 16 #include "grit/chromium_strings.h" | 17 #include "grit/chromium_strings.h" |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 | 245 |
| 245 DISALLOW_EVIL_CONSTRUCTORS(OTRInactiveWindowResources); | 246 DISALLOW_EVIL_CONSTRUCTORS(OTRInactiveWindowResources); |
| 246 }; | 247 }; |
| 247 | 248 |
| 248 // static | 249 // static |
| 249 SkBitmap* ActiveWindowResources::standard_frame_bitmaps_[]; | 250 SkBitmap* ActiveWindowResources::standard_frame_bitmaps_[]; |
| 250 SkBitmap* InactiveWindowResources::standard_frame_bitmaps_[]; | 251 SkBitmap* InactiveWindowResources::standard_frame_bitmaps_[]; |
| 251 SkBitmap* OTRActiveWindowResources::standard_frame_bitmaps_[]; | 252 SkBitmap* OTRActiveWindowResources::standard_frame_bitmaps_[]; |
| 252 SkBitmap* OTRInactiveWindowResources::standard_frame_bitmaps_[]; | 253 SkBitmap* OTRInactiveWindowResources::standard_frame_bitmaps_[]; |
| 253 | 254 |
| 254 views::WindowResources* OpaqueNonClientView::active_resources_ = NULL; | 255 views::WindowResources* OpaqueBrowserFrameView::active_resources_ = NULL; |
| 255 views::WindowResources* OpaqueNonClientView::inactive_resources_ = NULL; | 256 views::WindowResources* OpaqueBrowserFrameView::inactive_resources_ = NULL; |
| 256 views::WindowResources* OpaqueNonClientView::active_otr_resources_ = NULL; | 257 views::WindowResources* OpaqueBrowserFrameView::active_otr_resources_ = NULL; |
| 257 views::WindowResources* OpaqueNonClientView::inactive_otr_resources_ = NULL; | 258 views::WindowResources* OpaqueBrowserFrameView::inactive_otr_resources_ = NULL; |
| 258 SkBitmap* OpaqueNonClientView::distributor_logo_ = NULL; | 259 SkBitmap* OpaqueBrowserFrameView::distributor_logo_ = NULL; |
| 259 ChromeFont OpaqueNonClientView::title_font_; | 260 ChromeFont OpaqueBrowserFrameView::title_font_; |
| 260 | 261 |
| 261 namespace { | 262 namespace { |
| 262 // The frame border is only visible in restored mode and is hardcoded to 4 px on | 263 // The frame border is only visible in restored mode and is hardcoded to 4 px on |
| 263 // each side regardless of the system window border size. | 264 // each side regardless of the system window border size. |
| 264 const int kFrameBorderThickness = 4; | 265 const int kFrameBorderThickness = 4; |
| 265 // Besides the frame border, there's another 11 px of empty space atop the | 266 // Besides the frame border, there's another 11 px of empty space atop the |
| 266 // window in restored mode, to use to drag the window around. | 267 // window in restored mode, to use to drag the window around. |
| 267 const int kNonClientRestoredExtraThickness = 11; | 268 const int kNonClientRestoredExtraThickness = 11; |
| 268 // While resize areas on Windows are normally the same size as the window | 269 // While resize areas on Windows are normally the same size as the window |
| 269 // borders, our top area is shrunk by 1 px to make it easier to move the window | 270 // borders, our top area is shrunk by 1 px to make it easier to move the window |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 // When there's a distributor logo, we leave a 7 px gap between it and the | 319 // When there's a distributor logo, we leave a 7 px gap between it and the |
| 319 // caption buttons. | 320 // caption buttons. |
| 320 const int kLogoCaptionSpacing = 7; | 321 const int kLogoCaptionSpacing = 7; |
| 321 // The caption buttons are always drawn 1 px down from the visible top of the | 322 // The caption buttons are always drawn 1 px down from the visible top of the |
| 322 // window (the true top in restored mode, or the top of the screen in maximized | 323 // window (the true top in restored mode, or the top of the screen in maximized |
| 323 // mode). | 324 // mode). |
| 324 const int kCaptionTopSpacing = 1; | 325 const int kCaptionTopSpacing = 1; |
| 325 } | 326 } |
| 326 | 327 |
| 327 /////////////////////////////////////////////////////////////////////////////// | 328 /////////////////////////////////////////////////////////////////////////////// |
| 328 // OpaqueNonClientView, public: | 329 // OpaqueBrowserFrameView, public: |
| 329 | 330 |
| 330 OpaqueNonClientView::OpaqueNonClientView(OpaqueFrame* frame, | 331 OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame, |
| 331 BrowserView* browser_view) | 332 BrowserView* browser_view) |
| 332 : NonClientView(), | 333 : BrowserNonClientFrameView(), |
| 333 minimize_button_(new views::Button), | 334 minimize_button_(new views::Button), |
| 334 maximize_button_(new views::Button), | 335 maximize_button_(new views::Button), |
| 335 restore_button_(new views::Button), | 336 restore_button_(new views::Button), |
| 336 close_button_(new views::Button), | 337 close_button_(new views::Button), |
| 337 window_icon_(NULL), | 338 window_icon_(NULL), |
| 338 frame_(frame), | 339 frame_(frame), |
| 339 browser_view_(browser_view) { | 340 browser_view_(browser_view) { |
| 340 InitClass(); | 341 InitClass(); |
| 341 if (browser_view->IsOffTheRecord()) { | 342 if (browser_view->IsOffTheRecord()) { |
| 342 if (!active_otr_resources_) { | 343 if (!active_otr_resources_) { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 window_icon_->set_is_light(true); | 414 window_icon_->set_is_light(true); |
| 414 AddChildView(window_icon_); | 415 AddChildView(window_icon_); |
| 415 window_icon_->Update(); | 416 window_icon_->Update(); |
| 416 } | 417 } |
| 417 // Only load the title font if we're going to need to use it to paint. | 418 // Only load the title font if we're going to need to use it to paint. |
| 418 // Loading fonts is expensive. | 419 // Loading fonts is expensive. |
| 419 if (browser_view_->ShouldShowWindowTitle()) | 420 if (browser_view_->ShouldShowWindowTitle()) |
| 420 InitAppWindowResources(); | 421 InitAppWindowResources(); |
| 421 } | 422 } |
| 422 | 423 |
| 423 OpaqueNonClientView::~OpaqueNonClientView() { | 424 OpaqueBrowserFrameView::~OpaqueBrowserFrameView() { |
| 424 } | 425 } |
| 425 | 426 |
| 426 gfx::Rect OpaqueNonClientView::GetWindowBoundsForClientBounds( | 427 /////////////////////////////////////////////////////////////////////////////// |
| 427 const gfx::Rect& client_bounds) { | 428 // OpaqueBrowserFrameView, BrowserNonClientFrameView implementation: |
| 428 int top_height = NonClientTopBorderHeight(); | |
| 429 int border_thickness = NonClientBorderThickness(); | |
| 430 return gfx::Rect(std::max(0, client_bounds.x() - border_thickness), | |
| 431 std::max(0, client_bounds.y() - top_height), | |
| 432 client_bounds.width() + (2 * border_thickness), | |
| 433 client_bounds.height() + top_height + border_thickness); | |
| 434 } | |
| 435 | 429 |
| 436 gfx::Rect OpaqueNonClientView::GetBoundsForTabStrip(TabStrip* tabstrip) { | 430 gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip( |
| 431 TabStrip* tabstrip) const { |
| 437 int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ? | 432 int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ? |
| 438 (otr_avatar_bounds_.right() + kOTRSideSpacing) : | 433 (otr_avatar_bounds_.right() + kOTRSideSpacing) : |
| 439 NonClientBorderThickness(); | 434 NonClientBorderThickness(); |
| 440 int tabstrip_width = minimize_button_->x() - tabstrip_x - | 435 int tabstrip_width = minimize_button_->x() - tabstrip_x - |
| 441 (frame_->IsMaximized() ? | 436 (frame_->IsMaximized() ? |
| 442 kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing); | 437 kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing); |
| 443 return gfx::Rect(tabstrip_x, NonClientTopBorderHeight(), | 438 return gfx::Rect(tabstrip_x, NonClientTopBorderHeight(), |
| 444 std::max(0, tabstrip_width), tabstrip->GetPreferredHeight()); | 439 std::max(0, tabstrip_width), tabstrip->GetPreferredHeight()); |
| 445 } | 440 } |
| 446 | 441 |
| 447 void OpaqueNonClientView::UpdateWindowIcon() { | 442 void OpaqueBrowserFrameView::UpdateThrobber(bool running) { |
| 448 if (window_icon_) | 443 if (window_icon_) |
| 449 window_icon_->Update(); | 444 window_icon_->Update(); |
| 450 } | 445 } |
| 451 | 446 |
| 452 /////////////////////////////////////////////////////////////////////////////// | 447 /////////////////////////////////////////////////////////////////////////////// |
| 453 // OpaqueNonClientView, views::NonClientView implementation: | 448 // OpaqueBrowserFrameView, views::NonClientFrameView implementation: |
| 454 | 449 |
| 455 gfx::Rect OpaqueNonClientView::CalculateClientAreaBounds(int width, | 450 gfx::Rect OpaqueBrowserFrameView::GetBoundsForClientView() const { |
| 456 int height) const { | 451 return client_view_bounds_; |
| 452 } |
| 453 |
| 454 gfx::Rect OpaqueBrowserFrameView::GetWindowBoundsForClientBounds( |
| 455 const gfx::Rect& client_bounds) const { |
| 457 int top_height = NonClientTopBorderHeight(); | 456 int top_height = NonClientTopBorderHeight(); |
| 458 int border_thickness = NonClientBorderThickness(); | 457 int border_thickness = NonClientBorderThickness(); |
| 459 return gfx::Rect(border_thickness, top_height, | 458 return gfx::Rect(std::max(0, client_bounds.x() - border_thickness), |
| 460 std::max(0, width - (2 * border_thickness)), | 459 std::max(0, client_bounds.y() - top_height), |
| 461 std::max(0, height - top_height - border_thickness)); | 460 client_bounds.width() + (2 * border_thickness), |
| 461 client_bounds.height() + top_height + border_thickness); |
| 462 } | 462 } |
| 463 | 463 |
| 464 gfx::Size OpaqueNonClientView::CalculateWindowSizeForClientSize( | 464 gfx::Point OpaqueBrowserFrameView::GetSystemMenuPoint() const { |
| 465 int width, | |
| 466 int height) const { | |
| 467 int border_thickness = NonClientBorderThickness(); | |
| 468 return gfx::Size(width + (2 * border_thickness), | |
| 469 height + NonClientTopBorderHeight() + border_thickness); | |
| 470 } | |
| 471 | |
| 472 gfx::Point OpaqueNonClientView::GetSystemMenuPoint() const { | |
| 473 gfx::Point system_menu_point(FrameBorderThickness(), | 465 gfx::Point system_menu_point(FrameBorderThickness(), |
| 474 NonClientTopBorderHeight() + browser_view_->GetTabStripHeight() - | 466 NonClientTopBorderHeight() + browser_view_->GetTabStripHeight() - |
| 475 kClientEdgeThickness); | 467 kClientEdgeThickness); |
| 476 ConvertPointToScreen(this, &system_menu_point); | 468 ConvertPointToScreen(this, &system_menu_point); |
| 477 return system_menu_point; | 469 return system_menu_point; |
| 478 } | 470 } |
| 479 | 471 |
| 480 int OpaqueNonClientView::NonClientHitTest(const gfx::Point& point) { | 472 int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) { |
| 481 if (!bounds().Contains(point)) | 473 if (!bounds().Contains(point)) |
| 482 return HTNOWHERE; | 474 return HTNOWHERE; |
| 483 | 475 |
| 484 int frame_component = frame_->client_view()->NonClientHitTest(point); | 476 int frame_component = frame_->client_view()->NonClientHitTest(point); |
| 485 if (frame_component != HTNOWHERE) | 477 if (frame_component != HTNOWHERE) |
| 486 return frame_component; | 478 return frame_component; |
| 487 | 479 |
| 488 // Then see if the point is within any of the window controls. | 480 // Then see if the point is within any of the window controls. |
| 489 if (close_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains(point)) | 481 if (close_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains(point)) |
| 490 return HTCLOSE; | 482 return HTCLOSE; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 501 window_icon_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains(point)) | 493 window_icon_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains(point)) |
| 502 return HTSYSMENU; | 494 return HTSYSMENU; |
| 503 | 495 |
| 504 int window_component = GetHTComponentForFrame(point, TopResizeHeight(), | 496 int window_component = GetHTComponentForFrame(point, TopResizeHeight(), |
| 505 NonClientBorderThickness(), kResizeAreaCornerSize, kResizeAreaCornerSize, | 497 NonClientBorderThickness(), kResizeAreaCornerSize, kResizeAreaCornerSize, |
| 506 frame_->window_delegate()->CanResize()); | 498 frame_->window_delegate()->CanResize()); |
| 507 // Fall back to the caption if no other component matches. | 499 // Fall back to the caption if no other component matches. |
| 508 return (window_component == HTNOWHERE) ? HTCAPTION : window_component; | 500 return (window_component == HTNOWHERE) ? HTCAPTION : window_component; |
| 509 } | 501 } |
| 510 | 502 |
| 511 void OpaqueNonClientView::GetWindowMask(const gfx::Size& size, | 503 void OpaqueBrowserFrameView::GetWindowMask(const gfx::Size& size, |
| 512 gfx::Path* window_mask) { | 504 gfx::Path* window_mask) { |
| 513 DCHECK(window_mask); | 505 DCHECK(window_mask); |
| 514 | 506 |
| 515 if (browser_view_->IsFullscreen()) | 507 if (browser_view_->IsFullscreen()) |
| 516 return; | 508 return; |
| 517 | 509 |
| 518 // Redefine the window visible region for the new size. | 510 // Redefine the window visible region for the new size. |
| 519 window_mask->moveTo(0, 3); | 511 window_mask->moveTo(0, 3); |
| 520 window_mask->lineTo(1, 2); | 512 window_mask->lineTo(1, 2); |
| 521 window_mask->lineTo(1, 1); | 513 window_mask->lineTo(1, 1); |
| 522 window_mask->lineTo(2, 1); | 514 window_mask->lineTo(2, 1); |
| 523 window_mask->lineTo(3, 0); | 515 window_mask->lineTo(3, 0); |
| 524 | 516 |
| 525 window_mask->lineTo(SkIntToScalar(size.width() - 3), 0); | 517 window_mask->lineTo(SkIntToScalar(size.width() - 3), 0); |
| 526 window_mask->lineTo(SkIntToScalar(size.width() - 2), 1); | 518 window_mask->lineTo(SkIntToScalar(size.width() - 2), 1); |
| 527 window_mask->lineTo(SkIntToScalar(size.width() - 1), 1); | 519 window_mask->lineTo(SkIntToScalar(size.width() - 1), 1); |
| 528 window_mask->lineTo(SkIntToScalar(size.width() - 1), 2); | 520 window_mask->lineTo(SkIntToScalar(size.width() - 1), 2); |
| 529 window_mask->lineTo(SkIntToScalar(size.width()), 3); | 521 window_mask->lineTo(SkIntToScalar(size.width()), 3); |
| 530 | 522 |
| 531 window_mask->lineTo(SkIntToScalar(size.width()), | 523 window_mask->lineTo(SkIntToScalar(size.width()), |
| 532 SkIntToScalar(size.height())); | 524 SkIntToScalar(size.height())); |
| 533 window_mask->lineTo(0, SkIntToScalar(size.height())); | 525 window_mask->lineTo(0, SkIntToScalar(size.height())); |
| 534 window_mask->close(); | 526 window_mask->close(); |
| 535 } | 527 } |
| 536 | 528 |
| 537 void OpaqueNonClientView::EnableClose(bool enable) { | 529 void OpaqueBrowserFrameView::EnableClose(bool enable) { |
| 538 close_button_->SetEnabled(enable); | 530 close_button_->SetEnabled(enable); |
| 539 } | 531 } |
| 540 | 532 |
| 541 void OpaqueNonClientView::ResetWindowControls() { | 533 void OpaqueBrowserFrameView::ResetWindowControls() { |
| 542 restore_button_->SetState(views::Button::BS_NORMAL); | 534 restore_button_->SetState(views::Button::BS_NORMAL); |
| 543 minimize_button_->SetState(views::Button::BS_NORMAL); | 535 minimize_button_->SetState(views::Button::BS_NORMAL); |
| 544 maximize_button_->SetState(views::Button::BS_NORMAL); | 536 maximize_button_->SetState(views::Button::BS_NORMAL); |
| 545 // The close button isn't affected by this constraint. | 537 // The close button isn't affected by this constraint. |
| 546 } | 538 } |
| 547 | 539 |
| 548 /////////////////////////////////////////////////////////////////////////////// | 540 /////////////////////////////////////////////////////////////////////////////// |
| 549 // OpaqueNonClientView, views::View overrides: | 541 // OpaqueBrowserFrameView, views::View overrides: |
| 550 | 542 |
| 551 void OpaqueNonClientView::Paint(ChromeCanvas* canvas) { | 543 void OpaqueBrowserFrameView::Paint(ChromeCanvas* canvas) { |
| 552 if (browser_view_->IsFullscreen()) | 544 if (browser_view_->IsFullscreen()) |
| 553 return; // Nothing is visible, so don't bother to paint. | 545 return; // Nothing is visible, so don't bother to paint. |
| 554 | 546 |
| 555 if (frame_->IsMaximized()) | 547 if (frame_->IsMaximized()) |
| 556 PaintMaximizedFrameBorder(canvas); | 548 PaintMaximizedFrameBorder(canvas); |
| 557 else | 549 else |
| 558 PaintRestoredFrameBorder(canvas); | 550 PaintRestoredFrameBorder(canvas); |
| 559 PaintDistributorLogo(canvas); | 551 PaintDistributorLogo(canvas); |
| 560 PaintTitleBar(canvas); | 552 PaintTitleBar(canvas); |
| 561 PaintToolbarBackground(canvas); | 553 PaintToolbarBackground(canvas); |
| 562 PaintOTRAvatar(canvas); | 554 PaintOTRAvatar(canvas); |
| 563 if (!frame_->IsMaximized()) | 555 if (!frame_->IsMaximized()) |
| 564 PaintRestoredClientEdge(canvas); | 556 PaintRestoredClientEdge(canvas); |
| 565 } | 557 } |
| 566 | 558 |
| 567 void OpaqueNonClientView::Layout() { | 559 void OpaqueBrowserFrameView::Layout() { |
| 568 LayoutWindowControls(); | 560 LayoutWindowControls(); |
| 569 LayoutDistributorLogo(); | 561 LayoutDistributorLogo(); |
| 570 LayoutTitleBar(); | 562 LayoutTitleBar(); |
| 571 LayoutOTRAvatar(); | 563 LayoutOTRAvatar(); |
| 572 LayoutClientView(); | 564 LayoutClientView(); |
| 573 } | 565 } |
| 574 | 566 |
| 575 views::View* OpaqueNonClientView::GetViewForPoint(const gfx::Point& point, | 567 views::View* OpaqueBrowserFrameView::GetViewForPoint(const gfx::Point& point, |
| 576 bool can_create_floating) { | 568 bool can_create_floating) { |
| 577 // We override this function because the ClientView can overlap the non - | 569 // We override this function because the ClientView can overlap the non - |
| 578 // client view, making it impossible to click on the window controls. We need | 570 // client view, making it impossible to click on the window controls. We need |
| 579 // to ensure the window controls are checked _first_. | 571 // to ensure the window controls are checked _first_. |
| 580 views::View* views[] = | 572 views::View* views[] = |
| 581 { close_button_, restore_button_, maximize_button_, minimize_button_ }; | 573 { close_button_, restore_button_, maximize_button_, minimize_button_ }; |
| 582 for (int i = 0; i < arraysize(views); ++i) { | 574 for (int i = 0; i < arraysize(views); ++i) { |
| 583 if (!views[i]->IsVisible()) | 575 if (!views[i]->IsVisible()) |
| 584 continue; | 576 continue; |
| 585 // Apply mirroring transformation on view bounds for RTL chrome. | 577 // Apply mirroring transformation on view bounds for RTL chrome. |
| 586 if (views[i]->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains(point)) | 578 if (views[i]->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains(point)) |
| 587 return views[i]; | 579 return views[i]; |
| 588 } | 580 } |
| 589 return View::GetViewForPoint(point, can_create_floating); | 581 return View::GetViewForPoint(point, can_create_floating); |
| 590 } | 582 } |
| 591 | 583 |
| 592 void OpaqueNonClientView::ViewHierarchyChanged(bool is_add, | 584 void OpaqueBrowserFrameView::ViewHierarchyChanged(bool is_add, |
| 593 views::View* parent, | 585 views::View* parent, |
| 594 views::View* child) { | 586 views::View* child) { |
| 595 if (is_add && child == this) { | 587 if (is_add && child == this) { |
| 596 DCHECK(GetWidget()); | |
| 597 DCHECK(frame_->client_view()->GetParent() != this); | |
| 598 AddChildView(frame_->client_view()); | |
| 599 | |
| 600 // The Accessibility glue looks for the product name on these two views to | 588 // The Accessibility glue looks for the product name on these two views to |
| 601 // determine if this is in fact a Chrome window. | 589 // determine if this is in fact a Chrome window. |
| 602 GetRootView()->SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); | 590 GetRootView()->SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); |
| 603 SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); | 591 SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); |
| 604 } | 592 } |
| 605 } | 593 } |
| 606 | 594 |
| 607 bool OpaqueNonClientView::GetAccessibleRole(VARIANT* role) { | 595 bool OpaqueBrowserFrameView::GetAccessibleRole(VARIANT* role) { |
| 608 DCHECK(role); | 596 DCHECK(role); |
| 609 // We aren't actually the client area of the window, but we act like it as | 597 // We aren't actually the client area of the window, but we act like it as |
| 610 // far as MSAA and the UI tests are concerned. | 598 // far as MSAA and the UI tests are concerned. |
| 611 role->vt = VT_I4; | 599 role->vt = VT_I4; |
| 612 role->lVal = ROLE_SYSTEM_CLIENT; | 600 role->lVal = ROLE_SYSTEM_CLIENT; |
| 613 return true; | 601 return true; |
| 614 } | 602 } |
| 615 | 603 |
| 616 bool OpaqueNonClientView::GetAccessibleName(std::wstring* name) { | 604 bool OpaqueBrowserFrameView::GetAccessibleName(std::wstring* name) { |
| 617 if (!accessible_name_.empty()) { | 605 if (!accessible_name_.empty()) { |
| 618 *name = accessible_name_; | 606 *name = accessible_name_; |
| 619 return true; | 607 return true; |
| 620 } | 608 } |
| 621 return false; | 609 return false; |
| 622 } | 610 } |
| 623 | 611 |
| 624 void OpaqueNonClientView::SetAccessibleName(const std::wstring& name) { | 612 void OpaqueBrowserFrameView::SetAccessibleName(const std::wstring& name) { |
| 625 accessible_name_ = name; | 613 accessible_name_ = name; |
| 626 } | 614 } |
| 627 | 615 |
| 628 /////////////////////////////////////////////////////////////////////////////// | 616 /////////////////////////////////////////////////////////////////////////////// |
| 629 // OpaqueNonClientView, views::BaseButton::ButtonListener implementation: | 617 // OpaqueBrowserFrameView, views::BaseButton::ButtonListener implementation: |
| 630 | 618 |
| 631 void OpaqueNonClientView::ButtonPressed(views::BaseButton* sender) { | 619 void OpaqueBrowserFrameView::ButtonPressed(views::BaseButton* sender) { |
| 632 if (sender == minimize_button_) | 620 if (sender == minimize_button_) |
| 633 frame_->ExecuteSystemMenuCommand(SC_MINIMIZE); | 621 frame_->ExecuteSystemMenuCommand(SC_MINIMIZE); |
| 634 else if (sender == maximize_button_) | 622 else if (sender == maximize_button_) |
| 635 frame_->ExecuteSystemMenuCommand(SC_MAXIMIZE); | 623 frame_->ExecuteSystemMenuCommand(SC_MAXIMIZE); |
| 636 else if (sender == restore_button_) | 624 else if (sender == restore_button_) |
| 637 frame_->ExecuteSystemMenuCommand(SC_RESTORE); | 625 frame_->ExecuteSystemMenuCommand(SC_RESTORE); |
| 638 else if (sender == close_button_) | 626 else if (sender == close_button_) |
| 639 frame_->ExecuteSystemMenuCommand(SC_CLOSE); | 627 frame_->ExecuteSystemMenuCommand(SC_CLOSE); |
| 640 } | 628 } |
| 641 | 629 |
| 642 /////////////////////////////////////////////////////////////////////////////// | 630 /////////////////////////////////////////////////////////////////////////////// |
| 643 // OpaqueNonClientView, TabIconView::TabContentsProvider implementation: | 631 // OpaqueBrowserFrameView, TabIconView::TabContentsProvider implementation: |
| 644 | 632 |
| 645 bool OpaqueNonClientView::ShouldTabIconViewAnimate() const { | 633 bool OpaqueBrowserFrameView::ShouldTabIconViewAnimate() const { |
| 646 // This function is queried during the creation of the window as the | 634 // This function is queried during the creation of the window as the |
| 647 // TabIconView we host is initialized, so we need to NULL check the selected | 635 // TabIconView we host is initialized, so we need to NULL check the selected |
| 648 // TabContents because in this condition there is not yet a selected tab. | 636 // TabContents because in this condition there is not yet a selected tab. |
| 649 TabContents* current_tab = browser_view_->GetSelectedTabContents(); | 637 TabContents* current_tab = browser_view_->GetSelectedTabContents(); |
| 650 return current_tab ? current_tab->is_loading() : false; | 638 return current_tab ? current_tab->is_loading() : false; |
| 651 } | 639 } |
| 652 | 640 |
| 653 SkBitmap OpaqueNonClientView::GetFavIconForTabIconView() { | 641 SkBitmap OpaqueBrowserFrameView::GetFavIconForTabIconView() { |
| 654 return frame_->window_delegate()->GetWindowIcon(); | 642 return frame_->window_delegate()->GetWindowIcon(); |
| 655 } | 643 } |
| 656 | 644 |
| 657 /////////////////////////////////////////////////////////////////////////////// | 645 /////////////////////////////////////////////////////////////////////////////// |
| 658 // OpaqueNonClientView, private: | 646 // OpaqueBrowserFrameView, private: |
| 659 | 647 |
| 660 int OpaqueNonClientView::FrameBorderThickness() const { | 648 int OpaqueBrowserFrameView::FrameBorderThickness() const { |
| 661 if (browser_view_->IsFullscreen()) | 649 if (browser_view_->IsFullscreen()) |
| 662 return 0; | 650 return 0; |
| 663 return frame_->IsMaximized() ? | 651 return frame_->IsMaximized() ? |
| 664 GetSystemMetrics(SM_CXSIZEFRAME) : kFrameBorderThickness; | 652 GetSystemMetrics(SM_CXSIZEFRAME) : kFrameBorderThickness; |
| 665 } | 653 } |
| 666 | 654 |
| 667 int OpaqueNonClientView::TopResizeHeight() const { | 655 int OpaqueBrowserFrameView::TopResizeHeight() const { |
| 668 return FrameBorderThickness() - kTopResizeAdjust; | 656 return FrameBorderThickness() - kTopResizeAdjust; |
| 669 } | 657 } |
| 670 | 658 |
| 671 int OpaqueNonClientView::NonClientBorderThickness() const { | 659 int OpaqueBrowserFrameView::NonClientBorderThickness() const { |
| 672 // When we fill the screen, we don't show a client edge. | 660 // When we fill the screen, we don't show a client edge. |
| 673 return FrameBorderThickness() + | 661 return FrameBorderThickness() + |
| 674 (browser_view_->CanCurrentlyResize() ? kClientEdgeThickness : 0); | 662 (browser_view_->CanCurrentlyResize() ? kClientEdgeThickness : 0); |
| 675 } | 663 } |
| 676 | 664 |
| 677 int OpaqueNonClientView::NonClientTopBorderHeight() const { | 665 int OpaqueBrowserFrameView::NonClientTopBorderHeight() const { |
| 678 if (frame_->window_delegate()->ShouldShowWindowTitle()) { | 666 if (frame_->window_delegate()->ShouldShowWindowTitle()) { |
| 679 int title_top_spacing, title_thickness; | 667 int title_top_spacing, title_thickness; |
| 680 return TitleCoordinates(&title_top_spacing, &title_thickness); | 668 return TitleCoordinates(&title_top_spacing, &title_thickness); |
| 681 } | 669 } |
| 682 | 670 |
| 683 return FrameBorderThickness() + (browser_view_->CanCurrentlyResize() ? | 671 return FrameBorderThickness() + (browser_view_->CanCurrentlyResize() ? |
| 684 kNonClientRestoredExtraThickness : 0); | 672 kNonClientRestoredExtraThickness : 0); |
| 685 } | 673 } |
| 686 | 674 |
| 687 int OpaqueNonClientView::UnavailablePixelsAtBottomOfNonClientHeight() const { | 675 int OpaqueBrowserFrameView::UnavailablePixelsAtBottomOfNonClientHeight() const { |
| 688 // Tricky: When a toolbar is edging the titlebar, it not only draws its own | 676 // Tricky: When a toolbar is edging the titlebar, it not only draws its own |
| 689 // shadow and client edge, but an extra, light "shadow" pixel as well, which | 677 // shadow and client edge, but an extra, light "shadow" pixel as well, which |
| 690 // is treated as available space. Thus the nonclient area actually _fails_ to | 678 // is treated as available space. Thus the nonclient area actually _fails_ to |
| 691 // include some available pixels, leading to a negative number here. | 679 // include some available pixels, leading to a negative number here. |
| 692 if (browser_view_->IsToolbarVisible()) | 680 if (browser_view_->IsToolbarVisible()) |
| 693 return -kFrameShadowThickness; | 681 return -kFrameShadowThickness; |
| 694 | 682 |
| 695 return kFrameShadowThickness + | 683 return kFrameShadowThickness + |
| 696 (frame_->IsMaximized() ? 0 : kClientEdgeThickness); | 684 (frame_->IsMaximized() ? 0 : kClientEdgeThickness); |
| 697 } | 685 } |
| 698 | 686 |
| 699 int OpaqueNonClientView::TitleCoordinates(int* title_top_spacing, | 687 int OpaqueBrowserFrameView::TitleCoordinates(int* title_top_spacing, |
| 700 int* title_thickness) const { | 688 int* title_thickness) const { |
| 701 int frame_thickness = FrameBorderThickness(); | 689 int frame_thickness = FrameBorderThickness(); |
| 702 int min_titlebar_height = kTitlebarMinimumHeight + frame_thickness; | 690 int min_titlebar_height = kTitlebarMinimumHeight + frame_thickness; |
| 703 *title_top_spacing = frame_thickness + kTitleTopSpacing; | 691 *title_top_spacing = frame_thickness + kTitleTopSpacing; |
| 704 // The bottom spacing should be the same apparent height as the top spacing. | 692 // The bottom spacing should be the same apparent height as the top spacing. |
| 705 // Because the actual top spacing height varies based on the system border | 693 // Because the actual top spacing height varies based on the system border |
| 706 // thickness, we calculate this based on the restored top spacing and then | 694 // thickness, we calculate this based on the restored top spacing and then |
| 707 // adjust for maximized mode. We also don't include the frame shadow here, | 695 // adjust for maximized mode. We also don't include the frame shadow here, |
| 708 // since while it's part of the bottom spacing it will be added in at the end | 696 // since while it's part of the bottom spacing it will be added in at the end |
| 709 // as necessary (when a toolbar is present, the "shadow" is actually drawn by | 697 // as necessary (when a toolbar is present, the "shadow" is actually drawn by |
| 710 // the toolbar). | 698 // the toolbar). |
| 711 int title_bottom_spacing = | 699 int title_bottom_spacing = |
| 712 kFrameBorderThickness + kTitleTopSpacing - kFrameShadowThickness; | 700 kFrameBorderThickness + kTitleTopSpacing - kFrameShadowThickness; |
| 713 if (frame_->IsMaximized()) { | 701 if (frame_->IsMaximized()) { |
| 714 // When we maximize, the top border appears to be chopped off; shift the | 702 // When we maximize, the top border appears to be chopped off; shift the |
| 715 // title down to stay centered within the remaining space. | 703 // title down to stay centered within the remaining space. |
| 716 int title_adjust = (kFrameBorderThickness / 2); | 704 int title_adjust = (kFrameBorderThickness / 2); |
| 717 *title_top_spacing += title_adjust; | 705 *title_top_spacing += title_adjust; |
| 718 title_bottom_spacing -= title_adjust; | 706 title_bottom_spacing -= title_adjust; |
| 719 } | 707 } |
| 720 *title_thickness = std::max(title_font_.height(), | 708 *title_thickness = std::max(title_font_.height(), |
| 721 min_titlebar_height - *title_top_spacing - title_bottom_spacing); | 709 min_titlebar_height - *title_top_spacing - title_bottom_spacing); |
| 722 return *title_top_spacing + *title_thickness + title_bottom_spacing + | 710 return *title_top_spacing + *title_thickness + title_bottom_spacing + |
| 723 UnavailablePixelsAtBottomOfNonClientHeight(); | 711 UnavailablePixelsAtBottomOfNonClientHeight(); |
| 724 } | 712 } |
| 725 | 713 |
| 726 void OpaqueNonClientView::PaintRestoredFrameBorder(ChromeCanvas* canvas) { | 714 void OpaqueBrowserFrameView::PaintRestoredFrameBorder(ChromeCanvas* canvas) { |
| 727 SkBitmap* top_left_corner = resources()->GetPartBitmap(FRAME_TOP_LEFT_CORNER); | 715 SkBitmap* top_left_corner = resources()->GetPartBitmap(FRAME_TOP_LEFT_CORNER); |
| 728 SkBitmap* top_right_corner = | 716 SkBitmap* top_right_corner = |
| 729 resources()->GetPartBitmap(FRAME_TOP_RIGHT_CORNER); | 717 resources()->GetPartBitmap(FRAME_TOP_RIGHT_CORNER); |
| 730 SkBitmap* top_edge = resources()->GetPartBitmap(FRAME_TOP_EDGE); | 718 SkBitmap* top_edge = resources()->GetPartBitmap(FRAME_TOP_EDGE); |
| 731 SkBitmap* right_edge = resources()->GetPartBitmap(FRAME_RIGHT_EDGE); | 719 SkBitmap* right_edge = resources()->GetPartBitmap(FRAME_RIGHT_EDGE); |
| 732 SkBitmap* left_edge = resources()->GetPartBitmap(FRAME_LEFT_EDGE); | 720 SkBitmap* left_edge = resources()->GetPartBitmap(FRAME_LEFT_EDGE); |
| 733 SkBitmap* bottom_left_corner = | 721 SkBitmap* bottom_left_corner = |
| 734 resources()->GetPartBitmap(FRAME_BOTTOM_LEFT_CORNER); | 722 resources()->GetPartBitmap(FRAME_BOTTOM_LEFT_CORNER); |
| 735 SkBitmap* bottom_right_corner = | 723 SkBitmap* bottom_right_corner = |
| 736 resources()->GetPartBitmap(FRAME_BOTTOM_RIGHT_CORNER); | 724 resources()->GetPartBitmap(FRAME_BOTTOM_RIGHT_CORNER); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 764 bottom_edge->height()); | 752 bottom_edge->height()); |
| 765 canvas->DrawBitmapInt(*bottom_left_corner, 0, | 753 canvas->DrawBitmapInt(*bottom_left_corner, 0, |
| 766 height() - bottom_left_corner->height()); | 754 height() - bottom_left_corner->height()); |
| 767 | 755 |
| 768 // Left. | 756 // Left. |
| 769 canvas->TileImageInt(*left_edge, 0, top_left_corner->height(), | 757 canvas->TileImageInt(*left_edge, 0, top_left_corner->height(), |
| 770 left_edge->width(), | 758 left_edge->width(), |
| 771 height() - top_left_corner->height() - bottom_left_corner->height()); | 759 height() - top_left_corner->height() - bottom_left_corner->height()); |
| 772 } | 760 } |
| 773 | 761 |
| 774 void OpaqueNonClientView::PaintMaximizedFrameBorder(ChromeCanvas* canvas) { | 762 void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(ChromeCanvas* canvas) { |
| 775 SkBitmap* top_edge = resources()->GetPartBitmap(FRAME_TOP_EDGE); | 763 SkBitmap* top_edge = resources()->GetPartBitmap(FRAME_TOP_EDGE); |
| 776 canvas->TileImageInt(*top_edge, 0, FrameBorderThickness(), width(), | 764 canvas->TileImageInt(*top_edge, 0, FrameBorderThickness(), width(), |
| 777 top_edge->height()); | 765 top_edge->height()); |
| 778 | 766 |
| 779 if (!browser_view_->IsToolbarVisible()) { | 767 if (!browser_view_->IsToolbarVisible()) { |
| 780 // There's no toolbar to edge the frame border, so we need to draw a bottom | 768 // There's no toolbar to edge the frame border, so we need to draw a bottom |
| 781 // edge. The graphic we use for this has a built in client edge, so we clip | 769 // edge. The graphic we use for this has a built in client edge, so we clip |
| 782 // it off the bottom. | 770 // it off the bottom. |
| 783 SkBitmap* top_center = | 771 SkBitmap* top_center = |
| 784 resources()->GetPartBitmap(FRAME_NO_TOOLBAR_TOP_CENTER); | 772 resources()->GetPartBitmap(FRAME_NO_TOOLBAR_TOP_CENTER); |
| 785 int edge_height = top_center->height() - kClientEdgeThickness; | 773 int edge_height = top_center->height() - kClientEdgeThickness; |
| 786 canvas->TileImageInt(*top_center, 0, | 774 canvas->TileImageInt(*top_center, 0, |
| 787 frame_->client_view()->y() - edge_height, width(), edge_height); | 775 frame_->client_view()->y() - edge_height, width(), edge_height); |
| 788 } | 776 } |
| 789 } | 777 } |
| 790 | 778 |
| 791 void OpaqueNonClientView::PaintDistributorLogo(ChromeCanvas* canvas) { | 779 void OpaqueBrowserFrameView::PaintDistributorLogo(ChromeCanvas* canvas) { |
| 792 // The distributor logo is only painted when the frame is not maximized and | 780 // The distributor logo is only painted when the frame is not maximized and |
| 793 // when we actually have a logo. | 781 // when we actually have a logo. |
| 794 if (!frame_->IsMaximized() && distributor_logo_) { | 782 if (!frame_->IsMaximized() && distributor_logo_) { |
| 795 canvas->DrawBitmapInt(*distributor_logo_, | 783 canvas->DrawBitmapInt(*distributor_logo_, |
| 796 MirroredLeftPointForRect(logo_bounds_), logo_bounds_.y()); | 784 MirroredLeftPointForRect(logo_bounds_), logo_bounds_.y()); |
| 797 } | 785 } |
| 798 } | 786 } |
| 799 | 787 |
| 800 void OpaqueNonClientView::PaintTitleBar(ChromeCanvas* canvas) { | 788 void OpaqueBrowserFrameView::PaintTitleBar(ChromeCanvas* canvas) { |
| 801 // The window icon is painted by the TabIconView. | 789 // The window icon is painted by the TabIconView. |
| 802 views::WindowDelegate* d = frame_->window_delegate(); | 790 views::WindowDelegate* d = frame_->window_delegate(); |
| 803 if (d->ShouldShowWindowTitle()) { | 791 if (d->ShouldShowWindowTitle()) { |
| 804 canvas->DrawStringInt(d->GetWindowTitle(), title_font_, SK_ColorWHITE, | 792 canvas->DrawStringInt(d->GetWindowTitle(), title_font_, SK_ColorWHITE, |
| 805 MirroredLeftPointForRect(title_bounds_), title_bounds_.y(), | 793 MirroredLeftPointForRect(title_bounds_), title_bounds_.y(), |
| 806 title_bounds_.width(), title_bounds_.height()); | 794 title_bounds_.width(), title_bounds_.height()); |
| 807 /* TODO(pkasting): If this window is active, we should also draw a drop | 795 /* TODO(pkasting): If this window is active, we should also draw a drop |
| 808 * shadow on the title. This is tricky, because we don't want to hardcode a | 796 * shadow on the title. This is tricky, because we don't want to hardcode a |
| 809 * shadow color (since we want to work with various themes), but we can't | 797 * shadow color (since we want to work with various themes), but we can't |
| 810 * alpha-blend either (since the Windows text APIs don't really do this). | 798 * alpha-blend either (since the Windows text APIs don't really do this). |
| 811 * So we'd need to sample the background color at the right location and | 799 * So we'd need to sample the background color at the right location and |
| 812 * synthesize a good shadow color. */ | 800 * synthesize a good shadow color. */ |
| 813 } | 801 } |
| 814 } | 802 } |
| 815 | 803 |
| 816 void OpaqueNonClientView::PaintToolbarBackground(ChromeCanvas* canvas) { | 804 void OpaqueBrowserFrameView::PaintToolbarBackground(ChromeCanvas* canvas) { |
| 817 if (!browser_view_->IsToolbarVisible()) | 805 if (!browser_view_->IsToolbarVisible()) |
| 818 return; | 806 return; |
| 819 | 807 |
| 820 gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds()); | 808 gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds()); |
| 821 gfx::Point toolbar_origin(toolbar_bounds.origin()); | 809 gfx::Point toolbar_origin(toolbar_bounds.origin()); |
| 822 View::ConvertPointToView(frame_->client_view(), this, &toolbar_origin); | 810 View::ConvertPointToView(frame_->client_view(), this, &toolbar_origin); |
| 823 toolbar_bounds.set_origin(toolbar_origin); | 811 toolbar_bounds.set_origin(toolbar_origin); |
| 824 | 812 |
| 825 SkBitmap* toolbar_left = | 813 SkBitmap* toolbar_left = |
| 826 resources()->GetPartBitmap(FRAME_CLIENT_EDGE_TOP_LEFT); | 814 resources()->GetPartBitmap(FRAME_CLIENT_EDGE_TOP_LEFT); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 840 canvas->TileImageInt(*toolbar_center, 0, | 828 canvas->TileImageInt(*toolbar_center, 0, |
| 841 toolbar_center->height() - toolbar_bounds.height() + split_point, | 829 toolbar_center->height() - toolbar_bounds.height() + split_point, |
| 842 toolbar_bounds.x(), toolbar_bounds.y() + split_point, | 830 toolbar_bounds.x(), toolbar_bounds.y() + split_point, |
| 843 toolbar_bounds.width(), toolbar_bounds.height() - split_point); | 831 toolbar_bounds.width(), toolbar_bounds.height() - split_point); |
| 844 | 832 |
| 845 canvas->DrawBitmapInt( | 833 canvas->DrawBitmapInt( |
| 846 *resources()->GetPartBitmap(FRAME_CLIENT_EDGE_TOP_RIGHT), | 834 *resources()->GetPartBitmap(FRAME_CLIENT_EDGE_TOP_RIGHT), |
| 847 toolbar_bounds.right(), toolbar_bounds.y()); | 835 toolbar_bounds.right(), toolbar_bounds.y()); |
| 848 } | 836 } |
| 849 | 837 |
| 850 void OpaqueNonClientView::PaintOTRAvatar(ChromeCanvas* canvas) { | 838 void OpaqueBrowserFrameView::PaintOTRAvatar(ChromeCanvas* canvas) { |
| 851 if (!browser_view_->ShouldShowOffTheRecordAvatar()) | 839 if (!browser_view_->ShouldShowOffTheRecordAvatar()) |
| 852 return; | 840 return; |
| 853 | 841 |
| 854 SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon(); | 842 SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon(); |
| 855 canvas->DrawBitmapInt(otr_avatar_icon, 0, | 843 canvas->DrawBitmapInt(otr_avatar_icon, 0, |
| 856 (otr_avatar_icon.height() - otr_avatar_bounds_.height()) / 2, | 844 (otr_avatar_icon.height() - otr_avatar_bounds_.height()) / 2, |
| 857 otr_avatar_bounds_.width(), otr_avatar_bounds_.height(), | 845 otr_avatar_bounds_.width(), otr_avatar_bounds_.height(), |
| 858 MirroredLeftPointForRect(otr_avatar_bounds_), otr_avatar_bounds_.y(), | 846 MirroredLeftPointForRect(otr_avatar_bounds_), otr_avatar_bounds_.y(), |
| 859 otr_avatar_bounds_.width(), otr_avatar_bounds_.height(), false); | 847 otr_avatar_bounds_.width(), otr_avatar_bounds_.height(), false); |
| 860 } | 848 } |
| 861 | 849 |
| 862 void OpaqueNonClientView::PaintRestoredClientEdge(ChromeCanvas* canvas) { | 850 void OpaqueBrowserFrameView::PaintRestoredClientEdge(ChromeCanvas* canvas) { |
| 863 int client_area_top = frame_->client_view()->y(); | 851 int client_area_top = frame_->client_view()->y(); |
| 864 | 852 |
| 865 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); | 853 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); |
| 866 if (browser_view_->IsToolbarVisible()) { | 854 if (browser_view_->IsToolbarVisible()) { |
| 867 // The client edges start below the toolbar upper corner images regardless | 855 // The client edges start below the toolbar upper corner images regardless |
| 868 // of how tall the toolbar itself is. | 856 // of how tall the toolbar itself is. |
| 869 client_area_top += browser_view_->GetToolbarBounds().y() + | 857 client_area_top += browser_view_->GetToolbarBounds().y() + |
| 870 resources()->GetPartBitmap(FRAME_CLIENT_EDGE_TOP_LEFT)->height(); | 858 resources()->GetPartBitmap(FRAME_CLIENT_EDGE_TOP_LEFT)->height(); |
| 871 } else { | 859 } else { |
| 872 // The toolbar isn't going to draw a client edge for us, so draw one | 860 // The toolbar isn't going to draw a client edge for us, so draw one |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 SkBitmap* bottom_left = | 896 SkBitmap* bottom_left = |
| 909 resources()->GetPartBitmap(FRAME_CLIENT_EDGE_BOTTOM_LEFT); | 897 resources()->GetPartBitmap(FRAME_CLIENT_EDGE_BOTTOM_LEFT); |
| 910 canvas->DrawBitmapInt(*bottom_left, | 898 canvas->DrawBitmapInt(*bottom_left, |
| 911 client_area_bounds.x() - bottom_left->width(), client_area_bottom); | 899 client_area_bounds.x() - bottom_left->width(), client_area_bottom); |
| 912 | 900 |
| 913 SkBitmap* left = resources()->GetPartBitmap(FRAME_CLIENT_EDGE_LEFT); | 901 SkBitmap* left = resources()->GetPartBitmap(FRAME_CLIENT_EDGE_LEFT); |
| 914 canvas->TileImageInt(*left, client_area_bounds.x() - left->width(), | 902 canvas->TileImageInt(*left, client_area_bounds.x() - left->width(), |
| 915 client_area_top, left->width(), client_area_height); | 903 client_area_top, left->width(), client_area_height); |
| 916 } | 904 } |
| 917 | 905 |
| 918 void OpaqueNonClientView::LayoutWindowControls() { | 906 void OpaqueBrowserFrameView::LayoutWindowControls() { |
| 919 close_button_->SetImageAlignment(views::Button::ALIGN_LEFT, | 907 close_button_->SetImageAlignment(views::Button::ALIGN_LEFT, |
| 920 views::Button::ALIGN_BOTTOM); | 908 views::Button::ALIGN_BOTTOM); |
| 921 // Maximized buttons start at window top so that even if their images aren't | 909 // Maximized buttons start at window top so that even if their images aren't |
| 922 // drawn flush with the screen edge, they still obey Fitts' Law. | 910 // drawn flush with the screen edge, they still obey Fitts' Law. |
| 923 bool is_maximized = frame_->IsMaximized(); | 911 bool is_maximized = frame_->IsMaximized(); |
| 924 int frame_thickness = FrameBorderThickness(); | 912 int frame_thickness = FrameBorderThickness(); |
| 925 int caption_y = is_maximized ? frame_thickness : kCaptionTopSpacing; | 913 int caption_y = is_maximized ? frame_thickness : kCaptionTopSpacing; |
| 926 int top_extra_height = is_maximized ? kCaptionTopSpacing : 0; | 914 int top_extra_height = is_maximized ? kCaptionTopSpacing : 0; |
| 927 // There should always be the same number of non-shadow pixels visible to the | 915 // There should always be the same number of non-shadow pixels visible to the |
| 928 // side of the caption buttons. In maximized mode we extend the rightmost | 916 // side of the caption buttons. In maximized mode we extend the rightmost |
| (...skipping 28 matching lines...) Expand all Loading... |
| 957 minimize_button_->SetVisible(true); | 945 minimize_button_->SetVisible(true); |
| 958 minimize_button_->SetImageAlignment(views::Button::ALIGN_LEFT, | 946 minimize_button_->SetImageAlignment(views::Button::ALIGN_LEFT, |
| 959 views::Button::ALIGN_BOTTOM); | 947 views::Button::ALIGN_BOTTOM); |
| 960 gfx::Size minimize_button_size = minimize_button_->GetPreferredSize(); | 948 gfx::Size minimize_button_size = minimize_button_->GetPreferredSize(); |
| 961 minimize_button_->SetBounds( | 949 minimize_button_->SetBounds( |
| 962 visible_button->x() - minimize_button_size.width(), caption_y, | 950 visible_button->x() - minimize_button_size.width(), caption_y, |
| 963 minimize_button_size.width(), | 951 minimize_button_size.width(), |
| 964 minimize_button_size.height() + top_extra_height); | 952 minimize_button_size.height() + top_extra_height); |
| 965 } | 953 } |
| 966 | 954 |
| 967 void OpaqueNonClientView::LayoutDistributorLogo() { | 955 void OpaqueBrowserFrameView::LayoutDistributorLogo() { |
| 968 // Always lay out the logo, even when it's not present, so we can lay out the | 956 // Always lay out the logo, even when it's not present, so we can lay out the |
| 969 // window title based on its position. | 957 // window title based on its position. |
| 970 if (distributor_logo_) { | 958 if (distributor_logo_) { |
| 971 logo_bounds_.SetRect(minimize_button_->x() - distributor_logo_->width() - | 959 logo_bounds_.SetRect(minimize_button_->x() - distributor_logo_->width() - |
| 972 kLogoCaptionSpacing, TopResizeHeight(), distributor_logo_->width(), | 960 kLogoCaptionSpacing, TopResizeHeight(), distributor_logo_->width(), |
| 973 distributor_logo_->height()); | 961 distributor_logo_->height()); |
| 974 } else { | 962 } else { |
| 975 logo_bounds_.SetRect(minimize_button_->x(), TopResizeHeight(), 0, 0); | 963 logo_bounds_.SetRect(minimize_button_->x(), TopResizeHeight(), 0, 0); |
| 976 } | 964 } |
| 977 } | 965 } |
| 978 | 966 |
| 979 void OpaqueNonClientView::LayoutTitleBar() { | 967 void OpaqueBrowserFrameView::LayoutTitleBar() { |
| 980 // Always lay out the icon, even when it's not present, so we can lay out the | 968 // Always lay out the icon, even when it's not present, so we can lay out the |
| 981 // window title based on its position. | 969 // window title based on its position. |
| 982 int frame_thickness = FrameBorderThickness(); | 970 int frame_thickness = FrameBorderThickness(); |
| 983 int icon_x = frame_thickness + kIconLeftSpacing; | 971 int icon_x = frame_thickness + kIconLeftSpacing; |
| 984 | 972 |
| 985 // The usable height of the titlebar area is the total height minus the top | 973 // The usable height of the titlebar area is the total height minus the top |
| 986 // resize border and any edge area we draw at its bottom. | 974 // resize border and any edge area we draw at its bottom. |
| 987 int title_top_spacing, title_thickness; | 975 int title_top_spacing, title_thickness; |
| 988 int top_height = TitleCoordinates(&title_top_spacing, &title_thickness); | 976 int top_height = TitleCoordinates(&title_top_spacing, &title_thickness); |
| 989 int available_height = top_height - frame_thickness - | 977 int available_height = top_height - frame_thickness - |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1015 if (d->ShouldShowWindowTitle()) { | 1003 if (d->ShouldShowWindowTitle()) { |
| 1016 int title_x = icon_x + icon_size + | 1004 int title_x = icon_x + icon_size + |
| 1017 (d->ShouldShowWindowIcon() ? kIconTitleSpacing : 0); | 1005 (d->ShouldShowWindowIcon() ? kIconTitleSpacing : 0); |
| 1018 title_bounds_.SetRect(title_x, | 1006 title_bounds_.SetRect(title_x, |
| 1019 title_top_spacing + ((title_thickness - title_font_.height()) / 2), | 1007 title_top_spacing + ((title_thickness - title_font_.height()) / 2), |
| 1020 std::max(0, logo_bounds_.x() - kTitleLogoSpacing - title_x), | 1008 std::max(0, logo_bounds_.x() - kTitleLogoSpacing - title_x), |
| 1021 title_font_.height()); | 1009 title_font_.height()); |
| 1022 } | 1010 } |
| 1023 } | 1011 } |
| 1024 | 1012 |
| 1025 void OpaqueNonClientView::LayoutOTRAvatar() { | 1013 void OpaqueBrowserFrameView::LayoutOTRAvatar() { |
| 1026 SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon(); | 1014 SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon(); |
| 1027 int top_height = NonClientTopBorderHeight(); | 1015 int top_height = NonClientTopBorderHeight(); |
| 1028 int tabstrip_height, otr_height; | 1016 int tabstrip_height, otr_height; |
| 1029 if (browser_view_->IsTabStripVisible()) { | 1017 if (browser_view_->IsTabStripVisible()) { |
| 1030 tabstrip_height = browser_view_->GetTabStripHeight() - kOTRBottomSpacing; | 1018 tabstrip_height = browser_view_->GetTabStripHeight() - kOTRBottomSpacing; |
| 1031 otr_height = frame_->IsMaximized() ? | 1019 otr_height = frame_->IsMaximized() ? |
| 1032 (tabstrip_height - kOTRMaximizedTopSpacing) : | 1020 (tabstrip_height - kOTRMaximizedTopSpacing) : |
| 1033 otr_avatar_icon.height(); | 1021 otr_avatar_icon.height(); |
| 1034 } else { | 1022 } else { |
| 1035 tabstrip_height = otr_height = 0; | 1023 tabstrip_height = otr_height = 0; |
| 1036 } | 1024 } |
| 1037 otr_avatar_bounds_.SetRect(NonClientBorderThickness() + kOTRSideSpacing, | 1025 otr_avatar_bounds_.SetRect(NonClientBorderThickness() + kOTRSideSpacing, |
| 1038 top_height + tabstrip_height - otr_height, | 1026 top_height + tabstrip_height - otr_height, |
| 1039 otr_avatar_icon.width(), otr_height); | 1027 otr_avatar_icon.width(), otr_height); |
| 1040 } | 1028 } |
| 1041 | 1029 |
| 1042 void OpaqueNonClientView::LayoutClientView() { | 1030 void OpaqueBrowserFrameView::LayoutClientView() { |
| 1043 frame_->client_view()->SetBounds(CalculateClientAreaBounds(width(), | 1031 client_view_bounds_ = CalculateClientAreaBounds(width(), height()); |
| 1044 height())); | 1032 } |
| 1033 |
| 1034 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, |
| 1035 int height) const { |
| 1036 int top_height = NonClientTopBorderHeight(); |
| 1037 int border_thickness = NonClientBorderThickness(); |
| 1038 return gfx::Rect(border_thickness, top_height, |
| 1039 std::max(0, width - (2 * border_thickness)), |
| 1040 std::max(0, height - top_height - border_thickness)); |
| 1045 } | 1041 } |
| 1046 | 1042 |
| 1047 // static | 1043 // static |
| 1048 void OpaqueNonClientView::InitClass() { | 1044 void OpaqueBrowserFrameView::InitClass() { |
| 1049 static bool initialized = false; | 1045 static bool initialized = false; |
| 1050 if (!initialized) { | 1046 if (!initialized) { |
| 1051 active_resources_ = new ActiveWindowResources; | 1047 active_resources_ = new ActiveWindowResources; |
| 1052 inactive_resources_ = new InactiveWindowResources; | 1048 inactive_resources_ = new InactiveWindowResources; |
| 1053 | 1049 |
| 1054 #if defined(GOOGLE_CHROME_BUILD) | 1050 #if defined(GOOGLE_CHROME_BUILD) |
| 1055 distributor_logo_ = ResourceBundle::GetSharedInstance(). | 1051 distributor_logo_ = ResourceBundle::GetSharedInstance(). |
| 1056 GetBitmapNamed(IDR_DISTRIBUTOR_LOGO_LIGHT); | 1052 GetBitmapNamed(IDR_DISTRIBUTOR_LOGO_LIGHT); |
| 1057 #endif | 1053 #endif |
| 1058 | 1054 |
| 1059 initialized = true; | 1055 initialized = true; |
| 1060 } | 1056 } |
| 1061 } | 1057 } |
| 1062 | 1058 |
| 1063 // static | 1059 // static |
| 1064 void OpaqueNonClientView::InitAppWindowResources() { | 1060 void OpaqueBrowserFrameView::InitAppWindowResources() { |
| 1065 static bool initialized = false; | 1061 static bool initialized = false; |
| 1066 if (!initialized) { | 1062 if (!initialized) { |
| 1067 title_font_ = win_util::GetWindowTitleFont(); | 1063 title_font_ = win_util::GetWindowTitleFont(); |
| 1068 initialized = true; | 1064 initialized = true; |
| 1069 } | 1065 } |
| 1070 } | 1066 } |
| OLD | NEW |