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

Unified Diff: chrome/browser/ui/views/frame/browser_view.cc

Issue 1547563003: Fix and simplify bookmark bar detach/attach animation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/frame/browser_view.cc
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index 9bc227c3b0fa4bdbd3ef25bd14d78e63545cc168..f738e9e3df97b56c8702298fc0b788ae7919fce4 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -412,54 +412,26 @@ BookmarkBarViewBackground::BookmarkBarViewBackground(
void BookmarkBarViewBackground::Paint(gfx::Canvas* canvas,
views::View* view) const {
int toolbar_overlap = bookmark_bar_view_->GetToolbarOverlap();
- if (!bookmark_bar_view_->IsDetached()) {
+
+ // As 'hidden' according to the animation is the full in-tab state, we invert
+ // the value - when detach_percent is at '0', we expect the bar to be docked.
+ double detach_percent = 1 - bookmark_bar_view_->GetAnimationValue();
Peter Kasting 2015/12/22 05:52:42 Nit: Since this is the only callsite for GetAnimat
Evan Stade 2015/12/29 17:14:16 I changed uint8 to SkAlpha and changed BookmarkBar
+ if (detach_percent != 1.0) {
PaintAttachedBookmarkBar(canvas,
bookmark_bar_view_,
browser_view_,
browser_->host_desktop_type(),
toolbar_overlap);
- return;
}
- // As 'hidden' according to the animation is the full in-tab state, we invert
- // the value - when current_state is at '0', we expect the bar to be docked.
- double current_state = 1 - bookmark_bar_view_->GetAnimationValue();
-
- if (current_state == 0.0 || current_state == 1.0) {
- PaintDetachedBookmarkBar(canvas, bookmark_bar_view_, browser_->profile());
+ if (!bookmark_bar_view_->IsDetached() || detach_percent == 0.0)
return;
- }
+
// While animating, set opacity to cross-fade between attached and detached
// backgrounds including their respective separators.
- int detached_alpha = static_cast<uint8>(current_state * 255);
- int attached_alpha = 255 - detached_alpha;
- if (browser_->bookmark_bar_state() == BookmarkBar::DETACHED) {
- // To animate from attached to detached state:
- // - fade out attached background
- // - fade in detached background.
- canvas->SaveLayerAlpha(attached_alpha);
- PaintAttachedBookmarkBar(canvas,
- bookmark_bar_view_,
- browser_view_,
- browser_->host_desktop_type(),
- toolbar_overlap);
- canvas->Restore();
- canvas->SaveLayerAlpha(detached_alpha);
- PaintDetachedBookmarkBar(canvas, bookmark_bar_view_, browser_->profile());
- } else {
- // To animate from detached to attached state:
- // - fade out detached background
- // - fade in attached background.
- canvas->SaveLayerAlpha(detached_alpha);
- PaintDetachedBookmarkBar(canvas, bookmark_bar_view_, browser_->profile());
- canvas->Restore();
- canvas->SaveLayerAlpha(attached_alpha);
- PaintAttachedBookmarkBar(canvas,
- bookmark_bar_view_,
- browser_view_,
- browser_->host_desktop_type(),
- toolbar_overlap);
- }
+ int detached_alpha = static_cast<uint8>(detach_percent * 255);
+ canvas->SaveLayerAlpha(detached_alpha);
+ PaintDetachedBookmarkBar(canvas, bookmark_bar_view_, browser_->profile());
canvas->Restore();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698