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

Subscribers

People subscribed via source and target branches

to all changes: