Merge branch 'hotfix-1.7' into develop

This commit is contained in:
Jinhao
2019-04-22 01:08:49 +08:00
7 changed files with 246 additions and 43 deletions

View File

@@ -108,11 +108,16 @@ namespace std {
{
using namespace experimental::filesystem;
}
#ifndef __cpp_lib_experimental_filesystem
# define __cpp_lib_experimental_filesystem 201406
#endif
} // std
#else
# undef NANA_USING_STD_FILESYSTEM
# define NANA_USING_STD_FILESYSTEM 1
//Detects whether the compiler supports std::filesystem under current options
# if ((defined(_MSC_VER) && (_MSC_VER >= 1912) && defined(_MSVC_LANG) && _MSVC_LANG >= 201703)) || \
((__cplusplus >= 201703L) && \
(defined(__clang__) && (__clang_major__ >= 7) || \
@@ -125,14 +130,11 @@ namespace std {
using namespace std::experimental::filesystem;
}
}
# undef NANA_USING_STD_EXPERIMENTAL_FILESYSTEM
# define NANA_USING_STD_EXPERIMENTAL_FILESYSTEM
# endif
#endif
#ifndef __cpp_lib_experimental_filesystem
# define __cpp_lib_experimental_filesystem 201406
#endif
#if NANA_USING_NANA_FILESYSTEM
#include <string>
@@ -558,7 +560,23 @@ namespace std {
#endif
}
} // std
#else
//Implements the missing functions for various version of experimental/filesystem
# if defined(NANA_USING_STD_EXPERIMENTAL_FILESYSTEM)
namespace std
{
namespace filesystem
{
//Visual Studio 2017
#if (defined(_MSC_VER) && (_MSC_VER > 1912)) || \
(!defined(__clang__) && defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 801))
path weakly_canonical(const path& p);
path weakly_canonical(const path& p, std::error_code& err);
#endif
}
}
# endif
#endif //NANA_USING_NANA_FILESYSTEM

View File

@@ -1,6 +1,6 @@
/*
* A Tree Container class implementation
* Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com)
* Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@@ -193,6 +193,11 @@ namespace detail
node_type* insert(const std::string& key, const element_type& elem)
{
auto node = _m_locate<true>(key);
//Doesn't return the root node
if (node == &root_)
return nullptr;
if(node)
node->value.second = elem;
return node;
@@ -206,12 +211,14 @@ namespace detail
node_type* find(const std::string& path) const
{
return _m_locate(path);
auto p = _m_locate(path);
return (&root_ == p ? nullptr : p);
}
node_type* ref(const std::string& path)
{
return _m_locate<true>(path);
auto p = _m_locate<true>(path);
return (&root_ == p ? nullptr : p);
}
unsigned indent_size(const node_type* node) const
@@ -479,42 +486,42 @@ namespace detail
return nullptr;
}
// foreach elements of key.
// the root name "/" and "\\" are treated as a node. This is a feature that can easily support the UNIX-like path.
template<typename Function>
void _m_for_each(const ::std::string& key, Function function) const
{
if(key.size())
//Ignores separaters at the begin of key.
::std::string::size_type beg = key.find_first_not_of("\\/");
if (key.npos == beg)
return;
auto end = key.find_first_of("\\/", beg);
while(end != ::std::string::npos)
{
::std::string::size_type beg = 0;
auto end = key.find_first_of("\\/");
while(end != ::std::string::npos)
if(beg != end)
{
if(beg != end)
{
if(!function(key.substr(beg, end - beg)))
return;
}
auto next = key.find_first_not_of("\\/", end);
if ((next == ::std::string::npos) && end)
if(!function(key.substr(beg, end - beg)))
return;
if (0 == end)
{
if ((!function(key.substr(0, 1))) || (next == ::std::string::npos))
return;
}
beg = next;
end = key.find_first_of("\\/", beg);
}
function(key.substr(beg, key.size() - beg));
auto next = key.find_first_not_of("\\/", end);
if ((next == ::std::string::npos) && end)
return;
if (0 == end)
{
if ((!function(key.substr(0, 1))) || (next == ::std::string::npos))
return;
}
beg = next;
end = key.find_first_of("\\/", beg);
}
function(key.substr(beg, key.size() - beg));
}
template<bool CreateIfNotExists>

View File

@@ -1,7 +1,7 @@
/**
* A float_listbox Implementation
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
* Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@@ -46,8 +46,10 @@ namespace nana
class item_renderer
{
public:
typedef widget& widget_reference;
typedef paint::graphics& graph_reference;
using widget_reference = widget&;
using graph_reference = paint::graphics&;
using item_interface = float_listbox::item_interface;
enum state_t{StateNone, StateHighlighted};
virtual ~item_renderer() = default;

View File

@@ -480,6 +480,8 @@ namespace nana
*/
void scroll_into_view(item_proxy item);
/// Gets the current hovered node.
item_proxy hovered(bool exclude_expander) const;
private:
std::shared_ptr<scroll_operation_interface> _m_scroll_operation() override;