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

Side by Side Diff: ui/harmony/harmony_layout_delegate.cc

Issue 2485083003: views: add layout delegates (Closed)
Patch Set: Created 4 years, 1 month 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/base/material_design/material_design_controller.h"
6 #include "ui/harmony/harmony_layout_delegate.h"
7 #include "ui/views/view.h"
8
9 namespace ui {
10
11 static HarmonyLayoutDelegate harmony_layout_delegate_;
12
13 // static
14 HarmonyLayoutDelegate* HarmonyLayoutDelegate::Get() {
15 return &harmony_layout_delegate_;
16 }
17
18 // static
19 void HarmonyLayoutDelegate::ApplyToViewIfNeeded(views::View* view) {
20 if (ui::MaterialDesignController::IsSecondaryUiMaterial())
21 view->SetLayoutDelegate(&harmony_layout_delegate_);
22 }
23
24 int HarmonyLayoutDelegate::GetLayoutDistance(LayoutDistanceType type) const {
25 const int kLayoutUnit = 16;
26 switch (type) {
27 case PANEL_VERT_MARGIN:
28 return kLayoutUnit;
29 case RELATED_BUTTON_HORIZONTAL_SPACING:
30 return kLayoutUnit / 2;
31 case RELATED_CONTROL_HORIZONTAL_SPACING:
32 return kLayoutUnit;
33 case RELATED_CONTROL_VERTICAL_SPACING:
34 return kLayoutUnit / 2;
35 case UNRELATED_CONTROL_VERTICAL_SPACING:
36 return kLayoutUnit;
37 case UNRELATED_CONTROL_LARGE_VERTICAL_SPACING:
38 return kLayoutUnit;
39 case BUTTON_VEDGE_MARGIN_NEW:
40 return kLayoutUnit;
41 case BUTTON_HEDGE_MARGIN_NEW:
42 return kLayoutUnit;
43 }
44 }
45
46 bool HarmonyLayoutDelegate::UseExtraDialogPadding() const {
47 return false;
48 }
49
50 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698