| OLD | NEW |
| 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 "ui/gfx/screen.h" | 9 #include "ui/gfx/screen.h" |
| 10 #include "ui/views/bubble/bubble_border.h" | 10 #include "ui/views/bubble/bubble_border.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 BubbleFrameView::BubbleFrameView(const gfx::Insets& margins, | 42 BubbleFrameView::BubbleFrameView(const gfx::Insets& margins, |
| 43 BubbleBorder* border) | 43 BubbleBorder* border) |
| 44 : bubble_border_(border), | 44 : bubble_border_(border), |
| 45 content_margins_(margins) { | 45 content_margins_(margins) { |
| 46 set_border(bubble_border_); | 46 set_border(bubble_border_); |
| 47 } | 47 } |
| 48 | 48 |
| 49 BubbleFrameView::~BubbleFrameView() {} | 49 BubbleFrameView::~BubbleFrameView() {} |
| 50 | 50 |
| 51 gfx::Rect BubbleFrameView::GetBoundsForClientView() const { | 51 gfx::Rect BubbleFrameView::GetBoundsForClientView() const { |
| 52 gfx::Insets margin = bubble_border()->GetInsets(); | 52 gfx::Rect client_bounds = GetLocalBounds(); |
| 53 margin += content_margins(); | 53 client_bounds.Inset(border()->GetInsets()); |
| 54 return gfx::Rect(margin.left(), margin.top(), | 54 client_bounds.Inset(content_margins()); |
| 55 std::max(width() - margin.width(), 0), | 55 return client_bounds; |
| 56 std::max(height() - margin.height(), 0)); | |
| 57 } | 56 } |
| 58 | 57 |
| 59 gfx::Rect BubbleFrameView::GetWindowBoundsForClientBounds( | 58 gfx::Rect BubbleFrameView::GetWindowBoundsForClientBounds( |
| 60 const gfx::Rect& client_bounds) const { | 59 const gfx::Rect& client_bounds) const { |
| 61 return const_cast<BubbleFrameView*>(this)->GetUpdatedWindowBounds( | 60 return const_cast<BubbleFrameView*>(this)->GetUpdatedWindowBounds( |
| 62 gfx::Rect(), client_bounds.size(), false); | 61 gfx::Rect(), client_bounds.size(), false); |
| 63 } | 62 } |
| 64 | 63 |
| 65 int BubbleFrameView::NonClientHitTest(const gfx::Point& point) { | 64 int BubbleFrameView::NonClientHitTest(const gfx::Point& point) { |
| 66 return GetWidget()->client_view()->NonClientHitTest(point); | 65 return GetWidget()->client_view()->NonClientHitTest(point); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 // |offscreen_adjust|, e.g. positive |offscreen_adjust| means bubble | 161 // |offscreen_adjust|, e.g. positive |offscreen_adjust| means bubble |
| 163 // window needs to be moved to the right and that means we need to move arrow | 162 // window needs to be moved to the right and that means we need to move arrow |
| 164 // to the left, and that means negative offset. | 163 // to the left, and that means negative offset. |
| 165 bubble_border_->set_arrow_offset( | 164 bubble_border_->set_arrow_offset( |
| 166 bubble_border_->GetArrowOffset(window_bounds.size()) - offscreen_adjust); | 165 bubble_border_->GetArrowOffset(window_bounds.size()) - offscreen_adjust); |
| 167 if (offscreen_adjust) | 166 if (offscreen_adjust) |
| 168 SchedulePaint(); | 167 SchedulePaint(); |
| 169 } | 168 } |
| 170 | 169 |
| 171 } // namespace views | 170 } // namespace views |
| OLD | NEW |