diff options
-rw-r--r-- | chrome/browser/views/extensions/extension_popup.cc | 9 | ||||
-rw-r--r-- | chrome/browser/views/status_bubble_views.cc | 6 | ||||
-rw-r--r-- | views/widget/widget.h | 30 | ||||
-rw-r--r-- | views/widget/widget_gtk.cc | 17 | ||||
-rw-r--r-- | views/widget/widget_gtk.h | 2 | ||||
-rw-r--r-- | views/widget/widget_win.cc | 29 | ||||
-rw-r--r-- | views/widget/widget_win.h | 2 |
7 files changed, 79 insertions, 16 deletions
diff --git a/chrome/browser/views/extensions/extension_popup.cc b/chrome/browser/views/extensions/extension_popup.cc index 53025e9..37e21ec 100644 --- a/chrome/browser/views/extensions/extension_popup.cc +++ b/chrome/browser/views/extensions/extension_popup.cc @@ -16,8 +16,10 @@ #include "views/widget/root_view.h" +using views::Widget; + ExtensionPopup::ExtensionPopup(ExtensionHost* host, - views::Widget* frame, + Widget* frame, const gfx::Rect& relative_to) : BrowserBubble(host->view(), frame, gfx::Point()), relative_to_(relative_to), @@ -29,8 +31,9 @@ ExtensionPopup::ExtensionPopup(ExtensionHost* host, // TODO(erikkay) Some of this border code is derived from InfoBubble. // We should see if we can unify these classes. - // |true| here means the widget is set to delete on destroy. - border_widget_ = views::Widget::CreateTransparentPopupWidget(true); + border_widget_ = Widget::CreatePopupWidget(Widget::Transparent, + Widget::NotAcceptEvents, + Widget::DeleteOnDestroy); gfx::NativeView native_window = frame->GetNativeView(); border_widget_->Init(native_window, bounds()); border_ = new BubbleBorder; diff --git a/chrome/browser/views/status_bubble_views.cc b/chrome/browser/views/status_bubble_views.cc index 4ade4e6..935b894 100644 --- a/chrome/browser/views/status_bubble_views.cc +++ b/chrome/browser/views/status_bubble_views.cc @@ -27,6 +27,8 @@ #include "views/widget/widget.h" #include "views/window/window.h" +using views::Widget; + // The alpha and color of the bubble's shadow. static const SkColor kShadowColor = SkColorSetARGB(30, 0, 0, 0); @@ -462,7 +464,9 @@ StatusBubbleViews::~StatusBubbleViews() { void StatusBubbleViews::Init() { if (!popup_.get()) { - popup_.reset(views::Widget::CreateTransparentPopupWidget(false)); + popup_.reset(Widget::CreatePopupWidget(Widget::Transparent, + Widget::NotAcceptEvents, + Widget::NotDeleteOnDestroy)); if (!view_) view_ = new StatusView(this, popup_.get(), frame_->GetThemeProvider()); popup_->SetOpacity(0x00); diff --git a/views/widget/widget.h b/views/widget/widget.h index 7c60e41..05e475b 100644 --- a/views/widget/widget.h +++ b/views/widget/widget.h @@ -43,9 +43,25 @@ class Widget { public: virtual ~Widget() { } - // Creates a transparent popup widget specific to the current platform useful - // for transient status notifications. - static Widget* CreateTransparentPopupWidget(bool delete_on_destroy); + enum TransparencyParam { + Transparent, + NotTransparent + }; + + enum EventsParam { + AcceptEvents, + NotAcceptEvents + }; + + enum DeleteParam { + DeleteOnDestroy, + NotDeleteOnDestroy + }; + + // Creates a transient popup widget specific to the current platform. + static Widget* CreatePopupWidget(TransparencyParam transparent, + EventsParam accept_events, + DeleteParam delete_on_destroy); // Initialize the Widget with a parent and an initial desired size. // |contents_view| is the view that will be the single child of RootView @@ -57,7 +73,7 @@ class Widget { virtual void Init(gfx::NativeView parent, const gfx::Rect& bounds) = 0; // Sets the specified view as the contents of this Widget. There can only - // be one contnets view child of this Widget's RootView. This view is sized to + // be one contents view child of this Widget's RootView. This view is sized to // fit the entire size of the RootView. The RootView takes ownership of this // View, unless it is set as not being parent-owned. virtual void SetContentsView(View* view) = 0; @@ -72,6 +88,9 @@ class Widget { // Sizes and/or places the widget to the specified bounds, size or position. virtual void SetBounds(const gfx::Rect& bounds) = 0; + // Places the widget in front of the specified widget in z-order. + virtual void MoveAbove(Widget* widget) = 0; + // Sets a shape on the widget. virtual void SetShape(const gfx::Path& shape) = 0; @@ -99,6 +118,9 @@ class Widget { // repaint to allow this change to take effect. virtual void SetOpacity(unsigned char opacity) = 0; + // Sets the widget to be on top of all other widgets in the windowing system. + virtual void SetAlwaysOnTop(bool on_top) = 0; + // Returns the RootView contained by this Widget. virtual RootView* GetRootView() = 0; diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc index 1224414..cee2886 100644 --- a/views/widget/widget_gtk.cc +++ b/views/widget/widget_gtk.cc @@ -374,6 +374,10 @@ void WidgetGtk::SetBounds(const gfx::Rect& bounds) { } } +void WidgetGtk::MoveAbove(Widget* widget) { + NOTIMPLEMENTED(); +} + void WidgetGtk::SetShape(const gfx::Path& shape) { DCHECK(widget_); DCHECK(widget_->window); @@ -437,6 +441,10 @@ void WidgetGtk::SetOpacity(unsigned char opacity) { } } +void WidgetGtk::SetAlwaysOnTop(bool on_top) { + NOTIMPLEMENTED(); +} + RootView* WidgetGtk::GetRootView() { if (!root_view_.get()) { // First time the root view is being asked for, create it now. @@ -1218,10 +1226,13 @@ void WidgetGtk::HandleGrabBroke() { // Widget, public: // static -Widget* Widget::CreateTransparentPopupWidget(bool delete_on_destroy) { +Widget* Widget::CreatePopupWidget(TransparencyParam transparent, + EventsParam /*accept_events*/, + DeleteParam delete_on_destroy) { WidgetGtk* popup = new WidgetGtk(WidgetGtk::TYPE_POPUP); - popup->set_delete_on_destroy(delete_on_destroy); - popup->MakeTransparent(); + popup->set_delete_on_destroy(delete_on_destroy == DeleteOnDestroy); + if (transparent == Transparent) + popup->MakeTransparent(); return popup; } diff --git a/views/widget/widget_gtk.h b/views/widget/widget_gtk.h index b146b8e..0e2f818 100644 --- a/views/widget/widget_gtk.h +++ b/views/widget/widget_gtk.h @@ -117,6 +117,7 @@ class WidgetGtk virtual void SetContentsView(View* view); virtual void GetBounds(gfx::Rect* out, bool including_frame) const; virtual void SetBounds(const gfx::Rect& bounds); + virtual void MoveAbove(Widget* other); virtual void SetShape(const gfx::Path& shape); virtual void Close(); virtual void CloseNow(); @@ -125,6 +126,7 @@ class WidgetGtk virtual gfx::NativeView GetNativeView() const; virtual void PaintNow(const gfx::Rect& update_rect); virtual void SetOpacity(unsigned char opacity); + virtual void SetAlwaysOnTop(bool on_top); virtual RootView* GetRootView(); virtual Widget* GetRootWidget() const; virtual bool IsVisible() const; diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc index 15a10f2..b883edd 100644 --- a/views/widget/widget_win.cc +++ b/views/widget/widget_win.cc @@ -137,6 +137,13 @@ void WidgetWin::SetBounds(const gfx::Rect& bounds) { SWP_NOACTIVATE | SWP_NOZORDER); } +void WidgetWin::MoveAbove(Widget* other) { + gfx::Rect bounds; + GetBounds(&bounds, false); + SetWindowPos(other->GetNativeView(), bounds.x(), bounds.y(), + bounds.width(), bounds.height(), SWP_NOACTIVATE); +} + void WidgetWin::SetShape(const gfx::Path& shape) { SetWindowRgn(shape.CreateHRGN(), TRUE); } @@ -252,6 +259,13 @@ void WidgetWin::SetOpacity(unsigned char opacity) { layered_alpha_ = static_cast<BYTE>(opacity); } +void WidgetWin::SetAlwaysOnTop(bool on_top) { + if (on_top) + set_window_ex_style(window_ex_style() | WS_EX_TOPMOST); + else + set_window_ex_style(window_ex_style() & ~WS_EX_TOPMOST); +} + RootView* WidgetWin::GetRootView() { if (!root_view_.get()) { // First time the root view is being asked for, create it now. @@ -1155,13 +1169,18 @@ void WidgetWin::PostProcessActivateMessage(WidgetWin* widget, // Widget, public: // static -Widget* Widget::CreateTransparentPopupWidget(bool delete_on_destroy) { +Widget* Widget::CreatePopupWidget(TransparencyParam transparent, + EventsParam accept_events, + DeleteParam delete_on_destroy) { WidgetWin* popup = new WidgetWin; + DWORD ex_style = WS_EX_TOOLWINDOW | l10n_util::GetExtendedTooltipStyles(); + if (transparent == Transparent) + ex_style |= WS_EX_LAYERED; + if (accept_events != AcceptEvents) + ex_style |= WS_EX_TRANSPARENT; popup->set_window_style(WS_POPUP); - popup->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW | - WS_EX_TRANSPARENT | - l10n_util::GetExtendedTooltipStyles()); - popup->set_delete_on_destroy(delete_on_destroy); + popup->set_window_ex_style(ex_style); + popup->set_delete_on_destroy(delete_on_destroy == DeleteOnDestroy); return popup; } diff --git a/views/widget/widget_win.h b/views/widget/widget_win.h index 4f79a76..b8e21dd 100644 --- a/views/widget/widget_win.h +++ b/views/widget/widget_win.h @@ -183,6 +183,7 @@ class WidgetWin : public app::WindowImpl, virtual void SetContentsView(View* view); virtual void GetBounds(gfx::Rect* out, bool including_frame) const; virtual void SetBounds(const gfx::Rect& bounds); + virtual void MoveAbove(Widget* other); virtual void SetShape(const gfx::Path& shape); virtual void Close(); virtual void CloseNow(); @@ -191,6 +192,7 @@ class WidgetWin : public app::WindowImpl, virtual gfx::NativeView GetNativeView() const; virtual void PaintNow(const gfx::Rect& update_rect); virtual void SetOpacity(unsigned char opacity); + virtual void SetAlwaysOnTop(bool on_top); virtual RootView* GetRootView(); virtual Widget* GetRootWidget() const; virtual bool IsVisible() const; |