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

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

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_frame_view_unittest.cc ('k') | views/bubble/bubble_view.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_VIEW_H_ 5 #ifndef VIEWS_BUBBLE_BUBBLE_VIEW_H_
6 #define VIEWS_BUBBLE_BUBBLE_VIEW_H_ 6 #define VIEWS_BUBBLE_BUBBLE_VIEW_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string>
10
11 #include "base/gtest_prod_util.h"
12 #include "third_party/skia/include/core/SkColor.h"
13 #include "ui/base/animation/animation_delegate.h" 9 #include "ui/base/animation/animation_delegate.h"
14 #include "views/accelerator.h" 10 #include "views/accelerator.h"
15 #include "views/focus/focus_manager.h"
16 #include "views/view.h"
17 #include "views/window/client_view.h" 11 #include "views/window/client_view.h"
18 12
19 namespace ui { 13 namespace ui {
20 class SlideAnimation; 14 class SlideAnimation;
21 } // namespace ui 15 } // namespace ui
22 16
23 namespace views { 17 namespace views {
24 18
25 // To show a bubble:
26 // - Call Show() explicitly. This will not start a fading animation.
27 // - Call StartFade() this starts a fading out sequence that will be
28 // cut short on VKEY_ESCAPE.
29 class VIEWS_EXPORT BubbleView : public ClientView, 19 class VIEWS_EXPORT BubbleView : public ClientView,
30 public ui::AnimationDelegate { 20 public ui::AnimationDelegate {
31 public: 21 public:
32 BubbleView(Widget* widget, View* contents_view); 22 BubbleView(Widget* widget, View* contents_view);
33 virtual ~BubbleView(); 23 virtual ~BubbleView();
34 24
35 // Starts a fade (out) animation. Unless this method is called, bubble will 25 // ClientView overrides:
36 // stay until ui::VKEY_ESCAPE is sent. 26 virtual BubbleView* AsBubbleView() OVERRIDE { return this; }
37 void StartFade(); 27 virtual const BubbleView* AsBubbleView() const OVERRIDE { return this; }
38 28
39 // Shows the bubble. 29 void set_close_on_esc(bool close_on_esc) { close_on_esc_ = close_on_esc; }
40 void Show();
41 30
42 void set_animation_delegate(ui::AnimationDelegate* delegate); 31 // Starts a fade animation, fade out closes the widget upon completion.
43 32 void StartFade(bool fade_in);
44 virtual BubbleView* AsBubbleView() OVERRIDE;
45 virtual const BubbleView* AsBubbleView() const OVERRIDE;
46 33
47 protected: 34 protected:
48 virtual void ViewHierarchyChanged(bool is_add, 35 // View overrides:
49 views::View* parent,
50 views::View* child) OVERRIDE;
51
52 virtual bool AcceleratorPressed(const Accelerator& accelerator) OVERRIDE; 36 virtual bool AcceleratorPressed(const Accelerator& accelerator) OVERRIDE;
53 virtual void Layout() OVERRIDE;
54 virtual gfx::Size GetPreferredSize() OVERRIDE;
55 37
56 private: 38 private:
57 FRIEND_TEST(BubbleViewTest, FadeAnimation); 39 // ui::AnimationDelegate overrides:
58
59 void InitAnimation();
60
61 // Sets up the layout manager based on currently initialized views. Should be
62 // called when a view is initialized or changed.
63 void ResetLayoutManager();
64
65 // Close bubble when animation ended.
66 virtual void AnimationEnded(const ui::Animation* animation); 40 virtual void AnimationEnded(const ui::Animation* animation);
67
68 // notify on animation progress.
69 virtual void AnimationProgressed(const ui::Animation* animation); 41 virtual void AnimationProgressed(const ui::Animation* animation);
70 42
71 // Fade animation for bubble. 43 // Fade animation for bubble.
72 scoped_ptr<ui::SlideAnimation> fade_animation_; 44 scoped_ptr<ui::SlideAnimation> fade_animation_;
73 45
74 // Not owned. 46 // Should this bubble close on the escape key?
75 ui::AnimationDelegate* animation_delegate_; 47 bool close_on_esc_;
76
77 bool registered_accelerator_;
78
79 bool should_fade_;
80 48
81 DISALLOW_COPY_AND_ASSIGN(BubbleView); 49 DISALLOW_COPY_AND_ASSIGN(BubbleView);
82 }; 50 };
83 51
84 } // namespace views 52 } // namespace views
85 53
86 #endif // VIEWS_BUBBLE_BUBBLE_VIEW_H_ 54 #endif // VIEWS_BUBBLE_BUBBLE_VIEW_H_
OLDNEW
« no previous file with comments | « views/bubble/bubble_frame_view_unittest.cc ('k') | views/bubble/bubble_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698