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

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

Issue 2840623002: Re-land 4ced9f3c7e9534b6b730d: Fix layout of BubbleFrameView when there's only a close button in th… (Closed)
Patch Set: Created 3 years, 8 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 | « no previous file | ui/views/bubble/bubble_frame_view_unittest.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/bubble_frame_view.h" 5 #include "ui/views/bubble/bubble_frame_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 gfx::Insets BubbleFrameView::GetInsets() const { 252 gfx::Insets BubbleFrameView::GetInsets() const {
253 gfx::Insets insets = content_margins_; 253 gfx::Insets insets = content_margins_;
254 254
255 const int icon_height = title_icon_->GetPreferredSize().height(); 255 const int icon_height = title_icon_->GetPreferredSize().height();
256 const int label_height = title_->GetPreferredSize().height(); 256 const int label_height = title_->GetPreferredSize().height();
257 const bool has_title = icon_height > 0 || label_height > 0; 257 const bool has_title = icon_height > 0 || label_height > 0;
258 const int title_padding = has_title ? title_margins_.height() : 0; 258 const int title_padding = has_title ? title_margins_.height() : 0;
259 const int title_height = std::max(icon_height, label_height) + title_padding; 259 const int title_height = std::max(icon_height, label_height) + title_padding;
260 const int close_height = 260 const int close_height =
261 GetWidget()->widget_delegate()->ShouldShowCloseButton() 261 GetWidget()->widget_delegate()->ShouldShowCloseButton()
262 ? close_->height() 262 ? close_->height() + LayoutProvider::Get()->GetDistanceMetric(
263 DISTANCE_CLOSE_BUTTON_MARGIN)
263 : 0; 264 : 0;
264 insets += gfx::Insets(std::max(title_height, close_height), 0, 0, 0); 265 insets += gfx::Insets(std::max(title_height, close_height), 0, 0, 0);
265 return insets; 266 return insets;
266 } 267 }
267 268
268 gfx::Size BubbleFrameView::GetPreferredSize() const { 269 gfx::Size BubbleFrameView::GetPreferredSize() const {
269 // Get the preferred size of the client area. 270 // Get the preferred size of the client area.
270 gfx::Size client_size = GetWidget()->client_view()->GetPreferredSize(); 271 gfx::Size client_size = GetWidget()->client_view()->GetPreferredSize();
271 // Expand it to include the bubble border and space for the arrow. 272 // Expand it to include the bubble border and space for the arrow.
272 return GetWindowBoundsForClientBounds(gfx::Rect(client_size)).size(); 273 return GetWindowBoundsForClientBounds(gfx::Rect(client_size)).size();
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 size.Enlarge(client_insets.width(), client_insets.height()); 531 size.Enlarge(client_insets.width(), client_insets.height());
531 size.SetToMax(gfx::Size(title_bar_width, 0)); 532 size.SetToMax(gfx::Size(title_bar_width, 0));
532 533
533 if (footnote_container_) 534 if (footnote_container_)
534 size.Enlarge(0, footnote_container_->GetHeightForWidth(size.width())); 535 size.Enlarge(0, footnote_container_->GetHeightForWidth(size.width()));
535 536
536 return size; 537 return size;
537 } 538 }
538 539
539 } // namespace views 540 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/bubble/bubble_frame_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698