| OLD | NEW |
| 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/ash/browser_non_client_frame_view_ash.h" | 5 #include "chrome/browser/ui/views/ash/browser_non_client_frame_view_ash.h" |
| 6 | 6 |
| 7 #include "ash/wm/frame_painter.h" | 7 #include "ash/wm/frame_painter.h" |
| 8 #include "ash/wm/workspace/frame_maximize_button.h" | 8 #include "ash/wm/workspace/frame_maximize_button.h" |
| 9 #include "chrome/browser/themes/theme_service.h" | 9 #include "chrome/browser/themes/theme_service.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 ShouldPaintAsActive() ? | 271 ShouldPaintAsActive() ? |
| 272 ash::FramePainter::ACTIVE : ash::FramePainter::INACTIVE, | 272 ash::FramePainter::ACTIVE : ash::FramePainter::INACTIVE, |
| 273 GetThemeFrameImageId(), | 273 GetThemeFrameImageId(), |
| 274 GetThemeFrameOverlayImage()); | 274 GetThemeFrameOverlayImage()); |
| 275 if (browser_view()->ShouldShowWindowTitle()) | 275 if (browser_view()->ShouldShowWindowTitle()) |
| 276 frame_painter_->PaintTitleBar(this, canvas, BrowserFrame::GetTitleFont()); | 276 frame_painter_->PaintTitleBar(this, canvas, BrowserFrame::GetTitleFont()); |
| 277 if (browser_view()->IsToolbarVisible()) { | 277 if (browser_view()->IsToolbarVisible()) { |
| 278 chrome::search::Mode mode = | 278 chrome::search::Mode mode = |
| 279 browser_view()->browser()->search_model()->mode(); | 279 browser_view()->browser()->search_model()->mode(); |
| 280 bool fading_in = false; | 280 bool fading_in = false; |
| 281 // For |MODE_SEARCH|, get current state of background animation to figure | 281 // Get current opacity of gradient background animation to figure out if |
| 282 // out if we're waiting to fade in or in the process of fading in new | 282 // we need to paint both flat and gradient backgrounds or just one: |
| 283 // background for |MODE_SEARCH|. | 283 // - if |gradient_opacity| < 1f, paint flat background at full opacity, and |
| 284 // In the former case, just paint the previous background for |MODE_NTP|. | 284 // only paint gradient background if |gradient_opacity| is not 0f; |
| 285 // In the latter case, paint the previous background for |MODE_NTP| and then | 285 // - if |gradient_opacity| is 1f, paint the background for the current mode |
| 286 // the new background at specified opacity value. | 286 // at full opacity. |
| 287 if (mode.is_search()) { | 287 double gradient_opacity = browser_view()->browser()->search_delegate()-> |
| 288 chrome::search::ToolbarSearchAnimator::BackgroundState background_state = | 288 toolbar_search_animator().GetGradientOpacity(); |
| 289 chrome::search::ToolbarSearchAnimator::BACKGROUND_STATE_DEFAULT; | 289 if (gradient_opacity < 1.0f) { |
| 290 double search_background_opacity = -1.0f; | 290 // Paint flat background of |MODE_NTP|. |
| 291 browser_view()->browser()->search_delegate()->toolbar_search_animator(). | 291 PaintToolbarBackground(canvas, chrome::search::Mode::MODE_NTP); |
| 292 GetCurrentBackgroundState(&background_state, | 292 // We're done if we're not showing gradient background. |
| 293 &search_background_opacity); | 293 if (gradient_opacity == 0.0f) |
| 294 if (background_state & | 294 return; |
| 295 chrome::search::ToolbarSearchAnimator::BACKGROUND_STATE_NTP) { | 295 // Otherwise, we're fading in gradient background at |gradient_opacity|. |
| 296 // Paint background for |MODE_NTP|. | 296 fading_in = true; |
| 297 PaintToolbarBackground(canvas, chrome::search::Mode::MODE_NTP); | 297 canvas->SaveLayerAlpha(static_cast<uint8>(gradient_opacity * 0xFF)); |
| 298 // We're done if we're not showing background for SEARCH mode. | |
| 299 if (!(background_state & chrome::search::ToolbarSearchAnimator:: | |
| 300 BACKGROUND_STATE_SEARCH)) { | |
| 301 return; | |
| 302 } | |
| 303 // Otherwise, we're fading in the new background at | |
| 304 // |search_background_opacity|. | |
| 305 fading_in = true; | |
| 306 canvas->SaveLayerAlpha(static_cast<uint8>( | |
| 307 search_background_opacity * 0xFF)); | |
| 308 } | |
| 309 } | 298 } |
| 310 // Paint the background for the current mode. | 299 // Paint the background for the current mode. |
| 311 PaintToolbarBackground(canvas, mode.mode); | 300 PaintToolbarBackground(canvas, mode.mode); |
| 312 // If we're fading in and have saved canvas, restore it now. | 301 // If we're fading in and have saved canvas, restore it now. |
| 313 if (fading_in) | 302 if (fading_in) |
| 314 canvas->Restore(); | 303 canvas->Restore(); |
| 315 } else { | 304 } else { |
| 316 PaintContentEdge(canvas); | 305 PaintContentEdge(canvas); |
| 317 } | 306 } |
| 318 } | 307 } |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 toolbar_left->width(), theme_toolbar->height()); | 535 toolbar_left->width(), theme_toolbar->height()); |
| 547 gfx::ImageSkia* toolbar_right = | 536 gfx::ImageSkia* toolbar_right = |
| 548 tp->GetImageSkiaNamed(IDR_TOOLBAR_SHADE_RIGHT); | 537 tp->GetImageSkiaNamed(IDR_TOOLBAR_SHADE_RIGHT); |
| 549 canvas->TileImageInt(*toolbar_right, | 538 canvas->TileImageInt(*toolbar_right, |
| 550 0, 0, | 539 0, 0, |
| 551 w - toolbar_right->width() - 2 * kClientEdgeThickness, | 540 w - toolbar_right->width() - 2 * kClientEdgeThickness, |
| 552 y + kClientEdgeThickness + kContentShadowHeight, | 541 y + kClientEdgeThickness + kContentShadowHeight, |
| 553 toolbar_right->width(), theme_toolbar->height()); | 542 toolbar_right->width(), theme_toolbar->height()); |
| 554 | 543 |
| 555 // Only draw the content/toolbar separator if Instant Extended API is disabled | 544 // Only draw the content/toolbar separator if Instant Extended API is disabled |
| 556 // or mode is DEFAULT. | 545 // or mode is |DEFAULT|. |
| 557 bool extended_instant_enabled = chrome::search::IsInstantExtendedAPIEnabled( | 546 bool extended_instant_enabled = chrome::search::IsInstantExtendedAPIEnabled( |
| 558 browser_view()->browser()->profile()); | 547 browser_view()->browser()->profile()); |
| 559 if (!extended_instant_enabled || mode == chrome::search::Mode::MODE_DEFAULT) { | 548 if (!extended_instant_enabled || mode == chrome::search::Mode::MODE_DEFAULT) { |
| 560 canvas->FillRect( | 549 canvas->FillRect( |
| 561 gfx::Rect(x + kClientEdgeThickness, | 550 gfx::Rect(x + kClientEdgeThickness, |
| 562 toolbar_bounds.bottom() - kClientEdgeThickness, | 551 toolbar_bounds.bottom() - kClientEdgeThickness, |
| 563 w - (2 * kClientEdgeThickness), kClientEdgeThickness), | 552 w - (2 * kClientEdgeThickness), |
| 553 kClientEdgeThickness), |
| 564 ThemeService::GetDefaultColor(extended_instant_enabled ? | 554 ThemeService::GetDefaultColor(extended_instant_enabled ? |
| 565 ThemeService::COLOR_SEARCH_SEPARATOR_LINE : | 555 ThemeService::COLOR_SEARCH_SEPARATOR_LINE : |
| 566 ThemeService::COLOR_TOOLBAR_SEPARATOR)); | 556 ThemeService::COLOR_TOOLBAR_SEPARATOR)); |
| 567 } | 557 } |
| 568 } | 558 } |
| 569 | 559 |
| 570 void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) { | 560 void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) { |
| 571 canvas->FillRect(gfx::Rect(0, close_button_->bounds().bottom(), | 561 canvas->FillRect(gfx::Rect(0, close_button_->bounds().bottom(), |
| 572 width(), kClientEdgeThickness), | 562 width(), kClientEdgeThickness), |
| 573 ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR)); | 563 ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR)); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 599 BrowserNonClientFrameViewAsh::GetThemeFrameOverlayImage() const { | 589 BrowserNonClientFrameViewAsh::GetThemeFrameOverlayImage() const { |
| 600 ui::ThemeProvider* tp = GetThemeProvider(); | 590 ui::ThemeProvider* tp = GetThemeProvider(); |
| 601 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && | 591 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && |
| 602 browser_view()->IsBrowserTypeNormal() && | 592 browser_view()->IsBrowserTypeNormal() && |
| 603 !browser_view()->IsOffTheRecord()) { | 593 !browser_view()->IsOffTheRecord()) { |
| 604 return tp->GetImageSkiaNamed(ShouldPaintAsActive() ? | 594 return tp->GetImageSkiaNamed(ShouldPaintAsActive() ? |
| 605 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE); | 595 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE); |
| 606 } | 596 } |
| 607 return NULL; | 597 return NULL; |
| 608 } | 598 } |
| OLD | NEW |