| OLD | NEW |
| 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/toolbar_view.h" | 5 #include "chrome/browser/views/toolbar_view.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "chrome/app/chrome_dll_resource.h" | 9 #include "chrome/app/chrome_dll_resource.h" |
| 10 #include "chrome/browser/browser.h" | 10 #include "chrome/browser/browser.h" |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 transparent.allocPixels(); | 640 transparent.allocPixels(); |
| 641 transparent.eraseARGB(0, 0, 0, 0); | 641 transparent.eraseARGB(0, 0, 0, 0); |
| 642 badge = SkBitmapOperations::CreateBlendedBitmap( | 642 badge = SkBitmapOperations::CreateBlendedBitmap( |
| 643 *dot, transparent, 1.0 - update_reminder_animation_->GetCurrentValue()); | 643 *dot, transparent, 1.0 - update_reminder_animation_->GetCurrentValue()); |
| 644 if (update_reminder_animation_->GetCurrentValue() == 1.0) | 644 if (update_reminder_animation_->GetCurrentValue() == 1.0) |
| 645 has_faded_in = true; | 645 has_faded_in = true; |
| 646 } else { | 646 } else { |
| 647 // Convert animation values that start from 0.0 and incrementally go | 647 // Convert animation values that start from 0.0 and incrementally go |
| 648 // up to 1.0 into values that start in 0.0, go to 1.0 and then back | 648 // up to 1.0 into values that start in 0.0, go to 1.0 and then back |
| 649 // to 0.0 (to create a pulsing effect). | 649 // to 0.0 (to create a pulsing effect). |
| 650 double value = 1.0 - | 650 double value = |
| 651 abs(2.0 * update_reminder_animation_->GetCurrentValue() - | 651 1.0 - abs(2.0 * update_reminder_animation_->GetCurrentValue() - 1.0); |
| 652 1.0); | |
| 653 | 652 |
| 654 // Add the badge to it. | 653 // Add the badge to it. |
| 655 badge = SkBitmapOperations::CreateBlendedBitmap( | 654 badge = SkBitmapOperations::CreateBlendedBitmap( |
| 656 *tp->GetBitmapNamed(IDR_UPGRADE_DOT_INACTIVE), | 655 *tp->GetBitmapNamed(IDR_UPGRADE_DOT_INACTIVE), |
| 657 *tp->GetBitmapNamed(IDR_UPGRADE_DOT_ACTIVE), | 656 *tp->GetBitmapNamed(IDR_UPGRADE_DOT_ACTIVE), |
| 658 value); | 657 value); |
| 659 } | 658 } |
| 660 | 659 |
| 661 canvas->DrawBitmapInt(badge, kUpgradeDotOffset, | 660 canvas->DrawBitmapInt(badge, kUpgradeDotOffset, |
| 662 icon.height() - badge.height()); | 661 icon.height() - badge.height()); |
| 663 | 662 |
| 664 return canvas->ExtractBitmap(); | 663 return canvas->ExtractBitmap(); |
| 665 } | 664 } |
| 666 | |
| 667 void ToolbarView::ActivateMenuButton(views::MenuButton* menu_button) { | |
| 668 #if defined(OS_WIN) | |
| 669 // On Windows, we have to explicitly clear the focus before opening | |
| 670 // the pop-up menu, then set the focus again when it closes. | |
| 671 GetFocusManager()->ClearFocus(); | |
| 672 #elif defined(OS_LINUX) | |
| 673 // Under GTK, opening a pop-up menu causes the main window to lose focus. | |
| 674 // Focus is automatically returned when the menu closes. | |
| 675 // | |
| 676 // Make sure that the menu button being activated has focus, so that | |
| 677 // when the user escapes from the menu without selecting anything, focus | |
| 678 // will be returned here. | |
| 679 if (!menu_button->HasFocus()) { | |
| 680 menu_button->RequestFocus(); | |
| 681 GetFocusManager()->StoreFocusedView(); | |
| 682 } | |
| 683 #endif | |
| 684 | |
| 685 // Tell the menu button to activate, opening its pop-up menu. | |
| 686 menu_button->Activate(); | |
| 687 | |
| 688 #if defined(OS_WIN) | |
| 689 SetToolbarFocus(NULL, menu_button); | |
| 690 #endif | |
| 691 } | |
| OLD | NEW |