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

Side by Side Diff: chrome/browser/views/bookmark_bar_view.cc

Issue 204022: ExtensionShelf now uses the BookmarkExtensionBackground, just like the Bookma... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 // Icon to display when one isn't found for the page. 74 // Icon to display when one isn't found for the page.
75 static SkBitmap* kDefaultFavIcon = NULL; 75 static SkBitmap* kDefaultFavIcon = NULL;
76 76
77 // Icon used for folders. 77 // Icon used for folders.
78 static SkBitmap* kFolderIcon = NULL; 78 static SkBitmap* kFolderIcon = NULL;
79 79
80 // Border colors for the BookmarBarView. 80 // Border colors for the BookmarBarView.
81 static const SkColor kTopBorderColor = SkColorSetRGB(222, 234, 248); 81 static const SkColor kTopBorderColor = SkColorSetRGB(222, 234, 248);
82 82
83 // How round the 'new tab' style bookmarks bar is.
84 static const int kNewtabBarRoundness = 5;
85
86 // Offset for where the menu is shown relative to the bottom of the 83 // Offset for where the menu is shown relative to the bottom of the
87 // BookmarkBarView. 84 // BookmarkBarView.
88 static const int kMenuOffset = 3; 85 static const int kMenuOffset = 3;
89 86
90 // Delay during drag and drop before the menu pops up. This is only used if 87 // Delay during drag and drop before the menu pops up. This is only used if
91 // we can't get the value from the OS. 88 // we can't get the value from the OS.
92 static const int kShowFolderDropMenuDelay = 400; 89 static const int kShowFolderDropMenuDelay = 400;
93 90
94 // Color of the drop indicator. 91 // Color of the drop indicator.
95 static const SkColor kDropIndicatorColor = SK_ColorBLACK; 92 static const SkColor kDropIndicatorColor = SK_ColorBLACK;
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 }; 287 };
291 288
292 // ButtonSeparatorView -------------------------------------------------------- 289 // ButtonSeparatorView --------------------------------------------------------
293 290
294 class BookmarkBarView::ButtonSeparatorView : public views::View { 291 class BookmarkBarView::ButtonSeparatorView : public views::View {
295 public: 292 public:
296 ButtonSeparatorView() {} 293 ButtonSeparatorView() {}
297 virtual ~ButtonSeparatorView() {} 294 virtual ~ButtonSeparatorView() {}
298 295
299 virtual void Paint(gfx::Canvas* canvas) { 296 virtual void Paint(gfx::Canvas* canvas) {
300 SkPaint paint; 297 DetachableToolbarView::PaintVerticalDivider(
301 paint.setShader(skia::CreateGradientShader(0, 298 canvas, kSeparatorStartX, height(), 1, kTopBorderColor,
302 height() / 2,
303 kTopBorderColor,
304 kSeparatorColor))->safeUnref();
305 SkRect rc = {SkIntToScalar(kSeparatorStartX), SkIntToScalar(0),
306 SkIntToScalar(1), SkIntToScalar(height() / 2) };
307 canvas->drawRect(rc, paint);
308
309 SkPaint paint_down;
310 paint_down.setShader(skia::CreateGradientShader(height() / 2,
311 height(),
312 kSeparatorColor, 299 kSeparatorColor,
313 GetThemeProvider()->GetColor(BrowserThemeProvider::COLOR_TOOLBAR) 300 GetThemeProvider()->GetColor(BrowserThemeProvider::COLOR_TOOLBAR));
314 ))->safeUnref();
315 SkRect rc_down = {
316 SkIntToScalar(kSeparatorStartX), SkIntToScalar(height() / 2),
317 SkIntToScalar(1), SkIntToScalar(height() - 1) };
318 canvas->drawRect(rc_down, paint_down);
319 } 301 }
320 302
321 virtual gfx::Size GetPreferredSize() { 303 virtual gfx::Size GetPreferredSize() {
322 // We get the full height of the bookmark bar, so that the height returned 304 // We get the full height of the bookmark bar, so that the height returned
323 // here doesn't matter. 305 // here doesn't matter.
324 return gfx::Size(kSeparatorWidth, 1); 306 return gfx::Size(kSeparatorWidth, 1);
325 } 307 }
326 308
327 virtual bool GetAccessibleName(std::wstring* name) { 309 virtual bool GetAccessibleName(std::wstring* name) {
328 DCHECK(name); 310 DCHECK(name);
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 } 711 }
730 712
731 #ifdef CHROME_PERSONALIZATION 713 #ifdef CHROME_PERSONALIZATION
732 void BookmarkBarView::OnStateChanged() { 714 void BookmarkBarView::OnStateChanged() {
733 // When the sync state changes, it is sufficient to invoke View::Layout since 715 // When the sync state changes, it is sufficient to invoke View::Layout since
734 // during layout we query the profile sync service and determine whether the 716 // during layout we query the profile sync service and determine whether the
735 // new state requires showing the sync error button so that the user can 717 // new state requires showing the sync error button so that the user can
736 // re-enter her password. If extension shelf appears along with the bookmark 718 // re-enter her password. If extension shelf appears along with the bookmark
737 // shelf, it too needs to be layed out. Since both have the same parent, it is 719 // shelf, it too needs to be layed out. Since both have the same parent, it is
738 // enough to let the parent layout both of these children. 720 // enough to let the parent layout both of these children.
739 // TODO (sky): This should not require Layout() and SchedulePaint(). Needs 721 // TODO(sky): This should not require Layout() and SchedulePaint(). Needs
740 // some cleanup. 722 // some cleanup.
741 PreferredSizeChanged(); 723 PreferredSizeChanged();
742 Layout(); 724 Layout();
743 SchedulePaint(); 725 SchedulePaint();
744 } 726 }
745 #endif 727 #endif
746 728
747 void BookmarkBarView::OnFullscreenToggled(bool fullscreen) { 729 void BookmarkBarView::OnFullscreenToggled(bool fullscreen) {
748 if (!fullscreen) 730 if (!fullscreen)
749 size_animation_->Reset(IsAlwaysShown() ? 1 : 0); 731 size_animation_->Reset(IsAlwaysShown() ? 1 : 0);
750 else if (IsAlwaysShown()) 732 else if (IsAlwaysShown())
751 size_animation_->Reset(0); 733 size_animation_->Reset(0);
752 } 734 }
753 735
754 bool BookmarkBarView::IsDetachedStyle() { 736 bool BookmarkBarView::IsDetached() const {
755 return OnNewTabPage() && (size_animation_->GetCurrentValue() != 1); 737 return OnNewTabPage() && (size_animation_->GetCurrentValue() != 1);
756 } 738 }
757 739
758 bool BookmarkBarView::IsAlwaysShown() { 740 bool BookmarkBarView::IsOnTop() const {
741 return true;
742 }
743
744 bool BookmarkBarView::IsAlwaysShown() const {
759 return profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); 745 return profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar);
760 } 746 }
761 747
762 bool BookmarkBarView::OnNewTabPage() { 748 bool BookmarkBarView::OnNewTabPage() const {
763 return (browser_ && browser_->GetSelectedTabContents() && 749 return (browser_ && browser_->GetSelectedTabContents() &&
764 browser_->GetSelectedTabContents()->IsBookmarkBarAlwaysVisible()); 750 browser_->GetSelectedTabContents()->IsBookmarkBarAlwaysVisible());
765 } 751 }
766 752
767 int BookmarkBarView::GetToolbarOverlap(bool return_max) { 753 int BookmarkBarView::GetToolbarOverlap(bool return_max) {
768 return static_cast<int>(kToolbarOverlap * 754 return static_cast<int>(kToolbarOverlap *
769 (return_max ? 1.0 : size_animation_->GetCurrentValue())); 755 (return_max ? 1.0 : size_animation_->GetCurrentValue()));
770 } 756 }
771 757
772 void BookmarkBarView::AnimationProgressed(const Animation* animation) { 758 void BookmarkBarView::AnimationProgressed(const Animation* animation) {
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 gfx::NativeView hwnd) { 1069 gfx::NativeView hwnd) {
1084 const BookmarkNode* node; 1070 const BookmarkNode* node;
1085 MenuItemView::AnchorPosition anchor_point = MenuItemView::TOPLEFT; 1071 MenuItemView::AnchorPosition anchor_point = MenuItemView::TOPLEFT;
1086 1072
1087 // When we set the menu's position, we must take into account the mirrored 1073 // When we set the menu's position, we must take into account the mirrored
1088 // position of the View relative to its parent. This can be easily done by 1074 // position of the View relative to its parent. This can be easily done by
1089 // passing the right flag to View::x(). 1075 // passing the right flag to View::x().
1090 int x = view->GetX(APPLY_MIRRORING_TRANSFORMATION); 1076 int x = view->GetX(APPLY_MIRRORING_TRANSFORMATION);
1091 int bar_height = height() - kMenuOffset; 1077 int bar_height = height() - kMenuOffset;
1092 1078
1093 if (IsDetachedStyle()) 1079 if (IsDetached())
1094 bar_height -= kNewtabVerticalPadding; 1080 bar_height -= kNewtabVerticalPadding;
1095 1081
1096 int start_index = 0; 1082 int start_index = 0;
1097 if (view == other_bookmarked_button_) { 1083 if (view == other_bookmarked_button_) {
1098 UserMetrics::RecordAction(L"BookmarkBar_ShowOtherBookmarks", profile_); 1084 UserMetrics::RecordAction(L"BookmarkBar_ShowOtherBookmarks", profile_);
1099 1085
1100 node = model_->other_node(); 1086 node = model_->other_node();
1101 if (UILayoutIsRightToLeft()) 1087 if (UILayoutIsRightToLeft())
1102 anchor_point = MenuItemView::TOPLEFT; 1088 anchor_point = MenuItemView::TOPLEFT;
1103 else 1089 else
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
1678 height); 1664 height);
1679 } 1665 }
1680 x += other_bookmarked_pref.width() + kButtonPadding; 1666 x += other_bookmarked_pref.width() + kButtonPadding;
1681 1667
1682 #ifdef CHROME_PERSONALIZATION 1668 #ifdef CHROME_PERSONALIZATION
1683 // Set the real bounds of the sync error button only if it needs to appear on 1669 // Set the real bounds of the sync error button only if it needs to appear on
1684 // the bookmarks bar. 1670 // the bookmarks bar.
1685 if (should_show_sync_error_button) { 1671 if (should_show_sync_error_button) {
1686 x += kButtonPadding; 1672 x += kButtonPadding;
1687 if (!compute_bounds_only) { 1673 if (!compute_bounds_only) {
1688 sync_error_button_->SetBounds(x, y, sync_error_button_pref.width(), height ); 1674 sync_error_button_->SetBounds(
1675 x, y, sync_error_button_pref.width(), height);
1689 sync_error_button_->SetVisible(true); 1676 sync_error_button_->SetVisible(true);
1690 } 1677 }
1691 x += sync_error_button_pref.width(); 1678 x += sync_error_button_pref.width();
1692 } else if (!compute_bounds_only) { 1679 } else if (!compute_bounds_only) {
1693 sync_error_button_->SetBounds(x, y, 0, height); 1680 sync_error_button_->SetBounds(x, y, 0, height);
1694 sync_error_button_->SetVisible(false); 1681 sync_error_button_->SetVisible(false);
1695 } 1682 }
1696 #endif 1683 #endif
1697 1684
1698 // Set the preferred size computed so far. 1685 // Set the preferred size computed so far.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1742 sync_error_button->SetTooltipText( 1729 sync_error_button->SetTooltipText(
1743 l10n_util::GetString(IDS_SYNC_BOOKMARK_BAR_ERROR_DESC)); 1730 l10n_util::GetString(IDS_SYNC_BOOKMARK_BAR_ERROR_DESC));
1744 sync_error_button->SetAccessibleName( 1731 sync_error_button->SetAccessibleName(
1745 l10n_util::GetString(IDS_ACCNAME_SYNC_ERROR_BUTTON)); 1732 l10n_util::GetString(IDS_ACCNAME_SYNC_ERROR_BUTTON));
1746 sync_error_button->SetIcon( 1733 sync_error_button->SetIcon(
1747 *ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_WARNING)); 1734 *ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_WARNING));
1748 return sync_error_button; 1735 return sync_error_button;
1749 } 1736 }
1750 #endif 1737 #endif
1751 1738
OLDNEW
« no previous file with comments | « chrome/browser/views/bookmark_bar_view.h ('k') | chrome/browser/views/extensions/extension_shelf.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698