summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-25 21:40:18 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-25 21:40:18 +0000
commite77afc6699476ded4adc76456627bc6bce8f75ef (patch)
tree337a6106b95dd140ba2244cedb0fed5aa38989b1 /chrome/browser/ui
parentf9b019c1beba3877b4fb59b335b363b2a3a4c57b (diff)
downloadchromium_src-e77afc6699476ded4adc76456627bc6bce8f75ef.zip
chromium_src-e77afc6699476ded4adc76456627bc6bce8f75ef.tar.gz
chromium_src-e77afc6699476ded4adc76456627bc6bce8f75ef.tar.bz2
Makes the other bookmark button on the bookmark bar visible only if it
contains something. BUG=64997 TEST=none Review URL: http://codereview.chromium.org/6264011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72549 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui')
-rw-r--r--chrome/browser/ui/views/bookmark_bar_view.cc31
1 files changed, 21 insertions, 10 deletions
diff --git a/chrome/browser/ui/views/bookmark_bar_view.cc b/chrome/browser/ui/views/bookmark_bar_view.cc
index 456f92d..5e76410 100644
--- a/chrome/browser/ui/views/bookmark_bar_view.cc
+++ b/chrome/browser/ui/views/bookmark_bar_view.cc
@@ -974,6 +974,8 @@ void BookmarkBarView::Loaded(BookmarkModel* model) {
for (int i = 0, child_count = node->GetChildCount(); i < child_count; ++i)
AddChildView(i, CreateBookmarkButton(node->GetChild(i)));
UpdateColors();
+ other_bookmarked_button_->SetVisible(
+ model->other_node()->GetChildCount() > 0);
other_bookmarked_button_->SetEnabled(true);
Layout();
@@ -1011,6 +1013,8 @@ void BookmarkBarView::BookmarkNodeAdded(BookmarkModel* model,
void BookmarkBarView::BookmarkNodeAddedImpl(BookmarkModel* model,
const BookmarkNode* parent,
int index) {
+ other_bookmarked_button_->SetVisible(
+ model->other_node()->GetChildCount() > 0);
NotifyModelChanged();
if (parent != model_->GetBookmarkBarNode()) {
// We only care about nodes on the bookmark bar.
@@ -1037,6 +1041,9 @@ void BookmarkBarView::BookmarkNodeRemoved(BookmarkModel* model,
void BookmarkBarView::BookmarkNodeRemovedImpl(BookmarkModel* model,
const BookmarkNode* parent,
int index) {
+ other_bookmarked_button_->SetVisible(
+ model->other_node()->GetChildCount() > 0);
+
StopThrobbing(true);
// No need to start throbbing again as the bookmark bubble can't be up at
// the same time as the user reorders.
@@ -1560,9 +1567,9 @@ void BookmarkBarView::StartThrobbing(const BookmarkNode* node,
}
int BookmarkBarView::GetBookmarkButtonCount() {
- // We contain at least four non-bookmark button views: other bookmarks,
- // bookmarks separator, chevrons (for overflow), the instruction label and
- // the sync error button.
+ // We contain five non-bookmark button views: other bookmarks, bookmarks
+ // separator, chevrons (for overflow), the instruction label and the sync
+ // error button.
return GetChildViewCount() - 5;
}
@@ -1614,7 +1621,8 @@ gfx::Size BookmarkBarView::LayoutItems(bool compute_bounds_only) {
}
gfx::Size other_bookmarked_pref =
- other_bookmarked_button_->GetPreferredSize();
+ other_bookmarked_button_->IsVisible() ?
+ other_bookmarked_button_->GetPreferredSize() : gfx::Size();
gfx::Size overflow_pref = overflow_button_->GetPreferredSize();
gfx::Size bookmarks_separator_pref =
bookmarks_separator_view_->GetPreferredSize();
@@ -1624,9 +1632,10 @@ gfx::Size BookmarkBarView::LayoutItems(bool compute_bounds_only) {
if (sync_ui_util::ShouldShowSyncErrorButton(sync_service_)) {
sync_error_total_width += kButtonPadding + sync_error_button_pref.width();
}
- const int max_x = width - other_bookmarked_pref.width() - kButtonPadding -
- overflow_pref.width() - kButtonPadding -
+ int max_x = width - overflow_pref.width() - kButtonPadding -
bookmarks_separator_pref.width() - sync_error_total_width;
+ if (other_bookmarked_button_->IsVisible())
+ max_x -= other_bookmarked_pref.width() + kButtonPadding;
// Next, layout out the buttons. Any buttons that are placed beyond the
// visible region and made invisible.
@@ -1686,11 +1695,13 @@ gfx::Size BookmarkBarView::LayoutItems(bool compute_bounds_only) {
x += bookmarks_separator_pref.width();
// The other bookmarks button.
- if (!compute_bounds_only) {
- other_bookmarked_button_->SetBounds(x, y, other_bookmarked_pref.width(),
- height);
+ if (other_bookmarked_button_->IsVisible()) {
+ if (!compute_bounds_only) {
+ other_bookmarked_button_->SetBounds(x, y, other_bookmarked_pref.width(),
+ height);
+ }
+ x += other_bookmarked_pref.width() + kButtonPadding;
}
- x += other_bookmarked_pref.width() + kButtonPadding;
// Set the real bounds of the sync error button only if it needs to appear on
// the bookmarks bar.