OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "views/examples/widget_example.h" | 5 #include "views/examples/widget_example.h" |
6 | 6 |
7 #include "views/controls/button/native_button.h" | 7 #include "views/controls/button/native_button.h" |
8 #include "views/layout/box_layout.h" | 8 #include "views/layout/box_layout.h" |
9 #include "views/layout/layout_manager.h" | 9 #include "views/layout/layout_manager.h" |
10 #include "views/view.h" | 10 #include "views/view.h" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 views::View* parent, | 137 views::View* parent, |
138 const views::Widget::TransparencyParam transparency) { | 138 const views::Widget::TransparencyParam transparency) { |
139 views::Widget* widget = views::Widget::CreatePopupWidget( | 139 views::Widget* widget = views::Widget::CreatePopupWidget( |
140 transparency, | 140 transparency, |
141 views::Widget::AcceptEvents, | 141 views::Widget::AcceptEvents, |
142 views::Widget::DeleteOnDestroy, | 142 views::Widget::DeleteOnDestroy, |
143 views::Widget::MirrorOriginInRTL); | 143 views::Widget::MirrorOriginInRTL); |
144 | 144 |
145 // Compute where to place the popup widget. | 145 // Compute where to place the popup widget. |
146 // We'll place it right below the create button. | 146 // We'll place it right below the create button. |
147 gfx::Point point = parent->GetPosition(); | 147 gfx::Point point = parent->GetMirroredPosition(); |
148 // The position in point is relative to the parent. Make it absolute. | 148 // The position in point is relative to the parent. Make it absolute. |
149 views::View::ConvertPointToScreen(parent, &point); | 149 views::View::ConvertPointToScreen(parent, &point); |
150 // Add the height of create_button_. | 150 // Add the height of create_button_. |
151 point.Offset(0, parent->size().height()); | 151 point.Offset(0, parent->size().height()); |
152 gfx::Rect bounds(point.x(), point.y(), 200, 300); | 152 gfx::Rect bounds(point.x(), point.y(), 200, 300); |
153 // Initialize the popup widget with the computed bounds. | 153 // Initialize the popup widget with the computed bounds. |
154 widget->InitWithWidget(parent->GetWidget(), bounds); | 154 widget->InitWithWidget(parent->GetWidget(), bounds); |
155 InitWidget(widget, transparency); | 155 InitWidget(widget, transparency); |
156 } | 156 } |
157 | 157 |
(...skipping 14 matching lines...) Expand all Loading... |
172 CreateChild(sender, views::Widget::Transparent); | 172 CreateChild(sender, views::Widget::Transparent); |
173 break; | 173 break; |
174 #endif | 174 #endif |
175 case CLOSE_WIDGET: | 175 case CLOSE_WIDGET: |
176 sender->GetWidget()->Close(); | 176 sender->GetWidget()->Close(); |
177 break; | 177 break; |
178 } | 178 } |
179 } | 179 } |
180 | 180 |
181 } // namespace examples | 181 } // namespace examples |
OLD | NEW |