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"
17 views::View
* anchor_view
;
18 views::BubbleBorder::Arrow arrow
;
21 class ExampleBubbleDelegateView
: public views::BubbleDelegateView
{
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_
);
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
) {
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();