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

Side by Side Diff: chrome/browser/views/extensions/extension_shelf.cc

Issue 1961001: Refactors animation to allow for cleaner subclassing. I'm doing this (Closed)
Patch Set: Incorporated review feedback Created 10 years, 7 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
« no previous file with comments | « chrome/browser/views/dropdown_bar_host.cc ('k') | chrome/browser/views/frame/browser_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/views/extensions/extension_shelf.h" 5 #include "chrome/browser/views/extensions/extension_shelf.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "app/resource_bundle.h" 9 #include "app/resource_bundle.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 return; 427 return;
428 428
429 if (!window_.get()) { 429 if (!window_.get()) {
430 window_.reset(new BrowserBubble(this, shelf_->GetWidget(), 430 window_.reset(new BrowserBubble(this, shelf_->GetWidget(),
431 gfx::Point(0, 0), 431 gfx::Point(0, 0),
432 false)); // Do not add a drop-shadow. 432 false)); // Do not add a drop-shadow.
433 window_->set_delegate(this); 433 window_->set_delegate(this);
434 } 434 }
435 435
436 gfx::Size window_size = GetPreferredSize(); 436 gfx::Size window_size = GetPreferredSize();
437 if (mole_animation_->IsAnimating()) { 437 if (mole_animation_->is_animating()) {
438 // We only want to animate the body of the mole window. When we're 438 // We only want to animate the body of the mole window. When we're
439 // expanding, this is everything except for the handle. When we're 439 // expanding, this is everything except for the handle. When we're
440 // collapsing, this is everything except for the handle and the toolstrip. 440 // collapsing, this is everything except for the handle and the toolstrip.
441 // We subtract this amount from the target height, figure out the step in 441 // We subtract this amount from the target height, figure out the step in
442 // the animation from the rest, and then add it back in. 442 // the animation from the rest, and then add it back in.
443 int window_offset = shelf_->height(); 443 int window_offset = shelf_->height();
444 if (!mole_animation_->IsShowing()) 444 if (!mole_animation_->IsShowing())
445 window_offset += GetPreferredSize().height(); 445 window_offset += GetPreferredSize().height();
446 else 446 else
447 window_offset += GetHandlePreferredSize().height(); 447 window_offset += GetHandlePreferredSize().height();
448 int h = expanded_height_ - window_offset; 448 int h = expanded_height_ - window_offset;
449 window_size.set_height(window_offset + 449 window_size.set_height(window_offset +
450 static_cast<int>(h * mole_animation_->GetCurrentValue())); 450 static_cast<int>(h * mole_animation_->GetCurrentValue()));
451 } else if (!expanded_ && !dragging_) { 451 } else if (!expanded_ && !dragging_) {
452 window_size.set_height(GetHandlePreferredSize().height()); 452 window_size.set_height(GetHandlePreferredSize().height());
453 } 453 }
454 454
455 // Now figure out where to place the window on the screen. Since it's a top- 455 // Now figure out where to place the window on the screen. Since it's a top-
456 // level widget, we need to do some coordinate conversion to get this right. 456 // level widget, we need to do some coordinate conversion to get this right.
457 gfx::Point origin(-kToolstripPadding, 0); 457 gfx::Point origin(-kToolstripPadding, 0);
458 if (expanded_ || mole_animation_->IsAnimating()) { 458 if (expanded_ || mole_animation_->is_animating()) {
459 origin.set_y(GetShelfView()->height() - window_size.height()); 459 origin.set_y(GetShelfView()->height() - window_size.height());
460 views::View::ConvertPointToView(GetShelfView(), shelf_->GetRootView(), 460 views::View::ConvertPointToView(GetShelfView(), shelf_->GetRootView(),
461 &origin); 461 &origin);
462 } else { 462 } else {
463 origin.set_y(-(window_size.height() + kToolstripPadding - 1)); 463 origin.set_y(-(window_size.height() + kToolstripPadding - 1));
464 views::View::ConvertPointToWidget(view(), &origin); 464 views::View::ConvertPointToWidget(view(), &origin);
465 } 465 }
466 SetBounds(0, 0, window_size.width(), window_size.height()); 466 SetBounds(0, 0, window_size.width(), window_size.height());
467 window_->SetBounds(origin.x(), origin.y(), 467 window_->SetBounds(origin.x(), origin.y(),
468 window_size.width(), window_size.height()); 468 window_size.width(), window_size.height());
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 if (handle_visible()) 658 if (handle_visible())
659 return; 659 return;
660 MessageLoop::current()->PostDelayedTask(FROM_HERE, 660 MessageLoop::current()->PostDelayedTask(FROM_HERE,
661 timer_factory_.NewRunnableMethod( 661 timer_factory_.NewRunnableMethod(
662 &ExtensionShelf::Toolstrip::DoShowShelfHandle), 662 &ExtensionShelf::Toolstrip::DoShowShelfHandle),
663 kShowDelayMs); 663 kShowDelayMs);
664 } 664 }
665 665
666 void ExtensionShelf::Toolstrip::HideShelfHandle(int delay_ms) { 666 void ExtensionShelf::Toolstrip::HideShelfHandle(int delay_ms) {
667 StopHandleTimer(); 667 StopHandleTimer();
668 if (!handle_visible() || dragging_ || mole_animation_->IsAnimating()) 668 if (!handle_visible() || dragging_ || mole_animation_->is_animating())
669 return; 669 return;
670 if (delay_ms) { 670 if (delay_ms) {
671 MessageLoop::current()->PostDelayedTask(FROM_HERE, 671 MessageLoop::current()->PostDelayedTask(FROM_HERE,
672 timer_factory_.NewRunnableMethod( 672 timer_factory_.NewRunnableMethod(
673 &ExtensionShelf::Toolstrip::DoHideShelfHandle), 673 &ExtensionShelf::Toolstrip::DoHideShelfHandle),
674 delay_ms); 674 delay_ms);
675 } else { 675 } else {
676 DoHideShelfHandle(); 676 DoHideShelfHandle();
677 } 677 }
678 } 678 }
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 } 1095 }
1096 1096
1097 void ExtensionShelf::OnFullscreenToggled(bool fullscreen) { 1097 void ExtensionShelf::OnFullscreenToggled(bool fullscreen) {
1098 if (fullscreen == fullscreen_) 1098 if (fullscreen == fullscreen_)
1099 return; 1099 return;
1100 fullscreen_ = fullscreen; 1100 fullscreen_ = fullscreen;
1101 if (!IsAlwaysShown()) 1101 if (!IsAlwaysShown())
1102 return; 1102 return;
1103 size_animation_->Reset(fullscreen ? 0 : 1); 1103 size_animation_->Reset(fullscreen ? 0 : 1);
1104 } 1104 }
OLDNEW
« no previous file with comments | « chrome/browser/views/dropdown_bar_host.cc ('k') | chrome/browser/views/frame/browser_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698