summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorsatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-09 09:07:35 +0000
committersatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-09 09:07:35 +0000
commit2f45b08f418412272ef391f58f7953265e3f6aa6 (patch)
treeae8ca023fdabef652d2e5c548066d4d0a1cd9fca /views
parent11d2e078c37f1d56fe5862bf6b36e30f7527afa4 (diff)
downloadchromium_src-2f45b08f418412272ef391f58f7953265e3f6aa6.zip
chromium_src-2f45b08f418412272ef391f58f7953265e3f6aa6.tar.gz
chromium_src-2f45b08f418412272ef391f58f7953265e3f6aa6.tar.bz2
Compute where to place a popup widget in WidgetExample.
This is to demonstrate how to compute a position. TEST=manually BUG=none Review URL: http://codereview.chromium.org/460104 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34149 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/examples/widget_example.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/views/examples/widget_example.h b/views/examples/widget_example.h
index d7af468..85a7111 100644
--- a/views/examples/widget_example.h
+++ b/views/examples/widget_example.h
@@ -49,7 +49,18 @@ class WidgetExample : public ExampleBase, public views::ButtonListener {
views::Widget::NotTransparent,
views::Widget::AcceptEvents,
views::Widget::DeleteOnDestroy);
- popup_widget_->Init(NULL, gfx::Rect(100, 100, 200, 300));
+
+ // Compute where to place the popup widget.
+ // We'll place it right below the create_button_.
+ gfx::Point point = create_button_->GetPosition();
+ // The position in point is relative to the parent. Make it absolute.
+ views::View::ConvertPointToScreen(create_button_, &point);
+ // Add the height of create_button_.
+ point.Offset(0, create_button_->size().height());
+ gfx::Rect bounds(point.x(), point.y(), 200, 300);
+
+ // Initialize the popup widget with the computed bounds.
+ popup_widget_->Init(NULL, bounds);
// Add a button to close the popup widget.
close_button_ = new views::TextButton(this, L"Close");