Add abhijeet.k@samsung.com to AUTHORS list.
[chromium-blink-merge.git] / ash / shell / bubble.cc
blob1ecd7f5d7cdb13d5cfae915745cb4f8da0615996
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
3 // found in the LICENSE file.
5 #include "base/strings/utf_string_conversions.h"
6 #include "ui/views/bubble/bubble_border.h"
7 #include "ui/views/bubble/bubble_delegate.h"
8 #include "ui/views/controls/label.h"
9 #include "ui/views/layout/fill_layout.h"
10 #include "ui/views/widget/widget.h"
12 namespace ash {
13 namespace shell {
15 struct BubbleConfig {
16 base::string16 label;
17 views::View* anchor_view;
18 views::BubbleBorder::Arrow arrow;
21 class ExampleBubbleDelegateView : public views::BubbleDelegateView {
22 public:
23 explicit ExampleBubbleDelegateView(const BubbleConfig& config);
24 ~ExampleBubbleDelegateView() override;
26 void Init() override {
27 SetLayoutManager(new views::FillLayout());
28 views::Label* label = new views::Label(label_);
29 AddChildView(label);
32 private:
33 base::string16 label_;
36 ExampleBubbleDelegateView::ExampleBubbleDelegateView(const BubbleConfig& config)
37 : BubbleDelegateView(config.anchor_view, config.arrow),
38 label_(config.label) {
41 ExampleBubbleDelegateView::~ExampleBubbleDelegateView() {
44 void CreatePointyBubble(views::View* anchor_view) {
45 BubbleConfig config;
46 config.label = base::ASCIIToUTF16("PointyBubble");
47 config.anchor_view = anchor_view;
48 config.arrow = views::BubbleBorder::TOP_LEFT;
49 ExampleBubbleDelegateView* bubble = new ExampleBubbleDelegateView(config);
50 views::BubbleDelegateView::CreateBubble(bubble)->Show();
53 } // namespace shell
54 } // namespace ash