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

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

Issue 11365075: alternate ntp: tweaks and fixes for bookmark bar in ntp (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/views/bookmarks/bookmark_bar_view.h" 5 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 127
128 // Starting x-coordinate of the separator line within a separator. 128 // Starting x-coordinate of the separator line within a separator.
129 static const int kSeparatorStartX = 2; 129 static const int kSeparatorStartX = 2;
130 130
131 // Left-padding for the instructional text. 131 // Left-padding for the instructional text.
132 static const int kInstructionsPadding = 6; 132 static const int kInstructionsPadding = 6;
133 133
134 // Tag for the 'Other bookmarks' button. 134 // Tag for the 'Other bookmarks' button.
135 static const int kOtherFolderButtonTag = 1; 135 static const int kOtherFolderButtonTag = 1;
136 136
137 // TODO(kuan): change chrome::kNTPBookmarkBarHeight to this new height when
138 // search_ntp replaces ntp4; for now, while both versions exist, this new height
139 // is only needed locally.
140 static const int kSearchNewtabBookmarkBarHeight = 48;
141
137 namespace { 142 namespace {
138 143
139 // BookmarkButton ------------------------------------------------------------- 144 // BookmarkButton -------------------------------------------------------------
140 145
141 // Buttons used for the bookmarks on the bookmark bar. 146 // Buttons used for the bookmarks on the bookmark bar.
142 147
143 class BookmarkButton : public views::TextButton { 148 class BookmarkButton : public views::TextButton {
144 public: 149 public:
145 // The internal view class name. 150 // The internal view class name.
146 static const char kViewClassName[]; 151 static const char kViewClassName[];
(...skipping 1505 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 gfx::Size bookmarks_separator_pref = 1657 gfx::Size bookmarks_separator_pref =
1653 bookmarks_separator_view_->GetPreferredSize(); 1658 bookmarks_separator_view_->GetPreferredSize();
1654 1659
1655 int max_x = width - overflow_pref.width() - kButtonPadding - 1660 int max_x = width - overflow_pref.width() - kButtonPadding -
1656 bookmarks_separator_pref.width(); 1661 bookmarks_separator_pref.width();
1657 if (other_bookmarked_button_->visible()) 1662 if (other_bookmarked_button_->visible())
1658 max_x -= other_bookmarked_pref.width() + kButtonPadding; 1663 max_x -= other_bookmarked_pref.width() + kButtonPadding;
1659 1664
1660 // Next, layout out the buttons. Any buttons that are placed beyond the 1665 // Next, layout out the buttons. Any buttons that are placed beyond the
1661 // visible region and made invisible. 1666 // visible region and made invisible.
1662 if (GetBookmarkButtonCount() == 0 && model_ && model_->IsLoaded()) { 1667 if (GetBookmarkButtonCount() == 0 && model_ && model_->IsLoaded() &&
1668 !browser_->search_model()->mode().is_ntp()) {
1663 gfx::Size pref = instructions_->GetPreferredSize(); 1669 gfx::Size pref = instructions_->GetPreferredSize();
1664 if (!compute_bounds_only) { 1670 if (!compute_bounds_only) {
1665 instructions_->SetBounds( 1671 instructions_->SetBounds(
1666 x + kInstructionsPadding, y, 1672 x + kInstructionsPadding, y,
1667 std::min(static_cast<int>(pref.width()), 1673 std::min(static_cast<int>(pref.width()),
1668 max_x - x), 1674 max_x - x),
1669 height); 1675 height);
1670 instructions_->SetVisible(true); 1676 instructions_->SetVisible(true);
1671 } 1677 }
1672 } else { 1678 } else {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1722 height); 1728 height);
1723 } 1729 }
1724 x += other_bookmarked_pref.width() + kButtonPadding; 1730 x += other_bookmarked_pref.width() + kButtonPadding;
1725 } 1731 }
1726 1732
1727 // Set the preferred size computed so far. 1733 // Set the preferred size computed so far.
1728 if (compute_bounds_only) { 1734 if (compute_bounds_only) {
1729 x += kRightMargin; 1735 x += kRightMargin;
1730 prefsize.set_width(x); 1736 prefsize.set_width(x);
1731 if (IsDetached()) { 1737 if (IsDetached()) {
1738 int ntp_bookmark_bar_height = browser_->search_model()->mode().is_ntp() ?
1739 kSearchNewtabBookmarkBarHeight : chrome::kNTPBookmarkBarHeight;
1732 x += static_cast<int>( 1740 x += static_cast<int>(
1733 kNewtabHorizontalPadding * (1 - size_animation_->GetCurrentValue())); 1741 kNewtabHorizontalPadding * (1 - size_animation_->GetCurrentValue()));
1734 prefsize.set_height( 1742 prefsize.set_height(
1735 browser_defaults::kBookmarkBarHeight + 1743 browser_defaults::kBookmarkBarHeight +
1736 static_cast<int>( 1744 static_cast<int>(
1737 (chrome::kNTPBookmarkBarHeight - 1745 (ntp_bookmark_bar_height -
1738 browser_defaults::kBookmarkBarHeight) * 1746 browser_defaults::kBookmarkBarHeight) *
1739 (1 - size_animation_->GetCurrentValue()))); 1747 (1 - size_animation_->GetCurrentValue())));
1740 } else { 1748 } else {
1741 prefsize.set_height( 1749 prefsize.set_height(
1742 static_cast<int>( 1750 static_cast<int>(
1743 browser_defaults::kBookmarkBarHeight * 1751 browser_defaults::kBookmarkBarHeight *
1744 size_animation_->GetCurrentValue())); 1752 size_animation_->GetCurrentValue()));
1745 } 1753 }
1746 } 1754 }
1747 return prefsize; 1755 return prefsize;
1748 } 1756 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/search_ui.cc ('k') | chrome/browser/ui/views/detachable_toolbar_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698