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

Side by Side Diff: src/views/SkOSMenu.cpp

Issue 1549483002: SampleApp: Build list of devices dynamically Base URL: https://skia.googlesource.com/skia.git@sampleapp-01-no-picturedevice
Patch Set: Created 4 years, 11 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
« no previous file with comments | « samplecode/SampleApp.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 #include "SkAtomics.h" 7 #include "SkAtomics.h"
8 #include "SkOSMenu.h" 8 #include "SkOSMenu.h"
9 #include <stdarg.h> 9 #include <stdarg.h>
10 10
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 } 141 }
142 142
143 int SkOSMenu::appendAction(const char label[], SkEventSinkID target) { 143 int SkOSMenu::appendAction(const char label[], SkEventSinkID target) {
144 SkEvent* evt = new SkEvent(gMenuEventType, target); 144 SkEvent* evt = new SkEvent(gMenuEventType, target);
145 //Store label in event so it can be used to identify the action later 145 //Store label in event so it can be used to identify the action later
146 evt->setString(label, label); 146 evt->setString(label, label);
147 return appendItem(label, SkOSMenu::kAction_Type, "", evt); 147 return appendItem(label, SkOSMenu::kAction_Type, "", evt);
148 } 148 }
149 149
150 int SkOSMenu::appendList(const char label[], const char slotName[], 150 int SkOSMenu::appendList(const char label[], const char slotName[],
151 SkEventSinkID target, int index, const char option[], . ..) { 151 SkEventSinkID target, int index, const SkTArray<const c har*>& entries) {
152 SkEvent* evt = new SkEvent(gMenuEventType, target); 152 SkEvent* evt = new SkEvent(gMenuEventType, target);
153 va_list args; 153 if (!entries.empty()) {
154 if (option) { 154 SkString str(entries[0]);
155 SkString str(option); 155 for (int i = 1; i < entries.count(); ++i) {
156 va_start(args, option);
157 int count = 1;
158 for (const char* arg = va_arg(args, const char*); arg != nullptr; arg = va_arg(args, const char*)) {
159 str += gDelimiter; 156 str += gDelimiter;
160 str += arg; 157 str += entries[i];
161 ++count;
162 } 158 }
163 va_end(args);
164 evt->setString(gList_Items_Str, str); 159 evt->setString(gList_Items_Str, str);
165 evt->setS32(gList_ItemCount_S32, count); 160 evt->setS32(gList_ItemCount_S32, entries.count());
166 evt->setS32(slotName, index); 161 evt->setS32(slotName, index);
167 } 162 }
168 return appendItem(label, SkOSMenu::kList_Type, slotName, evt); 163 return appendItem(label, SkOSMenu::kList_Type, slotName, evt);
169 } 164 }
170 165
171 int SkOSMenu::appendSlider(const char label[], const char slotName[], 166 int SkOSMenu::appendSlider(const char label[], const char slotName[],
172 SkEventSinkID target, SkScalar min, SkScalar max, 167 SkEventSinkID target, SkScalar min, SkScalar max,
173 SkScalar defaultValue) { 168 SkScalar defaultValue) {
174 SkEvent* evt = new SkEvent(gMenuEventType, target); 169 SkEvent* evt = new SkEvent(gMenuEventType, target);
175 evt->setScalar(gSlider_Min_Scalar, min); 170 evt->setScalar(gSlider_Min_Scalar, min);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 const char* text = evt.findString(slotName); 249 const char* text = evt.findString(slotName);
255 if (!text || !*text) 250 if (!text || !*text)
256 return false; 251 return false;
257 else { 252 else {
258 value->set(text); 253 value->set(text);
259 return true; 254 return true;
260 } 255 }
261 } 256 }
262 return false; 257 return false;
263 } 258 }
OLDNEW
« no previous file with comments | « samplecode/SampleApp.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698