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

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: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/bubble/bubble_delegate.h ('k') | views/bubble/bubble_delegate_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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::CreateBubble(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 bubble_widget->SetBounds(bubble_delegate->GetBubbleBounds());
28 return bubble_widget;
25 } 29 }
26 30
27 NonClientFrameView* BubbleDelegate::CreateNonClientFrameView() { 31 ClientView* BubbleDelegateView::CreateClientView(Widget* widget) {
28 return new BubbleFrameView(GetWidget(), 32 return new BubbleView(widget, GetContentsView());
29 GetBounds(),
30 GetFrameBackgroundColor(),
31 GetFrameArrowLocation());
32 } 33 }
33 34
34 const BubbleView* BubbleDelegate::GetBubbleView() const { 35 NonClientFrameView* BubbleDelegateView::CreateNonClientFrameView() {
36 return new BubbleFrameView(GetArrowLocation(),
37 GetPreferredSize(),
38 GetColor());
39 }
40
41 gfx::Point BubbleDelegateView::GetAnchorPoint() const {
42 return gfx::Point();
43 }
44
45 const BubbleView* BubbleDelegateView::GetBubbleView() const {
35 return GetWidget()->client_view()->AsBubbleView(); 46 return GetWidget()->client_view()->AsBubbleView();
36 } 47 }
37 48
38 BubbleView* BubbleDelegate::GetBubbleView() { 49 const BubbleFrameView* BubbleDelegateView::GetBubbleFrameView() const {
39 return GetWidget()->client_view()->AsBubbleView();
40 }
41
42 const BubbleFrameView* BubbleDelegate::GetBubbleFrameView() const {
43 return static_cast<BubbleFrameView*>( 50 return static_cast<BubbleFrameView*>(
44 GetWidget()->non_client_view()->frame_view()); 51 GetWidget()->non_client_view()->frame_view());
45 } 52 }
46 53
47 BubbleFrameView* BubbleDelegate::GetBubbleFrameView() { 54 gfx::Rect BubbleDelegateView::GetBubbleBounds() {
48 return static_cast<BubbleFrameView*>( 55 // The argument rect has its origin at the bubble's arrow anchor point;
49 GetWidget()->non_client_view()->frame_view()); 56 // its size is the preferred size of the bubble's client view (this view).
50 } 57 return GetBubbleFrameView()->GetWindowBoundsForClientBounds(
51 58 gfx::Rect(GetAnchorPoint(), GetPreferredSize()));
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 } 59 }
65 60
66 } // namespace views 61 } // namespace views
OLDNEW
« 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