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

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

Issue 273223002: views: Make view::Views::GetPreferredSize() const. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More compile fix for ToT Created 6 years, 7 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
« no previous file with comments | « ui/views/bubble/tray_bubble_view.h ('k') | ui/views/color_chooser/color_chooser_view.cc » ('j') | 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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 gfx::Insets TrayBubbleView::GetBorderInsets() const { 386 gfx::Insets TrayBubbleView::GetBorderInsets() const {
387 return bubble_border_->GetInsets(); 387 return bubble_border_->GetInsets();
388 } 388 }
389 389
390 void TrayBubbleView::Init() { 390 void TrayBubbleView::Init() {
391 BoxLayout* layout = new BottomAlignedBoxLayout(this); 391 BoxLayout* layout = new BottomAlignedBoxLayout(this);
392 layout->set_main_axis_alignment(views::BoxLayout::MAIN_AXIS_ALIGNMENT_FILL); 392 layout->set_main_axis_alignment(views::BoxLayout::MAIN_AXIS_ALIGNMENT_FILL);
393 SetLayoutManager(layout); 393 SetLayoutManager(layout);
394 } 394 }
395 395
396 gfx::Rect TrayBubbleView::GetAnchorRect() { 396 gfx::Rect TrayBubbleView::GetAnchorRect() const {
397 if (!delegate_) 397 if (!delegate_)
398 return gfx::Rect(); 398 return gfx::Rect();
399 return delegate_->GetAnchorRect(anchor_widget(), 399 return delegate_->GetAnchorRect(anchor_widget(),
400 params_.anchor_type, 400 params_.anchor_type,
401 params_.anchor_alignment); 401 params_.anchor_alignment);
402 } 402 }
403 403
404 bool TrayBubbleView::CanActivate() const { 404 bool TrayBubbleView::CanActivate() const {
405 return params_.can_activate; 405 return params_.can_activate;
406 } 406 }
407 407
408 NonClientFrameView* TrayBubbleView::CreateNonClientFrameView(Widget* widget) { 408 NonClientFrameView* TrayBubbleView::CreateNonClientFrameView(Widget* widget) {
409 BubbleFrameView* frame = new BubbleFrameView(margins()); 409 BubbleFrameView* frame = new BubbleFrameView(margins());
410 frame->SetBubbleBorder(scoped_ptr<views::BubbleBorder>(bubble_border_)); 410 frame->SetBubbleBorder(scoped_ptr<views::BubbleBorder>(bubble_border_));
411 return frame; 411 return frame;
412 } 412 }
413 413
414 bool TrayBubbleView::WidgetHasHitTestMask() const { 414 bool TrayBubbleView::WidgetHasHitTestMask() const {
415 return true; 415 return true;
416 } 416 }
417 417
418 void TrayBubbleView::GetWidgetHitTestMask(gfx::Path* mask) const { 418 void TrayBubbleView::GetWidgetHitTestMask(gfx::Path* mask) const {
419 DCHECK(mask); 419 DCHECK(mask);
420 mask->addRect(gfx::RectToSkRect(GetBubbleFrameView()->GetContentsBounds())); 420 mask->addRect(gfx::RectToSkRect(GetBubbleFrameView()->GetContentsBounds()));
421 } 421 }
422 422
423 gfx::Size TrayBubbleView::GetPreferredSize() { 423 gfx::Size TrayBubbleView::GetPreferredSize() const {
424 return gfx::Size(preferred_width_, GetHeightForWidth(preferred_width_)); 424 return gfx::Size(preferred_width_, GetHeightForWidth(preferred_width_));
425 } 425 }
426 426
427 gfx::Size TrayBubbleView::GetMaximumSize() { 427 gfx::Size TrayBubbleView::GetMaximumSize() {
428 gfx::Size size = GetPreferredSize(); 428 gfx::Size size = GetPreferredSize();
429 size.set_width(params_.max_width); 429 size.set_width(params_.max_width);
430 return size; 430 return size;
431 } 431 }
432 432
433 int TrayBubbleView::GetHeightForWidth(int width) { 433 int TrayBubbleView::GetHeightForWidth(int width) const {
434 int height = GetInsets().height(); 434 int height = GetInsets().height();
435 width = std::max(width - GetInsets().width(), 0); 435 width = std::max(width - GetInsets().width(), 0);
436 for (int i = 0; i < child_count(); ++i) { 436 for (int i = 0; i < child_count(); ++i) {
437 View* child = child_at(i); 437 const View* child = child_at(i);
438 if (child->visible()) 438 if (child->visible())
439 height += child->GetHeightForWidth(width); 439 height += child->GetHeightForWidth(width);
440 } 440 }
441 441
442 return (params_.max_height != 0) ? 442 return (params_.max_height != 0) ?
443 std::min(height, params_.max_height) : height; 443 std::min(height, params_.max_height) : height;
444 } 444 }
445 445
446 void TrayBubbleView::OnMouseEntered(const ui::MouseEvent& event) { 446 void TrayBubbleView::OnMouseEntered(const ui::MouseEvent& event) {
447 mouse_watcher_.reset(); 447 mouse_watcher_.reset();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 void TrayBubbleView::ViewHierarchyChanged( 500 void TrayBubbleView::ViewHierarchyChanged(
501 const ViewHierarchyChangedDetails& details) { 501 const ViewHierarchyChangedDetails& details) {
502 if (details.is_add && details.child == this) { 502 if (details.is_add && details.child == this) {
503 details.parent->SetPaintToLayer(true); 503 details.parent->SetPaintToLayer(true);
504 details.parent->SetFillsBoundsOpaquely(true); 504 details.parent->SetFillsBoundsOpaquely(true);
505 details.parent->layer()->SetMasksToBounds(true); 505 details.parent->layer()->SetMasksToBounds(true);
506 } 506 }
507 } 507 }
508 508
509 } // namespace views 509 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/bubble/tray_bubble_view.h ('k') | ui/views/color_chooser/color_chooser_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698