summaryrefslogtreecommitdiff
path: root/chromium/ash/shell/bubble.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/ash/shell/bubble.cc')
-rw-r--r--chromium/ash/shell/bubble.cc47
1 files changed, 47 insertions, 0 deletions
diff --git a/chromium/ash/shell/bubble.cc b/chromium/ash/shell/bubble.cc
new file mode 100644
index 00000000000..c39f76a60f0
--- /dev/null
+++ b/chromium/ash/shell/bubble.cc
@@ -0,0 +1,47 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/strings/utf_string_conversions.h"
+#include "ui/views/bubble/bubble_border.h"
+#include "ui/views/bubble/bubble_delegate.h"
+#include "ui/views/controls/label.h"
+#include "ui/views/layout/fill_layout.h"
+#include "ui/views/widget/widget.h"
+
+namespace ash {
+namespace shell {
+
+struct BubbleConfig {
+ base::string16 label;
+ views::View* anchor_view;
+ views::BubbleBorder::Arrow arrow;
+};
+
+class ExampleBubbleDelegateView : public views::BubbleDelegateView {
+ public:
+ ExampleBubbleDelegateView(const BubbleConfig& config)
+ : BubbleDelegateView(config.anchor_view, config.arrow),
+ label_(config.label) {}
+
+ virtual void Init() OVERRIDE {
+ SetLayoutManager(new views::FillLayout());
+ views::Label* label = new views::Label(label_);
+ AddChildView(label);
+ }
+
+ private:
+ base::string16 label_;
+};
+
+void CreatePointyBubble(views::View* anchor_view) {
+ BubbleConfig config;
+ config.label = ASCIIToUTF16("PointyBubble");
+ config.anchor_view = anchor_view;
+ config.arrow = views::BubbleBorder::TOP_LEFT;
+ ExampleBubbleDelegateView* bubble = new ExampleBubbleDelegateView(config);
+ views::BubbleDelegateView::CreateBubble(bubble)->Show();
+}
+
+} // namespace shell
+} // namespace ash