| Index: ui/aura_shell/examples/bubble.cc
|
| diff --git a/ui/aura_shell/examples/bubble.cc b/ui/aura_shell/examples/bubble.cc
|
| index d0bbbdc58e459a3097ca0403926da97442b8b3ba..e66e9ec03c0f3609c728c9d3340ead151a8c00af 100644
|
| --- a/ui/aura_shell/examples/bubble.cc
|
| +++ b/ui/aura_shell/examples/bubble.cc
|
| @@ -7,62 +7,59 @@
|
| #include "views/bubble/bubble_delegate.h"
|
| #include "views/bubble/bubble_view.h"
|
| #include "views/controls/label.h"
|
| +#include "views/layout/fill_layout.h"
|
| #include "views/widget/widget.h"
|
|
|
| namespace aura_shell {
|
| +
|
| namespace examples {
|
|
|
| struct BubbleConfig {
|
| string16 label;
|
| SkColor color;
|
| - gfx::Rect bound;
|
| + gfx::Point arrow_point;
|
| views::BubbleBorder::ArrowLocation arrow;
|
| bool fade_out;
|
| };
|
|
|
| class ExampleBubbleDelegateView : public views::BubbleDelegateView {
|
| public:
|
| - ExampleBubbleDelegateView(const BubbleConfig& config, views::Widget* widget)
|
| - : BubbleDelegateView(widget),
|
| - config_(config) {}
|
| - virtual ~ExampleBubbleDelegateView() {}
|
| + ExampleBubbleDelegateView(const BubbleConfig& config)
|
| + : config_(config) {}
|
| +
|
| + virtual gfx::Point GetArrowPoint() const OVERRIDE {
|
| + return config_.arrow_point;
|
| + }
|
|
|
| - // Overridden from views::BubbleDelegateView
|
| - virtual views::View* GetContentsView() OVERRIDE { return this; }
|
| - virtual SkColor GetFrameBackgroundColor() OVERRIDE { return config_.color; }
|
| - virtual gfx::Rect GetBounds() OVERRIDE { return config_.bound; }
|
| - virtual views::BubbleBorder::ArrowLocation GetFrameArrowLocation() OVERRIDE {
|
| + views::BubbleBorder::ArrowLocation GetArrowLocation() const OVERRIDE {
|
| return config_.arrow;
|
| }
|
|
|
| - private:
|
| - const BubbleConfig config_;
|
| + SkColor GetColor() const OVERRIDE {
|
| + return config_.color;
|
| +}
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(ExampleBubbleDelegateView);
|
| -};
|
| + virtual void Init() OVERRIDE {
|
| + SetLayoutManager(new views::FillLayout());
|
| + views::Label* label = new views::Label(config_.label);
|
| + label->set_border(views::Border::CreateSolidBorder(10, config_.color));
|
| + AddChildView(label);
|
| + }
|
|
|
| -void CreateBubble(const BubbleConfig& config,
|
| - gfx::NativeWindow parent) {
|
| - views::Widget* bubble_widget = new views::Widget;
|
| - views::Widget::InitParams params(views::Widget::InitParams::TYPE_BUBBLE);
|
| - params.delegate = new ExampleBubbleDelegateView(config, bubble_widget);
|
| - params.transparent = true;
|
| - params.bounds = config.bound;
|
| - params.parent = parent;
|
| - bubble_widget->Init(params);
|
| - bubble_widget->client_view()->AsBubbleView()->AddChildView(
|
| - new views::Label(ASCIIToUTF16("I am a ") + config.label));
|
| - bubble_widget->Show();
|
| -}
|
| + private:
|
| + const BubbleConfig& config_;
|
| +};
|
|
|
| -void CreatePointyBubble(gfx::NativeWindow parent, const gfx::Point& origin) {
|
| +void CreatePointyBubble(views::Widget* parent, const gfx::Point& origin) {
|
| BubbleConfig config;
|
| config.label = ASCIIToUTF16("PointyBubble");
|
| config.color = SK_ColorWHITE;
|
| - config.bound = gfx::Rect(origin.x(), origin.y(), 180, 180);
|
| + config.arrow_point = origin;
|
| config.arrow = views::BubbleBorder::TOP_LEFT;
|
| config.fade_out = false;
|
| - CreateBubble(config, parent);
|
| + views::Widget* bubble = views::BubbleDelegateView::ConstructBubble(
|
| + new ExampleBubbleDelegateView(config), parent);
|
| + bubble->Show();
|
| }
|
|
|
| } // namespace examples
|
|
|