summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/browser_toolbar_gtk.cc
diff options
context:
space:
mode:
authordeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-27 08:13:43 +0000
committerdeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-27 08:13:43 +0000
commitaa90e58c7e88cbcae7e4a7667e047c320a3fc0aa (patch)
treeb5941c6472ea95896937f83548d06941b48af26d /chrome/browser/gtk/browser_toolbar_gtk.cc
parent1b24f85903fca15bb44122c43c2e0e4548d1e094 (diff)
downloadchromium_src-aa90e58c7e88cbcae7e4a7667e047c320a3fc0aa.zip
chromium_src-aa90e58c7e88cbcae7e4a7667e047c320a3fc0aa.tar.gz
chromium_src-aa90e58c7e88cbcae7e4a7667e047c320a3fc0aa.tar.bz2
Use AutocompletePopupPositioner for the Linux Omnibox.
Now a few less magic numbers in exchange for a lot more plumbing. BUG=10966 Review URL: http://codereview.chromium.org/92127 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14592 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/browser_toolbar_gtk.cc')
-rw-r--r--chrome/browser/gtk/browser_toolbar_gtk.cc41
1 files changed, 38 insertions, 3 deletions
diff --git a/chrome/browser/gtk/browser_toolbar_gtk.cc b/chrome/browser/gtk/browser_toolbar_gtk.cc
index 0ceba4b..e87f32c 100644
--- a/chrome/browser/gtk/browser_toolbar_gtk.cc
+++ b/chrome/browser/gtk/browser_toolbar_gtk.cc
@@ -31,15 +31,31 @@
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
-const int BrowserToolbarGtk::kToolbarHeight = 38;
+namespace {
+
+// Height of the toolbar in pixels.
+const int kToolbarHeight = 38;
+
+// The amount of space between the bottom of the star and the top of the
+// Omnibox results popup window. We want a two pixel space between the bottom
+// and the results, but have some extra space below the buttons already.
+const int kPopupTopMargin = 0;
+
+// Space between the edge of the star/go button and the popup frame. We want
+// to leave 1 pixel on both side here so that the borders line up.
+const int kPopupLeftRightMargin = 1;
+
// For the back/forward dropdown menus, the time in milliseconds between
// when the user clicks and the popup menu appears.
-static const int kMenuTimerDelay = 500;
+const int kMenuTimerDelay = 500;
+
+} // namespace
BrowserToolbarGtk::BrowserToolbarGtk(Browser* browser)
: toolbar_(NULL),
location_bar_(new LocationBarViewGtk(browser->command_updater(),
- browser->toolbar_model())),
+ browser->toolbar_model(),
+ this)),
model_(browser->toolbar_model()),
browser_(browser),
profile_(NULL),
@@ -221,6 +237,25 @@ void BrowserToolbarGtk::UpdateTabContents(TabContents* contents,
location_bar_->Update(should_restore_state ? contents : NULL);
}
+gfx::Rect BrowserToolbarGtk::GetPopupBounds() const {
+ GtkWidget* star = star_->widget();
+ GtkWidget* go = go_->widget();
+
+ // TODO(deanm): The go and star buttons probably share the same window,
+ // so this could be optimized to only one origin request.
+ gint go_x, go_y;
+ gdk_window_get_origin(go->window, &go_x, &go_y);
+ go_x += go->allocation.x + go->allocation.width; // Right edge.
+
+ gint star_x, star_y;
+ gdk_window_get_origin(star->window, &star_x, &star_y);
+ star_x += star->allocation.x; // Left edge.
+ star_y += star->allocation.y + star->allocation.height; // Bottom edge.
+
+ return gfx::Rect(star_x + kPopupLeftRightMargin, star_y + kPopupTopMargin,
+ go_x - star_x - (2 * kPopupLeftRightMargin), 0);
+}
+
CustomDrawButton* BrowserToolbarGtk::BuildToolbarButton(
int normal_id, int active_id, int highlight_id, int depressed_id,
const std::string& localized_tooltip) {