OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/vector_example.h" | 5 #include "ui/views/examples/vector_example.h" |
6 | 6 |
7 #include <stddef.h> | |
8 | |
9 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
11 #include "base/macros.h" | 9 #include "base/macros.h" |
12 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
14 #include "build/build_config.h" | 12 #include "build/build_config.h" |
15 #include "ui/gfx/paint_vector_icon.h" | 13 #include "ui/gfx/paint_vector_icon.h" |
16 #include "ui/gfx/vector_icons_public.h" | 14 #include "ui/gfx/vector_icons_public.h" |
17 #include "ui/views/border.h" | 15 #include "ui/views/border.h" |
18 #include "ui/views/controls/button/blue_button.h" | 16 #include "ui/views/controls/button/blue_button.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 UpdateImage(); | 90 UpdateImage(); |
93 return true; | 91 return true; |
94 } | 92 } |
95 return false; | 93 return false; |
96 } | 94 } |
97 | 95 |
98 // TextfieldController implementation. | 96 // TextfieldController implementation. |
99 void ContentsChanged(Textfield* sender, | 97 void ContentsChanged(Textfield* sender, |
100 const base::string16& new_contents) override { | 98 const base::string16& new_contents) override { |
101 if (sender == size_input_) { | 99 if (sender == size_input_) { |
102 if (base::StringToSizeT(new_contents, &size_)) | 100 if (base::StringToInt(new_contents, &size_)) |
sky
2016/08/23 23:53:37
If negative is considered an error condition shoul
Peter Kasting
2016/08/24 02:42:00
It looks like gfx::Size() will silently clamp nega
| |
103 UpdateImage(); | 101 UpdateImage(); |
104 else | 102 else |
105 size_input_->SetText(base::string16()); | 103 size_input_->SetText(base::string16()); |
106 | 104 |
107 return; | 105 return; |
108 } | 106 } |
109 | 107 |
110 DCHECK_EQ(color_input_, sender); | 108 DCHECK_EQ(color_input_, sender); |
111 if (new_contents.size() != 8u) | 109 if (new_contents.size() != 8u) |
112 return; | 110 return; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 | 144 |
147 private: | 145 private: |
148 ImageView* image_view_; | 146 ImageView* image_view_; |
149 View* image_view_container_; | 147 View* image_view_container_; |
150 Textfield* size_input_; | 148 Textfield* size_input_; |
151 Textfield* color_input_; | 149 Textfield* color_input_; |
152 Textfield* file_chooser_; | 150 Textfield* file_chooser_; |
153 Button* file_go_button_; | 151 Button* file_go_button_; |
154 | 152 |
155 int vector_id_; | 153 int vector_id_; |
156 size_t size_; | 154 int size_; |
157 SkColor color_; | 155 SkColor color_; |
158 | 156 |
159 DISALLOW_COPY_AND_ASSIGN(VectorIconGallery); | 157 DISALLOW_COPY_AND_ASSIGN(VectorIconGallery); |
160 }; | 158 }; |
161 | 159 |
162 } // namespace | 160 } // namespace |
163 | 161 |
164 VectorExample::VectorExample() : ExampleBase("Vector Icon") {} | 162 VectorExample::VectorExample() : ExampleBase("Vector Icon") {} |
165 | 163 |
166 VectorExample::~VectorExample() {} | 164 VectorExample::~VectorExample() {} |
167 | 165 |
168 void VectorExample::CreateExampleView(View* container) { | 166 void VectorExample::CreateExampleView(View* container) { |
169 container->SetLayoutManager(new FillLayout()); | 167 container->SetLayoutManager(new FillLayout()); |
170 container->AddChildView(new VectorIconGallery()); | 168 container->AddChildView(new VectorIconGallery()); |
171 } | 169 } |
172 | 170 |
173 } // namespace examples | 171 } // namespace examples |
174 } // namespace views | 172 } // namespace views |
OLD | NEW |