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

Side by Side 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: fix android build break Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 ShouldPaintAsActive() ? 275 ShouldPaintAsActive() ?
276 ash::FramePainter::ACTIVE : ash::FramePainter::INACTIVE, 276 ash::FramePainter::ACTIVE : ash::FramePainter::INACTIVE,
277 GetThemeFrameImageId(), 277 GetThemeFrameImageId(),
278 GetThemeFrameOverlayImage()); 278 GetThemeFrameOverlayImage());
279 if (browser_view()->ShouldShowWindowTitle()) 279 if (browser_view()->ShouldShowWindowTitle())
280 frame_painter_->PaintTitleBar(this, canvas, BrowserFrame::GetTitleFont()); 280 frame_painter_->PaintTitleBar(this, canvas, BrowserFrame::GetTitleFont());
281 if (browser_view()->IsToolbarVisible()) { 281 if (browser_view()->IsToolbarVisible()) {
282 chrome::search::Mode mode = 282 chrome::search::Mode mode =
283 browser_view()->browser()->search_model()->mode(); 283 browser_view()->browser()->search_model()->mode();
284 bool fading_in = false; 284 bool fading_in = false;
285 // For |MODE_SEARCH|, get current state of background animation to figure 285 // Get current opacity of gradient background animation to figure out if
286 // out if we're waiting to fade in or in the process of fading in new 286 // we need to paint both flat and gradient backgrounds or just one:
287 // background for |MODE_SEARCH|. 287 // - if |gradient_opacity| < 1f, paint flat background at full opacity, and
288 // In the former case, just paint the previous background for |MODE_NTP|. 288 // only paint gradient background if |gradient_opacity| is not 0f;
289 // In the latter case, paint the previous background for |MODE_NTP| and then 289 // - if |gradient_opacity| is 1f, paint the background for the current mode
290 // the new background at specified opacity value. 290 // at full opacity.
291 if (mode.is_search()) { 291 double gradient_opacity = browser_view()->browser()->search_delegate()->
292 chrome::search::ToolbarSearchAnimator::BackgroundState background_state = 292 toolbar_search_animator().GetGradientOpacity();
293 chrome::search::ToolbarSearchAnimator::BACKGROUND_STATE_DEFAULT; 293 if (gradient_opacity < 1.0f) {
294 double search_background_opacity = -1.0f; 294 // Paint flat background of |MODE_NTP|.
295 browser_view()->browser()->search_delegate()->toolbar_search_animator(). 295 PaintToolbarBackground(canvas, chrome::search::Mode::MODE_NTP);
296 GetCurrentBackgroundState(&background_state, 296 // We're done if we're not showing gradient background.
297 &search_background_opacity); 297 if (gradient_opacity == 0.0f)
298 if (background_state & 298 return;
299 chrome::search::ToolbarSearchAnimator::BACKGROUND_STATE_NTP) { 299 // Otherwise, we're fading in gradient background at |gradient_opacity|.
300 // Paint background for |MODE_NTP|. 300 fading_in = true;
301 PaintToolbarBackground(canvas, chrome::search::Mode::MODE_NTP); 301 canvas->SaveLayerAlpha(static_cast<uint8>(gradient_opacity * 0xFF));
302 // We're done if we're not showing background for SEARCH mode.
303 if (!(background_state & chrome::search::ToolbarSearchAnimator::
304 BACKGROUND_STATE_SEARCH)) {
305 return;
306 }
307 // Otherwise, we're fading in the new background at
308 // |search_background_opacity|.
309 fading_in = true;
310 canvas->SaveLayerAlpha(static_cast<uint8>(
311 search_background_opacity * 0xFF));
312 }
313 } 302 }
314 // Paint the background for the current mode. 303 // Paint the background for the current mode.
315 PaintToolbarBackground(canvas, mode.mode); 304 PaintToolbarBackground(canvas, mode.mode);
316 // If we're fading in and have saved canvas, restore it now. 305 // If we're fading in and have saved canvas, restore it now.
317 if (fading_in) 306 if (fading_in)
318 canvas->Restore(); 307 canvas->Restore();
319 } else { 308 } else {
320 PaintContentEdge(canvas); 309 PaintContentEdge(canvas);
321 } 310 }
322 } 311 }
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 toolbar_left->width(), theme_toolbar->height()); 542 toolbar_left->width(), theme_toolbar->height());
554 gfx::ImageSkia* toolbar_right = 543 gfx::ImageSkia* toolbar_right =
555 tp->GetImageSkiaNamed(IDR_TOOLBAR_SHADE_RIGHT); 544 tp->GetImageSkiaNamed(IDR_TOOLBAR_SHADE_RIGHT);
556 canvas->TileImageInt(*toolbar_right, 545 canvas->TileImageInt(*toolbar_right,
557 0, 0, 546 0, 0,
558 w - toolbar_right->width() - 2 * kClientEdgeThickness, 547 w - toolbar_right->width() - 2 * kClientEdgeThickness,
559 y + kClientEdgeThickness + kContentShadowHeight, 548 y + kClientEdgeThickness + kContentShadowHeight,
560 toolbar_right->width(), theme_toolbar->height()); 549 toolbar_right->width(), theme_toolbar->height());
561 550
562 // Only draw the content/toolbar separator if Instant Extended API is disabled 551 // Only draw the content/toolbar separator if Instant Extended API is disabled
563 // or mode is DEFAULT. 552 // or mode is |DEFAULT|.
564 bool extended_instant_enabled = chrome::search::IsInstantExtendedAPIEnabled( 553 bool extended_instant_enabled = chrome::search::IsInstantExtendedAPIEnabled(
565 browser_view()->browser()->profile()); 554 browser_view()->browser()->profile());
566 if (!extended_instant_enabled || mode == chrome::search::Mode::MODE_DEFAULT) { 555 if (!extended_instant_enabled || mode == chrome::search::Mode::MODE_DEFAULT) {
567 canvas->FillRect( 556 canvas->FillRect(
568 gfx::Rect(x + kClientEdgeThickness, 557 gfx::Rect(x + kClientEdgeThickness,
569 toolbar_bounds.bottom() - kClientEdgeThickness, 558 toolbar_bounds.bottom() - kClientEdgeThickness,
570 w - (2 * kClientEdgeThickness), kClientEdgeThickness), 559 w - (2 * kClientEdgeThickness),
560 kClientEdgeThickness),
571 ThemeService::GetDefaultColor(extended_instant_enabled ? 561 ThemeService::GetDefaultColor(extended_instant_enabled ?
572 ThemeService::COLOR_SEARCH_SEPARATOR_LINE : 562 ThemeService::COLOR_SEARCH_SEPARATOR_LINE :
573 ThemeService::COLOR_TOOLBAR_SEPARATOR)); 563 ThemeService::COLOR_TOOLBAR_SEPARATOR));
574 } 564 }
575 } 565 }
576 566
577 void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) { 567 void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) {
578 canvas->FillRect(gfx::Rect(0, close_button_->bounds().bottom(), 568 canvas->FillRect(gfx::Rect(0, close_button_->bounds().bottom(),
579 width(), kClientEdgeThickness), 569 width(), kClientEdgeThickness),
580 ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR)); 570 ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR));
(...skipping 25 matching lines...) Expand all
606 BrowserNonClientFrameViewAsh::GetThemeFrameOverlayImage() const { 596 BrowserNonClientFrameViewAsh::GetThemeFrameOverlayImage() const {
607 ui::ThemeProvider* tp = GetThemeProvider(); 597 ui::ThemeProvider* tp = GetThemeProvider();
608 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && 598 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) &&
609 browser_view()->IsBrowserTypeNormal() && 599 browser_view()->IsBrowserTypeNormal() &&
610 !browser_view()->IsOffTheRecord()) { 600 !browser_view()->IsOffTheRecord()) {
611 return tp->GetImageSkiaNamed(ShouldPaintAsActive() ? 601 return tp->GetImageSkiaNamed(ShouldPaintAsActive() ?
612 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE); 602 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE);
613 } 603 }
614 return NULL; 604 return NULL;
615 } 605 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/toolbar_search_animator_unittest.cc ('k') | chrome/browser/ui/views/location_bar/location_bar_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698