Merge lp:~abreu-alexandre/unity-js-scopes/expand-filter-support into lp:unity-js-scopes
- expand-filter-support
- Merge into trunk
Status: | Needs review | ||||
---|---|---|---|---|---|
Proposed branch: | lp:~abreu-alexandre/unity-js-scopes/expand-filter-support | ||||
Merge into: | lp:unity-js-scopes | ||||
Diff against target: |
1667 lines (+1451/-31) 12 files modified
src/bindings/index.js (+30/-0) src/bindings/src/addon.cc (+69/-2) src/bindings/src/filter-group.cc (+39/-0) src/bindings/src/filter-group.h (+82/-0) src/bindings/src/option-selector-filter.cc (+17/-1) src/bindings/src/option-selector-filter.h (+68/-28) src/bindings/src/range-input-filter.cc (+259/-0) src/bindings/src/range-input-filter.h (+312/-0) src/bindings/src/value-slider-filter.cc (+141/-0) src/bindings/src/value-slider-filter.h (+234/-0) src/bindings/src/value-slider-labels.cc (+91/-0) src/bindings/src/value-slider-labels.h (+109/-0) |
||||
To merge this branch: | bzr merge lp:~abreu-alexandre/unity-js-scopes/expand-filter-support | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Marcus Tomlinson (community) | Needs Fixing | ||
unity-api-1-bot | continuous-integration | Approve | |
PS Jenkins bot | continuous-integration | Pending | |
Review via email: mp+296067@code.launchpad.net |
Commit message
Add support for FilterGroup, ValueSliderLabels, ValueSliderFilter, RangeInputFilter; improve Filter handling
Description of the change
Add support for FilterGroup, ValueSliderLabels, ValueSliderFilter, RangeInputFilter; improve Filter handling
unity-api-1-bot (unity-api-1-bot) wrote : | # |
- 144. By Alexandre Abreu
-
Ooops forgot part of the commits, object constructors
unity-api-1-bot (unity-api-1-bot) wrote : | # |
FAILED: Continuous integration, rev:144
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Marcus Tomlinson (marcustomlinson) wrote : | # |
Yeah, looks mostly done. A few gaps here and there though.
You've only bound one constructor for the RangeInputFilter, ValueSliderFilter and ValueSliderLabels classes. We need to do the "v8::FunctionCa
Also, could you please test against the example scope I wrote in lp:~marcustomlinson/unity-js-scopes/filters_example. I suspect there will be other errors, but already I'm seeing:
/home/marcustom
Error: argument count does not match the corresponding C++ function definition
at Error (native)
at null.<anonymous> (/home/
Alexandre Abreu (abreu-alexandre) wrote : | # |
> Yeah, looks mostly done. A few gaps here and there though.
>
> You've only bound one constructor for the RangeInputFilter, ValueSliderFilter
> and ValueSliderLabels classes. We need to do the
> "v8::FunctionCa
> order to cover the available overrides.
>
> Also, could you please test against the example scope I wrote in
> lp:~marcustomlinson/unity-js-scopes/filters_example. I suspect there will be
> other errors, but already I'm seeing:
>
> /home/marcustom
> /filters-
> var price_filter = new scopes.
> "Min", "", "to", "Max", "", group);
> ^
>
> Error: argument count does not match the corresponding C++ function definition
> at Error (native)
> at null.<anonymous> (/home/
> scopes/
> build/src/
yes I remember chose to bind the most "complete" constructor ...
I used your example with null & null for the extra values,
Agree that it should be updated with varargs support though,
- 145. By Alexandre Abreu
-
Add varargs support for ValueSliderFilter & RangeInputFilter constructors
unity-api-1-bot (unity-api-1-bot) wrote : | # |
FAILED: Continuous integration, rev:145
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Marcus Tomlinson (marcustomlinson) wrote : | # |
This is what I get now, running the filters example scope:
#
# Fatal error in ../deps/
# Check failed: that == __null || (*reinterpret_
#
==== C stack trace =======
1: V8_Fatal
2: v8::Utils:
3: v8::Object:
4: ValueSliderLabe
5: ValueSliderLabels* v8cpp::
6: v8cpp::
7: v8cpp::
8: void v8cpp::
unity-api-1-bot (unity-api-1-bot) wrote : | # |
FAILED: Continuous integration, rev:145
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
ABORTED: https:/
SUCCESS: https:/
deb: https:/
ABORTED: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
- 146. By Alexandre Abreu
-
Update ValueSliderLabels' constructor to fit the Scopes API
Alexandre Abreu (abreu-alexandre) wrote : | # |
I updated the code to fit the js example
unity-api-1-bot (unity-api-1-bot) wrote : | # |
PASSED: Continuous integration, rev:146
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Marcus Tomlinson (marcustomlinson) wrote : | # |
While there are no longer any visible error messages when running the example scope from lp:~marcustomlinson/unity-js-scopes/filters_example, there are no results showing up in the scope at all.
I'm not sure where things are going wrong now. Running the example scope against lp:~marcustomlinson/unity-js-scopes/filters works fine, but obviously there are some changes here (especially documentation) that I don't have.
I wonder if it'd be wise to somewhat merge the 2?
Unmerged revisions
- 146. By Alexandre Abreu
-
Update ValueSliderLabels' constructor to fit the Scopes API
- 145. By Alexandre Abreu
-
Add varargs support for ValueSliderFilter & RangeInputFilter constructors
- 144. By Alexandre Abreu
-
Ooops forgot part of the commits, object constructors
- 143. By Alexandre Abreu
-
Add support for FilterGroup, ValueSliderLabels, ValueSliderFilter, RangeInputFilter; improve Filter handling
Preview Diff
1 | === modified file 'src/bindings/index.js' | |||
2 | --- src/bindings/index.js 2016-02-17 14:41:42 +0000 | |||
3 | +++ src/bindings/index.js 2016-08-17 20:30:06 +0000 | |||
4 | @@ -226,6 +226,35 @@ | |||
5 | 226 | UpdatePreview: 6 | 226 | UpdatePreview: 6 |
6 | 227 | }; | 227 | }; |
7 | 228 | 228 | ||
8 | 229 | /** | ||
9 | 230 | * Display hints for the Shell UI. | ||
10 | 231 | * | ||
11 | 232 | * @example | ||
12 | 233 | var scopes = require('unity-js-scopes') | ||
13 | 234 | var f = new scope.lib.OptionSelectorFilter("1", "label", false) | ||
14 | 235 | f.set_display_hint(scopes.defs.DisplayHint.Primary) | ||
15 | 236 | |||
16 | 237 | * @module ScopeJS | ||
17 | 238 | * | ||
18 | 239 | * | ||
19 | 240 | * @class DisplayHint | ||
20 | 241 | */ | ||
21 | 242 | DisplayHint = { | ||
22 | 243 | /** | ||
23 | 244 | * Default value (no hint) | ||
24 | 245 | * @property Default | ||
25 | 246 | * @static | ||
26 | 247 | */ | ||
27 | 248 | Default: 0, | ||
28 | 249 | /** | ||
29 | 250 | * Display this filter as a primary navigation, if possible. | ||
30 | 251 | * Currently only the OptionSelectorFilter can act as primary navigation. | ||
31 | 252 | * @property Primary | ||
32 | 253 | * @static | ||
33 | 254 | */ | ||
34 | 255 | Primary: 1 | ||
35 | 256 | }; | ||
36 | 257 | |||
37 | 229 | module.exports = { | 258 | module.exports = { |
38 | 230 | lib: lib, | 259 | lib: lib, |
39 | 231 | defs: { | 260 | defs: { |
40 | @@ -233,6 +262,7 @@ | |||
41 | 233 | VariantType: VariantType, | 262 | VariantType: VariantType, |
42 | 234 | ConnectivityStatus: ConnectivityStatus, | 263 | ConnectivityStatus: ConnectivityStatus, |
43 | 235 | OperationInfo: OperationInfo, | 264 | OperationInfo: OperationInfo, |
44 | 265 | DisplayHint: DisplayHint, | ||
45 | 236 | ActivationResponseStatus: ActivationResponseStatus | 266 | ActivationResponseStatus: ActivationResponseStatus |
46 | 237 | } | 267 | } |
47 | 238 | } | 268 | } |
48 | 239 | 269 | ||
49 | === modified file 'src/bindings/src/addon.cc' | |||
50 | --- src/bindings/src/addon.cc 2016-02-25 13:48:52 +0000 | |||
51 | +++ src/bindings/src/addon.cc 2016-08-17 20:30:06 +0000 | |||
52 | @@ -37,6 +37,7 @@ | |||
53 | 37 | #include "canned-query.h" | 37 | #include "canned-query.h" |
54 | 38 | #include "categorised-result.h" | 38 | #include "categorised-result.h" |
55 | 39 | #include "department.h" | 39 | #include "department.h" |
56 | 40 | #include "filter-group.h" | ||
57 | 40 | #include "online-account-client.h" | 41 | #include "online-account-client.h" |
58 | 41 | #include "option-selector-filter.h" | 42 | #include "option-selector-filter.h" |
59 | 42 | #include "preview-query.h" | 43 | #include "preview-query.h" |
60 | @@ -50,6 +51,9 @@ | |||
61 | 50 | #include "registry.h" | 51 | #include "registry.h" |
62 | 51 | #include "result.h" | 52 | #include "result.h" |
63 | 52 | #include "variant.h" | 53 | #include "variant.h" |
64 | 54 | #include "value-slider-labels.h" | ||
65 | 55 | #include "value-slider-filter.h" | ||
66 | 56 | #include "range-input-filter.h" | ||
67 | 53 | 57 | ||
68 | 54 | // TODO static | 58 | // TODO static |
69 | 55 | JavascriptScopeRuntime* new_scope(const std::string& runtime_config) { | 59 | JavascriptScopeRuntime* new_scope(const std::string& runtime_config) { |
70 | @@ -275,6 +279,12 @@ | |||
71 | 275 | .add_method("region_name", &unity::scopes::Location::region_name) | 279 | .add_method("region_name", &unity::scopes::Location::region_name) |
72 | 276 | .add_method("has_vertical_accuracy", &unity::scopes::Location::has_vertical_accuracy); | 280 | .add_method("has_vertical_accuracy", &unity::scopes::Location::has_vertical_accuracy); |
73 | 277 | 281 | ||
74 | 282 | v8cpp::Class<FilterGroup> filter_group(isolate); | ||
75 | 283 | filter_group | ||
76 | 284 | .set_constructor<std::string const&, std::string const&>() | ||
77 | 285 | .add_method("id", &FilterGroup::id) | ||
78 | 286 | .add_method("label", &FilterGroup::label); | ||
79 | 287 | |||
80 | 278 | v8cpp::Class<unity::scopes::FilterState> filter_state(isolate); | 288 | v8cpp::Class<unity::scopes::FilterState> filter_state(isolate); |
81 | 279 | filter_state | 289 | filter_state |
82 | 280 | .set_constructor<>() | 290 | .set_constructor<>() |
83 | @@ -299,8 +309,11 @@ | |||
84 | 299 | // FilterBase | 309 | // FilterBase |
85 | 300 | .add_method("set_display_hints", &OptionSelectorFilter::set_display_hints) | 310 | .add_method("set_display_hints", &OptionSelectorFilter::set_display_hints) |
86 | 301 | .add_method("display_hints", &OptionSelectorFilter::display_hints) | 311 | .add_method("display_hints", &OptionSelectorFilter::display_hints) |
87 | 312 | .add_method("set_title", &OptionSelectorFilter::set_title) | ||
88 | 313 | .add_method("title", &OptionSelectorFilter::title) | ||
89 | 302 | .add_method("id", &OptionSelectorFilter::id) | 314 | .add_method("id", &OptionSelectorFilter::id) |
91 | 303 | .add_method("filter_type", &OptionSelectorFilter::filter_type); | 315 | .add_method("filter_type", &OptionSelectorFilter::filter_type) |
92 | 316 | .add_method("filter_group", &OptionSelectorFilter::filter_group); | ||
93 | 304 | 317 | ||
94 | 305 | v8cpp::Class<unity::scopes::OperationInfo> operation_info(isolate); | 318 | v8cpp::Class<unity::scopes::OperationInfo> operation_info(isolate); |
95 | 306 | operation_info | 319 | operation_info |
96 | @@ -380,6 +393,29 @@ | |||
97 | 380 | .add_method("onrun", &SearchQuery::onrun) | 393 | .add_method("onrun", &SearchQuery::onrun) |
98 | 381 | .add_method("oncancelled", &SearchQuery::oncancelled); | 394 | .add_method("oncancelled", &SearchQuery::oncancelled); |
99 | 382 | 395 | ||
100 | 396 | v8cpp::Class<RangeInputFilter> range_input_filter(isolate); | ||
101 | 397 | range_input_filter | ||
102 | 398 | .set_constructor<v8::FunctionCallbackInfo<v8::Value>>() | ||
103 | 399 | .add_method("start_prefix_label", &RangeInputFilter::start_prefix_label) | ||
104 | 400 | .add_method("start_postfix_label", &RangeInputFilter::start_postfix_label) | ||
105 | 401 | .add_method("end_prefix_label", &RangeInputFilter::end_prefix_label) | ||
106 | 402 | .add_method("end_postfix_label", &RangeInputFilter::end_postfix_label) | ||
107 | 403 | .add_method("central_label", &RangeInputFilter::central_label) | ||
108 | 404 | .add_method("default_start_value", &RangeInputFilter::default_start_value) | ||
109 | 405 | .add_method("default_end_value", &RangeInputFilter::default_end_value) | ||
110 | 406 | .add_method("has_start_value", &RangeInputFilter::has_start_value) | ||
111 | 407 | .add_method("has_end_value", &RangeInputFilter::has_end_value) | ||
112 | 408 | .add_method("start_value", &RangeInputFilter::start_value) | ||
113 | 409 | .add_method("end_value", &RangeInputFilter::end_value) | ||
114 | 410 | .add_method("update_state", &RangeInputFilter::update_state) | ||
115 | 411 | .add_method("set_display_hints", &RangeInputFilter::set_display_hints) | ||
116 | 412 | .add_method("display_hints", &RangeInputFilter::display_hints) | ||
117 | 413 | .add_method("set_title", &RangeInputFilter::set_title) | ||
118 | 414 | .add_method("title", &RangeInputFilter::title) | ||
119 | 415 | .add_method("id", &RangeInputFilter::id) | ||
120 | 416 | .add_method("filter_type", &RangeInputFilter::filter_type) | ||
121 | 417 | .add_method("filter_group", &RangeInputFilter::filter_group); | ||
122 | 418 | |||
123 | 383 | v8cpp::Class<Registry> registry(isolate); | 419 | v8cpp::Class<Registry> registry(isolate); |
124 | 384 | registry | 420 | registry |
125 | 385 | // Registry | 421 | // Registry |
126 | @@ -390,7 +426,6 @@ | |||
127 | 390 | .add_method("set_scope_state_callback", &Registry::set_scope_state_callback) | 426 | .add_method("set_scope_state_callback", &Registry::set_scope_state_callback) |
128 | 391 | .add_method("set_list_update_callback", &Registry::set_list_update_callback); | 427 | .add_method("set_list_update_callback", &Registry::set_list_update_callback); |
129 | 392 | 428 | ||
130 | 393 | |||
131 | 394 | v8cpp::Class<unity::scopes::ScopeMetadata> scope_metadata(isolate); | 429 | v8cpp::Class<unity::scopes::ScopeMetadata> scope_metadata(isolate); |
132 | 395 | scope_metadata | 430 | scope_metadata |
133 | 396 | // unity::scopes::ScopeMetadata | 431 | // unity::scopes::ScopeMetadata |
134 | @@ -456,6 +491,34 @@ | |||
135 | 456 | .add_member("token_secret", &unity::scopes::OnlineAccountClient::ServiceStatus::token_secret) | 491 | .add_member("token_secret", &unity::scopes::OnlineAccountClient::ServiceStatus::token_secret) |
136 | 457 | .add_member("error", &unity::scopes::OnlineAccountClient::ServiceStatus::error); | 492 | .add_member("error", &unity::scopes::OnlineAccountClient::ServiceStatus::error); |
137 | 458 | 493 | ||
138 | 494 | v8cpp::Class<ValueSliderFilter> value_slider_filter(isolate); | ||
139 | 495 | value_slider_filter | ||
140 | 496 | .set_constructor<v8::FunctionCallbackInfo<v8::Value>>() | ||
141 | 497 | .add_method("set_default_value", &ValueSliderFilter::set_default_value) | ||
142 | 498 | .add_method("min", &ValueSliderFilter::min) | ||
143 | 499 | .add_method("max", &ValueSliderFilter::max) | ||
144 | 500 | .add_method("has_value", &ValueSliderFilter::has_value) | ||
145 | 501 | .add_method("value", &ValueSliderFilter::value) | ||
146 | 502 | .add_method("labels", &ValueSliderFilter::labels) | ||
147 | 503 | .add_method("update_state", &ValueSliderFilter::update_state) | ||
148 | 504 | .add_method("set_display_hints", &ValueSliderFilter::set_display_hints) | ||
149 | 505 | .add_method("display_hints", &ValueSliderFilter::display_hints) | ||
150 | 506 | .add_method("set_title", &ValueSliderFilter::set_title) | ||
151 | 507 | .add_method("title", &ValueSliderFilter::title) | ||
152 | 508 | .add_method("id", &ValueSliderFilter::id) | ||
153 | 509 | .add_method("filter_group", &ValueSliderFilter::filter_group) | ||
154 | 510 | .add_method("filter_type", &ValueSliderFilter::filter_type) | ||
155 | 511 | .add_method("default_value", &ValueSliderFilter::default_value); | ||
156 | 512 | |||
157 | 513 | v8cpp::Class<ValueSliderLabels> value_slider_labels(isolate); | ||
158 | 514 | value_slider_labels | ||
159 | 515 | .set_constructor<std::string, | ||
160 | 516 | std::string, | ||
161 | 517 | v8::Local<v8::Value>>() | ||
162 | 518 | .add_method("min_label", &ValueSliderLabels::min_label) | ||
163 | 519 | .add_method("max_label", &ValueSliderLabels::max_label) | ||
164 | 520 | .add_method("extra_labels", &ValueSliderLabels::extra_labels); | ||
165 | 521 | |||
166 | 459 | v8cpp::Module module(isolate); | 522 | v8cpp::Module module(isolate); |
167 | 460 | module.add_class("js_scope", js_scope); | 523 | module.add_class("js_scope", js_scope); |
168 | 461 | module.add_class("scope_base", scope_base); | 524 | module.add_class("scope_base", scope_base); |
169 | @@ -468,6 +531,7 @@ | |||
170 | 468 | module.add_class("CategoryRenderer", category_renderer); | 531 | module.add_class("CategoryRenderer", category_renderer); |
171 | 469 | module.add_class("ColumnLayout", column_layout); | 532 | module.add_class("ColumnLayout", column_layout); |
172 | 470 | module.add_class("Department", department); | 533 | module.add_class("Department", department); |
173 | 534 | module.add_class("FilterGroup", filter_group); | ||
174 | 471 | module.add_class("FilterOption", filter_option); | 535 | module.add_class("FilterOption", filter_option); |
175 | 472 | module.add_class("FilterState", filter_state); | 536 | module.add_class("FilterState", filter_state); |
176 | 473 | module.add_class("Location", location); | 537 | module.add_class("Location", location); |
177 | @@ -478,6 +542,7 @@ | |||
178 | 478 | module.add_class("PreviewWidget", preview_widget); | 542 | module.add_class("PreviewWidget", preview_widget); |
179 | 479 | module.add_class("PreviewQuery", preview_query); | 543 | module.add_class("PreviewQuery", preview_query); |
180 | 480 | module.add_class("PreviewReply", preview_reply); | 544 | module.add_class("PreviewReply", preview_reply); |
181 | 545 | module.add_class("RangeInputFilter", range_input_filter); | ||
182 | 481 | module.add_class("Registry", registry); | 546 | module.add_class("Registry", registry); |
183 | 482 | module.add_class("Result", result); | 547 | module.add_class("Result", result); |
184 | 483 | module.add_class("ScopeMetadata", scope_metadata); | 548 | module.add_class("ScopeMetadata", scope_metadata); |
185 | @@ -486,6 +551,8 @@ | |||
186 | 486 | module.add_class("SearchMetadata", search_metadata); | 551 | module.add_class("SearchMetadata", search_metadata); |
187 | 487 | module.add_class("Variant", variant); | 552 | module.add_class("Variant", variant); |
188 | 488 | module.add_class("VariantBase", variant_base); | 553 | module.add_class("VariantBase", variant_base); |
189 | 554 | module.add_class("ValueSliderFilter", value_slider_filter); | ||
190 | 555 | module.add_class("ValueSliderLabels", value_slider_labels); | ||
191 | 489 | 556 | ||
192 | 490 | // Factory functions | 557 | // Factory functions |
193 | 491 | module.add_function("new_scope", &new_scope); | 558 | module.add_function("new_scope", &new_scope); |
194 | 492 | 559 | ||
195 | === added file 'src/bindings/src/filter-group.cc' | |||
196 | --- src/bindings/src/filter-group.cc 1970-01-01 00:00:00 +0000 | |||
197 | +++ src/bindings/src/filter-group.cc 2016-08-17 20:30:06 +0000 | |||
198 | @@ -0,0 +1,39 @@ | |||
199 | 1 | /* | ||
200 | 2 | * Copyright 2016 Canonical Ltd. | ||
201 | 3 | * | ||
202 | 4 | * This file is part of unity-js-scopes. | ||
203 | 5 | * | ||
204 | 6 | * unity-js-scopes is free software; you can redistribute it and/or modify | ||
205 | 7 | * it under the terms of the GNU General Public License as published by | ||
206 | 8 | * the Free Software Foundation; version 3. | ||
207 | 9 | * | ||
208 | 10 | * unity-js-scopes is distributed in the hope that it will be useful, | ||
209 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
210 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
211 | 13 | * GNU General Public License for more details. | ||
212 | 14 | * | ||
213 | 15 | * You should have received a copy of the GNU General Public License | ||
214 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
215 | 17 | */ | ||
216 | 18 | |||
217 | 19 | #include "filter-group.h" | ||
218 | 20 | |||
219 | 21 | FilterGroup::FilterGroup(unity::scopes::FilterGroup::SCPtr p) | ||
220 | 22 | : _fg(p) { | ||
221 | 23 | } | ||
222 | 24 | |||
223 | 25 | FilterGroup::FilterGroup(std::string const& id, std::string const& label) | ||
224 | 26 | : _fg(unity::scopes::FilterGroup::create(id, label)) { | ||
225 | 27 | } | ||
226 | 28 | |||
227 | 29 | std::string FilterGroup::id() { | ||
228 | 30 | return _fg->id(); | ||
229 | 31 | } | ||
230 | 32 | |||
231 | 33 | std::string FilterGroup::label() { | ||
232 | 34 | return _fg->label(); | ||
233 | 35 | } | ||
234 | 36 | |||
235 | 37 | unity::scopes::FilterGroup::SCPtr FilterGroup::get_filter_group() { | ||
236 | 38 | return _fg; | ||
237 | 39 | } | ||
238 | 0 | 40 | ||
239 | === added file 'src/bindings/src/filter-group.h' | |||
240 | --- src/bindings/src/filter-group.h 1970-01-01 00:00:00 +0000 | |||
241 | +++ src/bindings/src/filter-group.h 2016-08-17 20:30:06 +0000 | |||
242 | @@ -0,0 +1,82 @@ | |||
243 | 1 | /* | ||
244 | 2 | * Copyright 2016 Canonical Ltd. | ||
245 | 3 | * | ||
246 | 4 | * This file is part of unity-js-scopes. | ||
247 | 5 | * | ||
248 | 6 | * unity-js-scopes is free software; you can redistribute it and/or modify | ||
249 | 7 | * it under the terms of the GNU General Public License as published by | ||
250 | 8 | * the Free Software Foundation; version 3. | ||
251 | 9 | * | ||
252 | 10 | * unity-js-scopes is distributed in the hope that it will be useful, | ||
253 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
254 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
255 | 13 | * GNU General Public License for more details. | ||
256 | 14 | * | ||
257 | 15 | * You should have received a copy of the GNU General Public License | ||
258 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
259 | 17 | */ | ||
260 | 18 | |||
261 | 19 | #ifndef _UNITY_JS_FILTER_GROUP_H_ | ||
262 | 20 | #define _UNITY_JS_FILTER_GROUP_H_ | ||
263 | 21 | |||
264 | 22 | #include <unity/scopes/FilterGroup.h> | ||
265 | 23 | |||
266 | 24 | #include <v8-cpp.h> | ||
267 | 25 | |||
268 | 26 | /** | ||
269 | 27 | |||
270 | 28 | --doc:class FilterGroup | ||
271 | 29 | * | ||
272 | 30 | * Groups several filters into an expandable widget in the UI. | ||
273 | 31 | * | ||
274 | 32 | * @module ScopeJS | ||
275 | 33 | * @class FilterGroup | ||
276 | 34 | --/doc:class | ||
277 | 35 | |||
278 | 36 | --doc:constructor | ||
279 | 37 | * | ||
280 | 38 | * @constructor | ||
281 | 39 | * @param id The id of the filter group. | ||
282 | 40 | * @param label The label corresponding to the filter group. | ||
283 | 41 | --/doc:constructor | ||
284 | 42 | |||
285 | 43 | --doc:prototype FilterGroup | ||
286 | 44 | |||
287 | 45 | --doc:member | ||
288 | 46 | * Get the id of the widget group. | ||
289 | 47 | * @method id | ||
290 | 48 | * @return {String} The identifier. | ||
291 | 49 | --doc:/member | ||
292 | 50 | id: function() { | ||
293 | 51 | } | ||
294 | 52 | --/doc:member | ||
295 | 53 | |||
296 | 54 | --doc:member | ||
297 | 55 | * Get the label of the widget group. | ||
298 | 56 | * @method label | ||
299 | 57 | * @return {String} The label. | ||
300 | 58 | --doc:/member | ||
301 | 59 | label: function() { | ||
302 | 60 | } | ||
303 | 61 | --/doc:member | ||
304 | 62 | |||
305 | 63 | --/doc:prototype | ||
306 | 64 | |||
307 | 65 | */ | ||
308 | 66 | |||
309 | 67 | class FilterGroup | ||
310 | 68 | { | ||
311 | 69 | public: | ||
312 | 70 | FilterGroup(unity::scopes::FilterGroup::SCPtr p); | ||
313 | 71 | FilterGroup(std::string const& id, std::string const& label); | ||
314 | 72 | |||
315 | 73 | std::string id(); | ||
316 | 74 | std::string label(); | ||
317 | 75 | |||
318 | 76 | unity::scopes::FilterGroup::SCPtr get_filter_group(); | ||
319 | 77 | |||
320 | 78 | private: | ||
321 | 79 | unity::scopes::FilterGroup::SCPtr _fg; | ||
322 | 80 | }; | ||
323 | 81 | |||
324 | 82 | #endif // _UNITY_JS_FILTER_GROUP_H_ | ||
325 | 0 | 83 | ||
326 | === modified file 'src/bindings/src/option-selector-filter.cc' | |||
327 | --- src/bindings/src/option-selector-filter.cc 2015-10-21 19:44:36 +0000 | |||
328 | +++ src/bindings/src/option-selector-filter.cc 2016-08-17 20:30:06 +0000 | |||
329 | @@ -1,5 +1,5 @@ | |||
330 | 1 | /* | 1 | /* |
332 | 2 | * Copyright 2015 Canonical Ltd. | 2 | * Copyright 2015-2016 Canonical Ltd. |
333 | 3 | * | 3 | * |
334 | 4 | * This file is part of unity-js-scopes. | 4 | * This file is part of unity-js-scopes. |
335 | 5 | * | 5 | * |
336 | @@ -84,3 +84,19 @@ | |||
337 | 84 | unity::scopes::OptionSelectorFilter::SPtr OptionSelectorFilter::get_filter() { | 84 | unity::scopes::OptionSelectorFilter::SPtr OptionSelectorFilter::get_filter() { |
338 | 85 | return filter_; | 85 | return filter_; |
339 | 86 | } | 86 | } |
340 | 87 | |||
341 | 88 | void OptionSelectorFilter::set_title(const std::string& title) { | ||
342 | 89 | filter_->set_title(title); | ||
343 | 90 | } | ||
344 | 91 | |||
345 | 92 | std::string OptionSelectorFilter::title() const { | ||
346 | 93 | return filter_->title(); | ||
347 | 94 | } | ||
348 | 95 | |||
349 | 96 | std::shared_ptr<FilterGroup> OptionSelectorFilter::filter_group() { | ||
350 | 97 | unity::scopes::FilterGroup::SCPtr fg = filter_->filter_group(); | ||
351 | 98 | if (!fg) { | ||
352 | 99 | return std::shared_ptr<FilterGroup>(); | ||
353 | 100 | } | ||
354 | 101 | return std::shared_ptr<FilterGroup>(new FilterGroup(fg)); | ||
355 | 102 | } | ||
356 | 87 | 103 | ||
357 | === modified file 'src/bindings/src/option-selector-filter.h' | |||
358 | --- src/bindings/src/option-selector-filter.h 2015-10-26 22:13:03 +0000 | |||
359 | +++ src/bindings/src/option-selector-filter.h 2016-08-17 20:30:06 +0000 | |||
360 | @@ -1,5 +1,5 @@ | |||
361 | 1 | /* | 1 | /* |
363 | 2 | * Copyright 2015 Canonical Ltd. | 2 | * Copyright 2015-2016 Canonical Ltd. |
364 | 3 | * | 3 | * |
365 | 4 | * This file is part of unity-js-scopes. | 4 | * This file is part of unity-js-scopes. |
366 | 5 | * | 5 | * |
367 | @@ -23,6 +23,7 @@ | |||
368 | 23 | 23 | ||
369 | 24 | #include <v8-cpp.h> | 24 | #include <v8-cpp.h> |
370 | 25 | 25 | ||
371 | 26 | #include "filter-group.h" | ||
372 | 26 | 27 | ||
373 | 27 | /** | 28 | /** |
374 | 28 | 29 | ||
375 | @@ -45,6 +46,69 @@ | |||
376 | 45 | --doc:prototype OptionSelectorFilter | 46 | --doc:prototype OptionSelectorFilter |
377 | 46 | 47 | ||
378 | 47 | --doc:member | 48 | --doc:member |
379 | 49 | * Sets display hints for the Shell UI | ||
380 | 50 | * @method set_display_hints | ||
381 | 51 | * @param hints {DisplayHints} A combination of DisplayHints for this filter. | ||
382 | 52 | --doc:/member | ||
383 | 53 | set_display_hints: function(hints) { | ||
384 | 54 | } | ||
385 | 55 | --/doc:member | ||
386 | 56 | |||
387 | 57 | --doc:member | ||
388 | 58 | * Get display hints of this filter | ||
389 | 59 | * @method display_hints | ||
390 | 60 | * @return {DisplayHints} Display hints flags | ||
391 | 61 | --doc:/member | ||
392 | 62 | display_hints: function() { | ||
393 | 63 | } | ||
394 | 64 | --/doc:member | ||
395 | 65 | |||
396 | 66 | --doc:member | ||
397 | 67 | * Set an optional title of this filter | ||
398 | 68 | * @method set_title | ||
399 | 69 | * @param title {String} The title. | ||
400 | 70 | --doc:/member | ||
401 | 71 | set_title: function(title) { | ||
402 | 72 | } | ||
403 | 73 | --/doc:member | ||
404 | 74 | |||
405 | 75 | --doc:member | ||
406 | 76 | * Get the optional title of this filter | ||
407 | 77 | * @method title | ||
408 | 78 | * @return {String} The title (possibly empty) | ||
409 | 79 | --doc:/member | ||
410 | 80 | title: function() { | ||
411 | 81 | } | ||
412 | 82 | --/doc:member | ||
413 | 83 | |||
414 | 84 | --doc:member | ||
415 | 85 | * Get the identifier of this filter | ||
416 | 86 | * @method id | ||
417 | 87 | * @return {String} identifier of this filter | ||
418 | 88 | --doc:/member | ||
419 | 89 | id: function() { | ||
420 | 90 | } | ||
421 | 91 | --/doc:member | ||
422 | 92 | |||
423 | 93 | --doc:member | ||
424 | 94 | * Get the type name of this filter | ||
425 | 95 | * @method filter_type | ||
426 | 96 | * @return {String} type name of this filter | ||
427 | 97 | --doc:/member | ||
428 | 98 | filter_type: function() { | ||
429 | 99 | } | ||
430 | 100 | --/doc:member | ||
431 | 101 | |||
432 | 102 | --doc:member | ||
433 | 103 | * Get the filter group this filter belongs to | ||
434 | 104 | * @method filter_group | ||
435 | 105 | * @return {FilterGroup} The filter group (or null) | ||
436 | 106 | --doc:/member | ||
437 | 107 | filter_group: function() { | ||
438 | 108 | } | ||
439 | 109 | --/doc:member | ||
440 | 110 | |||
441 | 111 | --doc:member | ||
442 | 48 | * Get the label of this filter | 112 | * Get the label of this filter |
443 | 49 | * @method label | 113 | * @method label |
444 | 50 | * @return {String} label of this filter | 114 | * @return {String} label of this filter |
445 | @@ -112,33 +176,6 @@ | |||
446 | 112 | } | 176 | } |
447 | 113 | --/doc:member | 177 | --/doc:member |
448 | 114 | 178 | ||
449 | 115 | --doc:member | ||
450 | 116 | * Sets display hints for the Shell UI | ||
451 | 117 | * @method set_display_hints | ||
452 | 118 | * @param hints {int} 0 is Default filter hint, 1 is Primary filter hint | ||
453 | 119 | --doc:/member | ||
454 | 120 | set_display_hints: function(hints) { | ||
455 | 121 | } | ||
456 | 122 | --/doc:member | ||
457 | 123 | |||
458 | 124 | --doc:member | ||
459 | 125 | * Get the identifier of this filter | ||
460 | 126 | * @method id | ||
461 | 127 | * @return {String} identifier of this filter | ||
462 | 128 | --doc:/member | ||
463 | 129 | id: function() { | ||
464 | 130 | } | ||
465 | 131 | --/doc:member | ||
466 | 132 | |||
467 | 133 | --doc:member | ||
468 | 134 | * Get the type name of this filter | ||
469 | 135 | * @method filter_type | ||
470 | 136 | * @return {String} type name of this filter | ||
471 | 137 | --doc:/member | ||
472 | 138 | filter_type: function() { | ||
473 | 139 | } | ||
474 | 140 | --/doc:member | ||
475 | 141 | |||
476 | 142 | --/doc:prototype | 179 | --/doc:prototype |
477 | 143 | 180 | ||
478 | 144 | */ | 181 | */ |
479 | @@ -159,9 +196,12 @@ | |||
480 | 159 | 196 | ||
481 | 160 | void set_display_hints(int hints); | 197 | void set_display_hints(int hints); |
482 | 161 | int display_hints() const; | 198 | int display_hints() const; |
483 | 199 | void set_title(const std::string& title); | ||
484 | 200 | std::string title() const; | ||
485 | 162 | std::string id() const; | 201 | std::string id() const; |
486 | 163 | unity::scopes::VariantMap serialize() const; | 202 | unity::scopes::VariantMap serialize() const; |
487 | 164 | std::string filter_type() const; | 203 | std::string filter_type() const; |
488 | 204 | std::shared_ptr<FilterGroup> filter_group(); | ||
489 | 165 | 205 | ||
490 | 166 | unity::scopes::OptionSelectorFilter::SPtr get_filter(); | 206 | unity::scopes::OptionSelectorFilter::SPtr get_filter(); |
491 | 167 | 207 | ||
492 | 168 | 208 | ||
493 | === added file 'src/bindings/src/range-input-filter.cc' | |||
494 | --- src/bindings/src/range-input-filter.cc 1970-01-01 00:00:00 +0000 | |||
495 | +++ src/bindings/src/range-input-filter.cc 2016-08-17 20:30:06 +0000 | |||
496 | @@ -0,0 +1,259 @@ | |||
497 | 1 | /* | ||
498 | 2 | * Copyright 2016 Canonical Ltd. | ||
499 | 3 | * | ||
500 | 4 | * This file is part of unity-js-scopes. | ||
501 | 5 | * | ||
502 | 6 | * unity-js-scopes is free software; you can redistribute it and/or modify | ||
503 | 7 | * it under the terms of the GNU General Public License as published by | ||
504 | 8 | * the Free Software Foundation; version 3. | ||
505 | 9 | * | ||
506 | 10 | * unity-js-scopes is distributed in the hope that it will be useful, | ||
507 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
508 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
509 | 13 | * GNU General Public License for more details. | ||
510 | 14 | * | ||
511 | 15 | * You should have received a copy of the GNU General Public License | ||
512 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
513 | 17 | */ | ||
514 | 18 | |||
515 | 19 | #include "range-input-filter.h" | ||
516 | 20 | |||
517 | 21 | #include "common.h" | ||
518 | 22 | |||
519 | 23 | RangeInputFilter::RangeInputFilter( | ||
520 | 24 | v8::FunctionCallbackInfo<v8::Value> args) { | ||
521 | 25 | if (args.Length() < 6 || args.Length() > 9) { | ||
522 | 26 | throw std::runtime_error("Invalid number of arguments"); | ||
523 | 27 | } | ||
524 | 28 | |||
525 | 29 | if (args.Length() == 6) { | ||
526 | 30 | auto id = | ||
527 | 31 | v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[0]); | ||
528 | 32 | auto start_prefix_label = | ||
529 | 33 | v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[1]); | ||
530 | 34 | auto start_postfix_label = | ||
531 | 35 | v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[2]); | ||
532 | 36 | auto central_label = | ||
533 | 37 | v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[3]); | ||
534 | 38 | auto end_prefix_label = | ||
535 | 39 | v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[4]); | ||
536 | 40 | auto end_postfix_label = | ||
537 | 41 | v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[5]); | ||
538 | 42 | |||
539 | 43 | filter_ = | ||
540 | 44 | unity::scopes::RangeInputFilter::create( | ||
541 | 45 | id, | ||
542 | 46 | start_prefix_label, | ||
543 | 47 | start_postfix_label, | ||
544 | 48 | central_label, | ||
545 | 49 | end_prefix_label, | ||
546 | 50 | end_postfix_label); | ||
547 | 51 | } else if (args.Length() == 8) { | ||
548 | 52 | auto id = | ||
549 | 53 | v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[0]); | ||
550 | 54 | unity::scopes::Variant default_start_value = | ||
551 | 55 | unity::scopesjs::to_variant(args[1]); | ||
552 | 56 | unity::scopes::Variant default_end_value = | ||
553 | 57 | unity::scopesjs::to_variant(args[2]); | ||
554 | 58 | auto start_prefix_label = | ||
555 | 59 | v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[3]); | ||
556 | 60 | auto start_postfix_label = | ||
557 | 61 | v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[4]); | ||
558 | 62 | auto central_label = | ||
559 | 63 | v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[5]); | ||
560 | 64 | auto end_prefix_label = | ||
561 | 65 | v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[6]); | ||
562 | 66 | auto end_postfix_label = | ||
563 | 67 | v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[7]); | ||
564 | 68 | |||
565 | 69 | filter_ = | ||
566 | 70 | unity::scopes::RangeInputFilter::create( | ||
567 | 71 | id, | ||
568 | 72 | default_start_value, | ||
569 | 73 | default_end_value, | ||
570 | 74 | start_prefix_label, | ||
571 | 75 | start_postfix_label, | ||
572 | 76 | central_label, | ||
573 | 77 | end_prefix_label, | ||
574 | 78 | end_postfix_label); | ||
575 | 79 | } else if (args.Length() == 7) { | ||
576 | 80 | auto id = | ||
577 | 81 | v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[0]); | ||
578 | 82 | auto start_prefix_label = | ||
579 | 83 | v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[1]); | ||
580 | 84 | auto start_postfix_label = | ||
581 | 85 | v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[2]); | ||
582 | 86 | auto central_label = | ||
583 | 87 | v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[3]); | ||
584 | 88 | auto end_prefix_label = | ||
585 | 89 | v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[4]); | ||
586 | 90 | auto end_postfix_label = | ||
587 | 91 | v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[5]); | ||
588 | 92 | auto fg = | ||
589 | 93 | v8cpp::from_v8<std::shared_ptr<FilterGroup>>( | ||
590 | 94 | v8::Isolate::GetCurrent(), args[6]); | ||
591 | 95 | |||
592 | 96 | unity::scopes::FilterGroup::SCPtr filter_group; | ||
593 | 97 | if (fg) { | ||
594 | 98 | filter_group = fg->get_filter_group(); | ||
595 | 99 | } | ||
596 | 100 | |||
597 | 101 | filter_ = | ||
598 | 102 | unity::scopes::RangeInputFilter::create( | ||
599 | 103 | id, | ||
600 | 104 | start_prefix_label, | ||
601 | 105 | start_postfix_label, | ||
602 | 106 | central_label, | ||
603 | 107 | end_prefix_label, | ||
604 | 108 | end_postfix_label, | ||
605 | 109 | filter_group); | ||
606 | 110 | } else { | ||
607 | 111 | auto id = | ||
608 | 112 | v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[0]); | ||
609 | 113 | unity::scopes::Variant default_start_value = | ||
610 | 114 | unity::scopesjs::to_variant(args[1]); | ||
611 | 115 | unity::scopes::Variant default_end_value = | ||
612 | 116 | unity::scopesjs::to_variant(args[2]); | ||
613 | 117 | auto start_prefix_label = | ||
614 | 118 | v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[3]); | ||
615 | 119 | auto start_postfix_label = | ||
616 | 120 | v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[4]); | ||
617 | 121 | auto central_label = | ||
618 | 122 | v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[5]); | ||
619 | 123 | auto end_prefix_label = | ||
620 | 124 | v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[6]); | ||
621 | 125 | auto end_postfix_label = | ||
622 | 126 | v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[7]); | ||
623 | 127 | auto fg = | ||
624 | 128 | v8cpp::from_v8<std::shared_ptr<FilterGroup>>( | ||
625 | 129 | v8::Isolate::GetCurrent(), args[8]); | ||
626 | 130 | |||
627 | 131 | unity::scopes::FilterGroup::SCPtr filter_group; | ||
628 | 132 | if (fg) { | ||
629 | 133 | filter_group = fg->get_filter_group(); | ||
630 | 134 | } | ||
631 | 135 | |||
632 | 136 | filter_ = | ||
633 | 137 | unity::scopes::RangeInputFilter::create( | ||
634 | 138 | id, | ||
635 | 139 | default_start_value, | ||
636 | 140 | default_end_value, | ||
637 | 141 | start_prefix_label, | ||
638 | 142 | start_postfix_label, | ||
639 | 143 | central_label, | ||
640 | 144 | end_prefix_label, | ||
641 | 145 | end_postfix_label, | ||
642 | 146 | filter_group); | ||
643 | 147 | } | ||
644 | 148 | } | ||
645 | 149 | |||
646 | 150 | std::string RangeInputFilter::start_prefix_label() const { | ||
647 | 151 | return filter_->start_prefix_label(); | ||
648 | 152 | } | ||
649 | 153 | |||
650 | 154 | std::string RangeInputFilter::start_postfix_label() const { | ||
651 | 155 | return filter_->start_postfix_label(); | ||
652 | 156 | } | ||
653 | 157 | |||
654 | 158 | std::string RangeInputFilter::end_prefix_label() const { | ||
655 | 159 | return filter_->end_prefix_label(); | ||
656 | 160 | } | ||
657 | 161 | |||
658 | 162 | std::string RangeInputFilter::end_postfix_label() const { | ||
659 | 163 | return filter_->end_postfix_label(); | ||
660 | 164 | } | ||
661 | 165 | |||
662 | 166 | std::string RangeInputFilter::central_label() const { | ||
663 | 167 | return filter_->central_label(); | ||
664 | 168 | } | ||
665 | 169 | |||
666 | 170 | v8::Local<v8::Value> RangeInputFilter::default_start_value() const { | ||
667 | 171 | unity::scopes::Variant v = | ||
668 | 172 | filter_->default_start_value(); | ||
669 | 173 | switch(v.which()) { | ||
670 | 174 | case unity::scopes::Variant::Null: | ||
671 | 175 | return v8::Null(v8::Isolate::GetCurrent()); | ||
672 | 176 | case unity::scopes::Variant::Int: | ||
673 | 177 | return v8::Integer::New(v8::Isolate::GetCurrent(), v.get_int()); | ||
674 | 178 | case unity::scopes::Variant::Double: | ||
675 | 179 | return v8::Number::New(v8::Isolate::GetCurrent(), v.get_double()); | ||
676 | 180 | default: | ||
677 | 181 | throw std::runtime_error("Invalid default start value"); | ||
678 | 182 | } | ||
679 | 183 | } | ||
680 | 184 | |||
681 | 185 | v8::Local<v8::Value> RangeInputFilter::default_end_value() const { | ||
682 | 186 | unity::scopes::Variant v = | ||
683 | 187 | filter_->default_end_value(); | ||
684 | 188 | switch(v.which()) { | ||
685 | 189 | case unity::scopes::Variant::Null: | ||
686 | 190 | return v8::Null(v8::Isolate::GetCurrent()); | ||
687 | 191 | case unity::scopes::Variant::Int: | ||
688 | 192 | return v8::Integer::New(v8::Isolate::GetCurrent(), v.get_int()); | ||
689 | 193 | case unity::scopes::Variant::Double: | ||
690 | 194 | return v8::Number::New(v8::Isolate::GetCurrent(), v.get_double()); | ||
691 | 195 | default: | ||
692 | 196 | throw std::runtime_error("Invalid default start value"); | ||
693 | 197 | } | ||
694 | 198 | } | ||
695 | 199 | |||
696 | 200 | bool RangeInputFilter::has_start_value(std::shared_ptr<unity::scopes::FilterState> filter_state) const { | ||
697 | 201 | return true; | ||
698 | 202 | } | ||
699 | 203 | |||
700 | 204 | bool RangeInputFilter::has_end_value(std::shared_ptr<unity::scopes::FilterState> filter_state) const { | ||
701 | 205 | return true; | ||
702 | 206 | } | ||
703 | 207 | |||
704 | 208 | double RangeInputFilter::start_value(std::shared_ptr<unity::scopes::FilterState> filter_state) const { | ||
705 | 209 | return true; | ||
706 | 210 | } | ||
707 | 211 | |||
708 | 212 | double RangeInputFilter::end_value(std::shared_ptr<unity::scopes::FilterState> filter_state) const { | ||
709 | 213 | return true; | ||
710 | 214 | } | ||
711 | 215 | |||
712 | 216 | void RangeInputFilter::update_state(std::shared_ptr<unity::scopes::FilterState> filter_state, | ||
713 | 217 | v8::Local<v8::Value> start_value, | ||
714 | 218 | v8::Local<v8::Value> end_value) const { | ||
715 | 219 | } | ||
716 | 220 | |||
717 | 221 | void RangeInputFilter::set_display_hints(int hints) { | ||
718 | 222 | filter_->set_display_hints(hints); | ||
719 | 223 | } | ||
720 | 224 | |||
721 | 225 | int RangeInputFilter::display_hints() const { | ||
722 | 226 | return filter_->display_hints(); | ||
723 | 227 | } | ||
724 | 228 | |||
725 | 229 | std::string RangeInputFilter::id() const { | ||
726 | 230 | return filter_->id(); | ||
727 | 231 | } | ||
728 | 232 | |||
729 | 233 | unity::scopes::VariantMap RangeInputFilter::serialize() const { | ||
730 | 234 | return filter_->serialize(); | ||
731 | 235 | } | ||
732 | 236 | |||
733 | 237 | std::string RangeInputFilter::filter_type() const { | ||
734 | 238 | return filter_->filter_type(); | ||
735 | 239 | } | ||
736 | 240 | |||
737 | 241 | unity::scopes::RangeInputFilter::SPtr RangeInputFilter::get_filter() { | ||
738 | 242 | return filter_; | ||
739 | 243 | } | ||
740 | 244 | |||
741 | 245 | void RangeInputFilter::set_title(const std::string& title) { | ||
742 | 246 | filter_->set_title(title); | ||
743 | 247 | } | ||
744 | 248 | |||
745 | 249 | std::string RangeInputFilter::title() const { | ||
746 | 250 | return filter_->title(); | ||
747 | 251 | } | ||
748 | 252 | |||
749 | 253 | std::shared_ptr<FilterGroup> RangeInputFilter::filter_group() { | ||
750 | 254 | unity::scopes::FilterGroup::SCPtr fg = filter_->filter_group(); | ||
751 | 255 | if (!fg) { | ||
752 | 256 | return std::shared_ptr<FilterGroup>(); | ||
753 | 257 | } | ||
754 | 258 | return std::shared_ptr<FilterGroup>(new FilterGroup(fg)); | ||
755 | 259 | } | ||
756 | 0 | 260 | ||
757 | === added file 'src/bindings/src/range-input-filter.h' | |||
758 | --- src/bindings/src/range-input-filter.h 1970-01-01 00:00:00 +0000 | |||
759 | +++ src/bindings/src/range-input-filter.h 2016-08-17 20:30:06 +0000 | |||
760 | @@ -0,0 +1,312 @@ | |||
761 | 1 | /* | ||
762 | 2 | * Copyright 2016 Canonical Ltd. | ||
763 | 3 | * | ||
764 | 4 | * This file is part of unity-js-scopes. | ||
765 | 5 | * | ||
766 | 6 | * unity-js-scopes is free software; you can redistribute it and/or modify | ||
767 | 7 | * it under the terms of the GNU General Public License as published by | ||
768 | 8 | * the Free Software Foundation; version 3. | ||
769 | 9 | * | ||
770 | 10 | * unity-js-scopes is distributed in the hope that it will be useful, | ||
771 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
772 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
773 | 13 | * GNU General Public License for more details. | ||
774 | 14 | * | ||
775 | 15 | * You should have received a copy of the GNU General Public License | ||
776 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
777 | 17 | */ | ||
778 | 18 | |||
779 | 19 | #ifndef _UNITY_JS_VALUE_SLIDE_FILTER_H_ | ||
780 | 20 | #define _UNITY_JS_VALUE_SLIDE_FILTER_H_ | ||
781 | 21 | |||
782 | 22 | #include <unity/scopes/RangeInputFilter.h> | ||
783 | 23 | |||
784 | 24 | #include <v8-cpp.h> | ||
785 | 25 | |||
786 | 26 | #include "filter-group.h" | ||
787 | 27 | |||
788 | 28 | |||
789 | 29 | /** | ||
790 | 30 | |||
791 | 31 | --doc:class RangeInputFilter | ||
792 | 32 | * | ||
793 | 33 | * A range filter allows a start and end value to be entered by the user. | ||
794 | 34 | * | ||
795 | 35 | * A RangeInputFilter is composed of two input boxes that accept numeric | ||
796 | 36 | * values (both of them optional). | ||
797 | 37 | * The filter can have prefix and/or postfix labels for the start and end | ||
798 | 38 | * value, respectively, plus a single label that is displayed between the two input boxes. | ||
799 | 39 | * The filter can provide defaults for that start and end value, which are | ||
800 | 40 | * used by the UI if the user does not enter explicit values. | ||
801 | 41 | * | ||
802 | 42 | * @module ScopeJS | ||
803 | 43 | * @class RangeInputFilter | ||
804 | 44 | --/doc:class | ||
805 | 45 | |||
806 | 46 | --doc:constructor | ||
807 | 47 | * Creates a RangeInputFilter | ||
808 | 48 | * | ||
809 | 49 | * @constructor | ||
810 | 50 | * @param {String} id A unique identifier for the filter that can be used to later identify it among several filters. | ||
811 | 51 | * @param {String} start_prefix_label A display label for the input box for the start value, displayed to the left (can be empty). | ||
812 | 52 | * @param {String} start_postfix_label A display label for the input box for the start value, displayed to the right (can be empty). | ||
813 | 53 | * @param {String} central_label A display label displayed between the two input boxes (can be empty). | ||
814 | 54 | * @param {String} end_prefix_label A display label for the input box for the end value, displayed to the left (can be empty). | ||
815 | 55 | * @param {String} end_postfix_label A display label for the input box for the end value, displayed to the right (can be empty). | ||
816 | 56 | --/doc:constructor | ||
817 | 57 | |||
818 | 58 | --doc:constructor | ||
819 | 59 | * Creates a RangeInputFilter with specific default values for start and end | ||
820 | 60 | * | ||
821 | 61 | * @constructor | ||
822 | 62 | * @param {String} id A unique identifier for the filter that can be used to later identify it among several filters. | ||
823 | 63 | * @param {Number} default_start_value The default start value or null. | ||
824 | 64 | * @param {Number} default_end_value The default end value or null. | ||
825 | 65 | * @param {String} start_prefix_label A display label for the input box for the start value, displayed to the left (can be empty). | ||
826 | 66 | * @param {String} start_postfix_label A display label for the input box for the start value, displayed to the right (can be empty). | ||
827 | 67 | * @param {String} central_label A display label displayed between the two input boxes (can be empty). | ||
828 | 68 | * @param {String} end_prefix_label A display label for the input box for the end value, displayed to the left (can be empty). | ||
829 | 69 | * @param {String} end_postfix_label A display label for the input box for the end value, displayed to the right (can be empty). | ||
830 | 70 | --/doc:constructor | ||
831 | 71 | |||
832 | 72 | --doc:constructor | ||
833 | 73 | * Creates a RangeInputFilter inside a FilterGroup | ||
834 | 74 | * | ||
835 | 75 | * @constructor | ||
836 | 76 | * @param {String} id A unique identifier for the filter that can be used to later identify it among several filters. | ||
837 | 77 | * @param {String} start_prefix_label A display label for the input box for the start value, displayed to the left (can be empty). | ||
838 | 78 | * @param {String} start_postfix_label A display label for the input box for the start value, displayed to the right (can be empty). | ||
839 | 79 | * @param {String} central_label A display label displayed between the two input boxes (can be empty). | ||
840 | 80 | * @param {String} end_prefix_label A display label for the input box for the end value, displayed to the left (can be empty). | ||
841 | 81 | * @param {String} end_postfix_label A display label for the input box for the end value, displayed to the right (can be empty). | ||
842 | 82 | * @param {FilterGroup} filter_group The filter group associated with this filter. | ||
843 | 83 | --/doc:constructor | ||
844 | 84 | |||
845 | 85 | --doc:constructor | ||
846 | 86 | * Creates a RangeInputFilter with specific default values for start and end, | ||
847 | 87 | * inside a FilterGroup | ||
848 | 88 | * | ||
849 | 89 | * @constructor | ||
850 | 90 | * @param {String} id A unique identifier for the filter that can be used to later identify it among several filters. | ||
851 | 91 | * @param {Number} default_start_value The default start value or null. | ||
852 | 92 | * @param {Number} default_end_value The default end value or null. | ||
853 | 93 | * @param {String} start_prefix_label A display label for the input box for the start value, displayed to the left (can be empty). | ||
854 | 94 | * @param {String} start_postfix_label A display label for the input box for the start value, displayed to the right (can be empty). | ||
855 | 95 | * @param {String} central_label A display label displayed between the two input boxes (can be empty). | ||
856 | 96 | * @param {String} end_prefix_label A display label for the input box for the end value, displayed to the left (can be empty). | ||
857 | 97 | * @param {String} end_postfix_label A display label for the input box for the end value, displayed to the right (can be empty). | ||
858 | 98 | * @param {FilterGroup} filter_group The filter group associated with this filter. | ||
859 | 99 | --/doc:constructor | ||
860 | 100 | |||
861 | 101 | --doc:prototype RangeInputFilter | ||
862 | 102 | |||
863 | 103 | --doc:member | ||
864 | 104 | * Sets display hints for the Shell UI | ||
865 | 105 | * @method set_display_hints | ||
866 | 106 | * @param hints {DisplayHints} A combination of DisplayHints for this filter. | ||
867 | 107 | --doc:/member | ||
868 | 108 | set_display_hints: function(hints) { | ||
869 | 109 | } | ||
870 | 110 | --/doc:member | ||
871 | 111 | |||
872 | 112 | --doc:member | ||
873 | 113 | * Get display hints of this filter | ||
874 | 114 | * @method display_hints | ||
875 | 115 | * @return {DisplayHints} Display hints flags | ||
876 | 116 | --doc:/member | ||
877 | 117 | display_hints: function() { | ||
878 | 118 | } | ||
879 | 119 | --/doc:member | ||
880 | 120 | |||
881 | 121 | --doc:member | ||
882 | 122 | * Set an optional title of this filter | ||
883 | 123 | * @method set_title | ||
884 | 124 | * @param title {String} The title. | ||
885 | 125 | --doc:/member | ||
886 | 126 | set_title: function(title) { | ||
887 | 127 | } | ||
888 | 128 | --/doc:member | ||
889 | 129 | |||
890 | 130 | --doc:member | ||
891 | 131 | * Get the optional title of this filter | ||
892 | 132 | * @method title | ||
893 | 133 | * @return {String} The title (possibly empty) | ||
894 | 134 | --doc:/member | ||
895 | 135 | title: function() { | ||
896 | 136 | } | ||
897 | 137 | --/doc:member | ||
898 | 138 | |||
899 | 139 | --doc:member | ||
900 | 140 | * Get the identifier of this filter | ||
901 | 141 | * @method id | ||
902 | 142 | * @return {String} identifier of this filter | ||
903 | 143 | --doc:/member | ||
904 | 144 | id: function() { | ||
905 | 145 | } | ||
906 | 146 | --/doc:member | ||
907 | 147 | |||
908 | 148 | --doc:member | ||
909 | 149 | * Get the type name of this filter | ||
910 | 150 | * @method filter_type | ||
911 | 151 | * @return {String} type name of this filter | ||
912 | 152 | --doc:/member | ||
913 | 153 | filter_type: function() { | ||
914 | 154 | } | ||
915 | 155 | --/doc:member | ||
916 | 156 | |||
917 | 157 | --doc:member | ||
918 | 158 | * Get the filter group this filter belongs to | ||
919 | 159 | * @method filter_group | ||
920 | 160 | * @return {FilterGroup} The filter group (or null) | ||
921 | 161 | --doc:/member | ||
922 | 162 | filter_group: function() { | ||
923 | 163 | } | ||
924 | 164 | --/doc:member | ||
925 | 165 | |||
926 | 166 | |||
927 | 167 | |||
928 | 168 | --doc:member | ||
929 | 169 | * Get the prefix label of start value | ||
930 | 170 | * @method start_prefix_label | ||
931 | 171 | * @return {String} The prefix label of start value | ||
932 | 172 | --doc:/member | ||
933 | 173 | start_prefix_label: function() { | ||
934 | 174 | } | ||
935 | 175 | --/doc:member | ||
936 | 176 | |||
937 | 177 | --doc:member | ||
938 | 178 | * Get the postfix label of start value | ||
939 | 179 | * @method start_postfix_label | ||
940 | 180 | * @return {String} The postfix label of start value | ||
941 | 181 | --doc:/member | ||
942 | 182 | start_postfix_label: function() { | ||
943 | 183 | } | ||
944 | 184 | --/doc:member | ||
945 | 185 | |||
946 | 186 | --doc:member | ||
947 | 187 | * Get the postfix label of end value | ||
948 | 188 | * @method end_postfix_label | ||
949 | 189 | * @return {String} The postfix label of end value | ||
950 | 190 | --doc:/member | ||
951 | 191 | end_postfix_label: function() { | ||
952 | 192 | } | ||
953 | 193 | --/doc:member | ||
954 | 194 | |||
955 | 195 | --doc:member | ||
956 | 196 | * Get the prefix label of end value | ||
957 | 197 | * @method end_prefix_label | ||
958 | 198 | * @return {String} The prefix label of end value | ||
959 | 199 | --doc:/member | ||
960 | 200 | end_prefix_label: function() { | ||
961 | 201 | } | ||
962 | 202 | --/doc:member | ||
963 | 203 | |||
964 | 204 | --doc:member | ||
965 | 205 | * Get the central label for this filter | ||
966 | 206 | * @method central_label | ||
967 | 207 | * @return {String} The central label of end value | ||
968 | 208 | --doc:/member | ||
969 | 209 | central_label: function() { | ||
970 | 210 | } | ||
971 | 211 | --/doc:member | ||
972 | 212 | |||
973 | 213 | --doc:member | ||
974 | 214 | * Check if filter state holds an start value for this filter instance | ||
975 | 215 | * @method has_start_value | ||
976 | 216 | * @param {FilterState} filter_state The state of filters | ||
977 | 217 | * @return {Boolean} `true` if filter_state has an start value for this filter. | ||
978 | 218 | --doc:/member | ||
979 | 219 | has_start_value: function(filter_state) { | ||
980 | 220 | } | ||
981 | 221 | --/doc:member | ||
982 | 222 | |||
983 | 223 | --doc:member | ||
984 | 224 | * Check if filter state holds an end value for this filter instance | ||
985 | 225 | * @method has_end_value | ||
986 | 226 | * @param {FilterState} filter_state The state of filters | ||
987 | 227 | * @return {Boolean} `true` if filter_state has an end value for this filter. | ||
988 | 228 | --doc:/member | ||
989 | 229 | has_end_value: function(filter_state) { | ||
990 | 230 | } | ||
991 | 231 | --/doc:member | ||
992 | 232 | |||
993 | 233 | --doc:member | ||
994 | 234 | * Get the start value for this filter instance | ||
995 | 235 | * @method start_value | ||
996 | 236 | * @param {FilterState} filter_state The state of filters | ||
997 | 237 | * @return The start value or the default start value if not null | ||
998 | 238 | --doc:/member | ||
999 | 239 | start_value: function(filter_state) { | ||
1000 | 240 | } | ||
1001 | 241 | --/doc:member | ||
1002 | 242 | |||
1003 | 243 | --doc:member | ||
1004 | 244 | * Get the end value for this filter instance | ||
1005 | 245 | * @method end_value | ||
1006 | 246 | * @param {FilterState} filter_state The state of filters | ||
1007 | 247 | * @return The start value or the default end value if not null | ||
1008 | 248 | --doc:/member | ||
1009 | 249 | end_value: function(filter_state) { | ||
1010 | 250 | } | ||
1011 | 251 | --/doc:member | ||
1012 | 252 | |||
1013 | 253 | --doc:member | ||
1014 | 254 | * Store start and end value for this filter in the filter state | ||
1015 | 255 | * Updates filter_state with start and end values for this filter instance. | ||
1016 | 256 | * Allowed data types for start_value and end_value are null or a number. | ||
1017 | 257 | * Pass null as start_value or end_value if that value is unspecified | ||
1018 | 258 | * (hasn't been entered or was erased by the user from the input box). | ||
1019 | 259 | * | ||
1020 | 260 | * @method update_state | ||
1021 | 261 | * @param filter_state {FilterState} | ||
1022 | 262 | * @param start_value Start value | ||
1023 | 263 | * @param end_value End value | ||
1024 | 264 | --doc:/member | ||
1025 | 265 | update_state: function(filter_state, start_value, end_value) { | ||
1026 | 266 | } | ||
1027 | 267 | --/doc:member | ||
1028 | 268 | |||
1029 | 269 | --/doc:prototype | ||
1030 | 270 | |||
1031 | 271 | */ | ||
1032 | 272 | |||
1033 | 273 | |||
1034 | 274 | class RangeInputFilter | ||
1035 | 275 | { | ||
1036 | 276 | public: | ||
1037 | 277 | RangeInputFilter(v8::FunctionCallbackInfo<v8::Value> args); | ||
1038 | 278 | |||
1039 | 279 | std::string start_prefix_label() const; | ||
1040 | 280 | std::string start_postfix_label() const; | ||
1041 | 281 | std::string end_prefix_label() const; | ||
1042 | 282 | std::string end_postfix_label() const; | ||
1043 | 283 | std::string central_label() const; | ||
1044 | 284 | v8::Local<v8::Value> default_start_value() const; | ||
1045 | 285 | v8::Local<v8::Value> default_end_value() const; | ||
1046 | 286 | bool has_start_value(std::shared_ptr<unity::scopes::FilterState> filter_state) const; | ||
1047 | 287 | bool has_end_value(std::shared_ptr<unity::scopes::FilterState> filter_state) const; | ||
1048 | 288 | double start_value(std::shared_ptr<unity::scopes::FilterState> filter_state) const; | ||
1049 | 289 | double end_value(std::shared_ptr<unity::scopes::FilterState> filter_state) const; | ||
1050 | 290 | |||
1051 | 291 | void update_state(std::shared_ptr<unity::scopes::FilterState> filter_state, | ||
1052 | 292 | v8::Local<v8::Value> start_value, | ||
1053 | 293 | v8::Local<v8::Value> end_value) const; | ||
1054 | 294 | |||
1055 | 295 | void set_display_hints(int hints); | ||
1056 | 296 | int display_hints() const; | ||
1057 | 297 | void set_title(const std::string& title); | ||
1058 | 298 | std::string title() const; | ||
1059 | 299 | std::string id() const; | ||
1060 | 300 | unity::scopes::VariantMap serialize() const; | ||
1061 | 301 | std::string filter_type() const; | ||
1062 | 302 | std::shared_ptr<FilterGroup> filter_group(); | ||
1063 | 303 | |||
1064 | 304 | unity::scopes::RangeInputFilter::SPtr get_filter(); | ||
1065 | 305 | |||
1066 | 306 | private: | ||
1067 | 307 | unity::scopes::RangeInputFilter::SPtr filter_; | ||
1068 | 308 | }; | ||
1069 | 309 | |||
1070 | 310 | #endif // _UNITY_JS_RANGE_INPUT_FILTER_H_ | ||
1071 | 311 | |||
1072 | 312 | |||
1073 | 0 | 313 | ||
1074 | === added file 'src/bindings/src/value-slider-filter.cc' | |||
1075 | --- src/bindings/src/value-slider-filter.cc 1970-01-01 00:00:00 +0000 | |||
1076 | +++ src/bindings/src/value-slider-filter.cc 2016-08-17 20:30:06 +0000 | |||
1077 | @@ -0,0 +1,141 @@ | |||
1078 | 1 | /* | ||
1079 | 2 | * Copyright 2016 Canonical Ltd. | ||
1080 | 3 | * | ||
1081 | 4 | * This file is part of unity-js-scopes. | ||
1082 | 5 | * | ||
1083 | 6 | * unity-js-scopes is free software; you can redistribute it and/or modify | ||
1084 | 7 | * it under the terms of the GNU General Public License as published by | ||
1085 | 8 | * the Free Software Foundation; version 3. | ||
1086 | 9 | * | ||
1087 | 10 | * unity-js-scopes is distributed in the hope that it will be useful, | ||
1088 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1089 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1090 | 13 | * GNU General Public License for more details. | ||
1091 | 14 | * | ||
1092 | 15 | * You should have received a copy of the GNU General Public License | ||
1093 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1094 | 17 | */ | ||
1095 | 18 | |||
1096 | 19 | #include "value-slider-filter.h" | ||
1097 | 20 | |||
1098 | 21 | #include <unity/scopes/FilterState.h> | ||
1099 | 22 | |||
1100 | 23 | ValueSliderFilter::ValueSliderFilter(v8::FunctionCallbackInfo<v8::Value> args) { | ||
1101 | 24 | if (args.Length() != 5 && args.Length() != 6) { | ||
1102 | 25 | throw std::runtime_error("Invalid number of arguments"); | ||
1103 | 26 | } | ||
1104 | 27 | |||
1105 | 28 | if (args.Length() == 5) { | ||
1106 | 29 | auto id = | ||
1107 | 30 | v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[0]); | ||
1108 | 31 | auto min = | ||
1109 | 32 | v8cpp::from_v8<double>(v8::Isolate::GetCurrent(), args[1]); | ||
1110 | 33 | auto max = | ||
1111 | 34 | v8cpp::from_v8<double>(v8::Isolate::GetCurrent(), args[2]); | ||
1112 | 35 | auto default_value = | ||
1113 | 36 | v8cpp::from_v8<double>(v8::Isolate::GetCurrent(), args[3]); | ||
1114 | 37 | auto value_slider_labels = | ||
1115 | 38 | v8cpp::from_v8<std::shared_ptr<ValueSliderLabels>>(v8::Isolate::GetCurrent(), args[4]); | ||
1116 | 39 | |||
1117 | 40 | unity::scopes::ValueSliderLabels labels = | ||
1118 | 41 | value_slider_labels->get_labels(); | ||
1119 | 42 | filter_ = | ||
1120 | 43 | unity::scopes::ValueSliderFilter::create( | ||
1121 | 44 | id, min, max, default_value, labels); | ||
1122 | 45 | } else { | ||
1123 | 46 | auto id = | ||
1124 | 47 | v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[0]); | ||
1125 | 48 | auto min = | ||
1126 | 49 | v8cpp::from_v8<double>(v8::Isolate::GetCurrent(), args[1]); | ||
1127 | 50 | auto max = | ||
1128 | 51 | v8cpp::from_v8<double>(v8::Isolate::GetCurrent(), args[2]); | ||
1129 | 52 | auto default_value = | ||
1130 | 53 | v8cpp::from_v8<double>(v8::Isolate::GetCurrent(), args[3]); | ||
1131 | 54 | auto value_slider_labels = | ||
1132 | 55 | v8cpp::from_v8<std::shared_ptr<ValueSliderLabels>>(v8::Isolate::GetCurrent(), args[4]); | ||
1133 | 56 | auto group = | ||
1134 | 57 | v8cpp::from_v8<std::shared_ptr<FilterGroup>>(v8::Isolate::GetCurrent(), args[5]); | ||
1135 | 58 | |||
1136 | 59 | unity::scopes::ValueSliderLabels labels = | ||
1137 | 60 | value_slider_labels->get_labels(); | ||
1138 | 61 | unity::scopes::FilterGroup::SCPtr filter_group; | ||
1139 | 62 | if (group) { | ||
1140 | 63 | filter_group = group->get_filter_group(); | ||
1141 | 64 | } | ||
1142 | 65 | filter_ = | ||
1143 | 66 | unity::scopes::ValueSliderFilter::create( | ||
1144 | 67 | id, min, max, default_value, labels, filter_group); | ||
1145 | 68 | } | ||
1146 | 69 | } | ||
1147 | 70 | |||
1148 | 71 | void ValueSliderFilter::set_default_value(double val) { | ||
1149 | 72 | filter_->set_default_value(val); | ||
1150 | 73 | } | ||
1151 | 74 | |||
1152 | 75 | double ValueSliderFilter::default_value() const { | ||
1153 | 76 | return filter_->default_value(); | ||
1154 | 77 | } | ||
1155 | 78 | |||
1156 | 79 | double ValueSliderFilter::min() const { | ||
1157 | 80 | return filter_->min(); | ||
1158 | 81 | } | ||
1159 | 82 | |||
1160 | 83 | double ValueSliderFilter::max() const { | ||
1161 | 84 | return filter_->max(); | ||
1162 | 85 | } | ||
1163 | 86 | |||
1164 | 87 | bool ValueSliderFilter::has_value(std::shared_ptr<unity::scopes::FilterState> filter_state) const { | ||
1165 | 88 | return filter_->has_value(*filter_state); | ||
1166 | 89 | } | ||
1167 | 90 | |||
1168 | 91 | double ValueSliderFilter::value(std::shared_ptr<unity::scopes::FilterState> filter_state) const { | ||
1169 | 92 | return filter_->value(*filter_state); | ||
1170 | 93 | } | ||
1171 | 94 | |||
1172 | 95 | std::shared_ptr<ValueSliderLabels> ValueSliderFilter::labels() const { | ||
1173 | 96 | return std::shared_ptr<ValueSliderLabels>( | ||
1174 | 97 | new ValueSliderLabels(filter_->labels())); | ||
1175 | 98 | } | ||
1176 | 99 | |||
1177 | 100 | void ValueSliderFilter::update_state( | ||
1178 | 101 | std::shared_ptr<unity::scopes::FilterState> filter_state, | ||
1179 | 102 | double value) const { | ||
1180 | 103 | filter_->update_state(*filter_state, value); | ||
1181 | 104 | } | ||
1182 | 105 | |||
1183 | 106 | void ValueSliderFilter::set_display_hints(int hints) { | ||
1184 | 107 | filter_->set_display_hints(hints); | ||
1185 | 108 | } | ||
1186 | 109 | |||
1187 | 110 | int ValueSliderFilter::display_hints() const { | ||
1188 | 111 | return filter_->display_hints(); | ||
1189 | 112 | } | ||
1190 | 113 | |||
1191 | 114 | std::string ValueSliderFilter::id() const { | ||
1192 | 115 | return filter_->id(); | ||
1193 | 116 | } | ||
1194 | 117 | |||
1195 | 118 | unity::scopes::VariantMap ValueSliderFilter::serialize() const { | ||
1196 | 119 | return filter_->serialize(); | ||
1197 | 120 | } | ||
1198 | 121 | |||
1199 | 122 | std::string ValueSliderFilter::filter_type() const { | ||
1200 | 123 | return filter_->filter_type(); | ||
1201 | 124 | } | ||
1202 | 125 | |||
1203 | 126 | void ValueSliderFilter::set_title(const std::string& title) { | ||
1204 | 127 | filter_->set_title(title); | ||
1205 | 128 | } | ||
1206 | 129 | |||
1207 | 130 | std::string ValueSliderFilter::title() const { | ||
1208 | 131 | return filter_->title(); | ||
1209 | 132 | } | ||
1210 | 133 | |||
1211 | 134 | std::shared_ptr<FilterGroup> ValueSliderFilter::filter_group() { | ||
1212 | 135 | unity::scopes::FilterGroup::SCPtr fg = filter_->filter_group(); | ||
1213 | 136 | if (!fg) { | ||
1214 | 137 | return std::shared_ptr<FilterGroup>(); | ||
1215 | 138 | } | ||
1216 | 139 | return std::shared_ptr<FilterGroup>( | ||
1217 | 140 | new FilterGroup(fg)); | ||
1218 | 141 | } | ||
1219 | 0 | 142 | ||
1220 | === added file 'src/bindings/src/value-slider-filter.h' | |||
1221 | --- src/bindings/src/value-slider-filter.h 1970-01-01 00:00:00 +0000 | |||
1222 | +++ src/bindings/src/value-slider-filter.h 2016-08-17 20:30:06 +0000 | |||
1223 | @@ -0,0 +1,234 @@ | |||
1224 | 1 | /* | ||
1225 | 2 | * Copyright 2016 Canonical Ltd. | ||
1226 | 3 | * | ||
1227 | 4 | * This file is part of unity-js-scopes. | ||
1228 | 5 | * | ||
1229 | 6 | * unity-js-scopes is free software; you can redistribute it and/or modify | ||
1230 | 7 | * it under the terms of the GNU General Public License as published by | ||
1231 | 8 | * the Free Software Foundation; version 3. | ||
1232 | 9 | * | ||
1233 | 10 | * unity-js-scopes is distributed in the hope that it will be useful, | ||
1234 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1235 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1236 | 13 | * GNU General Public License for more details. | ||
1237 | 14 | * | ||
1238 | 15 | * You should have received a copy of the GNU General Public License | ||
1239 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1240 | 17 | */ | ||
1241 | 18 | |||
1242 | 19 | #ifndef _UNITY_JS_VALUE_SLIDER_FILTER_H_ | ||
1243 | 20 | #define _UNITY_JS_VALUE_SLIDER_FILTER_H_ | ||
1244 | 21 | |||
1245 | 22 | #include <unity/scopes/ValueSliderFilter.h> | ||
1246 | 23 | |||
1247 | 24 | #include <v8-cpp.h> | ||
1248 | 25 | |||
1249 | 26 | #include "filter-group.h" | ||
1250 | 27 | #include "filter-state.h" | ||
1251 | 28 | #include "value-slider-labels.h" | ||
1252 | 29 | |||
1253 | 30 | |||
1254 | 31 | /** | ||
1255 | 32 | |||
1256 | 33 | --doc:class ValueSliderFilter | ||
1257 | 34 | * | ||
1258 | 35 | * A value slider filter that allows for selecting a value within a given range. | ||
1259 | 36 | * | ||
1260 | 37 | * The ValueSliderFilter allows for selecting a value within a range defined by minimum and maximum values. | ||
1261 | 38 | * Both minimum and maximum values can have labels and, in addition, the scope may provide extra labels to mark other values from that range - these label will serve as a guidance to the user. | ||
1262 | 39 | * | ||
1263 | 40 | * | ||
1264 | 41 | * @module ScopeJS | ||
1265 | 42 | * @class ValueSliderFilter | ||
1266 | 43 | --/doc:class | ||
1267 | 44 | |||
1268 | 45 | --doc:constructor | ||
1269 | 46 | * | ||
1270 | 47 | * @constructor | ||
1271 | 48 | * @param {String} id A unique identifier for the filter that can be used to later identify it among several filters. | ||
1272 | 49 | * @param {Number} min The minimum allowed value | ||
1273 | 50 | * @param {Number} max The maximum allowed value | ||
1274 | 51 | * @param {Number} default_value The default value of this filter, from the min..max range. | ||
1275 | 52 | * @param {ValueSliderLabels} value_labels The labels for min and max values as well as optional extra labels. | ||
1276 | 53 | --/doc:constructor | ||
1277 | 54 | |||
1278 | 55 | --doc:constructor | ||
1279 | 56 | * | ||
1280 | 57 | * @constructor | ||
1281 | 58 | * @param {String} id A unique identifier for the filter that can be used to later identify it among several filters. | ||
1282 | 59 | * @param {Number} min The minimum allowed value | ||
1283 | 60 | * @param {Number} max The maximum allowed value | ||
1284 | 61 | * @param {Number} default_value The default value of this filter, from the min..max range. | ||
1285 | 62 | * @param {ValueSliderLabels} value_labels The labels for min and max values as well as optional extra labels. | ||
1286 | 63 | * @param {FilterGroup} group [optional] A filter group this filter should be added to. | ||
1287 | 64 | --/doc:constructor | ||
1288 | 65 | |||
1289 | 66 | --doc:prototype ValueSliderFilter | ||
1290 | 67 | |||
1291 | 68 | --doc:member | ||
1292 | 69 | * Sets display hints for the Shell UI | ||
1293 | 70 | * @method set_display_hints | ||
1294 | 71 | * @param hints {DisplayHints} A combination of DisplayHints for this filter. | ||
1295 | 72 | --doc:/member | ||
1296 | 73 | set_display_hints: function(hints) { | ||
1297 | 74 | } | ||
1298 | 75 | --/doc:member | ||
1299 | 76 | |||
1300 | 77 | --doc:member | ||
1301 | 78 | * Get display hints of this filter | ||
1302 | 79 | * @method display_hints | ||
1303 | 80 | * @return {DisplayHints} Display hints flags | ||
1304 | 81 | --doc:/member | ||
1305 | 82 | display_hints: function() { | ||
1306 | 83 | } | ||
1307 | 84 | --/doc:member | ||
1308 | 85 | |||
1309 | 86 | --doc:member | ||
1310 | 87 | * Set an optional title of this filter | ||
1311 | 88 | * @method set_title | ||
1312 | 89 | * @param title {String} The title. | ||
1313 | 90 | --doc:/member | ||
1314 | 91 | set_title: function(title) { | ||
1315 | 92 | } | ||
1316 | 93 | --/doc:member | ||
1317 | 94 | |||
1318 | 95 | --doc:member | ||
1319 | 96 | * Get the optional title of this filter | ||
1320 | 97 | * @method title | ||
1321 | 98 | * @return {String} The title (possibly empty) | ||
1322 | 99 | --doc:/member | ||
1323 | 100 | title: function() { | ||
1324 | 101 | } | ||
1325 | 102 | --/doc:member | ||
1326 | 103 | |||
1327 | 104 | --doc:member | ||
1328 | 105 | * Get the identifier of this filter | ||
1329 | 106 | * @method id | ||
1330 | 107 | * @return {String} identifier of this filter | ||
1331 | 108 | --doc:/member | ||
1332 | 109 | id: function() { | ||
1333 | 110 | } | ||
1334 | 111 | --/doc:member | ||
1335 | 112 | |||
1336 | 113 | --doc:member | ||
1337 | 114 | * Get the type name of this filter | ||
1338 | 115 | * @method filter_type | ||
1339 | 116 | * @return {String} type name of this filter | ||
1340 | 117 | --doc:/member | ||
1341 | 118 | filter_type: function() { | ||
1342 | 119 | } | ||
1343 | 120 | --/doc:member | ||
1344 | 121 | |||
1345 | 122 | --doc:member | ||
1346 | 123 | * Get the filter group this filter belongs to | ||
1347 | 124 | * @method filter_group | ||
1348 | 125 | * @return {FilterGroup} The filter group (or null) | ||
1349 | 126 | --doc:/member | ||
1350 | 127 | filter_group: function() { | ||
1351 | 128 | } | ||
1352 | 129 | --/doc:member | ||
1353 | 130 | |||
1354 | 131 | --doc:member | ||
1355 | 132 | * Get the label of this filter | ||
1356 | 133 | * @method label | ||
1357 | 134 | * @return {String} label of this filter | ||
1358 | 135 | --doc:/member | ||
1359 | 136 | label: function() { | ||
1360 | 137 | } | ||
1361 | 138 | --/doc:member | ||
1362 | 139 | |||
1363 | 140 | --doc:member | ||
1364 | 141 | * Check if this filter supports multiple options to be selected | ||
1365 | 142 | * @method multi_select | ||
1366 | 143 | * @return {Boolean} True if this filter multiple options to be selected | ||
1367 | 144 | --doc:/member | ||
1368 | 145 | multi_select: function() { | ||
1369 | 146 | } | ||
1370 | 147 | --/doc:member | ||
1371 | 148 | |||
1372 | 149 | --doc:member | ||
1373 | 150 | * Add a new option to this filter | ||
1374 | 151 | * @method add_option | ||
1375 | 152 | * @return FilterOption The added filter option | ||
1376 | 153 | --doc:/member | ||
1377 | 154 | add_option: function() { | ||
1378 | 155 | } | ||
1379 | 156 | --/doc:member | ||
1380 | 157 | |||
1381 | 158 | --doc:member | ||
1382 | 159 | * Get all options of this filter, in the order they were added | ||
1383 | 160 | * @method options | ||
1384 | 161 | * @return {Array of FilterOption} | ||
1385 | 162 | --doc:/member | ||
1386 | 163 | options: function() { | ||
1387 | 164 | } | ||
1388 | 165 | --/doc:member | ||
1389 | 166 | |||
1390 | 167 | --doc:member | ||
1391 | 168 | * Check if an option is active for this filter | ||
1392 | 169 | * @method has_active_option | ||
1393 | 170 | * @param filter_state FilterState | ||
1394 | 171 | * @return {Boolean} True if an option is active for this filter | ||
1395 | 172 | --doc:/member | ||
1396 | 173 | has_active_option: function(filter_state) { | ||
1397 | 174 | } | ||
1398 | 175 | --/doc:member | ||
1399 | 176 | |||
1400 | 177 | --doc:member | ||
1401 | 178 | * Get active options from an instance of FilterState for this filter | ||
1402 | 179 | * @method active_options | ||
1403 | 180 | * @param filter_state FilterState | ||
1404 | 181 | * @return {Array of FilterOption} LIst of active FilterOption | ||
1405 | 182 | --doc:/member | ||
1406 | 183 | active_options: function() { | ||
1407 | 184 | } | ||
1408 | 185 | --/doc:member | ||
1409 | 186 | |||
1410 | 187 | --doc:member | ||
1411 | 188 | * Marks given FilterOption of this filter instance as active (or not active) in a FilterState object. | ||
1412 | 189 | * Records the given FilterOption as "selected" in the FilterState. This is meant to be used to modify a FilterState received with a search request before sending it back to the client (UI shell). | ||
1413 | 190 | * @method update_state | ||
1414 | 191 | * @param filter_state {FilterState} | ||
1415 | 192 | * @param option {FilterOption} | ||
1416 | 193 | * @param active {Boolean} | ||
1417 | 194 | --doc:/member | ||
1418 | 195 | update_state: function(filter_state, option, active) { | ||
1419 | 196 | } | ||
1420 | 197 | --/doc:member | ||
1421 | 198 | |||
1422 | 199 | --/doc:prototype | ||
1423 | 200 | |||
1424 | 201 | */ | ||
1425 | 202 | |||
1426 | 203 | |||
1427 | 204 | class ValueSliderFilter | ||
1428 | 205 | { | ||
1429 | 206 | public: | ||
1430 | 207 | ValueSliderFilter(v8::FunctionCallbackInfo<v8::Value> args); | ||
1431 | 208 | |||
1432 | 209 | void set_default_value(double val); | ||
1433 | 210 | double default_value() const; | ||
1434 | 211 | double min() const; | ||
1435 | 212 | double max() const; | ||
1436 | 213 | bool has_value(std::shared_ptr<unity::scopes::FilterState> filter_state) const; | ||
1437 | 214 | double value(std::shared_ptr<unity::scopes::FilterState> filter_state) const; | ||
1438 | 215 | std::shared_ptr<ValueSliderLabels> labels() const; | ||
1439 | 216 | |||
1440 | 217 | void update_state(std::shared_ptr<unity::scopes::FilterState> filter_state | ||
1441 | 218 | , double value) const; | ||
1442 | 219 | void set_display_hints(int hints); | ||
1443 | 220 | int display_hints() const; | ||
1444 | 221 | void set_title(const std::string& title); | ||
1445 | 222 | std::string title() const; | ||
1446 | 223 | std::string id() const; | ||
1447 | 224 | unity::scopes::VariantMap serialize() const; | ||
1448 | 225 | std::string filter_type() const; | ||
1449 | 226 | std::shared_ptr<FilterGroup> filter_group(); | ||
1450 | 227 | |||
1451 | 228 | private: | ||
1452 | 229 | unity::scopes::ValueSliderFilter::UPtr filter_; | ||
1453 | 230 | }; | ||
1454 | 231 | |||
1455 | 232 | #endif // _UNITY_JS_VALUE_SLIDER_FILTER_H_ | ||
1456 | 233 | |||
1457 | 234 | |||
1458 | 0 | 235 | ||
1459 | === added file 'src/bindings/src/value-slider-labels.cc' | |||
1460 | --- src/bindings/src/value-slider-labels.cc 1970-01-01 00:00:00 +0000 | |||
1461 | +++ src/bindings/src/value-slider-labels.cc 2016-08-17 20:30:06 +0000 | |||
1462 | @@ -0,0 +1,91 @@ | |||
1463 | 1 | /* | ||
1464 | 2 | * Copyright 2016 Canonical Ltd. | ||
1465 | 3 | * | ||
1466 | 4 | * This file is part of unity-js-scopes. | ||
1467 | 5 | * | ||
1468 | 6 | * unity-js-scopes is free software; you can redistribute it and/or modify | ||
1469 | 7 | * it under the terms of the GNU General Public License as published by | ||
1470 | 8 | * the Free Software Foundation; version 3. | ||
1471 | 9 | * | ||
1472 | 10 | * unity-js-scopes is distributed in the hope that it will be useful, | ||
1473 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1474 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1475 | 13 | * GNU General Public License for more details. | ||
1476 | 14 | * | ||
1477 | 15 | * You should have received a copy of the GNU General Public License | ||
1478 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1479 | 17 | */ | ||
1480 | 18 | |||
1481 | 19 | #include "value-slider-labels.h" | ||
1482 | 20 | |||
1483 | 21 | ValueSliderLabels::ValueSliderLabels(std::string const &min_label, | ||
1484 | 22 | std::string const &max_label, | ||
1485 | 23 | v8::Local<v8::Value> extra_labels) { | ||
1486 | 24 | if (extra_labels->IsNull() || extra_labels->IsUndefined()) { | ||
1487 | 25 | vsl_.reset(new unity::scopes::ValueSliderLabels(min_label, max_label)); | ||
1488 | 26 | } else if (extra_labels->IsArray()) { | ||
1489 | 27 | std::vector<std::vector<v8::Local<v8::Value>>> labels = | ||
1490 | 28 | v8cpp::from_v8<std::vector<std::vector<v8::Local<v8::Value>>>>( | ||
1491 | 29 | v8::Isolate::GetCurrent(), | ||
1492 | 30 | extra_labels); | ||
1493 | 31 | |||
1494 | 32 | unity::scopes::ValueLabelPairList vlp_list; | ||
1495 | 33 | |||
1496 | 34 | for (auto label : labels) { | ||
1497 | 35 | if (label.size() == 2 && | ||
1498 | 36 | label[0]->IsNumber() && | ||
1499 | 37 | label[1]->IsString()) { | ||
1500 | 38 | double v = v8cpp::from_v8<double>( | ||
1501 | 39 | v8::Isolate::GetCurrent(), | ||
1502 | 40 | label[0]); | ||
1503 | 41 | std::string l = v8cpp::from_v8<std::string>( | ||
1504 | 42 | v8::Isolate::GetCurrent(), | ||
1505 | 43 | label[1]); | ||
1506 | 44 | |||
1507 | 45 | vlp_list.push_back(unity::scopes::ValueLabelPair(v, l)); | ||
1508 | 46 | } | ||
1509 | 47 | } | ||
1510 | 48 | |||
1511 | 49 | vsl_.reset( | ||
1512 | 50 | new unity::scopes::ValueSliderLabels( | ||
1513 | 51 | min_label, max_label, vlp_list)); | ||
1514 | 52 | } else { | ||
1515 | 53 | throw std::runtime_error("Invalid ValueSliderLabels creation parameters"); | ||
1516 | 54 | } | ||
1517 | 55 | } | ||
1518 | 56 | |||
1519 | 57 | ValueSliderLabels::ValueSliderLabels(const unity::scopes::ValueSliderLabels& labels) { | ||
1520 | 58 | vsl_.reset(new unity::scopes::ValueSliderLabels(labels)); | ||
1521 | 59 | } | ||
1522 | 60 | |||
1523 | 61 | std::string ValueSliderLabels::min_label() const { | ||
1524 | 62 | return vsl_->min_label(); | ||
1525 | 63 | } | ||
1526 | 64 | |||
1527 | 65 | std::string ValueSliderLabels::max_label() const { | ||
1528 | 66 | return vsl_->max_label(); | ||
1529 | 67 | } | ||
1530 | 68 | |||
1531 | 69 | v8::Local<v8::Value> ValueSliderLabels::extra_labels() const { | ||
1532 | 70 | unity::scopes::ValueLabelPairList labels = | ||
1533 | 71 | vsl_->extra_labels(); | ||
1534 | 72 | |||
1535 | 73 | v8::Handle<v8::Array> a = | ||
1536 | 74 | v8::Array::New(v8::Isolate::GetCurrent(), labels.size()); | ||
1537 | 75 | |||
1538 | 76 | for (size_t i = 0; i < labels.size(); ++i) { | ||
1539 | 77 | v8::Handle<v8::Array> label_pair = | ||
1540 | 78 | v8::Array::New(v8::Isolate::GetCurrent(), 2); | ||
1541 | 79 | |||
1542 | 80 | label_pair->Set(0, v8::Number::New(v8::Isolate::GetCurrent(), labels[i].first)); | ||
1543 | 81 | label_pair->Set(1, v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), labels[i].second.c_str())); | ||
1544 | 82 | |||
1545 | 83 | a->Set(i, label_pair); | ||
1546 | 84 | } | ||
1547 | 85 | return a; | ||
1548 | 86 | } | ||
1549 | 87 | |||
1550 | 88 | unity::scopes::ValueSliderLabels ValueSliderLabels::get_labels() { | ||
1551 | 89 | return *vsl_; | ||
1552 | 90 | } | ||
1553 | 91 | |||
1554 | 0 | 92 | ||
1555 | === added file 'src/bindings/src/value-slider-labels.h' | |||
1556 | --- src/bindings/src/value-slider-labels.h 1970-01-01 00:00:00 +0000 | |||
1557 | +++ src/bindings/src/value-slider-labels.h 2016-08-17 20:30:06 +0000 | |||
1558 | @@ -0,0 +1,109 @@ | |||
1559 | 1 | /* | ||
1560 | 2 | * Copyright 2016 Canonical Ltd. | ||
1561 | 3 | * | ||
1562 | 4 | * This file is part of unity-js-scopes. | ||
1563 | 5 | * | ||
1564 | 6 | * unity-js-scopes is free software; you can redistribute it and/or modify | ||
1565 | 7 | * it under the terms of the GNU General Public License as published by | ||
1566 | 8 | * the Free Software Foundation; version 3. | ||
1567 | 9 | * | ||
1568 | 10 | * unity-js-scopes is distributed in the hope that it will be useful, | ||
1569 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1570 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1571 | 13 | * GNU General Public License for more details. | ||
1572 | 14 | * | ||
1573 | 15 | * You should have received a copy of the GNU General Public License | ||
1574 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1575 | 17 | */ | ||
1576 | 18 | |||
1577 | 19 | #ifndef _UNITY_JS_VALUE_SLIDER_LABELS_H_ | ||
1578 | 20 | #define _UNITY_JS_VALUE_SLIDER_LABELS_H_ | ||
1579 | 21 | |||
1580 | 22 | #include <unity/scopes/ValueSliderLabels.h> | ||
1581 | 23 | |||
1582 | 24 | #include <v8-cpp.h> | ||
1583 | 25 | |||
1584 | 26 | /** | ||
1585 | 27 | |||
1586 | 28 | --doc:class ValueSliderLabels | ||
1587 | 29 | * | ||
1588 | 30 | * Labels used by a ValueSliderFilter | ||
1589 | 31 | * | ||
1590 | 32 | * The ValueSliderLabels class holds labels for a ValueSliderFilter. | ||
1591 | 33 | * Labels for the minimum and maximum values must be provided. | ||
1592 | 34 | * In addition, an arbitrary number of extra labels can be defined; these labels | ||
1593 | 35 | * mark intermediate values between the minimum and maximum value. | ||
1594 | 36 | * | ||
1595 | 37 | * @module ScopeJS | ||
1596 | 38 | * @class ValueSliderLabels | ||
1597 | 39 | --/doc:class | ||
1598 | 40 | |||
1599 | 41 | --doc:constructor | ||
1600 | 42 | * Create a ValueSliderLabels instance with labels for minimum and maximum, as well as extra labels. | ||
1601 | 43 | * | ||
1602 | 44 | * Note that any extra labels act only as a guidance for the user | ||
1603 | 45 | * (i.e. they do not limit the available choices). | ||
1604 | 46 | * The Unity shell is free to omit some or all of the labels depending | ||
1605 | 47 | * on the available screen space. | ||
1606 | 48 | * | ||
1607 | 49 | * @constructor | ||
1608 | 50 | * @param min_label {String} The label for minimum value of the associated ValueSliderFilter filter. | ||
1609 | 51 | * @param max_label {String} The label for maximum value of the associated ValueSliderFilter filter. | ||
1610 | 52 | * @param extra_labels {Array of {"value": Number, "label": String} objects} [optional] Additional labels for values between minimum and maximum values. | ||
1611 | 53 | * | ||
1612 | 54 | --/doc:constructor | ||
1613 | 55 | |||
1614 | 56 | --doc:prototype ValueSliderLabels | ||
1615 | 57 | |||
1616 | 58 | --doc:member | ||
1617 | 59 | * Get the label for the minimum value of the filter. | ||
1618 | 60 | * @method min_label | ||
1619 | 61 | * @return {String} The label for the minimum value | ||
1620 | 62 | --doc:/member | ||
1621 | 63 | min_label: function() { | ||
1622 | 64 | } | ||
1623 | 65 | --/doc:member | ||
1624 | 66 | |||
1625 | 67 | --doc:member | ||
1626 | 68 | * Get the label for the maximum value of the filter. | ||
1627 | 69 | * @method max_label | ||
1628 | 70 | * @return {String} The label for the maximum value | ||
1629 | 71 | --doc:/member | ||
1630 | 72 | max_label: function() { | ||
1631 | 73 | } | ||
1632 | 74 | --/doc:member | ||
1633 | 75 | |||
1634 | 76 | --doc:member | ||
1635 | 77 | * Get the labels for intermediate values of the filter | ||
1636 | 78 | * @method extra_labels | ||
1637 | 79 | * @return {Array of {Number, String} object} | ||
1638 | 80 | --doc:/member | ||
1639 | 81 | extra_labels: function() { | ||
1640 | 82 | } | ||
1641 | 83 | --/doc:member | ||
1642 | 84 | |||
1643 | 85 | --/doc:prototype | ||
1644 | 86 | |||
1645 | 87 | */ | ||
1646 | 88 | |||
1647 | 89 | class ValueSliderLabels | ||
1648 | 90 | { | ||
1649 | 91 | public: | ||
1650 | 92 | ValueSliderLabels(const unity::scopes::ValueSliderLabels& labels); | ||
1651 | 93 | ValueSliderLabels(std::string const &min_label, | ||
1652 | 94 | std::string const &max_label, | ||
1653 | 95 | v8::Local<v8::Value> extra_labels); | ||
1654 | 96 | |||
1655 | 97 | std::string min_label() const; | ||
1656 | 98 | std::string max_label() const; | ||
1657 | 99 | v8::Local<v8::Value> extra_labels() const; | ||
1658 | 100 | |||
1659 | 101 | unity::scopes::ValueSliderLabels get_labels(); | ||
1660 | 102 | |||
1661 | 103 | private: | ||
1662 | 104 | std::unique_ptr<unity::scopes::ValueSliderLabels> vsl_; | ||
1663 | 105 | }; | ||
1664 | 106 | |||
1665 | 107 | #endif // _UNITY_JS_VALUE_SLIDER_LABELS_H_ | ||
1666 | 108 | |||
1667 | 109 |
FAILED: Continuous integration, rev:143 /jenkins. canonical. com/unity- api-1/job/ lp-unity- js-scopes- ci/9/ /jenkins. canonical. com/unity- api-1/job/ build/74/ console /jenkins. canonical. com/unity- api-1/job/ build-0- fetch/81/ console
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild: /jenkins. canonical. com/unity- api-1/job/ lp-unity- js-scopes- ci/9/rebuild
https:/