| 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 15 matching lines...) Expand all Loading... |
| 26 #include "grit/chromium_strings.h" | 26 #include "grit/chromium_strings.h" |
| 27 #include "grit/generated_resources.h" | 27 #include "grit/generated_resources.h" |
| 28 #include "gfx/skbitmap_operations.h" | 28 #include "gfx/skbitmap_operations.h" |
| 29 #include "grit/theme_resources.h" | 29 #include "grit/theme_resources.h" |
| 30 #include "views/controls/button/button_dropdown.h" | 30 #include "views/controls/button/button_dropdown.h" |
| 31 #include "views/focus/view_storage.h" | 31 #include "views/focus/view_storage.h" |
| 32 #include "views/widget/tooltip_manager.h" | 32 #include "views/widget/tooltip_manager.h" |
| 33 #include "views/window/non_client_view.h" | 33 #include "views/window/non_client_view.h" |
| 34 #include "views/window/window.h" | 34 #include "views/window/window.h" |
| 35 | 35 |
| 36 static const int kControlHorizOffset = 4; | 36 // The space between items is 4 px in general. |
| 37 static const int kControlVertOffset = 6; | 37 const int ToolbarView::kStandardSpacing = 4; |
| 38 static const int kControlIndent = 3; | 38 // The top of the toolbar has an edge we have to skip over in addition to the 4 |
| 39 // px of spacing. |
| 40 const int ToolbarView::kVertSpacing = kStandardSpacing + 1; |
| 41 // The edge graphics have some built-in spacing/shadowing, so we have to adjust |
| 42 // our spacing to make it still appear to be 4 px. |
| 43 static const int kEdgeSpacing = ToolbarView::kStandardSpacing - 1; |
| 44 // The buttons to the left of the omnibox are close together. |
| 45 static const int kButtonSpacing = 1; |
| 46 |
| 39 static const int kStatusBubbleWidth = 480; | 47 static const int kStatusBubbleWidth = 480; |
| 40 | 48 |
| 41 // The length of time to run the upgrade notification animation (the time it | 49 // The length of time to run the upgrade notification animation (the time it |
| 42 // takes one pulse to run its course and go back to its original brightness). | 50 // takes one pulse to run its course and go back to its original brightness). |
| 43 static const int kPulseDuration = 2000; | 51 static const int kPulseDuration = 2000; |
| 44 | 52 |
| 45 // How long to wait between pulsating the upgrade notifier. | 53 // How long to wait between pulsating the upgrade notifier. |
| 46 static const int kPulsateEveryMs = 8000; | 54 static const int kPulsateEveryMs = 8000; |
| 47 | 55 |
| 48 // The offset in pixels of the upgrade dot on the app menu. | |
| 49 static const int kUpgradeDotOffset = 11; | |
| 50 | |
| 51 // Separation between the location bar and the menus. | |
| 52 static const int kMenuButtonOffset = 3; | |
| 53 | |
| 54 // Padding to the right of the location bar | |
| 55 static const int kPaddingRight = 2; | |
| 56 | |
| 57 static const int kPopupTopSpacingNonGlass = 3; | 56 static const int kPopupTopSpacingNonGlass = 3; |
| 58 static const int kPopupBottomSpacingNonGlass = 2; | 57 static const int kPopupBottomSpacingNonGlass = 2; |
| 59 static const int kPopupBottomSpacingGlass = 1; | 58 static const int kPopupBottomSpacingGlass = 1; |
| 60 | 59 |
| 61 static SkBitmap* kPopupBackgroundEdge = NULL; | 60 static SkBitmap* kPopupBackgroundEdge = NULL; |
| 62 | 61 |
| 63 //////////////////////////////////////////////////////////////////////////////// | 62 //////////////////////////////////////////////////////////////////////////////// |
| 64 // ToolbarView, public: | 63 // ToolbarView, public: |
| 65 | 64 |
| 66 ToolbarView::ToolbarView(Browser* browser) | 65 ToolbarView::ToolbarView(Browser* browser) |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 home_->set_triggerable_event_flags(views::Event::EF_LEFT_BUTTON_DOWN | | 147 home_->set_triggerable_event_flags(views::Event::EF_LEFT_BUTTON_DOWN | |
| 149 views::Event::EF_MIDDLE_BUTTON_DOWN); | 148 views::Event::EF_MIDDLE_BUTTON_DOWN); |
| 150 home_->set_tag(IDC_HOME); | 149 home_->set_tag(IDC_HOME); |
| 151 home_->SetTooltipText(l10n_util::GetString(IDS_TOOLTIP_HOME)); | 150 home_->SetTooltipText(l10n_util::GetString(IDS_TOOLTIP_HOME)); |
| 152 home_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_HOME)); | 151 home_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_HOME)); |
| 153 home_->SetID(VIEW_ID_HOME_BUTTON); | 152 home_->SetID(VIEW_ID_HOME_BUTTON); |
| 154 | 153 |
| 155 browser_actions_ = new BrowserActionsContainer(browser_, this); | 154 browser_actions_ = new BrowserActionsContainer(browser_, this); |
| 156 | 155 |
| 157 app_menu_ = new views::MenuButton(NULL, std::wstring(), this, false); | 156 app_menu_ = new views::MenuButton(NULL, std::wstring(), this, false); |
| 157 app_menu_->set_border(NULL); |
| 158 app_menu_->EnableCanvasFlippingForRTLUI(true); | 158 app_menu_->EnableCanvasFlippingForRTLUI(true); |
| 159 app_menu_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_APP)); | 159 app_menu_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_APP)); |
| 160 app_menu_->SetTooltipText(l10n_util::GetStringF(IDS_APPMENU_TOOLTIP, | 160 app_menu_->SetTooltipText(l10n_util::GetStringF(IDS_APPMENU_TOOLTIP, |
| 161 l10n_util::GetString(IDS_PRODUCT_NAME))); | 161 l10n_util::GetString(IDS_PRODUCT_NAME))); |
| 162 app_menu_->SetID(VIEW_ID_APP_MENU); | 162 app_menu_->SetID(VIEW_ID_APP_MENU); |
| 163 | 163 |
| 164 // Catch the case where the window is created after we detect a new version. | 164 // Catch the case where the window is created after we detect a new version. |
| 165 if (Singleton<UpgradeDetector>::get()->notify_upgrade()) | 165 if (Singleton<UpgradeDetector>::get()->notify_upgrade()) |
| 166 ShowUpgradeReminder(); | 166 ShowUpgradeReminder(); |
| 167 | 167 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 DCHECK(model_->input_in_progress() != in_progress); | 274 DCHECK(model_->input_in_progress() != in_progress); |
| 275 | 275 |
| 276 model_->set_input_in_progress(in_progress); | 276 model_->set_input_in_progress(in_progress); |
| 277 location_bar_->Update(NULL); | 277 location_bar_->Update(NULL); |
| 278 } | 278 } |
| 279 | 279 |
| 280 //////////////////////////////////////////////////////////////////////////////// | 280 //////////////////////////////////////////////////////////////////////////////// |
| 281 // ToolbarView, AnimationDelegate implementation: | 281 // ToolbarView, AnimationDelegate implementation: |
| 282 | 282 |
| 283 void ToolbarView::AnimationProgressed(const Animation* animation) { | 283 void ToolbarView::AnimationProgressed(const Animation* animation) { |
| 284 app_menu_->SetIcon(GetAppMenuIcon()); | 284 app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::BS_NORMAL)); |
| 285 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT)); |
| 286 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED)); |
| 285 SchedulePaint(); | 287 SchedulePaint(); |
| 286 } | 288 } |
| 287 | 289 |
| 288 //////////////////////////////////////////////////////////////////////////////// | 290 //////////////////////////////////////////////////////////////////////////////// |
| 289 // ToolbarView, CommandUpdater::CommandObserver implementation: | 291 // ToolbarView, CommandUpdater::CommandObserver implementation: |
| 290 | 292 |
| 291 void ToolbarView::EnabledStateChangedForCommand(int id, bool enabled) { | 293 void ToolbarView::EnabledStateChangedForCommand(int id, bool enabled) { |
| 292 views::Button* button = NULL; | 294 views::Button* button = NULL; |
| 293 switch (id) { | 295 switch (id) { |
| 294 case IDC_BACK: | 296 case IDC_BACK: |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 | 381 |
| 380 void ToolbarView::ExecuteCommand(int command_id) { | 382 void ToolbarView::ExecuteCommand(int command_id) { |
| 381 browser_->ExecuteCommand(command_id); | 383 browser_->ExecuteCommand(command_id); |
| 382 } | 384 } |
| 383 | 385 |
| 384 //////////////////////////////////////////////////////////////////////////////// | 386 //////////////////////////////////////////////////////////////////////////////// |
| 385 // ToolbarView, views::View overrides: | 387 // ToolbarView, views::View overrides: |
| 386 | 388 |
| 387 gfx::Size ToolbarView::GetPreferredSize() { | 389 gfx::Size ToolbarView::GetPreferredSize() { |
| 388 if (IsDisplayModeNormal()) { | 390 if (IsDisplayModeNormal()) { |
| 389 int min_width = kControlIndent + back_->GetPreferredSize().width() + | 391 int min_width = kEdgeSpacing + |
| 390 forward_->GetPreferredSize().width() + kControlHorizOffset + | 392 back_->GetPreferredSize().width() + kButtonSpacing + |
| 391 reload_->GetPreferredSize().width() + kControlHorizOffset + | 393 forward_->GetPreferredSize().width() + kButtonSpacing + |
| 394 reload_->GetPreferredSize().width() + kStandardSpacing + |
| 392 (show_home_button_.GetValue() ? | 395 (show_home_button_.GetValue() ? |
| 393 (home_->GetPreferredSize().width() + kControlHorizOffset) : 0) + | 396 (home_->GetPreferredSize().width() + kButtonSpacing) : 0) + |
| 394 browser_actions_->GetPreferredSize().width() + | 397 browser_actions_->GetPreferredSize().width() + |
| 395 kMenuButtonOffset + | 398 app_menu_->GetPreferredSize().width() + kEdgeSpacing; |
| 396 app_menu_->GetPreferredSize().width() + kPaddingRight; | |
| 397 | 399 |
| 398 static SkBitmap normal_background; | 400 static SkBitmap normal_background; |
| 399 if (normal_background.isNull()) { | 401 if (normal_background.isNull()) { |
| 400 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 402 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 401 normal_background = *rb.GetBitmapNamed(IDR_CONTENT_TOP_CENTER); | 403 normal_background = *rb.GetBitmapNamed(IDR_CONTENT_TOP_CENTER); |
| 402 } | 404 } |
| 403 | 405 |
| 404 return gfx::Size(min_width, normal_background.height()); | 406 return gfx::Size(min_width, normal_background.height()); |
| 405 } | 407 } |
| 406 | 408 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 417 return; | 419 return; |
| 418 | 420 |
| 419 if (!IsDisplayModeNormal()) { | 421 if (!IsDisplayModeNormal()) { |
| 420 int edge_width = (browser_->window() && browser_->window()->IsMaximized()) ? | 422 int edge_width = (browser_->window() && browser_->window()->IsMaximized()) ? |
| 421 0 : kPopupBackgroundEdge->width(); // See Paint(). | 423 0 : kPopupBackgroundEdge->width(); // See Paint(). |
| 422 location_bar_->SetBounds(edge_width, PopupTopSpacing(), | 424 location_bar_->SetBounds(edge_width, PopupTopSpacing(), |
| 423 width() - (edge_width * 2), location_bar_->GetPreferredSize().height()); | 425 width() - (edge_width * 2), location_bar_->GetPreferredSize().height()); |
| 424 return; | 426 return; |
| 425 } | 427 } |
| 426 | 428 |
| 427 int child_y = std::min(kControlVertOffset, height()); | 429 int child_y = std::min(kVertSpacing, height()); |
| 428 // We assume all child elements are the same height. | 430 // We assume all child elements are the same height. |
| 429 int child_height = | 431 int child_height = |
| 430 std::min(back_->GetPreferredSize().height(), height() - child_y); | 432 std::min(back_->GetPreferredSize().height(), height() - child_y); |
| 431 | 433 |
| 432 // If the window is maximized, we extend the back button to the left so that | 434 // If the window is maximized, we extend the back button to the left so that |
| 433 // clicking on the left-most pixel will activate the back button. | 435 // clicking on the left-most pixel will activate the back button. |
| 434 // TODO(abarth): If the window becomes maximized but is not resized, | 436 // TODO(abarth): If the window becomes maximized but is not resized, |
| 435 // then Layout() might not be called and the back button | 437 // then Layout() might not be called and the back button |
| 436 // will be slightly the wrong size. We should force a | 438 // will be slightly the wrong size. We should force a |
| 437 // Layout() in this case. | 439 // Layout() in this case. |
| 438 // http://crbug.com/5540 | 440 // http://crbug.com/5540 |
| 439 int back_width = back_->GetPreferredSize().width(); | 441 int back_width = back_->GetPreferredSize().width(); |
| 440 if (browser_->window() && browser_->window()->IsMaximized()) | 442 if (browser_->window() && browser_->window()->IsMaximized()) |
| 441 back_->SetBounds(0, child_y, back_width + kControlIndent, child_height); | 443 back_->SetBounds(0, child_y, back_width + kEdgeSpacing, child_height); |
| 442 else | 444 else |
| 443 back_->SetBounds(kControlIndent, child_y, back_width, child_height); | 445 back_->SetBounds(kEdgeSpacing, child_y, back_width, child_height); |
| 444 | 446 |
| 445 forward_->SetBounds(back_->x() + back_->width(), child_y, | 447 forward_->SetBounds(back_->x() + back_->width() + kButtonSpacing, |
| 446 forward_->GetPreferredSize().width(), child_height); | 448 child_y, forward_->GetPreferredSize().width(), child_height); |
| 447 | 449 |
| 448 reload_->SetBounds(forward_->x() + forward_->width() + kControlHorizOffset, | 450 reload_->SetBounds(forward_->x() + forward_->width() + kButtonSpacing, |
| 449 child_y, reload_->GetPreferredSize().width(), child_height); | 451 child_y, reload_->GetPreferredSize().width(), child_height); |
| 450 | 452 |
| 451 if (show_home_button_.GetValue()) { | 453 if (show_home_button_.GetValue()) { |
| 452 home_->SetVisible(true); | 454 home_->SetVisible(true); |
| 453 home_->SetBounds(reload_->x() + reload_->width() + kControlHorizOffset, | 455 home_->SetBounds(reload_->x() + reload_->width() + kButtonSpacing, child_y, |
| 454 child_y, home_->GetPreferredSize().width(), child_height); | 456 home_->GetPreferredSize().width(), child_height); |
| 455 } else { | 457 } else { |
| 456 home_->SetVisible(false); | 458 home_->SetVisible(false); |
| 457 home_->SetBounds(reload_->x() + reload_->width(), child_y, 0, child_height); | 459 home_->SetBounds(reload_->x() + reload_->width(), child_y, 0, child_height); |
| 458 } | 460 } |
| 459 | 461 |
| 460 int browser_actions_width = browser_actions_->GetPreferredSize().width(); | 462 int browser_actions_width = browser_actions_->GetPreferredSize().width(); |
| 461 int app_menu_width = app_menu_->GetPreferredSize().width(); | 463 int app_menu_width = app_menu_->GetPreferredSize().width(); |
| 462 int location_x = home_->x() + home_->width() + kControlHorizOffset; | 464 int location_x = home_->x() + home_->width() + kStandardSpacing; |
| 463 int available_width = width() - kPaddingRight - app_menu_width - | 465 int available_width = width() - kEdgeSpacing - app_menu_width - |
| 464 browser_actions_width - kMenuButtonOffset - location_x; | 466 browser_actions_width - location_x; |
| 465 | 467 |
| 466 location_bar_->SetBounds(location_x, child_y, std::max(available_width, 0), | 468 location_bar_->SetBounds(location_x, child_y, std::max(available_width, 0), |
| 467 child_height); | 469 child_height); |
| 468 int next_menu_x = | |
| 469 location_bar_->x() + location_bar_->width() + kMenuButtonOffset; | |
| 470 | 470 |
| 471 browser_actions_->SetBounds(next_menu_x, 0, browser_actions_width, height()); | 471 browser_actions_->SetBounds(location_bar_->x() + location_bar_->width(), 0, |
| 472 browser_actions_width, height()); |
| 472 // The browser actions need to do a layout explicitly, because when an | 473 // The browser actions need to do a layout explicitly, because when an |
| 473 // extension is loaded/unloaded/changed, BrowserActionContainer removes and | 474 // extension is loaded/unloaded/changed, BrowserActionContainer removes and |
| 474 // re-adds everything, regardless of whether it has a page action. For a | 475 // re-adds everything, regardless of whether it has a page action. For a |
| 475 // page action, browser action bounds do not change, as a result of which | 476 // page action, browser action bounds do not change, as a result of which |
| 476 // SetBounds does not do a layout at all. | 477 // SetBounds does not do a layout at all. |
| 477 // TODO(sidchat): Rework the above behavior so that explicit layout is not | 478 // TODO(sidchat): Rework the above behavior so that explicit layout is not |
| 478 // required. | 479 // required. |
| 479 browser_actions_->Layout(); | 480 browser_actions_->Layout(); |
| 480 next_menu_x += browser_actions_width; | |
| 481 | 481 |
| 482 app_menu_->SetBounds(next_menu_x, child_y, app_menu_width, child_height); | 482 app_menu_->SetBounds(browser_actions_->x() + browser_actions_width, child_y, |
| 483 app_menu_width, child_height); |
| 483 } | 484 } |
| 484 | 485 |
| 485 void ToolbarView::Paint(gfx::Canvas* canvas) { | 486 void ToolbarView::Paint(gfx::Canvas* canvas) { |
| 486 View::Paint(canvas); | 487 View::Paint(canvas); |
| 487 | 488 |
| 488 if (IsDisplayModeNormal()) | 489 if (IsDisplayModeNormal()) |
| 489 return; | 490 return; |
| 490 | 491 |
| 491 // In maximized mode, we don't draw the endcaps on the location bar, because | 492 // In maximized mode, we don't draw the endcaps on the location bar, because |
| 492 // when they're flush against the edge of the screen they just look glitchy. | 493 // when they're flush against the edge of the screen they just look glitchy. |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 reload_->SetToggledImage(views::CustomButton::BS_HOT, | 561 reload_->SetToggledImage(views::CustomButton::BS_HOT, |
| 561 tp->GetBitmapNamed(IDR_STOP_H)); | 562 tp->GetBitmapNamed(IDR_STOP_H)); |
| 562 reload_->SetToggledImage(views::CustomButton::BS_PUSHED, | 563 reload_->SetToggledImage(views::CustomButton::BS_PUSHED, |
| 563 tp->GetBitmapNamed(IDR_STOP_P)); | 564 tp->GetBitmapNamed(IDR_STOP_P)); |
| 564 | 565 |
| 565 home_->SetImage(views::CustomButton::BS_NORMAL, tp->GetBitmapNamed(IDR_HOME)); | 566 home_->SetImage(views::CustomButton::BS_NORMAL, tp->GetBitmapNamed(IDR_HOME)); |
| 566 home_->SetImage(views::CustomButton::BS_HOT, tp->GetBitmapNamed(IDR_HOME_H)); | 567 home_->SetImage(views::CustomButton::BS_HOT, tp->GetBitmapNamed(IDR_HOME_H)); |
| 567 home_->SetImage(views::CustomButton::BS_PUSHED, | 568 home_->SetImage(views::CustomButton::BS_PUSHED, |
| 568 tp->GetBitmapNamed(IDR_HOME_P)); | 569 tp->GetBitmapNamed(IDR_HOME_P)); |
| 569 | 570 |
| 570 app_menu_->SetIcon(GetAppMenuIcon()); | 571 app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::BS_NORMAL)); |
| 572 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT)); |
| 573 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED)); |
| 571 } | 574 } |
| 572 | 575 |
| 573 void ToolbarView::ShowUpgradeReminder() { | 576 void ToolbarView::ShowUpgradeReminder() { |
| 574 update_reminder_animation_.reset(new SlideAnimation(this)); | 577 update_reminder_animation_.reset(new SlideAnimation(this)); |
| 575 update_reminder_animation_->SetSlideDuration(kPulseDuration); | 578 update_reminder_animation_->SetSlideDuration(kPulseDuration); |
| 576 | 579 |
| 577 // Then start the recurring timer for pulsating it. | 580 // Then start the recurring timer for pulsating it. |
| 578 upgrade_reminder_pulse_timer_.Start( | 581 upgrade_reminder_pulse_timer_.Start( |
| 579 base::TimeDelta::FromMilliseconds(kPulsateEveryMs), | 582 base::TimeDelta::FromMilliseconds(kPulsateEveryMs), |
| 580 this, &ToolbarView::PulsateUpgradeNotifier); | 583 this, &ToolbarView::PulsateUpgradeNotifier); |
| 581 } | 584 } |
| 582 | 585 |
| 583 void ToolbarView::PulsateUpgradeNotifier() { | 586 void ToolbarView::PulsateUpgradeNotifier() { |
| 584 // Start the pulsating animation. | 587 // Start the pulsating animation. |
| 585 update_reminder_animation_->Reset(0.0); | 588 update_reminder_animation_->Reset(0.0); |
| 586 update_reminder_animation_->Show(); | 589 update_reminder_animation_->Show(); |
| 587 } | 590 } |
| 588 | 591 |
| 589 SkBitmap ToolbarView::GetAppMenuIcon() { | 592 SkBitmap ToolbarView::GetAppMenuIcon(views::CustomButton::ButtonState state) { |
| 590 ThemeProvider* tp = GetThemeProvider(); | 593 ThemeProvider* tp = GetThemeProvider(); |
| 591 | 594 |
| 592 SkBitmap icon = *tp->GetBitmapNamed(IDR_TOOLS); | 595 int id = 0; |
| 596 switch (state) { |
| 597 case views::CustomButton::BS_NORMAL: id = IDR_TOOLS; break; |
| 598 case views::CustomButton::BS_HOT: id = IDR_TOOLS_H; break; |
| 599 case views::CustomButton::BS_PUSHED: id = IDR_TOOLS_P; break; |
| 600 default: NOTREACHED(); break; |
| 601 } |
| 602 SkBitmap icon = *tp->GetBitmapNamed(id); |
| 593 | 603 |
| 594 if (!Singleton<UpgradeDetector>::get()->notify_upgrade()) | 604 if (!Singleton<UpgradeDetector>::get()->notify_upgrade()) |
| 595 return icon; | 605 return icon; |
| 596 | 606 |
| 597 // Draw the chrome app menu icon onto the canvas. | 607 // Draw the chrome app menu icon onto the canvas. |
| 598 scoped_ptr<gfx::CanvasSkia> canvas( | 608 scoped_ptr<gfx::CanvasSkia> canvas( |
| 599 new gfx::CanvasSkia(icon.width(), icon.height(), false)); | 609 new gfx::CanvasSkia(icon.width(), icon.height(), false)); |
| 600 canvas->DrawBitmapInt(icon, 0, 0); | 610 canvas->DrawBitmapInt(icon, 0, 0); |
| 601 | 611 |
| 602 SkBitmap badge; | 612 SkBitmap badge; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 618 double value = | 628 double value = |
| 619 1.0 - abs(2.0 * update_reminder_animation_->GetCurrentValue() - 1.0); | 629 1.0 - abs(2.0 * update_reminder_animation_->GetCurrentValue() - 1.0); |
| 620 | 630 |
| 621 // Add the badge to it. | 631 // Add the badge to it. |
| 622 badge = SkBitmapOperations::CreateBlendedBitmap( | 632 badge = SkBitmapOperations::CreateBlendedBitmap( |
| 623 *tp->GetBitmapNamed(IDR_UPGRADE_DOT_INACTIVE), | 633 *tp->GetBitmapNamed(IDR_UPGRADE_DOT_INACTIVE), |
| 624 *tp->GetBitmapNamed(IDR_UPGRADE_DOT_ACTIVE), | 634 *tp->GetBitmapNamed(IDR_UPGRADE_DOT_ACTIVE), |
| 625 value); | 635 value); |
| 626 } | 636 } |
| 627 | 637 |
| 628 canvas->DrawBitmapInt(badge, kUpgradeDotOffset, | 638 static const int kBadgeLeftSpacing = 8; |
| 629 icon.height() - badge.height()); | 639 static const int kBadgeTopSpacing = 18; |
| 640 canvas->DrawBitmapInt(badge, kBadgeLeftSpacing, kBadgeTopSpacing); |
| 630 | 641 |
| 631 return canvas->ExtractBitmap(); | 642 return canvas->ExtractBitmap(); |
| 632 } | 643 } |
| OLD | NEW |