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

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

Issue 145033006: views: Make View::set_border() take a scoped_ptr<>. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove ClearBorder() Created 6 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 | Annotate | Revision Log
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/bubble_frame_view.h" 5 #include "ui/views/bubble/bubble_frame_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "grit/ui_resources.h" 9 #include "grit/ui_resources.h"
10 #include "ui/base/hit_test.h" 10 #include "ui/base/hit_test.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 AddChildView(title_); 73 AddChildView(title_);
74 74
75 close_ = new LabelButton(this, base::string16()); 75 close_ = new LabelButton(this, base::string16());
76 close_->SetImage(CustomButton::STATE_NORMAL, 76 close_->SetImage(CustomButton::STATE_NORMAL,
77 *rb.GetImageNamed(IDR_CLOSE_DIALOG).ToImageSkia()); 77 *rb.GetImageNamed(IDR_CLOSE_DIALOG).ToImageSkia());
78 close_->SetImage(CustomButton::STATE_HOVERED, 78 close_->SetImage(CustomButton::STATE_HOVERED,
79 *rb.GetImageNamed(IDR_CLOSE_DIALOG_H).ToImageSkia()); 79 *rb.GetImageNamed(IDR_CLOSE_DIALOG_H).ToImageSkia());
80 close_->SetImage(CustomButton::STATE_PRESSED, 80 close_->SetImage(CustomButton::STATE_PRESSED,
81 *rb.GetImageNamed(IDR_CLOSE_DIALOG_P).ToImageSkia()); 81 *rb.GetImageNamed(IDR_CLOSE_DIALOG_P).ToImageSkia());
82 close_->SetSize(close_->GetPreferredSize()); 82 close_->SetSize(close_->GetPreferredSize());
83 close_->set_border(NULL); 83 close_->SetBorder(scoped_ptr<Border>());
84 close_->SetVisible(false); 84 close_->SetVisible(false);
85 AddChildView(close_); 85 AddChildView(close_);
86 } 86 }
87 87
88 BubbleFrameView::~BubbleFrameView() {} 88 BubbleFrameView::~BubbleFrameView() {}
89 89
90 gfx::Rect BubbleFrameView::GetBoundsForClientView() const { 90 gfx::Rect BubbleFrameView::GetBoundsForClientView() const {
91 gfx::Rect client_bounds = GetLocalBounds(); 91 gfx::Rect client_bounds = GetLocalBounds();
92 client_bounds.Inset(GetInsets()); 92 client_bounds.Inset(GetInsets());
93 client_bounds.Inset(bubble_border_->GetInsets()); 93 client_bounds.Inset(bubble_border_->GetInsets());
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 UpdateWindowTitle(); 221 UpdateWindowTitle();
222 ResetWindowControls(); 222 ResetWindowControls();
223 UpdateWindowIcon(); 223 UpdateWindowIcon();
224 } 224 }
225 225
226 void BubbleFrameView::ButtonPressed(Button* sender, const ui::Event& event) { 226 void BubbleFrameView::ButtonPressed(Button* sender, const ui::Event& event) {
227 if (sender == close_) 227 if (sender == close_)
228 GetWidget()->Close(); 228 GetWidget()->Close();
229 } 229 }
230 230
231 void BubbleFrameView::SetBubbleBorder(BubbleBorder* border) { 231 void BubbleFrameView::SetBubbleBorder(scoped_ptr<BubbleBorder> border) {
232 bubble_border_ = border; 232 bubble_border_ = border.get();
233 set_border(bubble_border_); 233 SetBorder(border.PassAs<Border>());
234 234
235 // Update the background, which relies on the border. 235 // Update the background, which relies on the border.
236 set_background(new views::BubbleBackground(border)); 236 set_background(new views::BubbleBackground(bubble_border_));
237 } 237 }
238 238
239 void BubbleFrameView::SetTitlebarExtraView(View* view) { 239 void BubbleFrameView::SetTitlebarExtraView(View* view) {
240 DCHECK(view); 240 DCHECK(view);
241 DCHECK(!titlebar_extra_view_); 241 DCHECK(!titlebar_extra_view_);
242 AddChildView(view); 242 AddChildView(view);
243 titlebar_extra_view_ = view; 243 titlebar_extra_view_ = view;
244 } 244 }
245 245
246 gfx::Rect BubbleFrameView::GetUpdatedWindowBounds(const gfx::Rect& anchor_rect, 246 gfx::Rect BubbleFrameView::GetUpdatedWindowBounds(const gfx::Rect& anchor_rect,
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 if (titlebar_extra_view_ != NULL) 346 if (titlebar_extra_view_ != NULL)
347 title_bar_width += titlebar_extra_view_->GetPreferredSize().width(); 347 title_bar_width += titlebar_extra_view_->GetPreferredSize().width();
348 gfx::Size size(client_size); 348 gfx::Size size(client_size);
349 size.SetToMax(gfx::Size(title_bar_width, 0)); 349 size.SetToMax(gfx::Size(title_bar_width, 0));
350 const gfx::Insets insets(GetInsets()); 350 const gfx::Insets insets(GetInsets());
351 size.Enlarge(insets.width(), insets.height()); 351 size.Enlarge(insets.width(), insets.height());
352 return size; 352 return size;
353 } 353 }
354 354
355 } // namespace views 355 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698