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

Side by Side Diff: views/bubble/bubble_delegate.h

Issue 8588064: views: Move bubble, events, focus and layout to ui/views/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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_border.cc ('k') | views/bubble/bubble_delegate.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 #ifndef VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ 5 #ifndef VIEWS_BUBBLE_BUBBLE_DELEGATE_H_
6 #define VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ 6 #define VIEWS_BUBBLE_BUBBLE_DELEGATE_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/gtest_prod_util.h" 9 #include "ui/views/bubble/bubble_delegate.h"
10 #include "ui/base/animation/animation_delegate.h" 10 // TODO(tfarina): remove this file once all includes have been updated.
11 #include "views/bubble/bubble_border.h"
12 #include "views/widget/widget.h"
13 #include "views/widget/widget_delegate.h"
14
15 namespace ui {
16 class SlideAnimation;
17 } // namespace ui
18
19 namespace views {
20
21 class BubbleFrameView;
22
23 // BubbleDelegateView creates frame and client views for bubble Widgets.
24 // BubbleDelegateView itself is the client's contents view.
25 //
26 ///////////////////////////////////////////////////////////////////////////////
27 class VIEWS_EXPORT BubbleDelegateView : public WidgetDelegateView,
28 public ui::AnimationDelegate,
29 public Widget::Observer {
30 public:
31 BubbleDelegateView();
32 BubbleDelegateView(View* anchor_view,
33 BubbleBorder::ArrowLocation arrow_location,
34 const SkColor& color);
35 virtual ~BubbleDelegateView();
36
37 // Create and initialize the bubble Widget(s) with proper bounds.
38 static Widget* CreateBubble(BubbleDelegateView* bubble_delegate);
39
40 // WidgetDelegate overrides:
41 virtual View* GetInitiallyFocusedView() OVERRIDE;
42 virtual BubbleDelegateView* AsBubbleDelegate() OVERRIDE;
43 virtual View* GetContentsView() OVERRIDE;
44 virtual NonClientFrameView* CreateNonClientFrameView() OVERRIDE;
45
46 // Widget::Observer overrides:
47 virtual void OnWidgetActivationChanged(Widget* widget, bool active) OVERRIDE;
48
49 bool close_on_esc() const { return close_on_esc_; }
50 void set_close_on_esc(bool close_on_esc) { close_on_esc_ = close_on_esc; }
51
52 bool close_on_deactivate() const { return close_on_deactivate_; }
53 void set_close_on_deactivate(bool close_on_deactivate) {
54 close_on_deactivate_ = close_on_deactivate;
55 }
56
57 bool allow_bubble_offscreen() const { return allow_bubble_offscreen_; }
58 void set_allow_bubble_offscreen(bool allow_bubble_offscreen) {
59 allow_bubble_offscreen_ = allow_bubble_offscreen;
60 }
61
62 View* anchor_view() const { return anchor_view_; }
63
64 bool use_focusless() const { return use_focusless_; }
65 void set_use_focusless(bool use_focusless) {
66 use_focusless_ = use_focusless;
67 }
68
69 // Get the arrow's anchor point in screen space.
70 virtual gfx::Point GetAnchorPoint();
71
72 // Get the arrow's location on the bubble.
73 virtual BubbleBorder::ArrowLocation GetArrowLocation() const;
74
75 // Get the color used for the background and border.
76 virtual SkColor GetColor() const;
77
78 // Show the bubble's widget (and |border_widget_| on Windows).
79 void Show();
80
81 // Fade the bubble in or out via Widget transparency.
82 // Fade in calls Widget::Show; fade out calls Widget::Close upon completion.
83 void StartFade(bool fade_in);
84
85 // Reset fade and opacity of bubble. Restore the opacity of the
86 // bubble to the setting before StartFade() was called.
87 void ResetFade();
88
89 protected:
90 // View overrides:
91 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
92
93 // ui::AnimationDelegate overrides:
94 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE;
95 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
96
97 // Perform view initialization on the contents for bubble sizing.
98 virtual void Init();
99
100 // Resizes and potentially moves the Bubble to best accommodate the
101 // contents preferred size.
102 void SizeToContents();
103
104 private:
105 FRIEND_TEST_ALL_PREFIXES(BubbleFrameViewBasicTest, NonClientHitTest);
106 FRIEND_TEST_ALL_PREFIXES(BubbleDelegateTest, CreateDelegate);
107
108 BubbleFrameView* GetBubbleFrameView() const;
109
110 // Get bubble bounds from the anchor point and client view's preferred size.
111 gfx::Rect GetBubbleBounds();
112
113 #if defined(OS_WIN) && !defined(USE_AURA)
114 // Get bounds for the Windows-only widget that hosts the bubble's contents.
115 gfx::Rect GetBubbleClientBounds() const;
116 #endif
117
118 // Fade animation for bubble.
119 scoped_ptr<ui::SlideAnimation> fade_animation_;
120
121 // Flags controlling bubble closure on the escape key and deactivation.
122 bool close_on_esc_;
123 bool close_on_deactivate_;
124
125 // Whether the bubble is allowed to be displayed offscreen, or if auto
126 // re-positioning should be performed.
127 bool allow_bubble_offscreen_;
128
129 // The view hosting this bubble; the arrow is anchored to this view.
130 View* anchor_view_;
131
132 // The arrow's location on the bubble.
133 BubbleBorder::ArrowLocation arrow_location_;
134
135 // The background color of the bubble.
136 SkColor color_;
137
138 // Original opacity of the bubble.
139 int original_opacity_;
140
141 // The widget hosting the border for this bubble (non-Aura Windows only).
142 Widget* border_widget_;
143
144 // Create a popup window for focusless bubbles on Linux/ChromeOS.
145 // These bubbles are not interactive and should not gain focus.
146 bool use_focusless_;
147
148 DISALLOW_COPY_AND_ASSIGN(BubbleDelegateView);
149 };
150
151 } // namespace views
152 11
153 #endif // VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ 12 #endif // VIEWS_BUBBLE_BUBBLE_DELEGATE_H_
OLDNEW
« no previous file with comments | « views/bubble/bubble_border.cc ('k') | views/bubble/bubble_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698