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

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

Issue 2821413002: views: support dialog width snapping once and for all (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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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_provider.h" 5 #include "chrome/browser/ui/views/harmony/harmony_layout_provider.h"
6 6
7 gfx::Insets HarmonyLayoutProvider::GetInsetsMetric(int metric) const { 7 gfx::Insets HarmonyLayoutProvider::GetInsetsMetric(int metric) const {
8 DCHECK_LT(metric, views::VIEWS_INSETS_MAX); 8 DCHECK_LT(metric, views::VIEWS_INSETS_MAX);
9 switch (metric) { 9 switch (metric) {
10 case views::INSETS_DIALOG_BUTTON: 10 case views::INSETS_DIALOG_BUTTON:
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 } 87 }
88 88
89 bool HarmonyLayoutProvider::ShouldShowWindowIcon() const { 89 bool HarmonyLayoutProvider::ShouldShowWindowIcon() const {
90 return false; 90 return false;
91 } 91 }
92 92
93 bool HarmonyLayoutProvider::IsHarmonyMode() const { 93 bool HarmonyLayoutProvider::IsHarmonyMode() const {
94 return true; 94 return true;
95 } 95 }
96 96
97 int HarmonyLayoutProvider::GetDialogPreferredWidth(DialogWidth width) const { 97 int HarmonyLayoutProvider::GetSnappedDialogWidth(int min_width) const {
98 switch (width) { 98 for (int snap_point : {320, 448, 512}) {
99 case DialogWidth::SMALL: 99 if (min_width <= snap_point)
100 return 320; 100 return snap_point;
101 case DialogWidth::MEDIUM:
102 return 448;
103 case DialogWidth::LARGE:
104 return 512;
105 } 101 }
106 NOTREACHED(); 102
107 return 0; 103 return ((min_width + kHarmonyLayoutUnit - 1) / kHarmonyLayoutUnit) *
104 kHarmonyLayoutUnit;
108 } 105 }
109 106
110 const views::TypographyProvider& HarmonyLayoutProvider::GetTypographyProvider() 107 const views::TypographyProvider& HarmonyLayoutProvider::GetTypographyProvider()
111 const { 108 const {
112 return typography_provider_; 109 return typography_provider_;
113 } 110 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698