| OLD | NEW |
| 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; } |
| 27 virtual const BubbleView* AsBubbleView() const OVERRIDE { return this; } |
| 28 |
| 29 // Starts a fade-out animation, which closes the widget upon completion. |
| 37 void StartFade(); | 30 void StartFade(); |
| 38 | 31 |
| 39 // Shows the bubble. | |
| 40 void Show(); | |
| 41 | |
| 42 void set_animation_delegate(ui::AnimationDelegate* delegate); | |
| 43 | |
| 44 virtual BubbleView* AsBubbleView() OVERRIDE; | |
| 45 virtual const BubbleView* AsBubbleView() const OVERRIDE; | |
| 46 | |
| 47 protected: | 32 protected: |
| 48 virtual void ViewHierarchyChanged(bool is_add, | 33 // View overrides: |
| 49 views::View* parent, | |
| 50 views::View* child) OVERRIDE; | |
| 51 | |
| 52 virtual bool AcceleratorPressed(const Accelerator& accelerator) OVERRIDE; | 34 virtual bool AcceleratorPressed(const Accelerator& accelerator) OVERRIDE; |
| 53 virtual void Layout() OVERRIDE; | |
| 54 virtual gfx::Size GetPreferredSize() OVERRIDE; | |
| 55 | 35 |
| 56 private: | 36 private: |
| 57 FRIEND_TEST(BubbleViewTest, FadeAnimation); | 37 // 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); | 38 virtual void AnimationEnded(const ui::Animation* animation); |
| 67 | |
| 68 // notify on animation progress. | |
| 69 virtual void AnimationProgressed(const ui::Animation* animation); | 39 virtual void AnimationProgressed(const ui::Animation* animation); |
| 70 | 40 |
| 71 // Fade animation for bubble. | 41 // Fade animation for bubble. |
| 72 scoped_ptr<ui::SlideAnimation> fade_animation_; | 42 scoped_ptr<ui::SlideAnimation> fade_animation_; |
| 73 | 43 |
| 74 // Not owned. | |
| 75 ui::AnimationDelegate* animation_delegate_; | |
| 76 | |
| 77 bool registered_accelerator_; | |
| 78 | |
| 79 bool should_fade_; | |
| 80 | |
| 81 DISALLOW_COPY_AND_ASSIGN(BubbleView); | 44 DISALLOW_COPY_AND_ASSIGN(BubbleView); |
| 82 }; | 45 }; |
| 83 | 46 |
| 84 } // namespace views | 47 } // namespace views |
| 85 | 48 |
| 86 #endif // VIEWS_BUBBLE_BUBBLE_VIEW_H_ | 49 #endif // VIEWS_BUBBLE_BUBBLE_VIEW_H_ |
| OLD | NEW |