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

Side by Side 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: Merge 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/bubble/bubble_delegate.h" 5 #include "views/bubble/bubble_delegate.h"
6
6 #include "views/bubble/bubble_frame_view.h" 7 #include "views/bubble/bubble_frame_view.h"
7 #include "views/bubble/bubble_view.h" 8 #include "views/bubble/bubble_view.h"
8
9 #include "base/logging.h"
10 #include "views/widget/widget.h" 9 #include "views/widget/widget.h"
11 10
12 namespace views { 11 namespace views {
13 12
14 BubbleDelegate* BubbleDelegate::AsBubbleDelegate() { return this; } 13 BubbleDelegateView::~BubbleDelegateView() {}
15 14
16 ClientView* BubbleDelegate::CreateClientView(Widget* widget) { 15 // static
17 BubbleView* bubble_view = new BubbleView(widget, GetContentsView()); 16 Widget* BubbleDelegateView::ConstructBubble(BubbleDelegateView* bubble_delegate,
18 bubble_view->SetBounds(0, 0, GetBounds().width(), GetBounds().height()); 17 Widget* parent_widget) {
19 if (widget->GetFocusManager()) { 18 bubble_delegate->Init();
20 widget->GetFocusManager()->RegisterAccelerator( 19 views::Widget* bubble_widget = new views::Widget();
21 views::Accelerator(ui::VKEY_ESCAPE, false, false, false), 20 views::Widget::InitParams params(views::Widget::InitParams::TYPE_BUBBLE);
22 bubble_view); 21 params.delegate = bubble_delegate;
23 } 22 params.transparent = true;
24 return bubble_view; 23 if (!parent_widget)
24 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
25 params.parent_widget = parent_widget;
26 bubble_widget->Init(params);
27
28 // TODO(msw): Adjust the widget bounds to point the arrow as intended.
29 bubble_widget->SetBounds(gfx::Rect(bubble_delegate->GetArrowPoint(),
30 bubble_delegate->GetBubbleFrameView()->GetPreferredSize()));
31
32 return bubble_widget;
25 } 33 }
26 34
27 NonClientFrameView* BubbleDelegate::CreateNonClientFrameView() { 35 ClientView* BubbleDelegateView::CreateClientView(Widget* widget) {
28 return new BubbleFrameView(GetWidget(), 36 return new BubbleView(widget, GetContentsView());
29 GetBounds(),
30 GetFrameBackgroundColor(),
31 GetFrameArrowLocation());
32 } 37 }
33 38
34 const BubbleView* BubbleDelegate::GetBubbleView() const { 39 NonClientFrameView* BubbleDelegateView::CreateNonClientFrameView() {
40 return new BubbleFrameView(GetArrowLocation(),
41 GetPreferredSize(),
42 GetColor());
43 }
44
45 gfx::Point BubbleDelegateView::GetArrowPoint() const {
46 return gfx::Point();
47 }
48
49 BubbleView* BubbleDelegateView::GetBubbleView() {
35 return GetWidget()->client_view()->AsBubbleView(); 50 return GetWidget()->client_view()->AsBubbleView();
36 } 51 }
37 52
38 BubbleView* BubbleDelegate::GetBubbleView() { 53 BubbleFrameView* BubbleDelegateView::GetBubbleFrameView() {
39 return GetWidget()->client_view()->AsBubbleView();
40 }
41
42 const BubbleFrameView* BubbleDelegate::GetBubbleFrameView() const {
43 return static_cast<BubbleFrameView*>( 54 return static_cast<BubbleFrameView*>(
44 GetWidget()->non_client_view()->frame_view()); 55 GetWidget()->non_client_view()->frame_view());
45 } 56 }
46 57
47 BubbleFrameView* BubbleDelegate::GetBubbleFrameView() {
48 return static_cast<BubbleFrameView*>(
49 GetWidget()->non_client_view()->frame_view());
50 }
51
52 BubbleDelegateView::BubbleDelegateView(Widget* frame):frame_(frame) {
53 }
54
55 BubbleDelegateView::~BubbleDelegateView() {
56 }
57
58 Widget* BubbleDelegateView::GetWidget() {
59 return frame_;
60 }
61
62 const Widget* BubbleDelegateView::GetWidget() const {
63 return frame_;
64 }
65
66 } // namespace views 58 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698