Skip to content

Commit

Permalink
Merge pull request #175 from SylvainCorlay/xproperty-improved
Browse files Browse the repository at this point in the history
Update xproperty
  • Loading branch information
JohanMabille committed Jan 9, 2020
2 parents 373c0f1 + 2d97636 commit 5af08be
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ install:
- conda update -q conda
- conda info -a
# Install host dependencies
- conda install xeus=0.23.3 cppzmq=4.3.0 xproperty=0.8.1 nlohmann_json -c conda-forge
- conda install xeus=0.23.3 cppzmq=4.3.0 xproperty=0.9.0 nlohmann_json -c conda-forge
# Install build dependencies
- conda install gtest cmake -c conda-forge
- cmake -G "NMake Makefiles" -D CMAKE_INSTALL_PREFIX=%MINICONDA%\\LIBRARY -DBUILD_TESTS=ON .
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ install:
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
# Install host dependencies
- conda install xeus=0.23.3 cppzmq=4.3.0 xproperty=0.8.1 nlohmann_json -c conda-forge
- conda install xeus=0.23.3 cppzmq=4.3.0 xproperty=0.9.0 nlohmann_json -c conda-forge
# Install build dependencies
- conda install cmake -c conda-forge
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ message(STATUS "xwidgets binary version: v${XWIDGETS_BINARY_VERSION}")
find_package(cppzmq 4.3.0 REQUIRED)
find_package(xtl 0.6.5 REQUIRED)
find_package(xeus 0.21.1 REQUIRED)
find_package(xproperty 0.8.1 REQUIRED)
find_package(xproperty 0.9.0 REQUIRED)

# Source files
# ============
Expand Down
16 changes: 8 additions & 8 deletions include/xwidgets/xselection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ namespace xw
inline void xselection<D>::setup_properties()
{
auto self = this->self();
self->template observe<decltype(self->value)>([](auto& owner) {
self->observe("value", [](auto& owner) {
const options_type& opt = owner._options_labels();
auto new_index = index_type(std::find(opt.cbegin(), opt.cend(), owner.value()) - opt.cbegin());
if (new_index != owner.index())
Expand All @@ -167,15 +167,15 @@ namespace xw
}
});

self->template observe<decltype(self->index)>([](auto& owner) {
self->observe("index", [](auto& owner) {
auto new_value = owner._options_labels()[owner.index()];
if (new_value != owner.value())
{
owner.value = new_value;
}
});

self->template observe<decltype(self->_options_labels)>([](auto& owner) {
self->observe("_options_labels", [](auto& owner) {
const options_type& opt = owner._options_labels();
auto position = std::find(opt.cbegin(), opt.cend(), owner.value());
if (position == opt.cend())
Expand All @@ -185,7 +185,7 @@ namespace xw
owner.index = position - opt.cbegin();
});

self->template validate<decltype(self->value)>([](auto& owner, auto& proposal) {
self->template validate<typename decltype(self->value)::value_type>("value", [](auto& owner, auto& proposal) {
const options_type& opt = owner._options_labels();
if (std::find(opt.cbegin(), opt.cend(), proposal) == opt.cend())
{
Expand Down Expand Up @@ -256,7 +256,7 @@ namespace xw
inline void xmultiple_selection<D>::setup_properties()
{
auto self = this->self();
self->template observe<decltype(self->value)>([](auto& owner) {
self->observe("value", [](auto& owner) {
const options_type& opt = owner._options_labels();
index_type new_index;
for (const auto& val : owner.value())
Expand All @@ -269,7 +269,7 @@ namespace xw
}
});

self->template observe<decltype(self->index)>([](auto& owner) {
self->observe("index", [](auto& owner) {
value_type new_value;
for (const auto& i : owner.index())
{
Expand All @@ -281,11 +281,11 @@ namespace xw
}
});

self->template observe<decltype(self->_options_labels)>([](auto& owner) {
self->observe("_options_labels", [](auto& owner) {
owner.index = index_type();
});

self->template validate<decltype(self->value)>([](auto& owner, auto& proposal) {
self->template validate<typename decltype(self->value)::value_type>("value", [](auto& owner, auto& proposal) {
const options_type& opt = owner._options_labels();
for (const auto& val : proposal)
{
Expand Down
6 changes: 3 additions & 3 deletions include/xwidgets/xselectionslider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ namespace xw
}

auto self = this->self();
self->template validate<decltype(self->_options_labels)>([](auto&, auto& proposal) {
self->template validate<typename decltype(self->_options_labels)::value_type>("_options_labels", [](auto&, auto& proposal) {
if (proposal.empty())
{
throw std::runtime_error("Empty collection passed to selection slider");
Expand Down Expand Up @@ -205,7 +205,7 @@ namespace xw
}

auto self = this->self();
self->template validate<decltype(self->_options_labels)>([](auto&, auto& proposal) {
self->template validate<typename decltype(self->_options_labels)::value_type>("value", [](auto&, auto& proposal) {
if (proposal.empty())
{
throw std::runtime_error("Empty collection passed to selection slider");
Expand All @@ -225,7 +225,7 @@ namespace xw
}

auto self = this->self();
self->template validate<decltype(self->_options_labels)>([](auto&, auto& proposal) {
self->template validate<typename decltype(self->_options_labels)::value_type>("_options_labels", [](auto&, auto& proposal) {
if (proposal.empty())
{
throw std::runtime_error("Empty collection passed to selection slider");
Expand Down
6 changes: 3 additions & 3 deletions include/xwidgets/xslider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ namespace xw
inline void xslider<D>::setup_properties()
{
auto self = this->self();
self->template validate<decltype(self->value)>([](auto& owner, auto& proposal) {
self->template validate<typename decltype(self->value)::value_type>("value", [](auto& owner, auto& proposal) {
if (proposal > owner.max())
{
proposal = owner.max();
Expand All @@ -201,7 +201,7 @@ namespace xw
}
});

self->template validate<decltype(self->min)>([](auto& owner, auto& proposal) {
self->template validate<typename decltype(self->min)::value_type>("min", [](auto& owner, auto& proposal) {
if (proposal > owner.max())
{
throw std::runtime_error("setting min > max");
Expand All @@ -212,7 +212,7 @@ namespace xw
}
});

self->template validate<decltype(self->max)>([](auto& owner, auto& proposal) {
self->template validate<typename decltype(self->max)::value_type>("max", [](auto& owner, auto& proposal) {
if (proposal < owner.min())
{
throw std::runtime_error("setting max < min");
Expand Down

0 comments on commit 5af08be

Please sign in to comment.