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

Side by Side Diff: chrome/browser/ui/views/harmony/harmony_layout_delegate.cc

Issue 2785683003: views: implement width snapping for DialogDelegateViews (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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chrome/browser/ui/views/harmony/harmony_layout_delegate.h" 5 #include "chrome/browser/ui/views/harmony/harmony_layout_delegate.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 9
10 static base::LazyInstance<HarmonyLayoutDelegate>::DestructorAtExit 10 static base::LazyInstance<HarmonyLayoutDelegate>::DestructorAtExit
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } 73 }
74 74
75 bool HarmonyLayoutDelegate::ShouldShowWindowIcon() const { 75 bool HarmonyLayoutDelegate::ShouldShowWindowIcon() const {
76 return false; 76 return false;
77 } 77 }
78 78
79 bool HarmonyLayoutDelegate::IsHarmonyMode() const { 79 bool HarmonyLayoutDelegate::IsHarmonyMode() const {
80 return true; 80 return true;
81 } 81 }
82 82
83 int HarmonyLayoutDelegate::GetDialogPreferredWidth(DialogWidth width) const { 83 int HarmonyLayoutDelegate::GetSnappedDialogWidth(int width) const {
84 switch (width) { 84 const int kSizes[] = {320, 448, 512};
Peter Kasting 2017/03/30 00:35:35 Nit: Can probably just inline this into the next l
85 case DialogWidth::SMALL: 85 for (const auto& size : kSizes) {
86 return 320; 86 if (size >= width)
87 case DialogWidth::MEDIUM: 87 return size;
88 return 448;
89 case DialogWidth::LARGE:
90 return 512;
91 } 88 }
92 NOTREACHED(); 89
93 return 0; 90 return ((width + kHarmonyLayoutUnit - 1) / kHarmonyLayoutUnit) *
91 kHarmonyLayoutUnit;
94 } 92 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698