diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-04 21:36:49 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-04 21:36:49 +0000 |
commit | a0c6c257e5715e1e035f831c77ecb02ba209a86c (patch) | |
tree | f297b5e5d71e6d91d5c85779e49a41f34bb840ba | |
parent | e4e141d03e82e4918285711b7658e824e33b5107 (diff) | |
download | chromium_src-a0c6c257e5715e1e035f831c77ecb02ba209a86c.zip chromium_src-a0c6c257e5715e1e035f831c77ecb02ba209a86c.tar.gz chromium_src-a0c6c257e5715e1e035f831c77ecb02ba209a86c.tar.bz2 |
Browser action for compact loc bar, plus several visual fixes.
- added browser action container to compact location bar
- use toolbar background to match with bookmark bar (when visible)
- use given bounds to compute window edge
BUG=32327
TEST=none
Review URL: http://codereview.chromium.org/573017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38133 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/chromeos/browser_view.cc | 1 | ||||
-rw-r--r-- | chrome/browser/chromeos/compact_location_bar_host.cc | 5 | ||||
-rw-r--r-- | chrome/browser/chromeos/compact_location_bar_view.cc | 63 | ||||
-rw-r--r-- | chrome/browser/chromeos/compact_location_bar_view.h | 5 | ||||
-rw-r--r-- | chrome/browser/views/dropdown_bar_host.cc | 7 |
5 files changed, 58 insertions, 23 deletions
diff --git a/chrome/browser/chromeos/browser_view.cc b/chrome/browser/chromeos/browser_view.cc index 8d5d49d..b9c8bbd 100644 --- a/chrome/browser/chromeos/browser_view.cc +++ b/chrome/browser/chromeos/browser_view.cc @@ -416,6 +416,7 @@ void BrowserView::ToggleCompactNavigationBar() { ui_style_ = static_cast<UIStyle>((ui_style_ + 1) % 2); compact_navigation_bar_->SetFocusable(is_compact_style()); compact_location_bar_host_->SetEnabled(is_compact_style()); + compact_location_bar_host_->Hide(false); Layout(); } diff --git a/chrome/browser/chromeos/compact_location_bar_host.cc b/chrome/browser/chromeos/compact_location_bar_host.cc index aafb5fd..56a2fc4 100644 --- a/chrome/browser/chromeos/compact_location_bar_host.cc +++ b/chrome/browser/chromeos/compact_location_bar_host.cc @@ -213,7 +213,8 @@ gfx::Rect CompactLocationBarHost::GetBoundsUnderTab(int index) const { views::View::ConvertPointToWidget(tabstrip, &tab_left_bottom); // The compact location bar must be smaller than browser_width. - int width = std::min(browser_view()->width(), kDefaultLocationBarWidth); + gfx::Size pref_size = view()->GetPreferredSize(); + int width = std::min(browser_view()->width(), pref_size.width()); // Try to center around the tab, or align to the left of the window. // TODO(oshima): handle RTL @@ -229,7 +230,7 @@ gfx::Rect CompactLocationBarHost::GetBoundsUnderTab(int index) const { } else { y = tab_left_bottom.y(); } - return gfx::Rect(x, y, width, 28); + return gfx::Rect(x, y, width, pref_size.height()); } void CompactLocationBarHost::Update(int index, bool animate_x) { diff --git a/chrome/browser/chromeos/compact_location_bar_view.cc b/chrome/browser/chromeos/compact_location_bar_view.cc index eb8f987..16b00c4 100644 --- a/chrome/browser/chromeos/compact_location_bar_view.cc +++ b/chrome/browser/chromeos/compact_location_bar_view.cc @@ -8,6 +8,8 @@ #include <algorithm> #include "app/l10n_util.h" +#include "app/gfx/canvas.h" +#include "app/resource_bundle.h" #include "base/gfx/point.h" #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h" @@ -16,6 +18,7 @@ #include "chrome/browser/chromeos/compact_location_bar_host.h" #include "chrome/browser/profile.h" #include "chrome/browser/view_ids.h" +#include "chrome/browser/views/browser_actions_container.h" #include "chrome/browser/views/event_utils.h" #include "chrome/browser/views/frame/browser_view.h" #include "grit/chromium_strings.h" @@ -28,12 +31,19 @@ #include "views/window/window.h" namespace chromeos { -const int kCompactLocationBarDefaultWidth = 700; +const int kAutocompletePopupWidth = 700; +const int kDefaultLocationEntryWidth = 250; +const int kCompactLocationLeftRightMargin = 5; +const int kEntryLeftMargin = 2; +// TODO(oshima): ToolbarView gets this from background image's height; +// Find out the right way, value for compact location bar. +const int kDefaultLocationBarHeight = 34; CompactLocationBarView::CompactLocationBarView(CompactLocationBarHost* host) : DropdownBarView(host), - reload_(NULL) { - set_background(views::Background::CreateStandardPanelBackground()); + reload_(NULL), + location_entry_view_(NULL), + browser_actions_(NULL) { SetFocusable(true); } @@ -50,6 +60,7 @@ void CompactLocationBarView::SetFocusAndSelection() { void CompactLocationBarView::Update(const TabContents* contents) { location_entry_->Update(contents); + browser_actions_->RefreshBrowserActionViews(); } @@ -67,6 +78,8 @@ void CompactLocationBarView::Init() { // Reload button. reload_ = new views::ImageButton(this); + reload_->SetImageAlignment(views::ImageButton::ALIGN_CENTER, + views::ImageButton::ALIGN_MIDDLE); reload_->set_tag(IDC_RELOAD); reload_->SetTooltipText(l10n_util::GetString(IDS_TOOLTIP_RELOAD)); reload_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_RELOAD)); @@ -100,6 +113,9 @@ void CompactLocationBarView::Init() { // TODO(oshima): Add Star Button location_entry_->Update(browser()->GetSelectedTabContents()); + + browser_actions_ = new BrowserActionsContainer(browser(), this); + AddChildView(browser_actions_); } //////////////////////////////////////////////////////////////////////////////// @@ -109,30 +125,47 @@ gfx::Size CompactLocationBarView::GetPreferredSize() { if (!reload_) return gfx::Size(); // Not initialized yet, do nothing. - gfx::Size sz = reload_->GetPreferredSize(); - - return gfx::Size(500, sz.height()); + gfx::Size reload_size = reload_->GetPreferredSize(); + gfx::Size ba_size = browser_actions_->GetPreferredSize(); + int width = + reload_size.width() + + std::max(kDefaultLocationEntryWidth, + location_entry_view_->GetPreferredSize().width()) + + ba_size.width(); + return gfx::Size(width, kDefaultLocationBarHeight); } void CompactLocationBarView::Layout() { if (!reload_) return; // Not initialized yet, do nothing. - int cur_x = 0; + int cur_x = kCompactLocationLeftRightMargin; gfx::Size sz = reload_->GetPreferredSize(); - reload_->SetBounds(cur_x, 0, sz.width(), sz.height()); - cur_x += sz.width(); - - cur_x += 2; + reload_->SetBounds(cur_x, 0, sz.width(), height()); + cur_x += sz.width() + kEntryLeftMargin; + + gfx::Size ba_size = browser_actions_->GetPreferredSize(); + browser_actions_->SetBounds( + width() - ba_size.width(), 0, ba_size.width(), height()); + int location_entry_width = browser_actions_->x() - cur_x; + if (ba_size.IsEmpty()) { + // BrowserActionsContainer has its own margin on right. + // Use the our margin when if the browser action is empty. + location_entry_width -= kCompactLocationLeftRightMargin; + } // The location bar gets the rest of the space in the middle. - location_entry_view_->SetBounds(cur_x, 0, width() - cur_x * 2 - 2, height()); - - cur_x = width() - sz.width(); + location_entry_view_->SetBounds(cur_x, 0, location_entry_width, height()); } void CompactLocationBarView::Paint(gfx::Canvas* canvas) { + gfx::Rect lb = GetLocalBounds(true); + ThemeProvider* tp = GetThemeProvider(); + gfx::Rect bounds; + host()->GetThemePosition(&bounds); + canvas->TileImageInt(*tp->GetBitmapNamed(IDR_THEME_TOOLBAR), + bounds.x(), bounds.y(), 0, 0, lb.width(), lb.height()); View::Paint(canvas); } @@ -194,7 +227,7 @@ gfx::Rect CompactLocationBarView::GetLocationStackBounds() const { gfx::Point lower_left(0, height()); ConvertPointToScreen(this, &lower_left); gfx::Rect popup = gfx::Rect(lower_left.x(), lower_left.y(), - kCompactLocationBarDefaultWidth, 0); + kAutocompletePopupWidth, 0); return popup.AdjustToFit(GetWidget()->GetWindow()->GetBounds()); } diff --git a/chrome/browser/chromeos/compact_location_bar_view.h b/chrome/browser/chromeos/compact_location_bar_view.h index 4bf285d..883a17f 100644 --- a/chrome/browser/chromeos/compact_location_bar_view.h +++ b/chrome/browser/chromeos/compact_location_bar_view.h @@ -15,6 +15,7 @@ class AutocompleteEditViewGtk; class Browser; +class BrowserActionsContainer; class BrowserView; class ToolbarStarToggleGtk; class Tab; @@ -84,9 +85,7 @@ class CompactLocationBarView : public DropdownBarView, views::ImageButton* reload_; scoped_ptr<AutocompleteEditViewGtk> location_entry_; views::NativeViewHost* location_entry_view_; - - // scoped_ptr<ToolbarStarToggleGtk> star_; - views::NativeViewHost* star_view_; + BrowserActionsContainer* browser_actions_; DISALLOW_COPY_AND_ASSIGN(CompactLocationBarView); }; diff --git a/chrome/browser/views/dropdown_bar_host.cc b/chrome/browser/views/dropdown_bar_host.cc index 0bcd7aa..768c0a7 100644 --- a/chrome/browser/views/dropdown_bar_host.cc +++ b/chrome/browser/views/dropdown_bar_host.cc @@ -201,14 +201,15 @@ void DropdownBarHost::UpdateWindowEdges(const gfx::Rect& new_pos) { // this to a CustomFrameWindow. int w = new_pos.width() - 6; // -6 positions us at the left edge of the // rightmost background image of the view. + int h = new_pos.height(); // This polygon array represents the outline of the background image for the // window. Basically, it encompasses only the visible pixels of the // concatenated find_dlg_LMR_bg images (where LMR = [left | middle | right]). const Path::Point polygon[] = { - {0, 0}, {0, 1}, {2, 3}, {2, 29}, {4, 31}, - {4, 32}, {w+0, 32}, - {w+0, 31}, {w+1, 31}, {w+3, 29}, {w+3, 3}, {w+6, 0} + {0, 0}, {0, 1}, {2, 3}, {2, h - 3}, {4, h - 1}, + {4, h}, {w+0, h}, + {w+0, h - 1}, {w+1, h - 1}, {w+3, h - 3}, {w+3, 3}, {w+6, 0} }; // Find the largest x and y value in the polygon. |