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

Unified Diff: ui/views/bubble/bubble_frame_view.cc

Issue 15861012: Polish new dialog style layout and sizing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove long title example debugging code. Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/views/examples/widget_example.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/bubble/bubble_frame_view.cc
diff --git a/ui/views/bubble/bubble_frame_view.cc b/ui/views/bubble/bubble_frame_view.cc
index e6375dcaf61599a78701c97cd69ae70bfd369b8e..f9ba20df403c792801486c8e73104470d3df7e29 100644
--- a/ui/views/bubble/bubble_frame_view.cc
+++ b/ui/views/bubble/bubble_frame_view.cc
@@ -18,9 +18,10 @@
namespace {
-// Insets, in pixels, for the title view, when it exists.
-const int kTitleTopInset = 19;
-const int kTitleLeftInset = 10;
+// Padding, in pixels, for the title view, when it exists.
+const int kTitleTopInset = 12;
+const int kTitleLeftInset = 19;
+const int kTitleBottomInset = 12;
// Get the |vertical| or horizontal screen overflow of the |window_bounds|.
int GetOffScreenLength(const gfx::Rect& monitor_bounds,
@@ -122,33 +123,45 @@ void BubbleFrameView::UpdateWindowTitle() {}
gfx::Insets BubbleFrameView::GetInsets() const {
gfx::Insets insets = content_margins_;
- insets += gfx::Insets(
- std::max(title_->text().empty() ? 0 : title_->height() + kTitleTopInset,
- close_->visible() ? close_->height() : 0),
- 0, 0, 0);
+ const int title_height = title_->text().empty() ? 0 :
+ title_->GetPreferredSize().height() + kTitleTopInset + kTitleBottomInset;
+ const int close_height = close_->visible() ? close_->height() : 0;
+ insets += gfx::Insets(std::max(title_height, close_height), 0, 0, 0);
return insets;
}
gfx::Size BubbleFrameView::GetPreferredSize() {
- gfx::Size client_size(GetWidget()->client_view()->GetPreferredSize());
- return GetUpdatedWindowBounds(gfx::Rect(), client_size, false).size();
+ const gfx::Size client(GetWidget()->client_view()->GetPreferredSize());
+ gfx::Size size(GetUpdatedWindowBounds(gfx::Rect(), client, false).size());
+ // Accommodate the width of the title bar elements.
+ int title_bar_width = GetInsets().width() + border()->GetInsets().width() +
+ kTitleLeftInset + title_->GetPreferredSize().width() +
+ close_->width() + 1;
+ if (titlebar_extra_view_ != NULL)
+ title_bar_width += titlebar_extra_view_->GetPreferredSize().width();
+ size.ClampToMin(gfx::Size(title_bar_width, 0));
+ return size;
}
void BubbleFrameView::Layout() {
- gfx::Rect bounds = GetLocalBounds();
+ gfx::Rect bounds(GetLocalBounds());
bounds.Inset(border()->GetInsets());
// Small additional insets yield the desired 10px visual close button insets.
- bounds.Inset(0, 2, close_->width() + 1, 0);
- close_->SetPosition(gfx::Point(bounds.right(), bounds.y()));
-
- gfx::Rect title_bounds = bounds;
- title_bounds.Inset(kTitleTopInset, kTitleLeftInset, 0, 0);
-
- title_bounds.set_size(title_->GetPreferredSize());
+ bounds.Inset(0, 0, close_->width() + 1, 0);
+ close_->SetPosition(gfx::Point(bounds.right(), bounds.y() + 2));
+
+ gfx::Rect title_bounds(bounds);
+ title_bounds.Inset(kTitleLeftInset, kTitleTopInset, 0, 0);
+ gfx::Size title_size(title_->GetPreferredSize());
+ const int title_width = std::max(0, close_->bounds().x() - title_bounds.x());
+ title_size.ClampToMax(gfx::Size(title_width, title_size.height()));
+ title_bounds.set_size(title_size);
title_->SetBoundsRect(title_bounds);
if (titlebar_extra_view_) {
- const gfx::Size size = titlebar_extra_view_->GetPreferredSize();
+ const int extra_width = close_->bounds().x() - title_->bounds().right();
+ gfx::Size size = titlebar_extra_view_->GetPreferredSize();
+ size.ClampToMax(gfx::Size(std::max(0, extra_width), size.height()));
gfx::Rect titlebar_extra_view_bounds(
bounds.right() - size.width(),
title_bounds.y(),
« no previous file with comments | « no previous file | ui/views/examples/widget_example.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698