Merge lp:~abreu-alexandre/unity-js-scopes/expand-filter-support into lp:unity-js-scopes

Proposed by Alexandre Abreu
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
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

To post a comment you must log in.
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :
review: Needs Fixing (continuous-integration)
144. By Alexandre Abreu

Ooops forgot part of the commits, object constructors

Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
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::FunctionCallbackInfo<v8::Value> const& args" thing for each of these in 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/marcustomlinson/Projects/work/unity-js-scopes/filters_example/examples/filters-build/src/filters.marcustomlinson_filters.js:471
                  var price_filter = new scopes.lib.RangeInputFilter("price", "Min", "", "to", "Max", "", group);
                                     ^

Error: argument count does not match the corresponding C++ function definition
    at Error (native)
    at null.<anonymous> (/home/marcustomlinson/Projects/work/unity-js-scopes/filters_example/examples/filters-build/src/filters.marcustomlinson_filters.js:471:38)

review: Needs Fixing
Revision history for this message
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::FunctionCallbackInfo<v8::Value> const& args" thing for each of these in
> 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/marcustomlinson/Projects/work/unity-js-scopes/filters_example/examples
> /filters-build/src/filters.marcustomlinson_filters.js:471
> var price_filter = new scopes.lib.RangeInputFilter("price",
> "Min", "", "to", "Max", "", group);
> ^
>
> Error: argument count does not match the corresponding C++ function definition
> at Error (native)
> at null.<anonymous> (/home/marcustomlinson/Projects/work/unity-js-
> scopes/filters_example/examples/filters-
> build/src/filters.marcustomlinson_filters.js:471:38)

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

Revision history for this message
Alexandre Abreu (abreu-alexandre) wrote :

updated

Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :
Download full text (4.5 KiB)

This is what I get now, running the filters example scope:

#
# Fatal error in ../deps/v8/src/api.h, line 412
# Check failed: that == __null || (*reinterpret_cast<v8::internal::Object* const*>(that))->IsJSObject().
#

==== C stack trace ===============================

 1: V8_Fatal
 2: v8::Utils::OpenHandle(v8::Object const*, bool)
 3: v8::Object::Has(v8::Local<v8::Value>)
 4: ValueSliderLabels::ValueSliderLabels(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, v8::Local<v8::Value>)
 5: ValueSliderLabels* v8cpp::internal::ObjectFactory<ValueSliderLabels>::new_object<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, v8::Local<v8::Value> >(v8::Isolate*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, v8::Local<v8::Value>)
 6: v8cpp::internal::FunctionTraits<ValueSliderLabels* (*)(v8::Isolate*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, v8::Local<v8::Value>)>::ReturnType v8cpp::internal::call_from_v8_impl<ValueSliderLabels* (*)(v8::Isolate*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, v8::Local<v8::Value>), 0ul, 1ul, 2ul>(ValueSliderLabels* (*&&)(v8::Isolate*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, v8::Local<v8::Value>), v8::FunctionCallbackInfo<v8::Value> const&, v8cpp::internal::CallFromV8Traits<ValueSliderLabels* (*)(v8::Isolate*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, v8::Local<v8::Value>), 1ul>, v8cpp::internal::IntSequence<unsigned long, 0ul, 1ul, 2ul>)
 7: v8cpp::internal::FunctionTraits<ValueSliderLabels* (*)(v8::Isolate*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, v8::Local<v8::Value>)>::ReturnType v8cpp::internal::call_from_v8<ValueSliderLabels* (*)(v8::Isolate*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, v8::Local<v8::Value>)>(ValueSliderLabels* (*&&)(v8::Isolate*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, v8::Local<v8::Value>), v8::FunctionCallbackInfo<v8::Value> const&)
 8: void v8cpp::internal::Class<ValueSliderLabels>::set_constructor<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_tra...

Read more...

review: Needs Fixing
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

FAILED: Continuous integration, rev:145
https://jenkins.canonical.com/unity-api-1/job/lp-unity-js-scopes-ci/12/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build/105/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/112
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=vivid+overlay/69
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=xenial/69
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=yakkety/69
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/45/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial/45
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial/45/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/45
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/45/artifact/output/*zip*/output.zip
    ABORTED: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/45/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial/45
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial/45/artifact/output/*zip*/output.zip
    ABORTED: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/45/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/45/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial/45
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial/45/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/45
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/45/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-unity-js-scopes-ci/12/rebuild

review: Needs Fixing (continuous-integration)
146. By Alexandre Abreu

Update ValueSliderLabels' constructor to fit the Scopes API

Revision history for this message
Alexandre Abreu (abreu-alexandre) wrote :

I updated the code to fit the js example

Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

PASSED: Continuous integration, rev:146
https://jenkins.canonical.com/unity-api-1/job/lp-unity-js-scopes-ci/14/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build/396
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/402
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=vivid+overlay/317
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=xenial+overlay/317
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=yakkety/317
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/247
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/247/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/247
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/247/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/247
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/247/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/247
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/247/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/247
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/247/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/247
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/247/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/247
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/247/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/247
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/247/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/247
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/247/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-unity-js-scopes-ci/14/rebuild

review: Approve (continuous-integration)
Revision history for this message
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?

