Merge lp:~marcustomlinson/unity-js-scopes/filters into lp:unity-js-scopes
- filters
- Merge into trunk
Proposed by
Marcus Tomlinson
Status: | Work in progress |
---|---|
Proposed branch: | lp:~marcustomlinson/unity-js-scopes/filters |
Merge into: | lp:unity-js-scopes |
Diff against target: |
832 lines (+725/-0) 10 files modified
src/bindings/src/addon.cc (+63/-0) src/bindings/src/filter-group.cc (+39/-0) src/bindings/src/filter-group.h (+40/-0) src/bindings/src/range-input-filter.cc (+180/-0) src/bindings/src/range-input-filter.h (+65/-0) src/bindings/src/search-reply.cc (+10/-0) src/bindings/src/value-slider-filter.cc (+131/-0) src/bindings/src/value-slider-filter.h (+61/-0) src/bindings/src/value-slider-labels.cc (+90/-0) src/bindings/src/value-slider-labels.h (+46/-0) |
To merge this branch: | bzr merge lp:~marcustomlinson/unity-js-scopes/filters |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
WebApps | Pending | ||
Review via email: mp+294489@code.launchpad.net |
Commit message
Added filters support
Description of the change
To post a comment you must log in.
Unmerged revisions
- 150. By Marcus Tomlinson
-
ValueSliderFilter complete
- 149. By Marcus Tomlinson
-
RangeInputFilter complete
- 148. By Marcus Tomlinson
-
FilterGroup complete
- 147. By Marcus Tomlinson
-
ValueSliderLabels complete
- 146. By Marcus Tomlinson
-
Fix ValueSliderLabels
- 145. By Marcus Tomlinson
-
Fix ValueSliderFilter
- 144. By Marcus Tomlinson
-
Fix RangeInputFilter
- 143. By Marcus Tomlinson
-
Minimal classes to build
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/bindings/src/addon.cc' | |||
2 | --- src/bindings/src/addon.cc 2016-02-25 13:48:52 +0000 | |||
3 | +++ src/bindings/src/addon.cc 2016-05-12 12:10:04 +0000 | |||
4 | @@ -37,11 +37,13 @@ | |||
5 | 37 | #include "canned-query.h" | 37 | #include "canned-query.h" |
6 | 38 | #include "categorised-result.h" | 38 | #include "categorised-result.h" |
7 | 39 | #include "department.h" | 39 | #include "department.h" |
8 | 40 | #include "filter-group.h" | ||
9 | 40 | #include "online-account-client.h" | 41 | #include "online-account-client.h" |
10 | 41 | #include "option-selector-filter.h" | 42 | #include "option-selector-filter.h" |
11 | 42 | #include "preview-query.h" | 43 | #include "preview-query.h" |
12 | 43 | #include "preview-reply.h" | 44 | #include "preview-reply.h" |
13 | 44 | #include "preview-widget.h" | 45 | #include "preview-widget.h" |
14 | 46 | #include "range-input-filter.h" | ||
15 | 45 | #include "scope-base.h" | 47 | #include "scope-base.h" |
16 | 46 | #include "scope.h" | 48 | #include "scope.h" |
17 | 47 | #include "search-query.h" | 49 | #include "search-query.h" |
18 | @@ -49,6 +51,8 @@ | |||
19 | 49 | #include "search-metadata.h" | 51 | #include "search-metadata.h" |
20 | 50 | #include "registry.h" | 52 | #include "registry.h" |
21 | 51 | #include "result.h" | 53 | #include "result.h" |
22 | 54 | #include "value-slider-filter.h" | ||
23 | 55 | #include "value-slider-labels.h" | ||
24 | 52 | #include "variant.h" | 56 | #include "variant.h" |
25 | 53 | 57 | ||
26 | 54 | // TODO static | 58 | // TODO static |
27 | @@ -456,6 +460,61 @@ | |||
28 | 456 | .add_member("token_secret", &unity::scopes::OnlineAccountClient::ServiceStatus::token_secret) | 460 | .add_member("token_secret", &unity::scopes::OnlineAccountClient::ServiceStatus::token_secret) |
29 | 457 | .add_member("error", &unity::scopes::OnlineAccountClient::ServiceStatus::error); | 461 | .add_member("error", &unity::scopes::OnlineAccountClient::ServiceStatus::error); |
30 | 458 | 462 | ||
31 | 463 | v8cpp::Class<FilterGroup> filter_group(isolate); | ||
32 | 464 | filter_group | ||
33 | 465 | .set_constructor<std::string, std::string>() | ||
34 | 466 | .add_method("id", &FilterGroup::id) | ||
35 | 467 | .add_method("label", &FilterGroup::label); | ||
36 | 468 | |||
37 | 469 | v8cpp::Class<RangeInputFilter> range_input_filter(isolate); | ||
38 | 470 | range_input_filter | ||
39 | 471 | .set_constructor<v8::FunctionCallbackInfo<v8::Value>>() | ||
40 | 472 | .add_method("set_display_hints", &RangeInputFilter::set_display_hints) | ||
41 | 473 | .add_method("display_hints", &RangeInputFilter::display_hints) | ||
42 | 474 | .add_method("id", &RangeInputFilter::id) | ||
43 | 475 | .add_method("filter_type", &RangeInputFilter::filter_type) | ||
44 | 476 | .add_method("set_title", &RangeInputFilter::set_title) | ||
45 | 477 | .add_method("title", &RangeInputFilter::title) | ||
46 | 478 | .add_method("filter_group", &RangeInputFilter::filter_group) | ||
47 | 479 | .add_method("start_prefix_label", &RangeInputFilter::start_prefix_label) | ||
48 | 480 | .add_method("start_postfix_label", &RangeInputFilter::start_postfix_label) | ||
49 | 481 | .add_method("end_prefix_label", &RangeInputFilter::end_prefix_label) | ||
50 | 482 | .add_method("end_postfix_label", &RangeInputFilter::end_postfix_label) | ||
51 | 483 | .add_method("central_label", &RangeInputFilter::central_label) | ||
52 | 484 | .add_method("default_start_value", &RangeInputFilter::default_start_value) | ||
53 | 485 | .add_method("default_end_value", &RangeInputFilter::default_end_value) | ||
54 | 486 | .add_method("has_start_value", &RangeInputFilter::has_start_value) | ||
55 | 487 | .add_method("has_end_value", &RangeInputFilter::has_end_value) | ||
56 | 488 | .add_method("start_value", &RangeInputFilter::start_value) | ||
57 | 489 | .add_method("end_value", &RangeInputFilter::end_value) | ||
58 | 490 | .add_method("update_state", &RangeInputFilter::update_state); | ||
59 | 491 | |||
60 | 492 | v8cpp::Class<ValueSliderFilter> value_slider_filter(isolate); | ||
61 | 493 | value_slider_filter | ||
62 | 494 | .set_constructor<v8::FunctionCallbackInfo<v8::Value>>() | ||
63 | 495 | .add_method("set_display_hints", &ValueSliderFilter::set_display_hints) | ||
64 | 496 | .add_method("display_hints", &ValueSliderFilter::display_hints) | ||
65 | 497 | .add_method("id", &ValueSliderFilter::id) | ||
66 | 498 | .add_method("filter_type", &ValueSliderFilter::filter_type) | ||
67 | 499 | .add_method("set_title", &ValueSliderFilter::set_title) | ||
68 | 500 | .add_method("title", &ValueSliderFilter::title) | ||
69 | 501 | .add_method("filter_group", &ValueSliderFilter::filter_group) | ||
70 | 502 | .add_method("set_default_value", &ValueSliderFilter::set_default_value) | ||
71 | 503 | .add_method("default_value", &ValueSliderFilter::default_value) | ||
72 | 504 | .add_method("min", &ValueSliderFilter::min) | ||
73 | 505 | .add_method("max", &ValueSliderFilter::max) | ||
74 | 506 | .add_method("has_value", &ValueSliderFilter::has_value) | ||
75 | 507 | .add_method("value", &ValueSliderFilter::value) | ||
76 | 508 | .add_method("labels", &ValueSliderFilter::labels) | ||
77 | 509 | .add_method("update_state", &ValueSliderFilter::update_state); | ||
78 | 510 | |||
79 | 511 | v8cpp::Class<ValueSliderLabels> value_slider_labels(isolate); | ||
80 | 512 | value_slider_labels | ||
81 | 513 | .set_constructor<v8::FunctionCallbackInfo<v8::Value>>() | ||
82 | 514 | .add_method("min_label", &ValueSliderLabels::min_label) | ||
83 | 515 | .add_method("max_label", &ValueSliderLabels::max_label) | ||
84 | 516 | .add_method("extra_labels", &ValueSliderLabels::extra_labels); | ||
85 | 517 | |||
86 | 459 | v8cpp::Module module(isolate); | 518 | v8cpp::Module module(isolate); |
87 | 460 | module.add_class("js_scope", js_scope); | 519 | module.add_class("js_scope", js_scope); |
88 | 461 | module.add_class("scope_base", scope_base); | 520 | module.add_class("scope_base", scope_base); |
89 | @@ -468,6 +527,7 @@ | |||
90 | 468 | module.add_class("CategoryRenderer", category_renderer); | 527 | module.add_class("CategoryRenderer", category_renderer); |
91 | 469 | module.add_class("ColumnLayout", column_layout); | 528 | module.add_class("ColumnLayout", column_layout); |
92 | 470 | module.add_class("Department", department); | 529 | module.add_class("Department", department); |
93 | 530 | module.add_class("FilterGroup", filter_group); | ||
94 | 471 | module.add_class("FilterOption", filter_option); | 531 | module.add_class("FilterOption", filter_option); |
95 | 472 | module.add_class("FilterState", filter_state); | 532 | module.add_class("FilterState", filter_state); |
96 | 473 | module.add_class("Location", location); | 533 | module.add_class("Location", location); |
97 | @@ -478,12 +538,15 @@ | |||
98 | 478 | module.add_class("PreviewWidget", preview_widget); | 538 | module.add_class("PreviewWidget", preview_widget); |
99 | 479 | module.add_class("PreviewQuery", preview_query); | 539 | module.add_class("PreviewQuery", preview_query); |
100 | 480 | module.add_class("PreviewReply", preview_reply); | 540 | module.add_class("PreviewReply", preview_reply); |
101 | 541 | module.add_class("RangeInputFilter", range_input_filter); | ||
102 | 481 | module.add_class("Registry", registry); | 542 | module.add_class("Registry", registry); |
103 | 482 | module.add_class("Result", result); | 543 | module.add_class("Result", result); |
104 | 483 | module.add_class("ScopeMetadata", scope_metadata); | 544 | module.add_class("ScopeMetadata", scope_metadata); |
105 | 484 | module.add_class("SearchReply", search_reply); | 545 | module.add_class("SearchReply", search_reply); |
106 | 485 | module.add_class("SearchQuery", search_query); | 546 | module.add_class("SearchQuery", search_query); |
107 | 486 | module.add_class("SearchMetadata", search_metadata); | 547 | module.add_class("SearchMetadata", search_metadata); |
108 | 548 | module.add_class("ValueSliderFilter", value_slider_filter); | ||
109 | 549 | module.add_class("ValueSliderLabels", value_slider_labels); | ||
110 | 487 | module.add_class("Variant", variant); | 550 | module.add_class("Variant", variant); |
111 | 488 | module.add_class("VariantBase", variant_base); | 551 | module.add_class("VariantBase", variant_base); |
112 | 489 | 552 | ||
113 | 490 | 553 | ||
114 | === added file 'src/bindings/src/filter-group.cc' | |||
115 | --- src/bindings/src/filter-group.cc 1970-01-01 00:00:00 +0000 | |||
116 | +++ src/bindings/src/filter-group.cc 2016-05-12 12:10:04 +0000 | |||
117 | @@ -0,0 +1,39 @@ | |||
118 | 1 | /* | ||
119 | 2 | * Copyright 2016 Canonical Ltd. | ||
120 | 3 | * | ||
121 | 4 | * This file is part of unity-js-scopes. | ||
122 | 5 | * | ||
123 | 6 | * unity-js-scopes is free software; you can redistribute it and/or modify | ||
124 | 7 | * it under the terms of the GNU General Public License as published by | ||
125 | 8 | * the Free Software Foundation; version 3. | ||
126 | 9 | * | ||
127 | 10 | * unity-js-scopes is distributed in the hope that it will be useful, | ||
128 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
129 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
130 | 13 | * GNU General Public License for more details. | ||
131 | 14 | * | ||
132 | 15 | * You should have received a copy of the GNU General Public License | ||
133 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
134 | 17 | */ | ||
135 | 18 | |||
136 | 19 | #include "filter-group.h" | ||
137 | 20 | |||
138 | 21 | |||
139 | 22 | FilterGroup::FilterGroup(std::string const& id, std::string const& label) | ||
140 | 23 | : filter_group_(unity::scopes::FilterGroup::create(id, label)){ | ||
141 | 24 | } | ||
142 | 25 | |||
143 | 26 | std::string FilterGroup::id() const | ||
144 | 27 | { | ||
145 | 28 | return filter_group_->id(); | ||
146 | 29 | } | ||
147 | 30 | |||
148 | 31 | std::string FilterGroup::label() const | ||
149 | 32 | { | ||
150 | 33 | return filter_group_->label(); | ||
151 | 34 | } | ||
152 | 35 | |||
153 | 36 | unity::scopes::FilterGroup::SCPtr FilterGroup::get_filter_group() const | ||
154 | 37 | { | ||
155 | 38 | return filter_group_; | ||
156 | 39 | } | ||
157 | 0 | 40 | ||
158 | === added file 'src/bindings/src/filter-group.h' | |||
159 | --- src/bindings/src/filter-group.h 1970-01-01 00:00:00 +0000 | |||
160 | +++ src/bindings/src/filter-group.h 2016-05-12 12:10:04 +0000 | |||
161 | @@ -0,0 +1,40 @@ | |||
162 | 1 | /* | ||
163 | 2 | * Copyright 2016 Canonical Ltd. | ||
164 | 3 | * | ||
165 | 4 | * This file is part of unity-js-scopes. | ||
166 | 5 | * | ||
167 | 6 | * unity-js-scopes is free software; you can redistribute it and/or modify | ||
168 | 7 | * it under the terms of the GNU General Public License as published by | ||
169 | 8 | * the Free Software Foundation; version 3. | ||
170 | 9 | * | ||
171 | 10 | * unity-js-scopes is distributed in the hope that it will be useful, | ||
172 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
173 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
174 | 13 | * GNU General Public License for more details. | ||
175 | 14 | * | ||
176 | 15 | * You should have received a copy of the GNU General Public License | ||
177 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
178 | 17 | */ | ||
179 | 18 | |||
180 | 19 | #ifndef _UNITY_JS_FILTER_GROUP_H_ | ||
181 | 20 | #define _UNITY_JS_FILTER_GROUP_H_ | ||
182 | 21 | |||
183 | 22 | #include <unity/scopes/FilterGroup.h> | ||
184 | 23 | |||
185 | 24 | class FilterGroup | ||
186 | 25 | { | ||
187 | 26 | public: | ||
188 | 27 | FilterGroup(std::string const& id, std::string const& label); | ||
189 | 28 | |||
190 | 29 | std::string id() const; | ||
191 | 30 | std::string label() const; | ||
192 | 31 | |||
193 | 32 | unity::scopes::FilterGroup::SCPtr get_filter_group() const; | ||
194 | 33 | |||
195 | 34 | private: | ||
196 | 35 | unity::scopes::FilterGroup::SCPtr filter_group_; | ||
197 | 36 | }; | ||
198 | 37 | |||
199 | 38 | #endif // _UNITY_JS_FILTER_GROUP_H_ | ||
200 | 39 | |||
201 | 40 | |||
202 | 0 | 41 | ||
203 | === added file 'src/bindings/src/range-input-filter.cc' | |||
204 | --- src/bindings/src/range-input-filter.cc 1970-01-01 00:00:00 +0000 | |||
205 | +++ src/bindings/src/range-input-filter.cc 2016-05-12 12:10:04 +0000 | |||
206 | @@ -0,0 +1,180 @@ | |||
207 | 1 | /* | ||
208 | 2 | * Copyright 2016 Canonical Ltd. | ||
209 | 3 | * | ||
210 | 4 | * This file is part of unity-js-scopes. | ||
211 | 5 | * | ||
212 | 6 | * unity-js-scopes is free software; you can redistribute it and/or modify | ||
213 | 7 | * it under the terms of the GNU General Public License as published by | ||
214 | 8 | * the Free Software Foundation; version 3. | ||
215 | 9 | * | ||
216 | 10 | * unity-js-scopes is distributed in the hope that it will be useful, | ||
217 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
218 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
219 | 13 | * GNU General Public License for more details. | ||
220 | 14 | * | ||
221 | 15 | * You should have received a copy of the GNU General Public License | ||
222 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
223 | 17 | */ | ||
224 | 18 | |||
225 | 19 | #include "common.h" | ||
226 | 20 | #include "range-input-filter.h" | ||
227 | 21 | |||
228 | 22 | RangeInputFilter::RangeInputFilter(v8::FunctionCallbackInfo<v8::Value> const& args) | ||
229 | 23 | { | ||
230 | 24 | if (args.Length() == 6) | ||
231 | 25 | { | ||
232 | 26 | auto a = v8cpp::from_v8<std::string>(args.GetIsolate(), args[0]); | ||
233 | 27 | auto b = v8cpp::from_v8<std::string>(args.GetIsolate(), args[1]); | ||
234 | 28 | auto c = v8cpp::from_v8<std::string>(args.GetIsolate(), args[2]); | ||
235 | 29 | auto d = v8cpp::from_v8<std::string>(args.GetIsolate(), args[3]); | ||
236 | 30 | auto e = v8cpp::from_v8<std::string>(args.GetIsolate(), args[4]); | ||
237 | 31 | auto f = v8cpp::from_v8<std::string>(args.GetIsolate(), args[5]); | ||
238 | 32 | |||
239 | 33 | filter_ = unity::scopes::RangeInputFilter::create(a, b, c, d, e, f); | ||
240 | 34 | } | ||
241 | 35 | else if (args.Length() == 7) | ||
242 | 36 | { | ||
243 | 37 | auto a = v8cpp::from_v8<std::string>(args.GetIsolate(), args[0]); | ||
244 | 38 | auto b = v8cpp::from_v8<std::string>(args.GetIsolate(), args[1]); | ||
245 | 39 | auto c = v8cpp::from_v8<std::string>(args.GetIsolate(), args[2]); | ||
246 | 40 | auto d = v8cpp::from_v8<std::string>(args.GetIsolate(), args[3]); | ||
247 | 41 | auto e = v8cpp::from_v8<std::string>(args.GetIsolate(), args[4]); | ||
248 | 42 | auto f = v8cpp::from_v8<std::string>(args.GetIsolate(), args[5]); | ||
249 | 43 | auto g = v8cpp::from_v8<std::shared_ptr<FilterGroup>>(args.GetIsolate(), args[6]); | ||
250 | 44 | |||
251 | 45 | filter_ = unity::scopes::RangeInputFilter::create(a, b, c, d, e, f, g->get_filter_group()); | ||
252 | 46 | filter_group_ = g; | ||
253 | 47 | } | ||
254 | 48 | else if (args.Length() == 8) | ||
255 | 49 | { | ||
256 | 50 | auto a = v8cpp::from_v8<std::string>(args.GetIsolate(), args[0]); | ||
257 | 51 | auto b = unity::scopesjs::to_variant(args[1]); | ||
258 | 52 | auto c = unity::scopesjs::to_variant(args[2]); | ||
259 | 53 | auto d = v8cpp::from_v8<std::string>(args.GetIsolate(), args[3]); | ||
260 | 54 | auto e = v8cpp::from_v8<std::string>(args.GetIsolate(), args[4]); | ||
261 | 55 | auto f = v8cpp::from_v8<std::string>(args.GetIsolate(), args[5]); | ||
262 | 56 | auto g = v8cpp::from_v8<std::string>(args.GetIsolate(), args[6]); | ||
263 | 57 | auto h = v8cpp::from_v8<std::string>(args.GetIsolate(), args[7]); | ||
264 | 58 | |||
265 | 59 | filter_ = unity::scopes::RangeInputFilter::create(a, b, c, d, e, f, g, h); | ||
266 | 60 | } | ||
267 | 61 | else if (args.Length() == 9) | ||
268 | 62 | { | ||
269 | 63 | auto a = v8cpp::from_v8<std::string>(args.GetIsolate(), args[0]); | ||
270 | 64 | auto b = unity::scopesjs::to_variant(args[1]); | ||
271 | 65 | auto c = unity::scopesjs::to_variant(args[2]); | ||
272 | 66 | auto d = v8cpp::from_v8<std::string>(args.GetIsolate(), args[3]); | ||
273 | 67 | auto e = v8cpp::from_v8<std::string>(args.GetIsolate(), args[4]); | ||
274 | 68 | auto f = v8cpp::from_v8<std::string>(args.GetIsolate(), args[5]); | ||
275 | 69 | auto g = v8cpp::from_v8<std::string>(args.GetIsolate(), args[6]); | ||
276 | 70 | auto h = v8cpp::from_v8<std::string>(args.GetIsolate(), args[7]); | ||
277 | 71 | auto i = v8cpp::from_v8<std::shared_ptr<FilterGroup>>(args.GetIsolate(), args[8]); | ||
278 | 72 | |||
279 | 73 | filter_ = unity::scopes::RangeInputFilter::create(a, b, c, d, e, f, g, h, i->get_filter_group()); | ||
280 | 74 | filter_group_ = i; | ||
281 | 75 | } | ||
282 | 76 | else | ||
283 | 77 | { | ||
284 | 78 | throw std::runtime_error("Invalid number of arguments"); | ||
285 | 79 | } | ||
286 | 80 | } | ||
287 | 81 | |||
288 | 82 | void RangeInputFilter::set_display_hints(int hints) | ||
289 | 83 | { | ||
290 | 84 | filter_->set_display_hints(hints); | ||
291 | 85 | } | ||
292 | 86 | |||
293 | 87 | int RangeInputFilter::display_hints() const | ||
294 | 88 | { | ||
295 | 89 | return filter_->display_hints(); | ||
296 | 90 | } | ||
297 | 91 | |||
298 | 92 | std::string RangeInputFilter::id() const | ||
299 | 93 | { | ||
300 | 94 | return filter_->id(); | ||
301 | 95 | } | ||
302 | 96 | |||
303 | 97 | std::string RangeInputFilter::filter_type() const | ||
304 | 98 | { | ||
305 | 99 | return filter_->filter_type(); | ||
306 | 100 | } | ||
307 | 101 | |||
308 | 102 | void RangeInputFilter::set_title(std::string const& title) | ||
309 | 103 | { | ||
310 | 104 | filter_->set_title(title); | ||
311 | 105 | } | ||
312 | 106 | |||
313 | 107 | std::string RangeInputFilter::title() const | ||
314 | 108 | { | ||
315 | 109 | return filter_->title(); | ||
316 | 110 | } | ||
317 | 111 | |||
318 | 112 | std::shared_ptr<FilterGroup> RangeInputFilter::filter_group() const | ||
319 | 113 | { | ||
320 | 114 | return filter_group_; | ||
321 | 115 | } | ||
322 | 116 | |||
323 | 117 | std::string RangeInputFilter::start_prefix_label() const | ||
324 | 118 | { | ||
325 | 119 | return filter_->start_prefix_label(); | ||
326 | 120 | } | ||
327 | 121 | |||
328 | 122 | std::string RangeInputFilter::start_postfix_label() const | ||
329 | 123 | { | ||
330 | 124 | return filter_->start_postfix_label(); | ||
331 | 125 | } | ||
332 | 126 | |||
333 | 127 | std::string RangeInputFilter::end_prefix_label() const | ||
334 | 128 | { | ||
335 | 129 | return filter_->end_prefix_label(); | ||
336 | 130 | } | ||
337 | 131 | |||
338 | 132 | std::string RangeInputFilter::end_postfix_label() const | ||
339 | 133 | { | ||
340 | 134 | return filter_->end_postfix_label(); | ||
341 | 135 | } | ||
342 | 136 | |||
343 | 137 | std::string RangeInputFilter::central_label() const | ||
344 | 138 | { | ||
345 | 139 | return filter_->central_label(); | ||
346 | 140 | } | ||
347 | 141 | |||
348 | 142 | unity::scopes::Variant RangeInputFilter::default_start_value() const | ||
349 | 143 | { | ||
350 | 144 | return filter_->default_start_value(); | ||
351 | 145 | } | ||
352 | 146 | |||
353 | 147 | unity::scopes::Variant RangeInputFilter::default_end_value() const | ||
354 | 148 | { | ||
355 | 149 | return filter_->default_end_value(); | ||
356 | 150 | } | ||
357 | 151 | |||
358 | 152 | bool RangeInputFilter::has_start_value(unity::scopes::FilterState const& filter_state) const | ||
359 | 153 | { | ||
360 | 154 | return filter_->has_start_value(filter_state); | ||
361 | 155 | } | ||
362 | 156 | |||
363 | 157 | bool RangeInputFilter::has_end_value(unity::scopes::FilterState const& filter_state) const | ||
364 | 158 | { | ||
365 | 159 | return filter_->has_end_value(filter_state); | ||
366 | 160 | } | ||
367 | 161 | |||
368 | 162 | double RangeInputFilter::start_value(unity::scopes::FilterState const& filter_state) const | ||
369 | 163 | { | ||
370 | 164 | return filter_->start_value(filter_state); | ||
371 | 165 | } | ||
372 | 166 | |||
373 | 167 | double RangeInputFilter::end_value(unity::scopes::FilterState const& filter_state) const | ||
374 | 168 | { | ||
375 | 169 | return filter_->end_value(filter_state); | ||
376 | 170 | } | ||
377 | 171 | |||
378 | 172 | void RangeInputFilter::update_state(unity::scopes::FilterState& filter_state, unity::scopes::Variant const& start_value, unity::scopes::Variant const& end_value) const | ||
379 | 173 | { | ||
380 | 174 | return filter_->update_state(filter_state, start_value, end_value); | ||
381 | 175 | } | ||
382 | 176 | |||
383 | 177 | unity::scopes::RangeInputFilter::SPtr RangeInputFilter::get_filter() | ||
384 | 178 | { | ||
385 | 179 | return filter_; | ||
386 | 180 | } | ||
387 | 0 | 181 | ||
388 | === added file 'src/bindings/src/range-input-filter.h' | |||
389 | --- src/bindings/src/range-input-filter.h 1970-01-01 00:00:00 +0000 | |||
390 | +++ src/bindings/src/range-input-filter.h 2016-05-12 12:10:04 +0000 | |||
391 | @@ -0,0 +1,65 @@ | |||
392 | 1 | /* | ||
393 | 2 | * Copyright 2016 Canonical Ltd. | ||
394 | 3 | * | ||
395 | 4 | * This file is part of unity-js-scopes. | ||
396 | 5 | * | ||
397 | 6 | * unity-js-scopes is free software; you can redistribute it and/or modify | ||
398 | 7 | * it under the terms of the GNU General Public License as published by | ||
399 | 8 | * the Free Software Foundation; version 3. | ||
400 | 9 | * | ||
401 | 10 | * unity-js-scopes is distributed in the hope that it will be useful, | ||
402 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
403 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
404 | 13 | * GNU General Public License for more details. | ||
405 | 14 | * | ||
406 | 15 | * You should have received a copy of the GNU General Public License | ||
407 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
408 | 17 | */ | ||
409 | 18 | |||
410 | 19 | #ifndef _UNITY_JS_RANGE_INPUT_FILTER_H_ | ||
411 | 20 | #define _UNITY_JS_RANGE_INPUT_FILTER_H_ | ||
412 | 21 | |||
413 | 22 | #include "filter-group.h" | ||
414 | 23 | |||
415 | 24 | #include <unity/scopes/RangeInputFilter.h> | ||
416 | 25 | |||
417 | 26 | #include <v8-cpp.h> | ||
418 | 27 | |||
419 | 28 | class RangeInputFilter | ||
420 | 29 | { | ||
421 | 30 | public: | ||
422 | 31 | RangeInputFilter(v8::FunctionCallbackInfo<v8::Value> const& args); | ||
423 | 32 | |||
424 | 33 | // FilterBase | ||
425 | 34 | void set_display_hints(int hints); | ||
426 | 35 | int display_hints() const; | ||
427 | 36 | std::string id() const; | ||
428 | 37 | std::string filter_type() const; | ||
429 | 38 | void set_title(std::string const& title); | ||
430 | 39 | std::string title() const; | ||
431 | 40 | std::shared_ptr<FilterGroup> filter_group() const; | ||
432 | 41 | |||
433 | 42 | // RangeInputFilter | ||
434 | 43 | std::string start_prefix_label() const; | ||
435 | 44 | std::string start_postfix_label() const; | ||
436 | 45 | std::string end_prefix_label() const; | ||
437 | 46 | std::string end_postfix_label() const; | ||
438 | 47 | std::string central_label() const; | ||
439 | 48 | unity::scopes::Variant default_start_value() const; | ||
440 | 49 | unity::scopes::Variant default_end_value() const; | ||
441 | 50 | bool has_start_value(unity::scopes::FilterState const& filter_state) const; | ||
442 | 51 | bool has_end_value(unity::scopes::FilterState const& filter_state) const; | ||
443 | 52 | double start_value(unity::scopes::FilterState const& filter_state) const; | ||
444 | 53 | double end_value(unity::scopes::FilterState const& filter_state) const; | ||
445 | 54 | void update_state(unity::scopes::FilterState& filter_state, unity::scopes::Variant const& start_value, unity::scopes::Variant const& end_value) const; | ||
446 | 55 | |||
447 | 56 | unity::scopes::RangeInputFilter::SPtr get_filter(); | ||
448 | 57 | |||
449 | 58 | private: | ||
450 | 59 | unity::scopes::RangeInputFilter::SPtr filter_; | ||
451 | 60 | std::shared_ptr<FilterGroup> filter_group_; | ||
452 | 61 | }; | ||
453 | 62 | |||
454 | 63 | #endif // _UNITY_JS_RANGE_INPUT_FILTER_H_ | ||
455 | 64 | |||
456 | 65 | |||
457 | 0 | 66 | ||
458 | === modified file 'src/bindings/src/search-reply.cc' | |||
459 | --- src/bindings/src/search-reply.cc 2015-11-08 15:49:12 +0000 | |||
460 | +++ src/bindings/src/search-reply.cc 2016-05-12 12:10:04 +0000 | |||
461 | @@ -20,6 +20,8 @@ | |||
462 | 20 | 20 | ||
463 | 21 | #include "categorised-result.h" | 21 | #include "categorised-result.h" |
464 | 22 | #include "option-selector-filter.h" | 22 | #include "option-selector-filter.h" |
465 | 23 | #include "range-input-filter.h" | ||
466 | 24 | #include "value-slider-filter.h" | ||
467 | 23 | 25 | ||
468 | 24 | #include <stdexcept> | 26 | #include <stdexcept> |
469 | 25 | 27 | ||
470 | @@ -42,6 +44,14 @@ | |||
471 | 42 | auto f = v8cpp::from_v8<std::shared_ptr<OptionSelectorFilter>>(isolate, fv); | 44 | auto f = v8cpp::from_v8<std::shared_ptr<OptionSelectorFilter>>(isolate, fv); |
472 | 43 | filter_bases.push_back(f->get_filter()); | 45 | filter_bases.push_back(f->get_filter()); |
473 | 44 | } catch(...) { } | 46 | } catch(...) { } |
474 | 47 | try { | ||
475 | 48 | auto f = v8cpp::from_v8<std::shared_ptr<RangeInputFilter>>(isolate, fv); | ||
476 | 49 | filter_bases.push_back(f->get_filter()); | ||
477 | 50 | } catch(...) { } | ||
478 | 51 | try { | ||
479 | 52 | auto f = v8cpp::from_v8<std::shared_ptr<ValueSliderFilter>>(isolate, fv); | ||
480 | 53 | filter_bases.push_back(f->get_filter()); | ||
481 | 54 | } catch(...) { } | ||
482 | 45 | } | 55 | } |
483 | 46 | return filter_bases; | 56 | return filter_bases; |
484 | 47 | } | 57 | } |
485 | 48 | 58 | ||
486 | === added file 'src/bindings/src/value-slider-filter.cc' | |||
487 | --- src/bindings/src/value-slider-filter.cc 1970-01-01 00:00:00 +0000 | |||
488 | +++ src/bindings/src/value-slider-filter.cc 2016-05-12 12:10:04 +0000 | |||
489 | @@ -0,0 +1,131 @@ | |||
490 | 1 | /* | ||
491 | 2 | * Copyright 2016 Canonical Ltd. | ||
492 | 3 | * | ||
493 | 4 | * This file is part of unity-js-scopes. | ||
494 | 5 | * | ||
495 | 6 | * unity-js-scopes is free software; you can redistribute it and/or modify | ||
496 | 7 | * it under the terms of the GNU General Public License as published by | ||
497 | 8 | * the Free Software Foundation; version 3. | ||
498 | 9 | * | ||
499 | 10 | * unity-js-scopes is distributed in the hope that it will be useful, | ||
500 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
501 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
502 | 13 | * GNU General Public License for more details. | ||
503 | 14 | * | ||
504 | 15 | * You should have received a copy of the GNU General Public License | ||
505 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
506 | 17 | */ | ||
507 | 18 | |||
508 | 19 | #include "value-slider-filter.h" | ||
509 | 20 | |||
510 | 21 | ValueSliderFilter::ValueSliderFilter(v8::FunctionCallbackInfo<v8::Value> const& args) | ||
511 | 22 | { | ||
512 | 23 | if (args.Length() == 5) | ||
513 | 24 | { | ||
514 | 25 | auto a = v8cpp::from_v8<std::string>(args.GetIsolate(), args[0]); | ||
515 | 26 | auto b = v8cpp::from_v8<double>(args.GetIsolate(), args[1]); | ||
516 | 27 | auto c = v8cpp::from_v8<double>(args.GetIsolate(), args[2]); | ||
517 | 28 | auto d = v8cpp::from_v8<double>(args.GetIsolate(), args[3]); | ||
518 | 29 | auto e = v8cpp::from_v8<std::shared_ptr<ValueSliderLabels>>(args.GetIsolate(), args[4]); | ||
519 | 30 | |||
520 | 31 | filter_ = unity::scopes::ValueSliderFilter::create(a, b, c, d, e->get_labels()); | ||
521 | 32 | labels_ = e; | ||
522 | 33 | } | ||
523 | 34 | else if (args.Length() == 6) | ||
524 | 35 | { | ||
525 | 36 | auto a = v8cpp::from_v8<std::string>(args.GetIsolate(), args[0]); | ||
526 | 37 | auto b = v8cpp::from_v8<double>(args.GetIsolate(), args[1]); | ||
527 | 38 | auto c = v8cpp::from_v8<double>(args.GetIsolate(), args[2]); | ||
528 | 39 | auto d = v8cpp::from_v8<double>(args.GetIsolate(), args[3]); | ||
529 | 40 | auto e = v8cpp::from_v8<std::shared_ptr<ValueSliderLabels>>(args.GetIsolate(), args[4]); | ||
530 | 41 | auto f = v8cpp::from_v8<std::shared_ptr<FilterGroup>>(args.GetIsolate(), args[5]); | ||
531 | 42 | |||
532 | 43 | filter_ = unity::scopes::ValueSliderFilter::create(a, b, c, d, e->get_labels(), f->get_filter_group()); | ||
533 | 44 | labels_ = e; | ||
534 | 45 | filter_group_ = f; | ||
535 | 46 | } | ||
536 | 47 | else | ||
537 | 48 | { | ||
538 | 49 | throw std::runtime_error("Invalid number of arguments"); | ||
539 | 50 | } | ||
540 | 51 | } | ||
541 | 52 | |||
542 | 53 | void ValueSliderFilter::set_display_hints(int hints) | ||
543 | 54 | { | ||
544 | 55 | filter_->set_display_hints(hints); | ||
545 | 56 | } | ||
546 | 57 | |||
547 | 58 | int ValueSliderFilter::display_hints() const | ||
548 | 59 | { | ||
549 | 60 | return filter_->display_hints(); | ||
550 | 61 | } | ||
551 | 62 | |||
552 | 63 | std::string ValueSliderFilter::id() const | ||
553 | 64 | { | ||
554 | 65 | return filter_->id(); | ||
555 | 66 | } | ||
556 | 67 | |||
557 | 68 | std::string ValueSliderFilter::filter_type() const | ||
558 | 69 | { | ||
559 | 70 | return filter_->filter_type(); | ||
560 | 71 | } | ||
561 | 72 | |||
562 | 73 | void ValueSliderFilter::set_title(std::string const& title) | ||
563 | 74 | { | ||
564 | 75 | return filter_->set_title(title); | ||
565 | 76 | } | ||
566 | 77 | |||
567 | 78 | std::string ValueSliderFilter::title() const | ||
568 | 79 | { | ||
569 | 80 | return filter_->title(); | ||
570 | 81 | } | ||
571 | 82 | |||
572 | 83 | std::shared_ptr<FilterGroup> ValueSliderFilter::filter_group() const | ||
573 | 84 | { | ||
574 | 85 | return filter_group_; | ||
575 | 86 | } | ||
576 | 87 | |||
577 | 88 | void ValueSliderFilter::set_default_value(double val) | ||
578 | 89 | { | ||
579 | 90 | return filter_->set_default_value(val); | ||
580 | 91 | } | ||
581 | 92 | |||
582 | 93 | double ValueSliderFilter::default_value() const | ||
583 | 94 | { | ||
584 | 95 | return filter_->default_value(); | ||
585 | 96 | } | ||
586 | 97 | |||
587 | 98 | double ValueSliderFilter::min() const | ||
588 | 99 | { | ||
589 | 100 | return filter_->min(); | ||
590 | 101 | } | ||
591 | 102 | |||
592 | 103 | double ValueSliderFilter::max() const | ||
593 | 104 | { | ||
594 | 105 | return filter_->max(); | ||
595 | 106 | } | ||
596 | 107 | |||
597 | 108 | bool ValueSliderFilter::has_value(unity::scopes::FilterState const& filter_state) const | ||
598 | 109 | { | ||
599 | 110 | return filter_->has_value(filter_state); | ||
600 | 111 | } | ||
601 | 112 | |||
602 | 113 | double ValueSliderFilter::value(unity::scopes::FilterState const& filter_state) const | ||
603 | 114 | { | ||
604 | 115 | return filter_->value(filter_state); | ||
605 | 116 | } | ||
606 | 117 | |||
607 | 118 | std::shared_ptr<ValueSliderLabels> ValueSliderFilter::labels() const | ||
608 | 119 | { | ||
609 | 120 | return labels_; | ||
610 | 121 | } | ||
611 | 122 | |||
612 | 123 | void ValueSliderFilter::update_state(unity::scopes::FilterState& filter_state, double value) const | ||
613 | 124 | { | ||
614 | 125 | return filter_->update_state(filter_state, value); | ||
615 | 126 | } | ||
616 | 127 | |||
617 | 128 | unity::scopes::ValueSliderFilter::SPtr ValueSliderFilter::get_filter() | ||
618 | 129 | { | ||
619 | 130 | return filter_; | ||
620 | 131 | } | ||
621 | 0 | 132 | ||
622 | === added file 'src/bindings/src/value-slider-filter.h' | |||
623 | --- src/bindings/src/value-slider-filter.h 1970-01-01 00:00:00 +0000 | |||
624 | +++ src/bindings/src/value-slider-filter.h 2016-05-12 12:10:04 +0000 | |||
625 | @@ -0,0 +1,61 @@ | |||
626 | 1 | /* | ||
627 | 2 | * Copyright 2016 Canonical Ltd. | ||
628 | 3 | * | ||
629 | 4 | * This file is part of unity-js-scopes. | ||
630 | 5 | * | ||
631 | 6 | * unity-js-scopes is free software; you can redistribute it and/or modify | ||
632 | 7 | * it under the terms of the GNU General Public License as published by | ||
633 | 8 | * the Free Software Foundation; version 3. | ||
634 | 9 | * | ||
635 | 10 | * unity-js-scopes is distributed in the hope that it will be useful, | ||
636 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
637 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
638 | 13 | * GNU General Public License for more details. | ||
639 | 14 | * | ||
640 | 15 | * You should have received a copy of the GNU General Public License | ||
641 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
642 | 17 | */ | ||
643 | 18 | |||
644 | 19 | #ifndef _UNITY_JS_VALUE_SLIDER_FILTER_H_ | ||
645 | 20 | #define _UNITY_JS_VALUE_SLIDER_FILTER_H_ | ||
646 | 21 | |||
647 | 22 | #include "value-slider-labels.h" | ||
648 | 23 | #include "filter-group.h" | ||
649 | 24 | |||
650 | 25 | #include <unity/scopes/ValueSliderFilter.h> | ||
651 | 26 | |||
652 | 27 | class ValueSliderFilter | ||
653 | 28 | { | ||
654 | 29 | public: | ||
655 | 30 | ValueSliderFilter(v8::FunctionCallbackInfo<v8::Value> const& args); | ||
656 | 31 | |||
657 | 32 | // FilterBase | ||
658 | 33 | void set_display_hints(int hints); | ||
659 | 34 | int display_hints() const; | ||
660 | 35 | std::string id() const; | ||
661 | 36 | std::string filter_type() const; | ||
662 | 37 | void set_title(std::string const& title); | ||
663 | 38 | std::string title() const; | ||
664 | 39 | std::shared_ptr<FilterGroup> filter_group() const; | ||
665 | 40 | |||
666 | 41 | // ValueSliderFilter | ||
667 | 42 | void set_default_value(double val); | ||
668 | 43 | double default_value() const; | ||
669 | 44 | double min() const; | ||
670 | 45 | double max() const; | ||
671 | 46 | bool has_value(unity::scopes::FilterState const& filter_state) const; | ||
672 | 47 | double value(unity::scopes::FilterState const& filter_state) const; | ||
673 | 48 | std::shared_ptr<ValueSliderLabels> labels() const; | ||
674 | 49 | void update_state(unity::scopes::FilterState& filter_state, double value) const; | ||
675 | 50 | |||
676 | 51 | unity::scopes::ValueSliderFilter::SPtr get_filter(); | ||
677 | 52 | |||
678 | 53 | private: | ||
679 | 54 | unity::scopes::ValueSliderFilter::SPtr filter_; | ||
680 | 55 | std::shared_ptr<FilterGroup> filter_group_; | ||
681 | 56 | std::shared_ptr<ValueSliderLabels> labels_; | ||
682 | 57 | }; | ||
683 | 58 | |||
684 | 59 | #endif // _UNITY_JS_VALUE_SLIDER_FILTER_H_ | ||
685 | 60 | |||
686 | 61 | |||
687 | 0 | 62 | ||
688 | === added file 'src/bindings/src/value-slider-labels.cc' | |||
689 | --- src/bindings/src/value-slider-labels.cc 1970-01-01 00:00:00 +0000 | |||
690 | +++ src/bindings/src/value-slider-labels.cc 2016-05-12 12:10:04 +0000 | |||
691 | @@ -0,0 +1,90 @@ | |||
692 | 1 | /* | ||
693 | 2 | * Copyright 2016 Canonical Ltd. | ||
694 | 3 | * | ||
695 | 4 | * This file is part of unity-js-scopes. | ||
696 | 5 | * | ||
697 | 6 | * unity-js-scopes is free software; you can redistribute it and/or modify | ||
698 | 7 | * it under the terms of the GNU General Public License as published by | ||
699 | 8 | * the Free Software Foundation; version 3. | ||
700 | 9 | * | ||
701 | 10 | * unity-js-scopes is distributed in the hope that it will be useful, | ||
702 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
703 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
704 | 13 | * GNU General Public License for more details. | ||
705 | 14 | * | ||
706 | 15 | * You should have received a copy of the GNU General Public License | ||
707 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
708 | 17 | */ | ||
709 | 18 | |||
710 | 19 | #include "value-slider-labels.h" | ||
711 | 20 | |||
712 | 21 | #include "common.h" | ||
713 | 22 | |||
714 | 23 | //std::string const& min_label, std::string const& max_label, ValueLabelPairList const& extra_labels | ||
715 | 24 | |||
716 | 25 | ValueSliderLabels::ValueSliderLabels(v8::FunctionCallbackInfo<v8::Value> const& args) | ||
717 | 26 | { | ||
718 | 27 | if (args.Length() != 2 && args.Length() != 3) { | ||
719 | 28 | throw std::runtime_error("Invalid number of arguments"); | ||
720 | 29 | } | ||
721 | 30 | if (!args[0]->IsString()) { | ||
722 | 31 | throw std::runtime_error("Invalid argument type"); | ||
723 | 32 | } | ||
724 | 33 | if (!args[1]->IsString()) { | ||
725 | 34 | throw std::runtime_error("Invalid argument type"); | ||
726 | 35 | } | ||
727 | 36 | |||
728 | 37 | std::string min_label = | ||
729 | 38 | *(v8::String::Utf8Value(args[0]->ToString())); | ||
730 | 39 | |||
731 | 40 | std::string max_label = | ||
732 | 41 | *(v8::String::Utf8Value(args[1]->ToString())); | ||
733 | 42 | |||
734 | 43 | if (args.Length() == 3) | ||
735 | 44 | { | ||
736 | 45 | ValueLabelPairList extra_labels; | ||
737 | 46 | |||
738 | 47 | try | ||
739 | 48 | { | ||
740 | 49 | auto extra_labels_a = unity::scopesjs::to_variant(args[2]).get_array(); | ||
741 | 50 | |||
742 | 51 | for (auto const& label : extra_labels_a) | ||
743 | 52 | { | ||
744 | 53 | auto label_pair = label.get_array(); | ||
745 | 54 | if (label_pair.size() == 2) | ||
746 | 55 | { | ||
747 | 56 | extra_labels.push_back(ValueLabelPair(label_pair[0].get_double(), label_pair[1].get_string())); | ||
748 | 57 | } | ||
749 | 58 | } | ||
750 | 59 | } catch(...) | ||
751 | 60 | { | ||
752 | 61 | throw std::runtime_error("ValueSliderLabels::ValueSliderLabels: Malformed 'extra_labels' argument! Expected format: [[2, \"2\"], [4, \"4\"]]"); | ||
753 | 62 | } | ||
754 | 63 | |||
755 | 64 | labels_ = std::make_shared<unity::scopes::ValueSliderLabels>(unity::scopes::ValueSliderLabels(min_label, max_label, extra_labels)); | ||
756 | 65 | } | ||
757 | 66 | else | ||
758 | 67 | { | ||
759 | 68 | labels_ = std::make_shared<unity::scopes::ValueSliderLabels>(unity::scopes::ValueSliderLabels(min_label, max_label)); | ||
760 | 69 | } | ||
761 | 70 | } | ||
762 | 71 | |||
763 | 72 | std::string ValueSliderLabels::min_label() const | ||
764 | 73 | { | ||
765 | 74 | return labels_->min_label(); | ||
766 | 75 | } | ||
767 | 76 | |||
768 | 77 | std::string ValueSliderLabels::max_label() const | ||
769 | 78 | { | ||
770 | 79 | return labels_->max_label(); | ||
771 | 80 | } | ||
772 | 81 | |||
773 | 82 | ValueLabelPairList ValueSliderLabels::extra_labels() const | ||
774 | 83 | { | ||
775 | 84 | return labels_->extra_labels(); | ||
776 | 85 | } | ||
777 | 86 | |||
778 | 87 | unity::scopes::ValueSliderLabels ValueSliderLabels::get_labels() const | ||
779 | 88 | { | ||
780 | 89 | return *labels_; | ||
781 | 90 | } | ||
782 | 0 | 91 | ||
783 | === added file 'src/bindings/src/value-slider-labels.h' | |||
784 | --- src/bindings/src/value-slider-labels.h 1970-01-01 00:00:00 +0000 | |||
785 | +++ src/bindings/src/value-slider-labels.h 2016-05-12 12:10:04 +0000 | |||
786 | @@ -0,0 +1,46 @@ | |||
787 | 1 | /* | ||
788 | 2 | * Copyright 2016 Canonical Ltd. | ||
789 | 3 | * | ||
790 | 4 | * This file is part of unity-js-scopes. | ||
791 | 5 | * | ||
792 | 6 | * unity-js-scopes is free software; you can redistribute it and/or modify | ||
793 | 7 | * it under the terms of the GNU General Public License as published by | ||
794 | 8 | * the Free Software Foundation; version 3. | ||
795 | 9 | * | ||
796 | 10 | * unity-js-scopes is distributed in the hope that it will be useful, | ||
797 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
798 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
799 | 13 | * GNU General Public License for more details. | ||
800 | 14 | * | ||
801 | 15 | * You should have received a copy of the GNU General Public License | ||
802 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
803 | 17 | */ | ||
804 | 18 | |||
805 | 19 | #ifndef _UNITY_JS_VALUE_SLIDER_LABELS_H_ | ||
806 | 20 | #define _UNITY_JS_VALUE_SLIDER_LABELS_H_ | ||
807 | 21 | |||
808 | 22 | #include <unity/scopes/ValueSliderLabels.h> | ||
809 | 23 | |||
810 | 24 | #include <v8-cpp.h> | ||
811 | 25 | |||
812 | 26 | typedef std::pair<double, std::string> ValueLabelPair; | ||
813 | 27 | typedef std::vector<ValueLabelPair> ValueLabelPairList; | ||
814 | 28 | |||
815 | 29 | class ValueSliderLabels | ||
816 | 30 | { | ||
817 | 31 | public: | ||
818 | 32 | ValueSliderLabels(v8::FunctionCallbackInfo<v8::Value> const& args); | ||
819 | 33 | |||
820 | 34 | std::string min_label() const; | ||
821 | 35 | std::string max_label() const; | ||
822 | 36 | ValueLabelPairList extra_labels() const; | ||
823 | 37 | |||
824 | 38 | unity::scopes::ValueSliderLabels get_labels() const; | ||
825 | 39 | |||
826 | 40 | private: | ||
827 | 41 | std::shared_ptr<unity::scopes::ValueSliderLabels> labels_; | ||
828 | 42 | }; | ||
829 | 43 | |||
830 | 44 | #endif // _UNITY_JS_VALUE_SLIDER_LABELS_H_ | ||
831 | 45 | |||
832 | 46 |