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

Unified Diff: ui/views/window/dialog_client_view.cc

Issue 2750063002: views: implement dialog width snapping (Closed)
Patch Set: Created 3 years, 9 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 | « ui/views/views_delegate.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/window/dialog_client_view.cc
diff --git a/ui/views/window/dialog_client_view.cc b/ui/views/window/dialog_client_view.cc
index 5d543a7572efe2b85b8772f293c766cbdb19430f..62dad8b4dfa1cc14c356c7ad3e5b23369bb5f828 100644
--- a/ui/views/window/dialog_client_view.cc
+++ b/ui/views/window/dialog_client_view.cc
@@ -41,12 +41,22 @@ bool ShouldShow(View* view) {
return view && view->visible();
}
+// Snaps the width of |size| up to the next multiple of |unit|.
+gfx::Size SnapWidthToMultipleOf(gfx::Size size, int unit) {
+ size.Enlarge(unit - 1, 0);
tapted 2017/03/15 22:26:11 I find it a bit weird to manipulate the size in al
Peter Kasting 2017/03/21 19:17:03 FWIW, always manipulating reads OK to me, but in m
+ size.set_width(size.width() - (size.width() % unit));
+ return size;
+}
+
// Returns the bounding box required to contain |size1| and |size2|, placed one
// atop the other.
Peter Kasting 2017/03/21 19:17:03 I wonder if this function is the wrong place to im
gfx::Size GetBoundingSizeForVerticalStack(const gfx::Size& size1,
tapted 2017/03/15 22:26:11 rename -> GetSnappedBoundingSize?
const gfx::Size& size2) {
- return gfx::Size(std::max(size1.width(), size2.width()),
- size1.height() + size2.height());
+ return SnapWidthToMultipleOf(
+ gfx::Size(std::max(size1.width(), size2.width()),
+ size1.height() + size2.height()),
+ ViewsDelegate::GetInstance()->GetDistanceMetric(
+ views::DistanceMetric::DIALOG_WIDTH_SNAPPING_UNIT));
tapted 2017/03/15 22:26:11 This is the ClientView - I think we need to take i
}
} // namespace
« no previous file with comments | « ui/views/views_delegate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698