Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(441)

Unified Diff: ui/aura_shell/examples/bubble.cc

Issue 8227003: Views Bubble API adjustments and cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add close_on_esc setting and fade-in functionality. Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/aura_shell/examples/example_factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..bea8cb830556ee67076727b83f26c0376db591ac 100644
--- a/ui/aura_shell/examples/bubble.cc
+++ b/ui/aura_shell/examples/bubble.cc
@@ -7,6 +7,7 @@
#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 {
@@ -15,54 +16,47 @@ namespace examples {
struct BubbleConfig {
string16 label;
SkColor color;
- gfx::Rect bound;
+ gfx::Point anchor_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) {}
- // 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 {
+ virtual gfx::Point GetAnchorPoint() const OVERRIDE {
+ return config_.anchor_point;
+ }
+
+ views::BubbleBorder::ArrowLocation GetArrowLocation() const OVERRIDE {
return config_.arrow;
}
+ SkColor GetColor() const OVERRIDE {
+ return config_.color;
+}
+
+ 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);
+ }
+
private:
const BubbleConfig config_;
-
- DISALLOW_COPY_AND_ASSIGN(ExampleBubbleDelegateView);
};
-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();
-}
-
-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.anchor_point = origin;
config.arrow = views::BubbleBorder::TOP_LEFT;
- config.fade_out = false;
- CreateBubble(config, parent);
+ views::Widget* bubble = views::BubbleDelegateView::CreateBubble(
+ new ExampleBubbleDelegateView(config), parent);
+ bubble->Show();
}
} // namespace examples
« no previous file with comments | « no previous file | ui/aura_shell/examples/example_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698