OLD | NEW |
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 "ui/views/examples/button_sticker_sheet.h" | 5 #include "ui/views/examples/button_sticker_sheet.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "ui/base/material_design/material_design_controller.h" | 8 #include "ui/base/material_design/material_design_controller.h" |
9 #include "ui/views/controls/button/button.h" | 9 #include "ui/views/controls/button/button.h" |
10 #include "ui/views/controls/button/md_text_button.h" | 10 #include "ui/views/controls/button/md_text_button.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 // Add a row containing a label whose text is |label_text| and then all the | 50 // Add a row containing a label whose text is |label_text| and then all the |
51 // views in |views| to the supplied GridLayout, with padding between rows. | 51 // views in |views| to the supplied GridLayout, with padding between rows. |
52 void AddLabelledRowToGridLayout(GridLayout* layout, | 52 void AddLabelledRowToGridLayout(GridLayout* layout, |
53 const std::string& label_text, | 53 const std::string& label_text, |
54 std::vector<View*> views) { | 54 std::vector<View*> views) { |
55 const float kRowDoesNotResizeVertically = 0.0; | 55 const float kRowDoesNotResizeVertically = 0.0; |
56 const int kPaddingRowHeight = 8; | 56 const int kPaddingRowHeight = 8; |
57 layout->StartRow(kRowDoesNotResizeVertically, kStretchyGridColumnSetId); | 57 layout->StartRow(kRowDoesNotResizeVertically, kStretchyGridColumnSetId); |
58 layout->AddView(MakePlainLabel(label_text)); | 58 layout->AddView(MakePlainLabel(label_text)); |
59 for (const auto& view : views) | 59 for (auto* view : views) |
60 layout->AddView(view); | 60 layout->AddView(view); |
61 // This gets added extraneously after the last row, but it doesn't hurt and | 61 // This gets added extraneously after the last row, but it doesn't hurt and |
62 // means there's no need to keep track of whether to add it or not. | 62 // means there's no need to keep track of whether to add it or not. |
63 layout->AddPaddingRow(kRowDoesNotResizeVertically, kPaddingRowHeight); | 63 layout->AddPaddingRow(kRowDoesNotResizeVertically, kPaddingRowHeight); |
64 } | 64 } |
65 | 65 |
66 // Constructs a pair of MdTextButtons in the specified |state| with the | 66 // Constructs a pair of MdTextButtons in the specified |state| with the |
67 // specified |listener|, and returns them in |*primary| and |*secondary|. The | 67 // specified |listener|, and returns them in |*primary| and |*secondary|. The |
68 // button in |*primary| is a call-to-action button, and the button in | 68 // button in |*primary| is a call-to-action button, and the button in |
69 // |*secondary| is a regular button. | 69 // |*secondary| is a regular button. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 secondary->OnFocus(); | 122 secondary->OnFocus(); |
123 AddLabelledRowToGridLayout(layout, "Focused", {primary, secondary}); | 123 AddLabelledRowToGridLayout(layout, "Focused", {primary, secondary}); |
124 } | 124 } |
125 | 125 |
126 void ButtonStickerSheet::ButtonPressed(Button* button, const ui::Event& event) { | 126 void ButtonStickerSheet::ButtonPressed(Button* button, const ui::Event& event) { |
127 // Ignore button presses. | 127 // Ignore button presses. |
128 } | 128 } |
129 | 129 |
130 } // namespace examples | 130 } // namespace examples |
131 } // namespace views | 131 } // namespace views |
OLD | NEW |