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

Unified Diff: chrome/browser/ui/views/ash/browser_non_client_frame_view_ash.cc

Issue 10816027: alternate ntp: toolbar background and separator animation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 5 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/ash/browser_non_client_frame_view_ash.cc
diff --git a/chrome/browser/ui/views/ash/browser_non_client_frame_view_ash.cc b/chrome/browser/ui/views/ash/browser_non_client_frame_view_ash.cc
index 14d4faf1d06e271a19143abae6e2c9b7bfaab874..e979d91667ed8d790e5e9163950f740441611877 100644
--- a/chrome/browser/ui/views/ash/browser_non_client_frame_view_ash.cc
+++ b/chrome/browser/ui/views/ash/browser_non_client_frame_view_ash.cc
@@ -280,34 +280,23 @@ void BrowserNonClientFrameViewAsh::OnPaint(gfx::Canvas* canvas) {
chrome::search::Mode mode =
browser_view()->browser()->search_model()->mode();
bool fading_in = false;
- // For |MODE_SEARCH|, get current state of background animation to figure
- // out if we're waiting to fade in or in the process of fading in new
- // background for |MODE_SEARCH|.
- // In the former case, just paint the previous background for |MODE_NTP|.
- // In the latter case, paint the previous background for |MODE_NTP| and then
- // the new background at specified opacity value.
- if (mode.is_search()) {
- chrome::search::ToolbarSearchAnimator::BackgroundState background_state =
- chrome::search::ToolbarSearchAnimator::BACKGROUND_STATE_DEFAULT;
- double search_background_opacity = -1.0f;
- browser_view()->browser()->search_delegate()->toolbar_search_animator().
- GetCurrentBackgroundState(&background_state,
- &search_background_opacity);
- if (background_state &
- chrome::search::ToolbarSearchAnimator::BACKGROUND_STATE_NTP) {
- // Paint background for |MODE_NTP|.
- PaintToolbarBackground(canvas, chrome::search::Mode::MODE_NTP);
- // We're done if we're not showing background for SEARCH mode.
- if (!(background_state & chrome::search::ToolbarSearchAnimator::
- BACKGROUND_STATE_SEARCH)) {
- return;
- }
- // Otherwise, we're fading in the new background at
- // |search_background_opacity|.
- fading_in = true;
- canvas->SaveLayerAlpha(static_cast<uint8>(
- search_background_opacity * 0xFF));
- }
+ // Get current opacity of gradient background animation to figure out if
+ // we need to paint both flat and gradient backgrounds or just one:
+ // - if |gradient_opacity| < 1f, paint flat background at full opacity, and
+ // only paint gradient background if |gradient_opacity| is not 0f;
+ // - if |gradient_opacity| is 1f, paint the background for the current mode
+ // at full opacity.
+ double gradient_opacity = browser_view()->browser()->search_delegate()->
+ toolbar_search_animator().GetGradientOpacity();
+ if (gradient_opacity < 1.0f) {
+ // Paint flat background of |MODE_NTP|.
+ PaintToolbarBackground(canvas, chrome::search::Mode::MODE_NTP);
+ // We're done if we're not showing gradient background.
+ if (gradient_opacity == 0.0f)
+ return;
+ // Otherwise, we're fading in gradient background at |gradient_opacity|.
+ fading_in = true;
+ canvas->SaveLayerAlpha(static_cast<uint8>(gradient_opacity * 0xFF));
}
// Paint the background for the current mode.
PaintToolbarBackground(canvas, mode.mode);
@@ -425,6 +414,17 @@ void BrowserNonClientFrameViewAsh::OnToolbarBackgroundAnimatorCanceled(
browser_view()->toolbar()->SchedulePaint();
}
+void BrowserNonClientFrameViewAsh::OnToolbarSeparatorAnimatorProgressed() {
+ // We're fading the toolbar separator, repaint the toolbar separator.
+ browser_view()->toolbar()->SchedulePaint();
+}
+
+void BrowserNonClientFrameViewAsh::OnToolbarSeparatorAnimatorCanceled() {
+ // Fade in of toolbar background has been canceled, repaint the toolbar
+ // separator.
+ browser_view()->toolbar()->SchedulePaint();
+}
+
///////////////////////////////////////////////////////////////////////////////
// BrowserNonClientFrameViewAsh, private:
@@ -555,19 +555,30 @@ void BrowserNonClientFrameViewAsh::PaintToolbarBackground(
y + kClientEdgeThickness + kContentShadowHeight,
toolbar_right->width(), theme_toolbar->height());
- // Only draw the content/toolbar separator if Instant Extended API is disabled
- // or mode is DEFAULT.
+ // If Instant Extended API is disabled, draw the content/toolbar separator as
+ // is. Otherwise, draw or fade it per ToolbarSearchAnimator.
bool extended_instant_enabled = chrome::search::IsInstantExtendedAPIEnabled(
browser_view()->browser()->profile());
- if (!extended_instant_enabled || mode == chrome::search::Mode::MODE_DEFAULT) {
- canvas->FillRect(
- gfx::Rect(x + kClientEdgeThickness,
- toolbar_bounds.bottom() - kClientEdgeThickness,
- w - (2 * kClientEdgeThickness), kClientEdgeThickness),
- ThemeService::GetDefaultColor(extended_instant_enabled ?
- ThemeService::COLOR_SEARCH_SEPARATOR_LINE :
- ThemeService::COLOR_TOOLBAR_SEPARATOR));
+ double separator_opacity = !extended_instant_enabled ? 1.0f :
+ browser_view()->browser()->search_delegate()->toolbar_search_animator().
+ GetSeparatorOpacity();
+ if (separator_opacity == 0.0f)
+ return;
+ bool fading = separator_opacity < 1.0f;
+ gfx::Rect separator_rect(x + kClientEdgeThickness,
+ toolbar_bounds.bottom() - kClientEdgeThickness,
+ w - (2 * kClientEdgeThickness),
+ kClientEdgeThickness);
+ if (fading) {
+ canvas->SaveLayerAlpha(static_cast<uint8>(separator_opacity * 0xFF),
+ separator_rect);
}
+ canvas->FillRect(separator_rect,
+ ThemeService::GetDefaultColor(extended_instant_enabled ?
+ ThemeService::COLOR_SEARCH_SEPARATOR_LINE :
+ ThemeService::COLOR_TOOLBAR_SEPARATOR));
+ if (fading)
+ canvas->Restore();
}
void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) {

Powered by Google App Engine
This is Rietveld 408576698