diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-05 05:41:54 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-05 05:41:54 +0000 |
commit | cfc0accbc458f940bdf8feed5e24d44100b6930b (patch) | |
tree | cbf3e7d343eea0299418da298630492ce37b622d /views/examples | |
parent | 55f9c5a5466d0c7d5550252b653162d7dc775442 (diff) | |
download | chromium_src-cfc0accbc458f940bdf8feed5e24d44100b6930b.zip chromium_src-cfc0accbc458f940bdf8feed5e24d44100b6930b.tar.gz chromium_src-cfc0accbc458f940bdf8feed5e24d44100b6930b.tar.bz2 |
Add transparency to TYPE_CHILD WidgetGtk.
* This does not work with renderer as parent yet.(I need to investigate renderer what it's doing)
* gtk_widget_set_back_pixmap is not necessary and removed.
* changed to use clear operation to fill a background with transparent color.
BUG=none
TEST=manual: added transparent widget example to view_examples. I also tested with chrome and confirmed that info bubble, app launcher and tab dragging works.
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=46374
Review URL: http://codereview.chromium.org/1629024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46439 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/examples')
-rw-r--r-- | views/examples/widget_example.h | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/views/examples/widget_example.h b/views/examples/widget_example.h index 609e6ed..b84e8f8 100644 --- a/views/examples/widget_example.h +++ b/views/examples/widget_example.h @@ -43,7 +43,17 @@ class BoxLayout : public views::LayoutManager { } virtual gfx::Size GetPreferredSize(views::View* host) { - return host->GetPreferredSize(); + int count = host->GetChildViewCount(); + gfx::Rect bounds; + int y = 0; + for (int i = 0; i < count; i++) { + views::View* child = host->GetChildViewAt(i); + gfx::Size size = child->GetPreferredSize(); + gfx::Rect child_bounds(0, y, size.width(), size.height()); + bounds = bounds.Union(child_bounds); + y += size.height(); + } + return bounds.size(); } private: @@ -123,19 +133,29 @@ class WidgetExample : public ExampleBase, public views::ButtonListener { void InitWidget(Widget* widget, const Widget::TransparencyParam transparency) { - // Add a button to close the popup widget. + // Add view/native buttons to close the popup widget. views::TextButton* close_button = new views::TextButton(this, L"Close"); close_button->set_tag(CLOSE_WIDGET); + // TODO(oshima): support transparent native view. + views::NativeButton* native_button + = new views::NativeButton(this, L"Native Close"); + native_button->set_tag(CLOSE_WIDGET); + + views::View* button_container = new views::View(); + button_container->SetLayoutManager(new BoxLayout); + button_container->AddChildView(close_button); + button_container->AddChildView(native_button); + views::View* widget_container = new views::View(); widget_container->SetLayoutManager(new CenterLayout); - if (transparency == Widget::Transparent) - close_button->set_background( - views::Background::CreateStandardPanelBackground()); - else + widget_container->AddChildView(button_container); + + widget->SetContentsView(widget_container); + + if (transparency != Widget::Transparent) { widget_container->set_background( views::Background::CreateStandardPanelBackground()); - widget_container->AddChildView(close_button); - widget->GetRootView()->SetContentsView(widget_container); + } // Show the widget. widget->Show(); @@ -151,7 +171,7 @@ class WidgetExample : public ExampleBase, public views::ButtonListener { // Compute where to place the child widget. // We'll place it at the center of the root widget. views::WidgetGtk* parent_widget = - static_cast<views::WidgetGtk*>(parent->GetWidget()->GetRootWidget()); + static_cast<views::WidgetGtk*>(parent->GetWidget()); gfx::Rect bounds; parent_widget->GetBounds(&bounds, false); // Child widget is 200x200 square. |