summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorsidchat@google.com <sidchat@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-04 22:29:58 +0000
committersidchat@google.com <sidchat@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-04 22:29:58 +0000
commitc725116c7999b7a887b23d9bb9863d3429d05577 (patch)
treee4ea15d35c9cd518546b0fa37c550bc6a32901d1 /chrome/browser
parent5bd526dcfd534fca47095ee5806c964d3ae8c53e (diff)
downloadchromium_src-c725116c7999b7a887b23d9bb9863d3429d05577.zip
chromium_src-c725116c7999b7a887b23d9bb9863d3429d05577.tar.gz
chromium_src-c725116c7999b7a887b23d9bb9863d3429d05577.tar.bz2
Make the extension shelf appear on the left of the bookmark bar, instead of on the right.
BUG=http://www.crbug.com/20929 TEST=none Review URL: http://codereview.chromium.org/198002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25533 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/views/bookmark_bar_view.cc37
-rw-r--r--chrome/browser/views/frame/browser_view.cc38
2 files changed, 58 insertions, 17 deletions
diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc
index 6ff5c19..889e910 100644
--- a/chrome/browser/views/bookmark_bar_view.cc
+++ b/chrome/browser/views/bookmark_bar_view.cc
@@ -479,7 +479,35 @@ gfx::Size BookmarkBarView::GetPreferredSize() {
}
gfx::Size BookmarkBarView::GetMinimumSize() {
- return gfx::Size(0, kBarHeight);
+ // The minimum width of the bookmark bar should at least contain the overflow
+ // button, by which one can access all the Bookmark Bar items, and the "Other
+ // Bookmarks" folder, along with appropriate margins and button padding.
+ int width = kLeftMargin;
+
+ if (OnNewTabPage()) {
+ double current_state = 1 - size_animation_->GetCurrentValue();
+ width += 2 * static_cast<int>(static_cast<double>
+ (kNewtabHorizontalPadding) * current_state);
+ }
+
+ int sync_error_total_width = 0;
+#ifdef CHROME_PERSONALIZATION
+ gfx::Size sync_error_button_pref = sync_error_button_->GetPreferredSize();
+ if (ShouldShowSyncErrorButton())
+ sync_error_total_width += kButtonPadding + sync_error_button_pref.width();
+#endif
+
+ gfx::Size other_bookmarked_pref =
+ other_bookmarked_button_->GetPreferredSize();
+ gfx::Size overflow_pref = overflow_button_->GetPreferredSize();
+ gfx::Size bookmarks_separator_pref =
+ bookmarks_separator_view_->GetPreferredSize();
+
+ width += (other_bookmarked_pref.width() + kButtonPadding +
+ overflow_pref.width() + kButtonPadding +
+ bookmarks_separator_pref.width() + sync_error_total_width);
+
+ return gfx::Size(width, kBarHeight);
}
void BookmarkBarView::Layout() {
@@ -720,7 +748,12 @@ void BookmarkBarView::OnStateChanged() {
// When the sync state changes, it is sufficient to invoke View::Layout since
// during layout we query the profile sync service and determine whether the
// new state requires showing the sync error button so that the user can
- // re-enter her password.
+ // re-enter her password. If extension shelf appears along with the bookmark
+ // shelf, it too needs to be layed out. Since both have the same parent, it is
+ // enough to let the parent layout both of these children.
+ // TODO (sky): This should not require Layout() and SchedulePaint(). Needs
+ // some cleanup.
+ PreferredSizeChanged();
Layout();
SchedulePaint();
}
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index c7ee766..490109c 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -109,8 +109,6 @@ static const int kWindowBorderWidth = 5;
// If not -1, windows are shown with this state.
static int explicit_show_state = -1;
-static const float kMinimumBookmarkBarWidthAsRatioOfWidth = 0.5;
-
// How round the 'new tab' style bookmarks bar is.
static const int kNewtabBarRoundness = 5;
// ------------
@@ -1859,8 +1857,15 @@ int BrowserView::LayoutBookmarkAndInfoBars(int top) {
}
int BrowserView::LayoutTopBar(int top) {
+ // This method lays out the the bookmark bar, and, if required, the extension
+ // shelf by its side. The bookmark bar appears on the right of the extension
+ // shelf. If there are too many bookmark items and extension toolstrips to fit
+ // in the single bar, some compromises are made as follows:
+ // 1. The bookmark bar is shrunk till it reaches the minimum width.
+ // 2. After reaching the minimum width, the bookmark bar width is kept fixed -
+ // the extension shelf bar width is reduced.
DCHECK(active_bookmark_bar_);
- int y = top;
+ int y = top, x = 0;
if (!IsBookmarkBarVisible()) {
bookmark_bar_view_->SetVisible(false);
bookmark_bar_view_->SetBounds(0, y, width(), 0);
@@ -1869,7 +1874,6 @@ int BrowserView::LayoutTopBar(int top) {
return y;
}
- int bookmark_bar_width = width();
int bookmark_bar_height = bookmark_bar_view_->GetPreferredSize().height();
y -= kSeparationLineHeight + (bookmark_bar_view_->IsDetachedStyle() ?
0 : bookmark_bar_view_->GetToolbarOverlap(false));
@@ -1880,26 +1884,30 @@ int BrowserView::LayoutTopBar(int top) {
bookmark_bar_height = extensionshelf_height;
if (!bookmark_bar_view_->IsDetachedStyle()) {
- int extension_shelf_min_width =
+ int extension_shelf_width =
extension_shelf_->GetPreferredSize().width();
- bookmark_bar_width -= extension_shelf_min_width;
+ int bookmark_bar_given_width = width() - extension_shelf_width;
int minimum_allowed_bookmark_bar_width =
- static_cast<int>(width() * kMinimumBookmarkBarWidthAsRatioOfWidth);
- if (bookmark_bar_width < minimum_allowed_bookmark_bar_width)
- bookmark_bar_width = minimum_allowed_bookmark_bar_width;
+ bookmark_bar_view_->GetMinimumSize().width();
+ if (bookmark_bar_given_width < minimum_allowed_bookmark_bar_width) {
+ // The bookmark bar cannot compromise on its width any more. The
+ // extension shelf needs to shrink now.
+ extension_shelf_width =
+ width() - minimum_allowed_bookmark_bar_width;
+ }
extension_shelf_->SetVisible(true);
- extension_shelf_->SetBounds(bookmark_bar_width, y,
- width() - bookmark_bar_width,
+ extension_shelf_->SetBounds(x, y, extension_shelf_width,
bookmark_bar_height);
+ x += extension_shelf_width;
} else {
- // TODO (sidchat): For detached style bookmark bar, set the extensions
- // shelf in a better position. Issue = 20741.
- extension_shelf_->SetVisible(false);
+ // TODO (sidchat): For detached style bookmark bar, set the extensions
+ // shelf in a better position. Issue = 20741.
+ extension_shelf_->SetVisible(false);
}
}
bookmark_bar_view_->SetVisible(true);
- bookmark_bar_view_->SetBounds(0, y, bookmark_bar_width, bookmark_bar_height);
+ bookmark_bar_view_->SetBounds(x, y, width() - x, bookmark_bar_height);
return y + bookmark_bar_height;
}