Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(424)

Unified Diff: views/bubble/bubble_delegate.cc

Issue 8227003: Views Bubble API adjustments and cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add close_on_esc setting and fade-in functionality. Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « views/bubble/bubble_delegate.h ('k') | views/bubble/bubble_delegate_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/bubble/bubble_delegate.cc
diff --git a/views/bubble/bubble_delegate.cc b/views/bubble/bubble_delegate.cc
index 14a06e8ac0695fb6f69b9eb6ec05e1a7c0791932..1ba39f1fd4a6f9f66a3cd1aec6a5b357ed3f52bd 100644
--- a/views/bubble/bubble_delegate.cc
+++ b/views/bubble/bubble_delegate.cc
@@ -3,64 +3,59 @@
// found in the LICENSE file.
#include "views/bubble/bubble_delegate.h"
+
#include "views/bubble/bubble_frame_view.h"
#include "views/bubble/bubble_view.h"
-
-#include "base/logging.h"
#include "views/widget/widget.h"
namespace views {
-BubbleDelegate* BubbleDelegate::AsBubbleDelegate() { return this; }
+BubbleDelegateView::~BubbleDelegateView() {}
-ClientView* BubbleDelegate::CreateClientView(Widget* widget) {
- BubbleView* bubble_view = new BubbleView(widget, GetContentsView());
- bubble_view->SetBounds(0, 0, GetBounds().width(), GetBounds().height());
- if (widget->GetFocusManager()) {
- widget->GetFocusManager()->RegisterAccelerator(
- views::Accelerator(ui::VKEY_ESCAPE, false, false, false),
- bubble_view);
- }
- return bubble_view;
+// static
+Widget* BubbleDelegateView::CreateBubble(BubbleDelegateView* bubble_delegate,
+ Widget* parent_widget) {
+ bubble_delegate->Init();
+ views::Widget* bubble_widget = new views::Widget();
+ views::Widget::InitParams params(views::Widget::InitParams::TYPE_BUBBLE);
+ params.delegate = bubble_delegate;
+ params.transparent = true;
+ if (!parent_widget)
+ params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+ params.parent_widget = parent_widget;
+ bubble_widget->Init(params);
+ bubble_widget->SetBounds(bubble_delegate->GetBubbleBounds());
+ return bubble_widget;
}
-NonClientFrameView* BubbleDelegate::CreateNonClientFrameView() {
- return new BubbleFrameView(GetWidget(),
- GetBounds(),
- GetFrameBackgroundColor(),
- GetFrameArrowLocation());
+ClientView* BubbleDelegateView::CreateClientView(Widget* widget) {
+ return new BubbleView(widget, GetContentsView());
}
-const BubbleView* BubbleDelegate::GetBubbleView() const {
- return GetWidget()->client_view()->AsBubbleView();
+NonClientFrameView* BubbleDelegateView::CreateNonClientFrameView() {
+ return new BubbleFrameView(GetArrowLocation(),
+ GetPreferredSize(),
+ GetColor());
}
-BubbleView* BubbleDelegate::GetBubbleView() {
- return GetWidget()->client_view()->AsBubbleView();
+gfx::Point BubbleDelegateView::GetAnchorPoint() const {
+ return gfx::Point();
}
-const BubbleFrameView* BubbleDelegate::GetBubbleFrameView() const {
- return static_cast<BubbleFrameView*>(
- GetWidget()->non_client_view()->frame_view());
+const BubbleView* BubbleDelegateView::GetBubbleView() const {
+ return GetWidget()->client_view()->AsBubbleView();
}
-BubbleFrameView* BubbleDelegate::GetBubbleFrameView() {
+const BubbleFrameView* BubbleDelegateView::GetBubbleFrameView() const {
return static_cast<BubbleFrameView*>(
GetWidget()->non_client_view()->frame_view());
}
-BubbleDelegateView::BubbleDelegateView(Widget* frame):frame_(frame) {
-}
-
-BubbleDelegateView::~BubbleDelegateView() {
-}
-
-Widget* BubbleDelegateView::GetWidget() {
- return frame_;
-}
-
-const Widget* BubbleDelegateView::GetWidget() const {
- return frame_;
+gfx::Rect BubbleDelegateView::GetBubbleBounds() {
+ // The argument rect has its origin at the bubble's arrow anchor point;
+ // its size is the preferred size of the bubble's client view (this view).
+ return GetBubbleFrameView()->GetWindowBoundsForClientBounds(
+ gfx::Rect(GetAnchorPoint(), GetPreferredSize()));
}
} // namespace views
« no previous file with comments | « views/bubble/bubble_delegate.h ('k') | views/bubble/bubble_delegate_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698