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

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

Issue 1950863002: [Views] Center bubble title text vertically when title icon is tall. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 if (bounds.IsEmpty()) 295 if (bounds.IsEmpty())
296 return; 296 return;
297 297
298 // The close button is positioned somewhat closer to the edge of the bubble. 298 // The close button is positioned somewhat closer to the edge of the bubble.
299 gfx::Point close_position = GetContentsBounds().top_right(); 299 gfx::Point close_position = GetContentsBounds().top_right();
300 close_position += gfx::Vector2d(-close_->width() - 7, 6); 300 close_position += gfx::Vector2d(-close_->width() - 7, 6);
301 close_->SetPosition(close_position); 301 close_->SetPosition(close_position);
302 302
303 gfx::Size title_icon_pref_size(title_icon_->GetPreferredSize()); 303 gfx::Size title_icon_pref_size(title_icon_->GetPreferredSize());
304 int padding = 0; 304 int padding = 0;
305 int title_height = title_icon_pref_size.height();
305 306
306 if (title_->visible() && !title_->text().empty()) { 307 if (title_->visible() && !title_->text().empty()) {
307 if (title_icon_pref_size.width() > 0) 308 if (title_icon_pref_size.width() > 0)
308 padding = title_margins_.left(); 309 padding = title_margins_.left();
309 310
310 const int title_label_x = 311 const int title_label_x =
311 bounds.x() + title_icon_pref_size.width() + padding; 312 bounds.x() + title_icon_pref_size.width() + padding;
312 title_->SizeToFit(std::max(1, close_->x() - title_label_x)); 313 title_->SizeToFit(std::max(1, close_->x() - title_label_x));
313 title_->SetPosition(gfx::Point(title_label_x, bounds.y())); 314 title_height = std::max(title_height, title_->height());
315 title_->SetPosition(gfx::Point(
316 title_label_x, bounds.y() + (title_height - title_->height()) / 2));
314 } 317 }
315 318
316 const int title_height =
317 std::max(title_icon_pref_size.height(), title_->height());
318 title_icon_->SetBounds(bounds.x(), bounds.y(), title_icon_pref_size.width(), 319 title_icon_->SetBounds(bounds.x(), bounds.y(), title_icon_pref_size.width(),
319 title_height); 320 title_height);
320 bounds.set_width(title_->bounds().right() - bounds.x()); 321 bounds.set_width(title_->bounds().right() - bounds.x());
321 bounds.set_height(title_height); 322 bounds.set_height(title_height);
322 323
323 if (footnote_container_) { 324 if (footnote_container_) {
324 gfx::Rect local_bounds = GetContentsBounds(); 325 gfx::Rect local_bounds = GetContentsBounds();
325 int height = footnote_container_->GetHeightForWidth(local_bounds.width()); 326 int height = footnote_container_->GetHeightForWidth(local_bounds.width());
326 footnote_container_->SetBounds(local_bounds.x(), 327 footnote_container_->SetBounds(local_bounds.x(),
327 local_bounds.bottom() - height, 328 local_bounds.bottom() - height,
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 size.Enlarge(client_insets.width(), client_insets.height()); 511 size.Enlarge(client_insets.width(), client_insets.height());
511 size.SetToMax(gfx::Size(title_bar_width, 0)); 512 size.SetToMax(gfx::Size(title_bar_width, 0));
512 513
513 if (footnote_container_) 514 if (footnote_container_)
514 size.Enlarge(0, footnote_container_->GetHeightForWidth(size.width())); 515 size.Enlarge(0, footnote_container_->GetHeightForWidth(size.width()));
515 516
516 return size; 517 return size;
517 } 518 }
518 519
519 } // namespace views 520 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698