review: Needs Fixing

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

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/bindings/index.js'
--- src/bindings/index.js 2016-02-17 14:41:42 +0000
+++ src/bindings/index.js 2016-08-17 20:30:06 +0000
@@ -226,6 +226,35 @@
226 UpdatePreview: 6226 UpdatePreview: 6
227};227};
228228
229/**
230 * Display hints for the Shell UI.
231 *
232 * @example
233 var scopes = require('unity-js-scopes')
234 var f = new scope.lib.OptionSelectorFilter("1", "label", false)
235 f.set_display_hint(scopes.defs.DisplayHint.Primary)
236
237 * @module ScopeJS
238 *
239 *
240 * @class DisplayHint
241 */
242DisplayHint = {
243 /**
244 * Default value (no hint)
245 * @property Default
246 * @static
247 */
248 Default: 0,
249 /**
250 * Display this filter as a primary navigation, if possible.
251 * Currently only the OptionSelectorFilter can act as primary navigation.
252 * @property Primary
253 * @static
254 */
255 Primary: 1
256};
257
229module.exports = {258module.exports = {
230 lib: lib,259 lib: lib,
231 defs: {260 defs: {
@@ -233,6 +262,7 @@
233 VariantType: VariantType,262 VariantType: VariantType,
234 ConnectivityStatus: ConnectivityStatus,263 ConnectivityStatus: ConnectivityStatus,
235 OperationInfo: OperationInfo,264 OperationInfo: OperationInfo,
265 DisplayHint: DisplayHint,
236 ActivationResponseStatus: ActivationResponseStatus266 ActivationResponseStatus: ActivationResponseStatus
237 }267 }
238}268}
239269
=== modified file 'src/bindings/src/addon.cc'
--- src/bindings/src/addon.cc 2016-02-25 13:48:52 +0000
+++ src/bindings/src/addon.cc 2016-08-17 20:30:06 +0000
@@ -37,6 +37,7 @@
37#include "canned-query.h"37#include "canned-query.h"
38#include "categorised-result.h"38#include "categorised-result.h"
39#include "department.h"39#include "department.h"
40#include "filter-group.h"
40#include "online-account-client.h"41#include "online-account-client.h"
41#include "option-selector-filter.h"42#include "option-selector-filter.h"
42#include "preview-query.h"43#include "preview-query.h"
@@ -50,6 +51,9 @@
50#include "registry.h"51#include "registry.h"
51#include "result.h"52#include "result.h"
52#include "variant.h"53#include "variant.h"
54#include "value-slider-labels.h"
55#include "value-slider-filter.h"
56#include "range-input-filter.h"
5357
54// TODO static58// TODO static
55JavascriptScopeRuntime* new_scope(const std::string& runtime_config) {59JavascriptScopeRuntime* new_scope(const std::string& runtime_config) {
@@ -275,6 +279,12 @@
275 .add_method("region_name", &unity::scopes::Location::region_name)279 .add_method("region_name", &unity::scopes::Location::region_name)
276 .add_method("has_vertical_accuracy", &unity::scopes::Location::has_vertical_accuracy);280 .add_method("has_vertical_accuracy", &unity::scopes::Location::has_vertical_accuracy);
277281
282 v8cpp::Class<FilterGroup> filter_group(isolate);
283 filter_group
284 .set_constructor<std::string const&, std::string const&>()
285 .add_method("id", &FilterGroup::id)
286 .add_method("label", &FilterGroup::label);
287
278 v8cpp::Class<unity::scopes::FilterState> filter_state(isolate);288 v8cpp::Class<unity::scopes::FilterState> filter_state(isolate);
279 filter_state289 filter_state
280 .set_constructor<>()290 .set_constructor<>()
@@ -299,8 +309,11 @@
299 // FilterBase309 // FilterBase
300 .add_method("set_display_hints", &OptionSelectorFilter::set_display_hints)310 .add_method("set_display_hints", &OptionSelectorFilter::set_display_hints)
301 .add_method("display_hints", &OptionSelectorFilter::display_hints)311 .add_method("display_hints", &OptionSelectorFilter::display_hints)
312 .add_method("set_title", &OptionSelectorFilter::set_title)
313 .add_method("title", &OptionSelectorFilter::title)
302 .add_method("id", &OptionSelectorFilter::id)314 .add_method("id", &OptionSelectorFilter::id)
303 .add_method("filter_type", &OptionSelectorFilter::filter_type);315 .add_method("filter_type", &OptionSelectorFilter::filter_type)
316 .add_method("filter_group", &OptionSelectorFilter::filter_group);
304317
305 v8cpp::Class<unity::scopes::OperationInfo> operation_info(isolate);318 v8cpp::Class<unity::scopes::OperationInfo> operation_info(isolate);
306 operation_info319 operation_info
@@ -380,6 +393,29 @@
380 .add_method("onrun", &SearchQuery::onrun)393 .add_method("onrun", &SearchQuery::onrun)
381 .add_method("oncancelled", &SearchQuery::oncancelled);394 .add_method("oncancelled", &SearchQuery::oncancelled);
382395
396 v8cpp::Class<RangeInputFilter> range_input_filter(isolate);
397 range_input_filter
398 .set_constructor<v8::FunctionCallbackInfo<v8::Value>>()
399 .add_method("start_prefix_label", &RangeInputFilter::start_prefix_label)
400 .add_method("start_postfix_label", &RangeInputFilter::start_postfix_label)
401 .add_method("end_prefix_label", &RangeInputFilter::end_prefix_label)
402 .add_method("end_postfix_label", &RangeInputFilter::end_postfix_label)
403 .add_method("central_label", &RangeInputFilter::central_label)
404 .add_method("default_start_value", &RangeInputFilter::default_start_value)
405 .add_method("default_end_value", &RangeInputFilter::default_end_value)
406 .add_method("has_start_value", &RangeInputFilter::has_start_value)
407 .add_method("has_end_value", &RangeInputFilter::has_end_value)
408 .add_method("start_value", &RangeInputFilter::start_value)
409 .add_method("end_value", &RangeInputFilter::end_value)
410 .add_method("update_state", &RangeInputFilter::update_state)
411 .add_method("set_display_hints", &RangeInputFilter::set_display_hints)
412 .add_method("display_hints", &RangeInputFilter::display_hints)
413 .add_method("set_title", &RangeInputFilter::set_title)
414 .add_method("title", &RangeInputFilter::title)
415 .add_method("id", &RangeInputFilter::id)
416 .add_method("filter_type", &RangeInputFilter::filter_type)
417 .add_method("filter_group", &RangeInputFilter::filter_group);
418
383 v8cpp::Class<Registry> registry(isolate);419 v8cpp::Class<Registry> registry(isolate);
384 registry420 registry
385 // Registry421 // Registry
@@ -390,7 +426,6 @@
390 .add_method("set_scope_state_callback", &Registry::set_scope_state_callback)426 .add_method("set_scope_state_callback", &Registry::set_scope_state_callback)
391 .add_method("set_list_update_callback", &Registry::set_list_update_callback);427 .add_method("set_list_update_callback", &Registry::set_list_update_callback);
392428
393
394 v8cpp::Class<unity::scopes::ScopeMetadata> scope_metadata(isolate);429 v8cpp::Class<unity::scopes::ScopeMetadata> scope_metadata(isolate);
395 scope_metadata430 scope_metadata
396 // unity::scopes::ScopeMetadata431 // unity::scopes::ScopeMetadata
@@ -456,6 +491,34 @@
456 .add_member("token_secret", &unity::scopes::OnlineAccountClient::ServiceStatus::token_secret)491 .add_member("token_secret", &unity::scopes::OnlineAccountClient::ServiceStatus::token_secret)
457 .add_member("error", &unity::scopes::OnlineAccountClient::ServiceStatus::error);492 .add_member("error", &unity::scopes::OnlineAccountClient::ServiceStatus::error);
458493
494 v8cpp::Class<ValueSliderFilter> value_slider_filter(isolate);
495 value_slider_filter
496 .set_constructor<v8::FunctionCallbackInfo<v8::Value>>()
497 .add_method("set_default_value", &ValueSliderFilter::set_default_value)
498 .add_method("min", &ValueSliderFilter::min)
499 .add_method("max", &ValueSliderFilter::max)
500 .add_method("has_value", &ValueSliderFilter::has_value)
501 .add_method("value", &ValueSliderFilter::value)
502 .add_method("labels", &ValueSliderFilter::labels)
503 .add_method("update_state", &ValueSliderFilter::update_state)
504 .add_method("set_display_hints", &ValueSliderFilter::set_display_hints)
505 .add_method("display_hints", &ValueSliderFilter::display_hints)
506 .add_method("set_title", &ValueSliderFilter::set_title)
507 .add_method("title", &ValueSliderFilter::title)
508 .add_method("id", &ValueSliderFilter::id)
509 .add_method("filter_group", &ValueSliderFilter::filter_group)
510 .add_method("filter_type", &ValueSliderFilter::filter_type)
511 .add_method("default_value", &ValueSliderFilter::default_value);
512
513 v8cpp::Class<ValueSliderLabels> value_slider_labels(isolate);
514 value_slider_labels
515 .set_constructor<std::string,
516 std::string,
517 v8::Local<v8::Value>>()
518 .add_method("min_label", &ValueSliderLabels::min_label)
519 .add_method("max_label", &ValueSliderLabels::max_label)
520 .add_method("extra_labels", &ValueSliderLabels::extra_labels);
521
459 v8cpp::Module module(isolate);522 v8cpp::Module module(isolate);
460 module.add_class("js_scope", js_scope);523 module.add_class("js_scope", js_scope);
461 module.add_class("scope_base", scope_base);524 module.add_class("scope_base", scope_base);
@@ -468,6 +531,7 @@
468 module.add_class("CategoryRenderer", category_renderer);531 module.add_class("CategoryRenderer", category_renderer);
469 module.add_class("ColumnLayout", column_layout);532 module.add_class("ColumnLayout", column_layout);
470 module.add_class("Department", department);533 module.add_class("Department", department);
534 module.add_class("FilterGroup", filter_group);
471 module.add_class("FilterOption", filter_option);535 module.add_class("FilterOption", filter_option);
472 module.add_class("FilterState", filter_state);536 module.add_class("FilterState", filter_state);
473 module.add_class("Location", location);537 module.add_class("Location", location);
@@ -478,6 +542,7 @@
478 module.add_class("PreviewWidget", preview_widget);542 module.add_class("PreviewWidget", preview_widget);
479 module.add_class("PreviewQuery", preview_query);543 module.add_class("PreviewQuery", preview_query);
480 module.add_class("PreviewReply", preview_reply);544 module.add_class("PreviewReply", preview_reply);
545 module.add_class("RangeInputFilter", range_input_filter);
481 module.add_class("Registry", registry);546 module.add_class("Registry", registry);
482 module.add_class("Result", result);547 module.add_class("Result", result);
483 module.add_class("ScopeMetadata", scope_metadata);548 module.add_class("ScopeMetadata", scope_metadata);
@@ -486,6 +551,8 @@
486 module.add_class("SearchMetadata", search_metadata);551 module.add_class("SearchMetadata", search_metadata);
487 module.add_class("Variant", variant);552 module.add_class("Variant", variant);
488 module.add_class("VariantBase", variant_base);553 module.add_class("VariantBase", variant_base);
554 module.add_class("ValueSliderFilter", value_slider_filter);
555 module.add_class("ValueSliderLabels", value_slider_labels);
489556
490 // Factory functions557 // Factory functions
491 module.add_function("new_scope", &new_scope);558 module.add_function("new_scope", &new_scope);
492559
=== added file 'src/bindings/src/filter-group.cc'
--- src/bindings/src/filter-group.cc 1970-01-01 00:00:00 +0000
+++ src/bindings/src/filter-group.cc 2016-08-17 20:30:06 +0000
@@ -0,0 +1,39 @@
1/*
2 * Copyright 2016 Canonical Ltd.
3 *
4 * This file is part of unity-js-scopes.
5 *
6 * unity-js-scopes is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * unity-js-scopes is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include "filter-group.h"
20
21FilterGroup::FilterGroup(unity::scopes::FilterGroup::SCPtr p)
22 : _fg(p) {
23}
24
25FilterGroup::FilterGroup(std::string const& id, std::string const& label)
26 : _fg(unity::scopes::FilterGroup::create(id, label)) {
27}
28
29std::string FilterGroup::id() {
30 return _fg->id();
31}
32
33std::string FilterGroup::label() {
34 return _fg->label();
35}
36
37unity::scopes::FilterGroup::SCPtr FilterGroup::get_filter_group() {
38 return _fg;
39}
040
=== added file 'src/bindings/src/filter-group.h'
--- src/bindings/src/filter-group.h 1970-01-01 00:00:00 +0000
+++ src/bindings/src/filter-group.h 2016-08-17 20:30:06 +0000
@@ -0,0 +1,82 @@
1/*
2 * Copyright 2016 Canonical Ltd.
3 *
4 * This file is part of unity-js-scopes.
5 *
6 * unity-js-scopes is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * unity-js-scopes is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef _UNITY_JS_FILTER_GROUP_H_
20#define _UNITY_JS_FILTER_GROUP_H_
21
22#include <unity/scopes/FilterGroup.h>
23
24#include <v8-cpp.h>
25
26/**
27
28--doc:class FilterGroup
29 *
30 * Groups several filters into an expandable widget in the UI.
31 *
32 * @module ScopeJS
33 * @class FilterGroup
34--/doc:class
35
36--doc:constructor
37 *
38 * @constructor
39 * @param id The id of the filter group.
40 * @param label The label corresponding to the filter group.
41--/doc:constructor
42
43--doc:prototype FilterGroup
44
45--doc:member
46 * Get the id of the widget group.
47 * @method id
48 * @return {String} The identifier.
49--doc:/member
50id: function() {
51}
52--/doc:member
53
54--doc:member
55 * Get the label of the widget group.
56 * @method label
57 * @return {String} The label.
58--doc:/member
59label: function() {
60}
61--/doc:member
62
63--/doc:prototype
64
65 */
66
67class FilterGroup
68{
69 public:
70 FilterGroup(unity::scopes::FilterGroup::SCPtr p);
71 FilterGroup(std::string const& id, std::string const& label);
72
73 std::string id();
74 std::string label();
75
76 unity::scopes::FilterGroup::SCPtr get_filter_group();
77
78 private:
79 unity::scopes::FilterGroup::SCPtr _fg;
80};
81
82#endif // _UNITY_JS_FILTER_GROUP_H_
083
=== modified file 'src/bindings/src/option-selector-filter.cc'
--- src/bindings/src/option-selector-filter.cc 2015-10-21 19:44:36 +0000
+++ src/bindings/src/option-selector-filter.cc 2016-08-17 20:30:06 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright 2015 Canonical Ltd.2 * Copyright 2015-2016 Canonical Ltd.
3 *3 *
4 * This file is part of unity-js-scopes.4 * This file is part of unity-js-scopes.
5 *5 *
@@ -84,3 +84,19 @@
84unity::scopes::OptionSelectorFilter::SPtr OptionSelectorFilter::get_filter() {84unity::scopes::OptionSelectorFilter::SPtr OptionSelectorFilter::get_filter() {
85 return filter_;85 return filter_;
86}86}
87
88void OptionSelectorFilter::set_title(const std::string& title) {
89 filter_->set_title(title);
90}
91
92std::string OptionSelectorFilter::title() const {
93 return filter_->title();
94}
95
96std::shared_ptr<FilterGroup> OptionSelectorFilter::filter_group() {
97 unity::scopes::FilterGroup::SCPtr fg = filter_->filter_group();
98 if (!fg) {
99 return std::shared_ptr<FilterGroup>();
100 }
101 return std::shared_ptr<FilterGroup>(new FilterGroup(fg));
102}
87103
=== modified file 'src/bindings/src/option-selector-filter.h'
--- src/bindings/src/option-selector-filter.h 2015-10-26 22:13:03 +0000
+++ src/bindings/src/option-selector-filter.h 2016-08-17 20:30:06 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright 2015 Canonical Ltd.2 * Copyright 2015-2016 Canonical Ltd.
3 *3 *
4 * This file is part of unity-js-scopes.4 * This file is part of unity-js-scopes.
5 *5 *
@@ -23,6 +23,7 @@
2323
24#include <v8-cpp.h>24#include <v8-cpp.h>
2525
26#include "filter-group.h"
2627
27/**28/**
2829
@@ -45,6 +46,69 @@
45--doc:prototype OptionSelectorFilter46--doc:prototype OptionSelectorFilter
4647
47--doc:member48--doc:member
49 * Sets display hints for the Shell UI
50 * @method set_display_hints
51 * @param hints {DisplayHints} A combination of DisplayHints for this filter.
52--doc:/member
53set_display_hints: function(hints) {
54}
55--/doc:member
56
57--doc:member
58 * Get display hints of this filter
59 * @method display_hints
60 * @return {DisplayHints} Display hints flags
61--doc:/member
62display_hints: function() {
63}
64--/doc:member
65
66--doc:member
67 * Set an optional title of this filter
68 * @method set_title
69 * @param title {String} The title.
70--doc:/member
71set_title: function(title) {
72}
73--/doc:member
74
75--doc:member
76 * Get the optional title of this filter
77 * @method title
78 * @return {String} The title (possibly empty)
79--doc:/member
80title: function() {
81}
82--/doc:member
83
84--doc:member
85 * Get the identifier of this filter
86 * @method id
87 * @return {String} identifier of this filter
88--doc:/member
89id: function() {
90}
91--/doc:member
92
93--doc:member
94 * Get the type name of this filter
95 * @method filter_type
96 * @return {String} type name of this filter
97--doc:/member
98filter_type: function() {
99}
100--/doc:member
101
102--doc:member
103 * Get the filter group this filter belongs to
104 * @method filter_group
105 * @return {FilterGroup} The filter group (or null)
106--doc:/member
107filter_group: function() {
108}
109--/doc:member
110
111--doc:member
48 * Get the label of this filter112 * Get the label of this filter
49 * @method label113 * @method label
50 * @return {String} label of this filter114 * @return {String} label of this filter
@@ -112,33 +176,6 @@
112}176}
113--/doc:member177--/doc:member
114178
115--doc:member
116 * Sets display hints for the Shell UI
117 * @method set_display_hints
118 * @param hints {int} 0 is Default filter hint, 1 is Primary filter hint
119--doc:/member
120set_display_hints: function(hints) {
121}
122--/doc:member
123
124--doc:member
125 * Get the identifier of this filter
126 * @method id
127 * @return {String} identifier of this filter
128--doc:/member
129id: function() {
130}
131--/doc:member
132
133--doc:member
134 * Get the type name of this filter
135 * @method filter_type
136 * @return {String} type name of this filter
137--doc:/member
138filter_type: function() {
139}
140--/doc:member
141
142--/doc:prototype179--/doc:prototype
143180
144 */181 */
@@ -159,9 +196,12 @@
159196
160 void set_display_hints(int hints);197 void set_display_hints(int hints);
161 int display_hints() const;198 int display_hints() const;
199 void set_title(const std::string& title);
200 std::string title() const;
162 std::string id() const;201 std::string id() const;
163 unity::scopes::VariantMap serialize() const;202 unity::scopes::VariantMap serialize() const;
164 std::string filter_type() const;203 std::string filter_type() const;
204 std::shared_ptr<FilterGroup> filter_group();
165205
166 unity::scopes::OptionSelectorFilter::SPtr get_filter();206 unity::scopes::OptionSelectorFilter::SPtr get_filter();
167207
168208
=== added file 'src/bindings/src/range-input-filter.cc'
--- src/bindings/src/range-input-filter.cc 1970-01-01 00:00:00 +0000
+++ src/bindings/src/range-input-filter.cc 2016-08-17 20:30:06 +0000
@@ -0,0 +1,259 @@
1/*
2 * Copyright 2016 Canonical Ltd.
3 *
4 * This file is part of unity-js-scopes.
5 *
6 * unity-js-scopes is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * unity-js-scopes is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include "range-input-filter.h"
20
21#include "common.h"
22
23RangeInputFilter::RangeInputFilter(
24 v8::FunctionCallbackInfo<v8::Value> args) {
25 if (args.Length() < 6 || args.Length() > 9) {
26 throw std::runtime_error("Invalid number of arguments");
27 }
28
29 if (args.Length() == 6) {
30 auto id =
31 v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[0]);
32 auto start_prefix_label =
33 v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[1]);
34 auto start_postfix_label =
35 v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[2]);
36 auto central_label =
37 v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[3]);
38 auto end_prefix_label =
39 v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[4]);
40 auto end_postfix_label =
41 v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[5]);
42
43 filter_ =
44 unity::scopes::RangeInputFilter::create(
45 id,
46 start_prefix_label,
47 start_postfix_label,
48 central_label,
49 end_prefix_label,
50 end_postfix_label);
51 } else if (args.Length() == 8) {
52 auto id =
53 v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[0]);
54 unity::scopes::Variant default_start_value =
55 unity::scopesjs::to_variant(args[1]);
56 unity::scopes::Variant default_end_value =
57 unity::scopesjs::to_variant(args[2]);
58 auto start_prefix_label =
59 v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[3]);
60 auto start_postfix_label =
61 v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[4]);
62 auto central_label =
63 v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[5]);
64 auto end_prefix_label =
65 v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[6]);
66 auto end_postfix_label =
67 v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[7]);
68
69 filter_ =
70 unity::scopes::RangeInputFilter::create(
71 id,
72 default_start_value,
73 default_end_value,
74 start_prefix_label,
75 start_postfix_label,
76 central_label,
77 end_prefix_label,
78 end_postfix_label);
79 } else if (args.Length() == 7) {
80 auto id =
81 v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[0]);
82 auto start_prefix_label =
83 v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[1]);
84 auto start_postfix_label =
85 v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[2]);
86 auto central_label =
87 v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[3]);
88 auto end_prefix_label =
89 v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[4]);
90 auto end_postfix_label =
91 v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[5]);
92 auto fg =
93 v8cpp::from_v8<std::shared_ptr<FilterGroup>>(
94 v8::Isolate::GetCurrent(), args[6]);
95
96 unity::scopes::FilterGroup::SCPtr filter_group;
97 if (fg) {
98 filter_group = fg->get_filter_group();
99 }
100
101 filter_ =
102 unity::scopes::RangeInputFilter::create(
103 id,
104 start_prefix_label,
105 start_postfix_label,
106 central_label,
107 end_prefix_label,
108 end_postfix_label,
109 filter_group);
110 } else {
111 auto id =
112 v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[0]);
113 unity::scopes::Variant default_start_value =
114 unity::scopesjs::to_variant(args[1]);
115 unity::scopes::Variant default_end_value =
116 unity::scopesjs::to_variant(args[2]);
117 auto start_prefix_label =
118 v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[3]);
119 auto start_postfix_label =
120 v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[4]);
121 auto central_label =
122 v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[5]);
123 auto end_prefix_label =
124 v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[6]);
125 auto end_postfix_label =
126 v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[7]);
127 auto fg =
128 v8cpp::from_v8<std::shared_ptr<FilterGroup>>(
129 v8::Isolate::GetCurrent(), args[8]);
130
131 unity::scopes::FilterGroup::SCPtr filter_group;
132 if (fg) {
133 filter_group = fg->get_filter_group();
134 }
135
136 filter_ =
137 unity::scopes::RangeInputFilter::create(
138 id,
139 default_start_value,
140 default_end_value,
141 start_prefix_label,
142 start_postfix_label,
143 central_label,
144 end_prefix_label,
145 end_postfix_label,
146 filter_group);
147 }
148}
149
150std::string RangeInputFilter::start_prefix_label() const {
151 return filter_->start_prefix_label();
152}
153
154std::string RangeInputFilter::start_postfix_label() const {
155 return filter_->start_postfix_label();
156}
157
158std::string RangeInputFilter::end_prefix_label() const {
159 return filter_->end_prefix_label();
160}
161
162std::string RangeInputFilter::end_postfix_label() const {
163 return filter_->end_postfix_label();
164}
165
166std::string RangeInputFilter::central_label() const {
167 return filter_->central_label();
168}
169
170v8::Local<v8::Value> RangeInputFilter::default_start_value() const {
171 unity::scopes::Variant v =
172 filter_->default_start_value();
173 switch(v.which()) {
174 case unity::scopes::Variant::Null:
175 return v8::Null(v8::Isolate::GetCurrent());
176 case unity::scopes::Variant::Int:
177 return v8::Integer::New(v8::Isolate::GetCurrent(), v.get_int());
178 case unity::scopes::Variant::Double:
179 return v8::Number::New(v8::Isolate::GetCurrent(), v.get_double());
180 default:
181 throw std::runtime_error("Invalid default start value");
182 }
183}
184
185v8::Local<v8::Value> RangeInputFilter::default_end_value() const {
186 unity::scopes::Variant v =
187 filter_->default_end_value();
188 switch(v.which()) {
189 case unity::scopes::Variant::Null:
190 return v8::Null(v8::Isolate::GetCurrent());
191 case unity::scopes::Variant::Int:
192 return v8::Integer::New(v8::Isolate::GetCurrent(), v.get_int());
193 case unity::scopes::Variant::Double:
194 return v8::Number::New(v8::Isolate::GetCurrent(), v.get_double());
195 default:
196 throw std::runtime_error("Invalid default start value");
197 }
198}
199
200bool RangeInputFilter::has_start_value(std::shared_ptr<unity::scopes::FilterState> filter_state) const {
201 return true;
202}
203
204bool RangeInputFilter::has_end_value(std::shared_ptr<unity::scopes::FilterState> filter_state) const {
205 return true;
206}
207
208double RangeInputFilter::start_value(std::shared_ptr<unity::scopes::FilterState> filter_state) const {
209 return true;
210}
211
212double RangeInputFilter::end_value(std::shared_ptr<unity::scopes::FilterState> filter_state) const {
213 return true;
214}
215
216void RangeInputFilter::update_state(std::shared_ptr<unity::scopes::FilterState> filter_state,
217 v8::Local<v8::Value> start_value,
218 v8::Local<v8::Value> end_value) const {
219}
220
221void RangeInputFilter::set_display_hints(int hints) {
222 filter_->set_display_hints(hints);
223}
224
225int RangeInputFilter::display_hints() const {
226 return filter_->display_hints();
227}
228
229std::string RangeInputFilter::id() const {
230 return filter_->id();
231}
232
233unity::scopes::VariantMap RangeInputFilter::serialize() const {
234 return filter_->serialize();
235}
236
237std::string RangeInputFilter::filter_type() const {
238 return filter_->filter_type();
239}
240
241unity::scopes::RangeInputFilter::SPtr RangeInputFilter::get_filter() {
242 return filter_;
243}
244
245void RangeInputFilter::set_title(const std::string& title) {
246 filter_->set_title(title);
247}
248
249std::string RangeInputFilter::title() const {
250 return filter_->title();
251}
252
253std::shared_ptr<FilterGroup> RangeInputFilter::filter_group() {
254 unity::scopes::FilterGroup::SCPtr fg = filter_->filter_group();
255 if (!fg) {
256 return std::shared_ptr<FilterGroup>();
257 }
258 return std::shared_ptr<FilterGroup>(new FilterGroup(fg));
259}
0260
=== added file 'src/bindings/src/range-input-filter.h'
--- src/bindings/src/range-input-filter.h 1970-01-01 00:00:00 +0000
+++ src/bindings/src/range-input-filter.h 2016-08-17 20:30:06 +0000
@@ -0,0 +1,312 @@
1/*
2 * Copyright 2016 Canonical Ltd.
3 *
4 * This file is part of unity-js-scopes.
5 *
6 * unity-js-scopes is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * unity-js-scopes is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef _UNITY_JS_VALUE_SLIDE_FILTER_H_
20#define _UNITY_JS_VALUE_SLIDE_FILTER_H_
21
22#include <unity/scopes/RangeInputFilter.h>
23
24#include <v8-cpp.h>
25
26#include "filter-group.h"
27
28
29/**
30
31--doc:class RangeInputFilter
32 *
33 * A range filter allows a start and end value to be entered by the user.
34 *
35 * A RangeInputFilter is composed of two input boxes that accept numeric
36 * values (both of them optional).
37 * The filter can have prefix and/or postfix labels for the start and end
38 * value, respectively, plus a single label that is displayed between the two input boxes.
39 * The filter can provide defaults for that start and end value, which are
40 * used by the UI if the user does not enter explicit values.
41 *
42 * @module ScopeJS
43 * @class RangeInputFilter
44--/doc:class
45
46--doc:constructor
47 * Creates a RangeInputFilter
48 *
49 * @constructor
50 * @param {String} id A unique identifier for the filter that can be used to later identify it among several filters.
51 * @param {String} start_prefix_label A display label for the input box for the start value, displayed to the left (can be empty).
52 * @param {String} start_postfix_label A display label for the input box for the start value, displayed to the right (can be empty).
53 * @param {String} central_label A display label displayed between the two input boxes (can be empty).
54 * @param {String} end_prefix_label A display label for the input box for the end value, displayed to the left (can be empty).
55 * @param {String} end_postfix_label A display label for the input box for the end value, displayed to the right (can be empty).
56--/doc:constructor
57
58--doc:constructor
59 * Creates a RangeInputFilter with specific default values for start and end
60 *
61 * @constructor
62 * @param {String} id A unique identifier for the filter that can be used to later identify it among several filters.
63 * @param {Number} default_start_value The default start value or null.
64 * @param {Number} default_end_value The default end value or null.
65 * @param {String} start_prefix_label A display label for the input box for the start value, displayed to the left (can be empty).
66 * @param {String} start_postfix_label A display label for the input box for the start value, displayed to the right (can be empty).
67 * @param {String} central_label A display label displayed between the two input boxes (can be empty).
68 * @param {String} end_prefix_label A display label for the input box for the end value, displayed to the left (can be empty).
69 * @param {String} end_postfix_label A display label for the input box for the end value, displayed to the right (can be empty).
70--/doc:constructor
71
72--doc:constructor
73 * Creates a RangeInputFilter inside a FilterGroup
74 *
75 * @constructor
76 * @param {String} id A unique identifier for the filter that can be used to later identify it among several filters.
77 * @param {String} start_prefix_label A display label for the input box for the start value, displayed to the left (can be empty).
78 * @param {String} start_postfix_label A display label for the input box for the start value, displayed to the right (can be empty).
79 * @param {String} central_label A display label displayed between the two input boxes (can be empty).
80 * @param {String} end_prefix_label A display label for the input box for the end value, displayed to the left (can be empty).
81 * @param {String} end_postfix_label A display label for the input box for the end value, displayed to the right (can be empty).
82 * @param {FilterGroup} filter_group The filter group associated with this filter.
83--/doc:constructor
84
85--doc:constructor
86 * Creates a RangeInputFilter with specific default values for start and end,
87 * inside a FilterGroup
88 *
89 * @constructor
90 * @param {String} id A unique identifier for the filter that can be used to later identify it among several filters.
91 * @param {Number} default_start_value The default start value or null.
92 * @param {Number} default_end_value The default end value or null.
93 * @param {String} start_prefix_label A display label for the input box for the start value, displayed to the left (can be empty).
94 * @param {String} start_postfix_label A display label for the input box for the start value, displayed to the right (can be empty).
95 * @param {String} central_label A display label displayed between the two input boxes (can be empty).
96 * @param {String} end_prefix_label A display label for the input box for the end value, displayed to the left (can be empty).
97 * @param {String} end_postfix_label A display label for the input box for the end value, displayed to the right (can be empty).
98 * @param {FilterGroup} filter_group The filter group associated with this filter.
99--/doc:constructor
100
101--doc:prototype RangeInputFilter
102
103--doc:member
104 * Sets display hints for the Shell UI
105 * @method set_display_hints
106 * @param hints {DisplayHints} A combination of DisplayHints for this filter.
107--doc:/member
108set_display_hints: function(hints) {
109}
110--/doc:member
111
112--doc:member
113 * Get display hints of this filter
114 * @method display_hints
115 * @return {DisplayHints} Display hints flags
116--doc:/member
117display_hints: function() {
118}
119--/doc:member
120
121--doc:member
122 * Set an optional title of this filter
123 * @method set_title
124 * @param title {String} The title.
125--doc:/member
126set_title: function(title) {
127}
128--/doc:member
129
130--doc:member
131 * Get the optional title of this filter
132 * @method title
133 * @return {String} The title (possibly empty)
134--doc:/member
135title: function() {
136}
137--/doc:member
138
139--doc:member
140 * Get the identifier of this filter
141 * @method id
142 * @return {String} identifier of this filter
143--doc:/member
144id: function() {
145}
146--/doc:member
147
148--doc:member
149 * Get the type name of this filter
150 * @method filter_type
151 * @return {String} type name of this filter
152--doc:/member
153filter_type: function() {
154}
155--/doc:member
156
157--doc:member
158 * Get the filter group this filter belongs to
159 * @method filter_group
160 * @return {FilterGroup} The filter group (or null)
161--doc:/member
162filter_group: function() {
163}
164--/doc:member
165
166
167
168--doc:member
169 * Get the prefix label of start value
170 * @method start_prefix_label
171 * @return {String} The prefix label of start value
172--doc:/member
173start_prefix_label: function() {
174}
175--/doc:member
176
177--doc:member
178 * Get the postfix label of start value
179 * @method start_postfix_label
180 * @return {String} The postfix label of start value
181--doc:/member
182start_postfix_label: function() {
183}
184--/doc:member
185
186--doc:member
187 * Get the postfix label of end value
188 * @method end_postfix_label
189 * @return {String} The postfix label of end value
190--doc:/member
191end_postfix_label: function() {
192}
193--/doc:member
194
195--doc:member
196 * Get the prefix label of end value
197 * @method end_prefix_label
198 * @return {String} The prefix label of end value
199--doc:/member
200end_prefix_label: function() {
201}
202--/doc:member
203
204--doc:member
205 * Get the central label for this filter
206 * @method central_label
207 * @return {String} The central label of end value
208--doc:/member
209central_label: function() {
210}
211--/doc:member
212
213--doc:member
214 * Check if filter state holds an start value for this filter instance
215 * @method has_start_value
216 * @param {FilterState} filter_state The state of filters
217 * @return {Boolean} `true` if filter_state has an start value for this filter.
218--doc:/member
219has_start_value: function(filter_state) {
220}
221--/doc:member
222
223--doc:member
224 * Check if filter state holds an end value for this filter instance
225 * @method has_end_value
226 * @param {FilterState} filter_state The state of filters
227 * @return {Boolean} `true` if filter_state has an end value for this filter.
228--doc:/member
229has_end_value: function(filter_state) {
230}
231--/doc:member
232
233--doc:member
234 * Get the start value for this filter instance
235 * @method start_value
236 * @param {FilterState} filter_state The state of filters
237 * @return The start value or the default start value if not null
238--doc:/member
239start_value: function(filter_state) {
240}
241--/doc:member
242
243--doc:member
244 * Get the end value for this filter instance
245 * @method end_value
246 * @param {FilterState} filter_state The state of filters
247 * @return The start value or the default end value if not null
248--doc:/member
249end_value: function(filter_state) {
250}
251--/doc:member
252
253--doc:member
254 * Store start and end value for this filter in the filter state
255 * Updates filter_state with start and end values for this filter instance.
256 * Allowed data types for start_value and end_value are null or a number.
257 * Pass null as start_value or end_value if that value is unspecified
258 * (hasn't been entered or was erased by the user from the input box).
259 *
260 * @method update_state
261 * @param filter_state {FilterState}
262 * @param start_value Start value
263 * @param end_value End value
264--doc:/member
265update_state: function(filter_state, start_value, end_value) {
266}
267--/doc:member
268
269--/doc:prototype
270
271 */
272
273
274class RangeInputFilter
275{
276 public:
277 RangeInputFilter(v8::FunctionCallbackInfo<v8::Value> args);
278
279 std::string start_prefix_label() const;
280 std::string start_postfix_label() const;
281 std::string end_prefix_label() const;
282 std::string end_postfix_label() const;
283 std::string central_label() const;
284 v8::Local<v8::Value> default_start_value() const;
285 v8::Local<v8::Value> default_end_value() const;
286 bool has_start_value(std::shared_ptr<unity::scopes::FilterState> filter_state) const;
287 bool has_end_value(std::shared_ptr<unity::scopes::FilterState> filter_state) const;
288 double start_value(std::shared_ptr<unity::scopes::FilterState> filter_state) const;
289 double end_value(std::shared_ptr<unity::scopes::FilterState> filter_state) const;
290
291 void update_state(std::shared_ptr<unity::scopes::FilterState> filter_state,
292 v8::Local<v8::Value> start_value,
293 v8::Local<v8::Value> end_value) const;
294
295 void set_display_hints(int hints);
296 int display_hints() const;
297 void set_title(const std::string& title);
298 std::string title() const;
299 std::string id() const;
300 unity::scopes::VariantMap serialize() const;
301 std::string filter_type() const;
302 std::shared_ptr<FilterGroup> filter_group();
303
304 unity::scopes::RangeInputFilter::SPtr get_filter();
305
306 private:
307 unity::scopes::RangeInputFilter::SPtr filter_;
308};
309
310#endif // _UNITY_JS_RANGE_INPUT_FILTER_H_
311
312
0313
=== added file 'src/bindings/src/value-slider-filter.cc'
--- src/bindings/src/value-slider-filter.cc 1970-01-01 00:00:00 +0000
+++ src/bindings/src/value-slider-filter.cc 2016-08-17 20:30:06 +0000
@@ -0,0 +1,141 @@
1/*
2 * Copyright 2016 Canonical Ltd.
3 *
4 * This file is part of unity-js-scopes.
5 *
6 * unity-js-scopes is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * unity-js-scopes is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include "value-slider-filter.h"
20
21#include <unity/scopes/FilterState.h>
22
23ValueSliderFilter::ValueSliderFilter(v8::FunctionCallbackInfo<v8::Value> args) {
24 if (args.Length() != 5 && args.Length() != 6) {
25 throw std::runtime_error("Invalid number of arguments");
26 }
27
28 if (args.Length() == 5) {
29 auto id =
30 v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[0]);
31 auto min =
32 v8cpp::from_v8<double>(v8::Isolate::GetCurrent(), args[1]);
33 auto max =
34 v8cpp::from_v8<double>(v8::Isolate::GetCurrent(), args[2]);
35 auto default_value =
36 v8cpp::from_v8<double>(v8::Isolate::GetCurrent(), args[3]);
37 auto value_slider_labels =
38 v8cpp::from_v8<std::shared_ptr<ValueSliderLabels>>(v8::Isolate::GetCurrent(), args[4]);
39
40 unity::scopes::ValueSliderLabels labels =
41 value_slider_labels->get_labels();
42 filter_ =
43 unity::scopes::ValueSliderFilter::create(
44 id, min, max, default_value, labels);
45 } else {
46 auto id =
47 v8cpp::from_v8<std::string>(v8::Isolate::GetCurrent(), args[0]);
48 auto min =
49 v8cpp::from_v8<double>(v8::Isolate::GetCurrent(), args[1]);
50 auto max =
51 v8cpp::from_v8<double>(v8::Isolate::GetCurrent(), args[2]);
52 auto default_value =
53 v8cpp::from_v8<double>(v8::Isolate::GetCurrent(), args[3]);
54 auto value_slider_labels =
55 v8cpp::from_v8<std::shared_ptr<ValueSliderLabels>>(v8::Isolate::GetCurrent(), args[4]);
56 auto group =
57 v8cpp::from_v8<std::shared_ptr<FilterGroup>>(v8::Isolate::GetCurrent(), args[5]);
58
59 unity::scopes::ValueSliderLabels labels =
60 value_slider_labels->get_labels();
61 unity::scopes::FilterGroup::SCPtr filter_group;
62 if (group) {
63 filter_group = group->get_filter_group();
64 }
65 filter_ =
66 unity::scopes::ValueSliderFilter::create(
67 id, min, max, default_value, labels, filter_group);
68 }
69}
70
71void ValueSliderFilter::set_default_value(double val) {
72 filter_->set_default_value(val);
73}
74
75double ValueSliderFilter::default_value() const {
76 return filter_->default_value();
77}
78
79double ValueSliderFilter::min() const {
80 return filter_->min();
81}
82
83double ValueSliderFilter::max() const {
84 return filter_->max();
85}
86
87bool ValueSliderFilter::has_value(std::shared_ptr<unity::scopes::FilterState> filter_state) const {
88 return filter_->has_value(*filter_state);
89}
90
91double ValueSliderFilter::value(std::shared_ptr<unity::scopes::FilterState> filter_state) const {
92 return filter_->value(*filter_state);
93}
94
95std::shared_ptr<ValueSliderLabels> ValueSliderFilter::labels() const {
96 return std::shared_ptr<ValueSliderLabels>(
97 new ValueSliderLabels(filter_->labels()));
98}
99
100void ValueSliderFilter::update_state(
101 std::shared_ptr<unity::scopes::FilterState> filter_state,
102 double value) const {
103 filter_->update_state(*filter_state, value);
104}
105
106void ValueSliderFilter::set_display_hints(int hints) {
107 filter_->set_display_hints(hints);
108}
109
110int ValueSliderFilter::display_hints() const {
111 return filter_->display_hints();
112}
113
114std::string ValueSliderFilter::id() const {
115 return filter_->id();
116}
117
118unity::scopes::VariantMap ValueSliderFilter::serialize() const {
119 return filter_->serialize();
120}
121
122std::string ValueSliderFilter::filter_type() const {
123 return filter_->filter_type();
124}
125
126void ValueSliderFilter::set_title(const std::string& title) {
127 filter_->set_title(title);
128}
129
130std::string ValueSliderFilter::title() const {
131 return filter_->title();
132}
133
134std::shared_ptr<FilterGroup> ValueSliderFilter::filter_group() {
135 unity::scopes::FilterGroup::SCPtr fg = filter_->filter_group();
136 if (!fg) {
137 return std::shared_ptr<FilterGroup>();
138 }
139 return std::shared_ptr<FilterGroup>(
140 new FilterGroup(fg));
141}
0142
=== added file 'src/bindings/src/value-slider-filter.h'
--- src/bindings/src/value-slider-filter.h 1970-01-01 00:00:00 +0000
+++ src/bindings/src/value-slider-filter.h 2016-08-17 20:30:06 +0000
@@ -0,0 +1,234 @@
1/*
2 * Copyright 2016 Canonical Ltd.
3 *
4 * This file is part of unity-js-scopes.
5 *
6 * unity-js-scopes is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * unity-js-scopes is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef _UNITY_JS_VALUE_SLIDER_FILTER_H_
20#define _UNITY_JS_VALUE_SLIDER_FILTER_H_
21
22#include <unity/scopes/ValueSliderFilter.h>
23
24#include <v8-cpp.h>
25
26#include "filter-group.h"
27#include "filter-state.h"
28#include "value-slider-labels.h"
29
30
31/**
32
33--doc:class ValueSliderFilter
34 *
35 * A value slider filter that allows for selecting a value within a given range.
36 *
37 * The ValueSliderFilter allows for selecting a value within a range defined by minimum and maximum values.
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.
39 *
40 *
41 * @module ScopeJS
42 * @class ValueSliderFilter
43--/doc:class
44
45--doc:constructor
46 *
47 * @constructor
48 * @param {String} id A unique identifier for the filter that can be used to later identify it among several filters.
49 * @param {Number} min The minimum allowed value
50 * @param {Number} max The maximum allowed value
51 * @param {Number} default_value The default value of this filter, from the min..max range.
52 * @param {ValueSliderLabels} value_labels The labels for min and max values as well as optional extra labels.
53--/doc:constructor
54
55--doc:constructor
56 *
57 * @constructor
58 * @param {String} id A unique identifier for the filter that can be used to later identify it among several filters.
59 * @param {Number} min The minimum allowed value
60 * @param {Number} max The maximum allowed value
61 * @param {Number} default_value The default value of this filter, from the min..max range.
62 * @param {ValueSliderLabels} value_labels The labels for min and max values as well as optional extra labels.
63 * @param {FilterGroup} group [optional] A filter group this filter should be added to.
64--/doc:constructor
65
66--doc:prototype ValueSliderFilter
67
68--doc:member
69 * Sets display hints for the Shell UI
70 * @method set_display_hints
71 * @param hints {DisplayHints} A combination of DisplayHints for this filter.
72--doc:/member
73set_display_hints: function(hints) {
74}
75--/doc:member
76
77--doc:member
78 * Get display hints of this filter
79 * @method display_hints
80 * @return {DisplayHints} Display hints flags
81--doc:/member
82display_hints: function() {
83}
84--/doc:member
85
86--doc:member
87 * Set an optional title of this filter
88 * @method set_title
89 * @param title {String} The title.
90--doc:/member
91set_title: function(title) {
92}
93--/doc:member
94
95--doc:member
96 * Get the optional title of this filter
97 * @method title
98 * @return {String} The title (possibly empty)
99--doc:/member
100title: function() {
101}
102--/doc:member
103
104--doc:member
105 * Get the identifier of this filter
106 * @method id
107 * @return {String} identifier of this filter
108--doc:/member
109id: function() {
110}
111--/doc:member
112
113--doc:member
114 * Get the type name of this filter
115 * @method filter_type
116 * @return {String} type name of this filter
117--doc:/member
118filter_type: function() {
119}
120--/doc:member
121
122--doc:member
123 * Get the filter group this filter belongs to
124 * @method filter_group
125 * @return {FilterGroup} The filter group (or null)
126--doc:/member
127filter_group: function() {
128}
129--/doc:member
130
131--doc:member
132 * Get the label of this filter
133 * @method label
134 * @return {String} label of this filter
135--doc:/member
136label: function() {
137}
138--/doc:member
139
140--doc:member
141 * Check if this filter supports multiple options to be selected
142 * @method multi_select
143 * @return {Boolean} True if this filter multiple options to be selected
144--doc:/member
145multi_select: function() {
146}
147--/doc:member
148
149--doc:member
150 * Add a new option to this filter
151 * @method add_option
152 * @return FilterOption The added filter option
153--doc:/member
154add_option: function() {
155}
156--/doc:member
157
158--doc:member
159 * Get all options of this filter, in the order they were added
160 * @method options
161 * @return {Array of FilterOption}
162--doc:/member
163options: function() {
164}
165--/doc:member
166
167--doc:member
168 * Check if an option is active for this filter
169 * @method has_active_option
170 * @param filter_state FilterState
171 * @return {Boolean} True if an option is active for this filter
172--doc:/member
173has_active_option: function(filter_state) {
174}
175--/doc:member
176
177--doc:member
178 * Get active options from an instance of FilterState for this filter
179 * @method active_options
180 * @param filter_state FilterState
181 * @return {Array of FilterOption} LIst of active FilterOption
182--doc:/member
183active_options: function() {
184}
185--/doc:member
186
187--doc:member
188 * Marks given FilterOption of this filter instance as active (or not active) in a FilterState object.
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).
190 * @method update_state
191 * @param filter_state {FilterState}
192 * @param option {FilterOption}
193 * @param active {Boolean}
194--doc:/member
195update_state: function(filter_state, option, active) {
196}
197--/doc:member
198
199--/doc:prototype
200
201 */
202
203
204class ValueSliderFilter
205{
206 public:
207 ValueSliderFilter(v8::FunctionCallbackInfo<v8::Value> args);
208
209 void set_default_value(double val);
210 double default_value() const;
211 double min() const;
212 double max() const;
213 bool has_value(std::shared_ptr<unity::scopes::FilterState> filter_state) const;
214 double value(std::shared_ptr<unity::scopes::FilterState> filter_state) const;
215 std::shared_ptr<ValueSliderLabels> labels() const;
216
217 void update_state(std::shared_ptr<unity::scopes::FilterState> filter_state
218 , double value) const;
219 void set_display_hints(int hints);
220 int display_hints() const;
221 void set_title(const std::string& title);
222 std::string title() const;
223 std::string id() const;
224 unity::scopes::VariantMap serialize() const;
225 std::string filter_type() const;
226 std::shared_ptr<FilterGroup> filter_group();
227
228 private:
229 unity::scopes::ValueSliderFilter::UPtr filter_;
230};
231
232#endif // _UNITY_JS_VALUE_SLIDER_FILTER_H_
233
234
0235
=== added file 'src/bindings/src/value-slider-labels.cc'
--- src/bindings/src/value-slider-labels.cc 1970-01-01 00:00:00 +0000
+++ src/bindings/src/value-slider-labels.cc 2016-08-17 20:30:06 +0000
@@ -0,0 +1,91 @@
1/*
2 * Copyright 2016 Canonical Ltd.
3 *
4 * This file is part of unity-js-scopes.
5 *
6 * unity-js-scopes is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * unity-js-scopes is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include "value-slider-labels.h"
20
21ValueSliderLabels::ValueSliderLabels(std::string const &min_label,
22 std::string const &max_label,
23 v8::Local<v8::Value> extra_labels) {
24 if (extra_labels->IsNull() || extra_labels->IsUndefined()) {
25 vsl_.reset(new unity::scopes::ValueSliderLabels(min_label, max_label));
26 } else if (extra_labels->IsArray()) {
27 std::vector<std::vector<v8::Local<v8::Value>>> labels =
28 v8cpp::from_v8<std::vector<std::vector<v8::Local<v8::Value>>>>(
29 v8::Isolate::GetCurrent(),
30 extra_labels);
31
32 unity::scopes::ValueLabelPairList vlp_list;
33
34 for (auto label : labels) {
35 if (label.size() == 2 &&
36 label[0]->IsNumber() &&
37 label[1]->IsString()) {
38 double v = v8cpp::from_v8<double>(
39 v8::Isolate::GetCurrent(),
40 label[0]);
41 std::string l = v8cpp::from_v8<std::string>(
42 v8::Isolate::GetCurrent(),
43 label[1]);
44
45 vlp_list.push_back(unity::scopes::ValueLabelPair(v, l));
46 }
47 }
48
49 vsl_.reset(
50 new unity::scopes::ValueSliderLabels(
51 min_label, max_label, vlp_list));
52 } else {
53 throw std::runtime_error("Invalid ValueSliderLabels creation parameters");
54 }
55}
56
57ValueSliderLabels::ValueSliderLabels(const unity::scopes::ValueSliderLabels& labels) {
58 vsl_.reset(new unity::scopes::ValueSliderLabels(labels));
59}
60
61std::string ValueSliderLabels::min_label() const {
62 return vsl_->min_label();
63}
64
65std::string ValueSliderLabels::max_label() const {
66 return vsl_->max_label();
67}
68
69v8::Local<v8::Value> ValueSliderLabels::extra_labels() const {
70 unity::scopes::ValueLabelPairList labels =
71 vsl_->extra_labels();
72
73 v8::Handle<v8::Array> a =
74 v8::Array::New(v8::Isolate::GetCurrent(), labels.size());
75
76 for (size_t i = 0; i < labels.size(); ++i) {
77 v8::Handle<v8::Array> label_pair =
78 v8::Array::New(v8::Isolate::GetCurrent(), 2);
79
80 label_pair->Set(0, v8::Number::New(v8::Isolate::GetCurrent(), labels[i].first));
81 label_pair->Set(1, v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), labels[i].second.c_str()));
82
83 a->Set(i, label_pair);
84 }
85 return a;
86}
87
88unity::scopes::ValueSliderLabels ValueSliderLabels::get_labels() {
89 return *vsl_;
90}
91
092
=== added file 'src/bindings/src/value-slider-labels.h'
--- src/bindings/src/value-slider-labels.h 1970-01-01 00:00:00 +0000
+++ src/bindings/src/value-slider-labels.h 2016-08-17 20:30:06 +0000
@@ -0,0 +1,109 @@
1/*
2 * Copyright 2016 Canonical Ltd.
3 *
4 * This file is part of unity-js-scopes.
5 *
6 * unity-js-scopes is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * unity-js-scopes is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef _UNITY_JS_VALUE_SLIDER_LABELS_H_
20#define _UNITY_JS_VALUE_SLIDER_LABELS_H_
21
22#include <unity/scopes/ValueSliderLabels.h>
23
24#include <v8-cpp.h>
25
26/**
27
28--doc:class ValueSliderLabels
29 *
30 * Labels used by a ValueSliderFilter
31 *
32 * The ValueSliderLabels class holds labels for a ValueSliderFilter.
33 * Labels for the minimum and maximum values must be provided.
34 * In addition, an arbitrary number of extra labels can be defined; these labels
35 * mark intermediate values between the minimum and maximum value.
36 *
37 * @module ScopeJS
38 * @class ValueSliderLabels
39--/doc:class
40
41--doc:constructor
42 * Create a ValueSliderLabels instance with labels for minimum and maximum, as well as extra labels.
43 *
44 * Note that any extra labels act only as a guidance for the user
45 * (i.e. they do not limit the available choices).
46 * The Unity shell is free to omit some or all of the labels depending
47 * on the available screen space.
48 *
49 * @constructor
50 * @param min_label {String} The label for minimum value of the associated ValueSliderFilter filter.
51 * @param max_label {String} The label for maximum value of the associated ValueSliderFilter filter.
52 * @param extra_labels {Array of {"value": Number, "label": String} objects} [optional] Additional labels for values between minimum and maximum values.
53 *
54--/doc:constructor
55
56--doc:prototype ValueSliderLabels
57
58--doc:member
59 * Get the label for the minimum value of the filter.
60 * @method min_label
61 * @return {String} The label for the minimum value
62--doc:/member
63min_label: function() {
64}
65--/doc:member
66
67--doc:member
68 * Get the label for the maximum value of the filter.
69 * @method max_label
70 * @return {String} The label for the maximum value
71--doc:/member
72max_label: function() {
73}
74--/doc:member
75
76--doc:member
77 * Get the labels for intermediate values of the filter
78 * @method extra_labels
79 * @return {Array of {Number, String} object}
80--doc:/member
81extra_labels: function() {
82}
83--/doc:member
84
85--/doc:prototype
86
87 */
88
89class ValueSliderLabels
90{
91 public:
92 ValueSliderLabels(const unity::scopes::ValueSliderLabels& labels);
93 ValueSliderLabels(std::string const &min_label,
94 std::string const &max_label,
95 v8::Local<v8::Value> extra_labels);
96
97 std::string min_label() const;
98 std::string max_label() const;
99 v8::Local<v8::Value> extra_labels() const;
100
101 unity::scopes::ValueSliderLabels get_labels();
102
103 private:
104 std::unique_ptr<unity::scopes::ValueSliderLabels> vsl_;
105};
106
107#endif // _UNITY_JS_VALUE_SLIDER_LABELS_H_
108
109

Subscribers

People subscribed via source and target branches

to all changes: