OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef ASH_POPUP_MESSAGE_H_ |
| 6 #define ASH_POPUP_MESSAGE_H_ |
| 7 |
| 8 #include "ash/ash_export.h" |
| 9 #include "base/basictypes.h" |
| 10 #include "base/string16.h" |
| 11 #include "ui/gfx/rect.h" |
| 12 #include "ui/views/bubble/bubble_border.h" |
| 13 |
| 14 namespace views { |
| 15 class BubbleDelegateView; |
| 16 } |
| 17 |
| 18 namespace ash { |
| 19 |
| 20 // PopupMessage shows a message to the user. Since the user is not able to |
| 21 // dismiss it, the calling code needs to explictly close and destroy it. |
| 22 class ASH_EXPORT PopupMessage { |
| 23 public: |
| 24 enum IconType { |
| 25 ICON_WARNING, |
| 26 ICON_NONE |
| 27 }; |
| 28 |
| 29 // Creates a message pointing towards |anchor| with the requested |
| 30 // |arrow_orientation|. The message contains an optional |caption| which is |
| 31 // drawn in bold and an optional |message| together with an optional icon of |
| 32 // shape |message_type|. If a component in |size_override| is not 0 the value |
| 33 // is the used as output size. If |arrow_offset| is not 0, the number is the |
| 34 // arrow offset in pixels from the border. |
| 35 // |
| 36 // Here is the layout (arrow given as TOP_LEFT): |
| 37 // |--------| |
| 38 // | Anchor | |
| 39 // |--------| |
| 40 // |-arrow_offset---^ |
| 41 // +-------------------------------------------------+ |
| 42 // -| |- |
| 43 // icon | [!] Caption in bold which can be multi line | caption_label |
| 44 // -| |- |
| 45 // | Message text which can be multi line | message_label |
| 46 // | as well. | |
| 47 // | |- |
| 48 // +-------------------------------------------------+ |
| 49 PopupMessage(const base::string16& caption, |
| 50 const base::string16& message, |
| 51 IconType message_type, |
| 52 views::View* anchor, |
| 53 views::BubbleBorder::Arrow arrow, |
| 54 const gfx::Size& size_override, |
| 55 int arrow_offset); |
| 56 // If the message was not explicitly closed before, it closes the message |
| 57 // without animation. |
| 58 virtual ~PopupMessage(); |
| 59 |
| 60 // Closes the message with a fade out animation. |
| 61 void Close(); |
| 62 |
| 63 private: |
| 64 class MessageBubble; |
| 65 |
| 66 void CancelHidingAnimation(); |
| 67 |
| 68 MessageBubble* view_; |
| 69 views::Widget* widget_; |
| 70 |
| 71 // Variables of the construction time. |
| 72 views::View* anchor_; |
| 73 base::string16 caption_; |
| 74 base::string16 message_; |
| 75 IconType message_type_; |
| 76 views::BubbleBorder::Arrow arrow_orientation_; |
| 77 |
| 78 DISALLOW_COPY_AND_ASSIGN(PopupMessage); |
| 79 }; |
| 80 |
| 81 } // namespace ash |
| 82 |
| 83 #endif // ASH_POPUP_MESSAGE_H_ |
OLD | NEW |