| 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 "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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 gfx::Insets BubbleFrameView::GetInsets() const { | 161 gfx::Insets BubbleFrameView::GetInsets() const { |
| 162 gfx::Insets insets = content_margins_; | 162 gfx::Insets insets = content_margins_; |
| 163 const int title_height = title_->text().empty() ? 0 : | 163 const int title_height = title_->text().empty() ? 0 : |
| 164 title_->GetPreferredSize().height() + kTitleTopInset + kTitleBottomInset; | 164 title_->GetPreferredSize().height() + kTitleTopInset + kTitleBottomInset; |
| 165 const int close_height = close_->visible() ? close_->height() : 0; | 165 const int close_height = close_->visible() ? close_->height() : 0; |
| 166 insets += gfx::Insets(std::max(title_height, close_height), 0, 0, 0); | 166 insets += gfx::Insets(std::max(title_height, close_height), 0, 0, 0); |
| 167 return insets; | 167 return insets; |
| 168 } | 168 } |
| 169 | 169 |
| 170 gfx::Size BubbleFrameView::GetPreferredSize() { | 170 gfx::Size BubbleFrameView::GetPreferredSize() { |
| 171 const gfx::Size client(GetWidget()->client_view()->GetPreferredSize()); | 171 return GetNeededSize(GetWidget()->client_view()->GetPreferredSize()); |
| 172 gfx::Size size(GetUpdatedWindowBounds(gfx::Rect(), client, false).size()); | 172 } |
| 173 |
| 174 gfx::Size BubbleFrameView::GetMinimumSize() { |
| 175 return GetNeededSize(GetWidget()->client_view()->GetMinimumSize()); |
| 176 } |
| 177 |
| 178 gfx::Size BubbleFrameView::GetNeededSize(const gfx::Size& client_size) { |
| 179 gfx::Size size( |
| 180 GetUpdatedWindowBounds(gfx::Rect(), client_size, false).size()); |
| 173 // Accommodate the width of the title bar elements. | 181 // Accommodate the width of the title bar elements. |
| 174 int title_bar_width = GetInsets().width() + border()->GetInsets().width(); | 182 int title_bar_width = GetInsets().width() + border()->GetInsets().width(); |
| 175 if (!title_->text().empty()) | 183 if (!title_->text().empty()) |
| 176 title_bar_width += kTitleLeftInset + title_->GetPreferredSize().width(); | 184 title_bar_width += kTitleLeftInset + title_->GetPreferredSize().width(); |
| 177 if (close_->visible()) | 185 if (close_->visible()) |
| 178 title_bar_width += close_->width() + 1; | 186 title_bar_width += close_->width() + 1; |
| 179 if (titlebar_extra_view_ != NULL) | 187 if (titlebar_extra_view_ != NULL) |
| 180 title_bar_width += titlebar_extra_view_->GetPreferredSize().width(); | 188 title_bar_width += titlebar_extra_view_->GetPreferredSize().width(); |
| 181 size.SetToMax(gfx::Size(title_bar_width, 0)); | 189 size.SetToMax(gfx::Size(title_bar_width, 0)); |
| 182 return size; | 190 return size; |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 // |offscreen_adjust|, e.g. positive |offscreen_adjust| means bubble | 336 // |offscreen_adjust|, e.g. positive |offscreen_adjust| means bubble |
| 329 // window needs to be moved to the right and that means we need to move arrow | 337 // window needs to be moved to the right and that means we need to move arrow |
| 330 // to the left, and that means negative offset. | 338 // to the left, and that means negative offset. |
| 331 bubble_border_->set_arrow_offset( | 339 bubble_border_->set_arrow_offset( |
| 332 bubble_border_->GetArrowOffset(window_bounds.size()) - offscreen_adjust); | 340 bubble_border_->GetArrowOffset(window_bounds.size()) - offscreen_adjust); |
| 333 if (offscreen_adjust) | 341 if (offscreen_adjust) |
| 334 SchedulePaint(); | 342 SchedulePaint(); |
| 335 } | 343 } |
| 336 | 344 |
| 337 } // namespace views | 345 } // namespace views |
| OLD | NEW |