diff options
author | jcivelli@chromium.org <jcivelli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-23 21:45:43 +0000 |
---|---|---|
committer | jcivelli@chromium.org <jcivelli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-23 21:45:43 +0000 |
commit | f4481633ac082f136453be1926c77d0c079b10c4 (patch) | |
tree | c5eacd0695e35a513c8e5b0b3d291b4463117797 /chrome | |
parent | 6f3ad64a8dae4529cd88358f6d91d8750b836367 (diff) | |
download | chromium_src-f4481633ac082f136453be1926c77d0c079b10c4.zip chromium_src-f4481633ac082f136453be1926c77d0c079b10c4.tar.gz chromium_src-f4481633ac082f136453be1926c77d0c079b10c4.tar.bz2 |
Some layout related fixes for the app launchers.
BUG=None
TEST=Check that the app launcher is displayed correctly on ChromeOS
and Windows (when using the --app-launcher-new-tab)
Review URL: http://codereview.chromium.org/1171002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42383 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/browser.cc | 2 | ||||
-rw-r--r-- | chrome/browser/chromeos/frame/browser_view.cc | 7 | ||||
-rw-r--r-- | chrome/browser/views/app_launcher.cc | 31 | ||||
-rw-r--r-- | chrome/browser/views/app_launcher.h | 8 | ||||
-rw-r--r-- | chrome/browser/views/tabs/tab_strip.cc | 3 | ||||
-rwxr-xr-x | chrome/chrome_browser.gypi | 2 |
6 files changed, 36 insertions, 17 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 3b77d38..990c6a2 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -1033,7 +1033,7 @@ void Browser::NewTab() { #if defined(OS_WIN) if (CommandLine::ForCurrentProcess()->HasSwitch( switches::kAppLauncherForNewTab)) { - AppLauncher::Show(this); + AppLauncher::ShowForNewTab(this); return; } #endif diff --git a/chrome/browser/chromeos/frame/browser_view.cc b/chrome/browser/chromeos/frame/browser_view.cc index db06e22..e199b02 100644 --- a/chrome/browser/chromeos/frame/browser_view.cc +++ b/chrome/browser/chromeos/frame/browser_view.cc @@ -33,6 +33,7 @@ #include "views/controls/button/button.h" #include "views/controls/button/image_button.h" #include "views/controls/menu/menu_2.h" +#include "views/widget/root_view.h" #include "views/window/hit_test.h" #include "views/window/window.h" @@ -446,7 +447,11 @@ void BrowserView::ShowBookmarkBubble(const GURL& url, bool already_bookmarked) { // views::ButtonListener overrides. void BrowserView::ButtonPressed(views::Button* sender, const views::Event& event) { - AppLauncher::Show(browser()); + gfx::Rect bounds = main_menu_button_->bounds(); + gfx::Point origin = bounds.origin(); + views::RootView::ConvertPointToScreen(this, &origin); + bounds.set_origin(origin); + ::AppLauncher::Show(browser(), bounds); } // views::ContextMenuController overrides. diff --git a/chrome/browser/views/app_launcher.cc b/chrome/browser/views/app_launcher.cc index d787f16..f9c99a8 100644 --- a/chrome/browser/views/app_launcher.cc +++ b/chrome/browser/views/app_launcher.cc @@ -343,13 +343,14 @@ void InfoBubbleContentsView::ViewHierarchyChanged( gfx::Size InfoBubbleContentsView::GetPreferredSize() { gfx::Rect bounds = app_launcher_->browser()->window()->GetRestoredBounds(); - return gfx::Size(bounds.width() * 2 / 3, bounds.width() * 4 / 5); + return gfx::Size(bounds.width() * 2 / 3, bounds.height() * 4 / 5); } void InfoBubbleContentsView::Layout() { if (bounds().IsEmpty() || GetChildViewCount() == 0) return; + gfx::Rect bounds = GetLocalBounds(false); int navigation_bar_height = kNavigationBarHeight + kNavigationEntryYMargin * 2; const views::Border* border = navigation_bar_->border(); @@ -358,11 +359,12 @@ void InfoBubbleContentsView::Layout() { border->GetInsets(&insets); navigation_bar_height += insets.height(); } - navigation_bar_->SetBounds(x(), y(), width(), navigation_bar_height); + navigation_bar_->SetBounds(bounds.x(), bounds.y(), + bounds.width(), navigation_bar_height); int render_y = navigation_bar_->bounds().bottom(); gfx::Size rwhv_size = - gfx::Size(width(), std::max(0, height() - render_y + y())); - render_view_container_->SetBounds(x(), render_y, + gfx::Size(width(), std::max(0, bounds.height() - render_y + bounds.y())); + render_view_container_->SetBounds(bounds.x(), render_y, rwhv_size.width(), rwhv_size.height()); app_launcher_->rwhv_->SetSize(rwhv_size); } @@ -408,24 +410,27 @@ AppLauncher::~AppLauncher() { } // static -AppLauncher* AppLauncher::Show(Browser* browser) { +AppLauncher* AppLauncher::Show(Browser* browser, const gfx::Rect& bounds) { AppLauncher* app_launcher = new AppLauncher(browser); + BrowserView* browser_view = static_cast<BrowserView*>(browser->window()); + app_launcher->info_bubble_ = + InfoBubble::Show(browser_view->frame()->GetWindow(), bounds, + app_launcher->info_bubble_content_, app_launcher); + app_launcher->info_bubble_content_->BubbleShown(); + return app_launcher; +} +// static +AppLauncher* AppLauncher::ShowForNewTab(Browser* browser) { BrowserView* browser_view = static_cast<BrowserView*>(browser->window()); TabStrip* tabstrip = browser_view->tabstrip()->AsTabStrip(); - if (!tabstrip) { - delete app_launcher; + if (!tabstrip) return NULL; - } gfx::Rect bounds = tabstrip->GetNewTabButtonBounds(); gfx::Point origin = bounds.origin(); views::RootView::ConvertPointToScreen(tabstrip, &origin); bounds.set_origin(origin); - app_launcher->info_bubble_ = - InfoBubble::Show(browser_view->frame()->GetWindow(), bounds, - app_launcher->info_bubble_content_, app_launcher); - app_launcher->info_bubble_content_->BubbleShown(); - return app_launcher; + return Show(browser, bounds); } void AppLauncher::Hide() { diff --git a/chrome/browser/views/app_launcher.h b/chrome/browser/views/app_launcher.h index c641988..c98d435 100644 --- a/chrome/browser/views/app_launcher.h +++ b/chrome/browser/views/app_launcher.h @@ -55,10 +55,16 @@ class AppLauncher : public InfoBubbleDelegate, public RenderViewHostDelegate, public RenderViewHostDelegate::View { public: + // Shows an application launcher bubble pointing to the |bounds| (which should + // be in screen coordinates). + // The caller DOES NOT OWN the AppLauncher returned. It is deleted + // automatically when the AppLauncher is closed. + static AppLauncher* Show(Browser* browser, const gfx::Rect& bounds); + // Shows an application launcher bubble pointing to the new tab button. // The caller DOES NOT OWN the AppLauncher returned. It is deleted // automatically when the AppLauncher is closed. - static AppLauncher* Show(Browser* browser); + static AppLauncher* ShowForNewTab(Browser* browser); // Returns the browser this AppLauncher is associated with. Browser* browser() const { return browser_; } diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc index c3da175..e5728af 100644 --- a/chrome/browser/views/tabs/tab_strip.cc +++ b/chrome/browser/views/tabs/tab_strip.cc @@ -1417,7 +1417,8 @@ void TabStrip::ButtonPressed(views::Button* sender, const views::Event& event) { switches::kAppLauncherForNewTab)) { NavigationController& controller = model_->GetSelectedTabContents()->controller(); - AppLauncher::Show(Browser::GetBrowserForController(&controller, NULL)); + AppLauncher::ShowForNewTab(Browser::GetBrowserForController(&controller, + NULL)); return; } UserMetrics::RecordAction(UserMetricsAction("NewTab_Button"), diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 121c4d4..1d981ec 100755 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -2679,6 +2679,8 @@ ['include', '^browser/extensions/'], ['include', '^browser/views/about_chrome_view.cc'], ['include', '^browser/views/about_chrome_view.h'], + ['include', '^browser/views/app_launcher.cc'], + ['include', '^browser/views/app_launcher.h'], ['include', '^browser/views/accelerator_table_gtk.cc'], ['include', '^browser/views/accelerator_table_gtk.h'], ['include', '^browser/views/accessible_toolbar_view.cc'], |