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

Side by Side Diff: ui/views/bubble/tray_bubble_view.cc

Issue 11819048: Implement message center on Windows (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Address miket comments. Created 7 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/bubble/tray_bubble_view.h" 5 #include "ui/views/bubble/tray_bubble_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "third_party/skia/include/core/SkCanvas.h" 9 #include "third_party/skia/include/core/SkCanvas.h"
10 #include "third_party/skia/include/core/SkColor.h" 10 #include "third_party/skia/include/core/SkColor.h"
(...skipping 30 matching lines...) Expand all
41 // to stack bubbles with no arrows correctly. Also calculates the arrow offset. 41 // to stack bubbles with no arrows correctly. Also calculates the arrow offset.
42 class TrayBubbleBorder : public views::BubbleBorder { 42 class TrayBubbleBorder : public views::BubbleBorder {
43 public: 43 public:
44 TrayBubbleBorder(views::View* owner, 44 TrayBubbleBorder(views::View* owner,
45 views::View* anchor, 45 views::View* anchor,
46 TrayBubbleView::InitParams params) 46 TrayBubbleView::InitParams params)
47 : views::BubbleBorder(params.arrow_location, params.shadow), 47 : views::BubbleBorder(params.arrow_location, params.shadow),
48 owner_(owner), 48 owner_(owner),
49 anchor_(anchor), 49 anchor_(anchor),
50 tray_arrow_offset_(params.arrow_offset) { 50 tray_arrow_offset_(params.arrow_offset) {
51 set_alignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); 51 set_alignment(params.arrow_alignment);
52 set_background_color(params.arrow_color); 52 set_background_color(params.arrow_color);
53 } 53 }
54 54
55 virtual ~TrayBubbleBorder() {} 55 virtual ~TrayBubbleBorder() {}
56 56
57 // Overridden from views::BubbleBorder. 57 // Overridden from views::BubbleBorder.
58 // Override views::BubbleBorder to set the bubble on top of the anchor when 58 // Override views::BubbleBorder to set the bubble on top of the anchor when
59 // it has no arrow. 59 // it has no arrow.
60 virtual gfx::Rect GetBounds(const gfx::Rect& position_relative_to, 60 virtual gfx::Rect GetBounds(const gfx::Rect& position_relative_to,
61 const gfx::Size& contents_size) const OVERRIDE { 61 const gfx::Size& contents_size) const OVERRIDE {
62 if (arrow_location() != NONE) { 62 if (has_arrow(arrow_location())) {
63 return views::BubbleBorder::GetBounds(position_relative_to, 63 return views::BubbleBorder::GetBounds(position_relative_to,
64 contents_size); 64 contents_size);
65 } 65 }
66 66
67 gfx::Size border_size(contents_size); 67 gfx::Size border_size(contents_size);
68 gfx::Insets insets = GetInsets(); 68 gfx::Insets insets = GetInsets();
69 border_size.Enlarge(insets.width(), insets.height()); 69 border_size.Enlarge(insets.width(), insets.height());
70 70
71 const int x = position_relative_to.x() + 71 const int x = position_relative_to.x() +
72 position_relative_to.width() / 2 - border_size.width() / 2; 72 position_relative_to.width() / 2 - border_size.width() / 2;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 : anchor_type(anchor_type), 226 : anchor_type(anchor_type),
227 anchor_alignment(anchor_alignment), 227 anchor_alignment(anchor_alignment),
228 min_width(min_width), 228 min_width(min_width),
229 max_width(max_width), 229 max_width(max_width),
230 max_height(0), 230 max_height(0),
231 can_activate(false), 231 can_activate(false),
232 close_on_deactivate(true), 232 close_on_deactivate(true),
233 arrow_color(SK_ColorBLACK), 233 arrow_color(SK_ColorBLACK),
234 arrow_location(views::BubbleBorder::NONE), 234 arrow_location(views::BubbleBorder::NONE),
235 arrow_offset(kArrowDefaultOffset), 235 arrow_offset(kArrowDefaultOffset),
236 shadow(views::BubbleBorder::BIG_SHADOW) { 236 shadow(views::BubbleBorder::BIG_SHADOW),
237 arrow_alignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE) {
237 } 238 }
238 239
239 // static 240 // static
240 TrayBubbleView* TrayBubbleView::Create(gfx::NativeView parent_window, 241 TrayBubbleView* TrayBubbleView::Create(gfx::NativeView parent_window,
241 views::View* anchor, 242 views::View* anchor,
242 Delegate* delegate, 243 Delegate* delegate,
243 InitParams* init_params) { 244 InitParams* init_params) {
244 // Set arrow_location here so that it can be passed correctly to the 245 // Set arrow_location here so that it can be passed correctly to the
245 // BubbleView constructor. 246 // BubbleView constructor.
246 if (init_params->anchor_type == ANCHOR_TYPE_TRAY) { 247 if (init_params->anchor_type == ANCHOR_TYPE_TRAY) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 } 287 }
287 288
288 TrayBubbleView::~TrayBubbleView() { 289 TrayBubbleView::~TrayBubbleView() {
289 // Inform host items (models) that their views are being destroyed. 290 // Inform host items (models) that their views are being destroyed.
290 if (delegate_) 291 if (delegate_)
291 delegate_->BubbleViewDestroyed(); 292 delegate_->BubbleViewDestroyed();
292 } 293 }
293 294
294 void TrayBubbleView::InitializeAndShowBubble() { 295 void TrayBubbleView::InitializeAndShowBubble() {
295 // Must occur after call to BubbleDelegateView::CreateBubble(). 296 // Must occur after call to BubbleDelegateView::CreateBubble().
296 SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); 297 SetAlignment(params_.arrow_alignment);
297 bubble_border_->UpdateArrowOffset(); 298 bubble_border_->UpdateArrowOffset();
298 299
299 if (get_use_acceleration_when_possible()) 300 if (get_use_acceleration_when_possible())
300 layer()->parent()->SetMaskLayer(bubble_content_mask_->layer()); 301 layer()->parent()->SetMaskLayer(bubble_content_mask_->layer());
301 302
302 Show(); 303 Show();
303 UpdateBubble(); 304 UpdateBubble();
304 } 305 }
305 306
306 void TrayBubbleView::UpdateBubble() { 307 void TrayBubbleView::UpdateBubble() {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 views::View* parent, 408 views::View* parent,
408 views::View* child) { 409 views::View* child) {
409 if (get_use_acceleration_when_possible() && is_add && child == this) { 410 if (get_use_acceleration_when_possible() && is_add && child == this) {
410 parent->SetPaintToLayer(true); 411 parent->SetPaintToLayer(true);
411 parent->SetFillsBoundsOpaquely(true); 412 parent->SetFillsBoundsOpaquely(true);
412 parent->layer()->SetMasksToBounds(true); 413 parent->layer()->SetMasksToBounds(true);
413 } 414 }
414 } 415 }
415 416
416 } // namespace views 417 } // namespace views
OLDNEW
« ui/views/bubble/tray_bubble_view.h ('K') | « ui/views/bubble/tray_bubble_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698