| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/bookmark_bar_view.h" | 5 #include "chrome/browser/views/bookmark_bar_view.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "app/gfx/canvas.h" | 9 #include "app/gfx/canvas.h" |
| 10 #include "app/gfx/text_elider.h" | 10 #include "app/gfx/text_elider.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 // Margins around the content. | 61 // Margins around the content. |
| 62 static const int kTopMargin = 1; | 62 static const int kTopMargin = 1; |
| 63 static const int kBottomMargin = 2; | 63 static const int kBottomMargin = 2; |
| 64 static const int kLeftMargin = 1; | 64 static const int kLeftMargin = 1; |
| 65 static const int kRightMargin = 1; | 65 static const int kRightMargin = 1; |
| 66 | 66 |
| 67 // Preferred height of the bookmarks bar. | 67 // Preferred height of the bookmarks bar. |
| 68 static const int kBarHeight = 29; | 68 static const int kBarHeight = 29; |
| 69 | 69 |
| 70 // Preferred height of the bookmarks bar when only shown on the new tab page. | 70 // Preferred height of the bookmarks bar when only shown on the new tab page. |
| 71 static const int kNewtabBarHeight = 57; | 71 const int BookmarkBarView::kNewtabBarHeight = 57; |
| 72 | 72 |
| 73 // How inset the bookmarks bar is when displayed on the new tab page. This is | 73 // How inset the bookmarks bar is when displayed on the new tab page. This is |
| 74 // in addition to the margins above. | 74 // in addition to the margins above. |
| 75 static const int kNewtabHorizontalPadding = 8; | 75 static const int kNewtabHorizontalPadding = 8; |
| 76 static const int kNewtabVerticalPadding = 12; | 76 static const int kNewtabVerticalPadding = 12; |
| 77 | 77 |
| 78 // Padding between buttons. | 78 // Padding between buttons. |
| 79 static const int kButtonPadding = 0; | 79 static const int kButtonPadding = 0; |
| 80 | 80 |
| 81 // Command ids used in the menu allowing the user to choose when we're visible. | 81 // Command ids used in the menu allowing the user to choose when we're visible. |
| 82 static const int kAlwaysShowCommandID = 1; | 82 static const int kAlwaysShowCommandID = 1; |
| 83 | 83 |
| 84 // Icon to display when one isn't found for the page. | 84 // Icon to display when one isn't found for the page. |
| 85 static SkBitmap* kDefaultFavIcon = NULL; | 85 static SkBitmap* kDefaultFavIcon = NULL; |
| 86 | 86 |
| 87 // Icon used for folders. | 87 // Icon used for folders. |
| 88 static SkBitmap* kFolderIcon = NULL; | 88 static SkBitmap* kFolderIcon = NULL; |
| 89 | 89 |
| 90 // Border colors for the BookmarBarView. | 90 // Border colors for the BookmarBarView. |
| 91 static const SkColor kTopBorderColor = SkColorSetRGB(222, 234, 248); | 91 static const SkColor kTopBorderColor = SkColorSetRGB(222, 234, 248); |
| 92 | 92 |
| 93 // Background color for when the bookmarks bar is only being displayed on the | |
| 94 // new tab page - this color should match the background color of the new tab | |
| 95 // page (white, most likely). | |
| 96 static const SkColor kNewtabBackgroundColor = SkColorSetRGB(255, 255, 255); | |
| 97 | |
| 98 // Border color for the 'new tab' style bookmarks bar. | 93 // Border color for the 'new tab' style bookmarks bar. |
| 99 static const SkColor kNewtabBorderColor = SkColorSetRGB(195, 206, 224); | 94 static const SkColor kNewtabBorderColor = SkColorSetRGB(195, 206, 224); |
| 100 | 95 |
| 101 // How round the 'new tab' style bookmarks bar is. | 96 // How round the 'new tab' style bookmarks bar is. |
| 102 static const int kNewtabBarRoundness = 5; | 97 static const int kNewtabBarRoundness = 5; |
| 103 | 98 |
| 104 // Offset for where the menu is shown relative to the bottom of the | 99 // Offset for where the menu is shown relative to the bottom of the |
| 105 // BookmarkBarView. | 100 // BookmarkBarView. |
| 106 static const int kMenuOffset = 3; | 101 static const int kMenuOffset = 3; |
| 107 | 102 |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 // We only layout while parented. When we become parented, if our bounds | 552 // We only layout while parented. When we become parented, if our bounds |
| 558 // haven't changed, DidChangeBounds won't get invoked and we won't layout. | 553 // haven't changed, DidChangeBounds won't get invoked and we won't layout. |
| 559 // Therefore we always force a layout when added. | 554 // Therefore we always force a layout when added. |
| 560 Layout(); | 555 Layout(); |
| 561 } | 556 } |
| 562 } | 557 } |
| 563 | 558 |
| 564 void BookmarkBarView::Paint(gfx::Canvas* canvas) { | 559 void BookmarkBarView::Paint(gfx::Canvas* canvas) { |
| 565 if (IsDetachedStyle()) { | 560 if (IsDetachedStyle()) { |
| 566 // Draw the background to match the new tab page. | 561 // Draw the background to match the new tab page. |
| 567 canvas->FillRectInt(kNewtabBackgroundColor, 0, 0, width(), height()); | 562 ThemeProvider* tp = GetThemeProvider(); |
| 563 canvas->FillRectInt( |
| 564 tp->GetColor(BrowserThemeProvider::COLOR_NTP_BACKGROUND), |
| 565 0, 0, width(), height()); |
| 566 |
| 567 int alignment; |
| 568 if (tp->GetDisplayProperty(BrowserThemeProvider::NTP_BACKGROUND_ALIGNMENT, |
| 569 &alignment)) { |
| 570 if (alignment & BrowserThemeProvider::ALIGN_TOP) { |
| 571 SkBitmap* ntp_background = tp->GetBitmapNamed(IDR_THEME_NTP_BACKGROUND); |
| 572 |
| 573 if (alignment & BrowserThemeProvider::ALIGN_LEFT) { |
| 574 canvas->DrawBitmapInt(*ntp_background, 0, 0); |
| 575 } else if (alignment & BrowserThemeProvider::ALIGN_RIGHT) { |
| 576 canvas->DrawBitmapInt(*ntp_background, width() - |
| 577 ntp_background->width(), 0); |
| 578 } else { |
| 579 canvas->DrawBitmapInt(*ntp_background, width() / 2- |
| 580 ntp_background->width() / 2, 0); |
| 581 } |
| 582 } |
| 583 } |
| 568 | 584 |
| 569 // Draw the 'bottom' of the toolbar above our bubble. | 585 // Draw the 'bottom' of the toolbar above our bubble. |
| 570 canvas->FillRectInt(ResourceBundle::toolbar_separator_color, | 586 canvas->FillRectInt(ResourceBundle::toolbar_separator_color, |
| 571 0, 0, width(), 1); | 587 0, 0, width(), 1); |
| 572 | 588 |
| 573 SkRect rect; | 589 SkRect rect; |
| 574 | 590 |
| 575 // As 'hidden' according to the animation is the full in-tab state, | 591 // As 'hidden' according to the animation is the full in-tab state, |
| 576 // we invert the value - when current_state is at '0', we expect the | 592 // we invert the value - when current_state is at '0', we expect the |
| 577 // bar to be docked. | 593 // bar to be docked. |
| (...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1534 } | 1550 } |
| 1535 | 1551 |
| 1536 void BookmarkBarView::StopThrobbing(bool immediate) { | 1552 void BookmarkBarView::StopThrobbing(bool immediate) { |
| 1537 if (!throbbing_view_) | 1553 if (!throbbing_view_) |
| 1538 return; | 1554 return; |
| 1539 | 1555 |
| 1540 // If not immediate, cycle through 2 more complete cycles. | 1556 // If not immediate, cycle through 2 more complete cycles. |
| 1541 throbbing_view_->StartThrobbing(immediate ? 0 : 4); | 1557 throbbing_view_->StartThrobbing(immediate ? 0 : 4); |
| 1542 throbbing_view_ = NULL; | 1558 throbbing_view_ = NULL; |
| 1543 } | 1559 } |
| OLD | NEW |