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

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

Issue 12310022: More flexibility in BubbleBorder arrow rendering. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Address msw style nits. Created 7 years, 10 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
« no previous file with comments | « ui/views/bubble/tray_bubble_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 public: 43 public:
44 TrayBubbleBorder(View* owner, 44 TrayBubbleBorder(View* owner,
45 View* anchor, 45 View* anchor,
46 TrayBubbleView::InitParams params) 46 TrayBubbleView::InitParams params)
47 : BubbleBorder(params.arrow_location, params.shadow, params.arrow_color), 47 : BubbleBorder(params.arrow_location, params.shadow, params.arrow_color),
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(params.arrow_alignment); 51 set_alignment(params.arrow_alignment);
52 set_background_color(params.arrow_color); 52 set_background_color(params.arrow_color);
53 set_paint_arrow(!params.hide_arrow); 53 set_paint_arrow(params.arrow_paint_type);
54 } 54 }
55 55
56 virtual ~TrayBubbleBorder() {} 56 virtual ~TrayBubbleBorder() {}
57 57
58 // Overridden from BubbleBorder. 58 // Overridden from BubbleBorder.
59 // Sets the bubble on top of the anchor when it has no arrow. 59 // Sets the bubble on top of the anchor when 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 (has_arrow(arrow_location())) 62 if (has_arrow(arrow_location()))
63 return BubbleBorder::GetBounds(position_relative_to, contents_size); 63 return BubbleBorder::GetBounds(position_relative_to, contents_size);
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 : anchor_type(anchor_type), 220 : anchor_type(anchor_type),
221 anchor_alignment(anchor_alignment), 221 anchor_alignment(anchor_alignment),
222 min_width(min_width), 222 min_width(min_width),
223 max_width(max_width), 223 max_width(max_width),
224 max_height(0), 224 max_height(0),
225 can_activate(false), 225 can_activate(false),
226 close_on_deactivate(true), 226 close_on_deactivate(true),
227 arrow_color(SK_ColorBLACK), 227 arrow_color(SK_ColorBLACK),
228 arrow_location(BubbleBorder::NONE), 228 arrow_location(BubbleBorder::NONE),
229 arrow_offset(kArrowDefaultOffset), 229 arrow_offset(kArrowDefaultOffset),
230 hide_arrow(false), 230 arrow_paint_type(BubbleBorder::PAINT_NORMAL),
231 shadow(BubbleBorder::BIG_SHADOW), 231 shadow(BubbleBorder::BIG_SHADOW),
232 arrow_alignment(BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE) { 232 arrow_alignment(BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE) {
233 } 233 }
234 234
235 // static 235 // static
236 TrayBubbleView* TrayBubbleView::Create(gfx::NativeView parent_window, 236 TrayBubbleView* TrayBubbleView::Create(gfx::NativeView parent_window,
237 View* anchor, 237 View* anchor,
238 Delegate* delegate, 238 Delegate* delegate,
239 InitParams* init_params) { 239 InitParams* init_params) {
240 // Set arrow_location here so that it can be passed correctly to the 240 // Set arrow_location here so that it can be passed correctly to the
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 314
315 void TrayBubbleView::SetWidth(int width) { 315 void TrayBubbleView::SetWidth(int width) {
316 width = std::max(std::min(width, params_.max_width), params_.min_width); 316 width = std::max(std::min(width, params_.max_width), params_.min_width);
317 if (preferred_width_ == width) 317 if (preferred_width_ == width)
318 return; 318 return;
319 preferred_width_ = width; 319 preferred_width_ = width;
320 if (GetWidget()) 320 if (GetWidget())
321 SizeToContents(); 321 SizeToContents();
322 } 322 }
323 323
324 void TrayBubbleView::SetPaintArrow(bool paint_arrow) { 324 void TrayBubbleView::SetArrowPaintType(
325 bubble_border_->set_paint_arrow(paint_arrow && !params_.hide_arrow); 325 views::BubbleBorder::ArrowPaintType paint_type) {
326 bubble_border_->set_paint_arrow(paint_type);
326 } 327 }
327 328
328 gfx::Insets TrayBubbleView::GetBorderInsets() const { 329 gfx::Insets TrayBubbleView::GetBorderInsets() const {
329 return bubble_border_->GetInsets(); 330 return bubble_border_->GetInsets();
330 } 331 }
331 332
332 void TrayBubbleView::Init() { 333 void TrayBubbleView::Init() {
333 BoxLayout* layout = new BottomAlignedBoxLayout(this); 334 BoxLayout* layout = new BottomAlignedBoxLayout(this);
334 layout->set_spread_blank_space(true); 335 layout->set_spread_blank_space(true);
335 SetLayoutManager(layout); 336 SetLayoutManager(layout);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 View* parent, 402 View* parent,
402 View* child) { 403 View* child) {
403 if (get_use_acceleration_when_possible() && is_add && child == this) { 404 if (get_use_acceleration_when_possible() && is_add && child == this) {
404 parent->SetPaintToLayer(true); 405 parent->SetPaintToLayer(true);
405 parent->SetFillsBoundsOpaquely(true); 406 parent->SetFillsBoundsOpaquely(true);
406 parent->layer()->SetMasksToBounds(true); 407 parent->layer()->SetMasksToBounds(true);
407 } 408 }
408 } 409 }
409 410
410 } // namespace views 411 } // namespace views
OLDNEW
« no previous file with comments | « 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