| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/frame/browser_view.h" | 5 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 BookmarkBarView* bookmark_bar_view, | 409 BookmarkBarView* bookmark_bar_view, |
| 410 Browser* browser) | 410 Browser* browser) |
| 411 : browser_view_(browser_view), | 411 : browser_view_(browser_view), |
| 412 bookmark_bar_view_(bookmark_bar_view), | 412 bookmark_bar_view_(bookmark_bar_view), |
| 413 browser_(browser) { | 413 browser_(browser) { |
| 414 } | 414 } |
| 415 | 415 |
| 416 void BookmarkBarViewBackground::Paint(gfx::Canvas* canvas, | 416 void BookmarkBarViewBackground::Paint(gfx::Canvas* canvas, |
| 417 views::View* view) const { | 417 views::View* view) const { |
| 418 int toolbar_overlap = bookmark_bar_view_->GetToolbarOverlap(); | 418 int toolbar_overlap = bookmark_bar_view_->GetToolbarOverlap(); |
| 419 if (!bookmark_bar_view_->IsDetached()) { | |
| 420 PaintAttachedBookmarkBar(canvas, | |
| 421 bookmark_bar_view_, | |
| 422 browser_view_, | |
| 423 browser_->host_desktop_type(), | |
| 424 toolbar_overlap); | |
| 425 return; | |
| 426 } | |
| 427 | 419 |
| 428 // As 'hidden' according to the animation is the full in-tab state, we invert | 420 SkAlpha detached_alpha = static_cast<SkAlpha>( |
| 429 // the value - when current_state is at '0', we expect the bar to be docked. | 421 bookmark_bar_view_->size_animation().CurrentValueBetween(0xff, 0)); |
| 430 double current_state = 1 - bookmark_bar_view_->GetAnimationValue(); | 422 if (detached_alpha != 0xff) { |
| 431 | |
| 432 if (current_state == 0.0 || current_state == 1.0) { | |
| 433 PaintDetachedBookmarkBar(canvas, bookmark_bar_view_, browser_->profile()); | |
| 434 return; | |
| 435 } | |
| 436 // While animating, set opacity to cross-fade between attached and detached | |
| 437 // backgrounds including their respective separators. | |
| 438 int detached_alpha = static_cast<uint8_t>(current_state * 255); | |
| 439 int attached_alpha = 255 - detached_alpha; | |
| 440 if (browser_->bookmark_bar_state() == BookmarkBar::DETACHED) { | |
| 441 // To animate from attached to detached state: | |
| 442 // - fade out attached background | |
| 443 // - fade in detached background. | |
| 444 canvas->SaveLayerAlpha(attached_alpha); | |
| 445 PaintAttachedBookmarkBar(canvas, | |
| 446 bookmark_bar_view_, | |
| 447 browser_view_, | |
| 448 browser_->host_desktop_type(), | |
| 449 toolbar_overlap); | |
| 450 canvas->Restore(); | |
| 451 canvas->SaveLayerAlpha(detached_alpha); | |
| 452 PaintDetachedBookmarkBar(canvas, bookmark_bar_view_, browser_->profile()); | |
| 453 } else { | |
| 454 // To animate from detached to attached state: | |
| 455 // - fade out detached background | |
| 456 // - fade in attached background. | |
| 457 canvas->SaveLayerAlpha(detached_alpha); | |
| 458 PaintDetachedBookmarkBar(canvas, bookmark_bar_view_, browser_->profile()); | |
| 459 canvas->Restore(); | |
| 460 canvas->SaveLayerAlpha(attached_alpha); | |
| 461 PaintAttachedBookmarkBar(canvas, | 423 PaintAttachedBookmarkBar(canvas, |
| 462 bookmark_bar_view_, | 424 bookmark_bar_view_, |
| 463 browser_view_, | 425 browser_view_, |
| 464 browser_->host_desktop_type(), | 426 browser_->host_desktop_type(), |
| 465 toolbar_overlap); | 427 toolbar_overlap); |
| 466 } | 428 } |
| 429 |
| 430 if (!bookmark_bar_view_->IsDetached() || detached_alpha == 0) |
| 431 return; |
| 432 |
| 433 // While animating, set opacity to cross-fade between attached and detached |
| 434 // backgrounds including their respective separators. |
| 435 canvas->SaveLayerAlpha(detached_alpha); |
| 436 PaintDetachedBookmarkBar(canvas, bookmark_bar_view_, browser_->profile()); |
| 467 canvas->Restore(); | 437 canvas->Restore(); |
| 468 } | 438 } |
| 469 | 439 |
| 470 /////////////////////////////////////////////////////////////////////////////// | 440 /////////////////////////////////////////////////////////////////////////////// |
| 471 // BrowserView, public: | 441 // BrowserView, public: |
| 472 | 442 |
| 473 // static | 443 // static |
| 474 const char BrowserView::kViewClassName[] = "BrowserView"; | 444 const char BrowserView::kViewClassName[] = "BrowserView"; |
| 475 | 445 |
| 476 BrowserView::BrowserView() | 446 BrowserView::BrowserView() |
| (...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1271 if (bookmark_bar_view_->GetPreferredSize().height() == 0) | 1241 if (bookmark_bar_view_->GetPreferredSize().height() == 0) |
| 1272 return false; | 1242 return false; |
| 1273 // New tab page needs visible bookmarks even when top-views are hidden. | 1243 // New tab page needs visible bookmarks even when top-views are hidden. |
| 1274 if (immersive_mode_controller_->ShouldHideTopViews() && | 1244 if (immersive_mode_controller_->ShouldHideTopViews() && |
| 1275 !bookmark_bar_view_->IsDetached()) | 1245 !bookmark_bar_view_->IsDetached()) |
| 1276 return false; | 1246 return false; |
| 1277 return true; | 1247 return true; |
| 1278 } | 1248 } |
| 1279 | 1249 |
| 1280 bool BrowserView::IsBookmarkBarAnimating() const { | 1250 bool BrowserView::IsBookmarkBarAnimating() const { |
| 1281 return bookmark_bar_view_.get() && bookmark_bar_view_->is_animating(); | 1251 return bookmark_bar_view_.get() && |
| 1252 bookmark_bar_view_->size_animation().is_animating(); |
| 1282 } | 1253 } |
| 1283 | 1254 |
| 1284 bool BrowserView::IsTabStripEditable() const { | 1255 bool BrowserView::IsTabStripEditable() const { |
| 1285 return tabstrip_->IsTabStripEditable(); | 1256 return tabstrip_->IsTabStripEditable(); |
| 1286 } | 1257 } |
| 1287 | 1258 |
| 1288 bool BrowserView::IsToolbarVisible() const { | 1259 bool BrowserView::IsToolbarVisible() const { |
| 1289 if (immersive_mode_controller_->ShouldHideTopViews()) | 1260 if (immersive_mode_controller_->ShouldHideTopViews()) |
| 1290 return false; | 1261 return false; |
| 1291 return browser_->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) || | 1262 return browser_->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) || |
| (...skipping 1415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2707 return immersive_mode_controller()->IsEnabled(); | 2678 return immersive_mode_controller()->IsEnabled(); |
| 2708 } | 2679 } |
| 2709 | 2680 |
| 2710 views::Widget* BrowserView::GetBubbleAssociatedWidget() { | 2681 views::Widget* BrowserView::GetBubbleAssociatedWidget() { |
| 2711 return GetWidget(); | 2682 return GetWidget(); |
| 2712 } | 2683 } |
| 2713 | 2684 |
| 2714 gfx::Rect BrowserView::GetTopContainerBoundsInScreen() { | 2685 gfx::Rect BrowserView::GetTopContainerBoundsInScreen() { |
| 2715 return top_container_->GetBoundsInScreen(); | 2686 return top_container_->GetBoundsInScreen(); |
| 2716 } | 2687 } |
| OLD | NEW |