diff --git a/include/eepp/ui/tools/uidocfindreplace.hpp b/include/eepp/ui/tools/uidocfindreplace.hpp index 3b3aed9f2..aa5438438 100644 --- a/include/eepp/ui/tools/uidocfindreplace.hpp +++ b/include/eepp/ui/tools/uidocfindreplace.hpp @@ -63,7 +63,7 @@ class EE_API UIDocFindReplace : public UILinearLayout, public WidgetCommandExecu UIWidget* mToggle{ nullptr }; UIWidget* mReplaceBox{ nullptr }; std::shared_ptr mDoc; - std::vector>> mDataBinds; + std::vector> mDataBinds; std::unique_ptr> mPatternBind; UIDocFindReplace( diff --git a/include/eepp/ui/uidatabind.hpp b/include/eepp/ui/uidatabind.hpp index 12f825fb8..1cddca656 100644 --- a/include/eepp/ui/uidatabind.hpp +++ b/include/eepp/ui/uidatabind.hpp @@ -12,8 +12,7 @@ template class UIDataBind { Converter( std::function*, T&, const std::string& )> toVal = []( const UIDataBind*, T& val, const std::string& str ) { - auto base = std::is_same::value ? std::boolalpha : std::dec; - return String::fromString( val, str, base ); + return String::fromString( val, str ); }, std::function*, std::string&, const T& )> fromVal = []( const UIDataBind*, std::string& str, const T& val ) { @@ -25,7 +24,19 @@ template class UIDataBind { std::function*, std::string&, const T& )> fromVal; }; - UIDataBind( T* t, std::set widgets, const Converter& converter = {}, + static Converter converterBool() { + return Converter( + []( const UIDataBind* databind, T& val, const std::string& str ) -> bool { + val = StyleSheetProperty( databind->getPropertyDefinition(), str ).asBool(); + return true; + }, + []( const UIDataBind*, std::string& str, const T& val ) -> bool { + str = val ? "true" : "false"; + return true; + } ); + } + + UIDataBind( T* t, const std::set& widgets, const Converter& converter = {}, const std::string& valueKey = "value" ) : data( t ), widgets( widgets ), @@ -138,6 +149,16 @@ template class UIDataBind { } }; +class UIDataBindBool : public UIDataBind { + public: + UIDataBindBool( bool* t, const std::set& widgets, + const std::string& valueKey = "value" ) : + UIDataBind( t, widgets, UIDataBind::converterBool(), valueKey ) {} + + UIDataBindBool( bool* t, UIWidget* widget, const std::string& valueKey = "value" ) : + UIDataBind( t, widget, UIDataBind::converterBool(), valueKey ) {} +}; + }} // namespace EE::UI #endif // EE_UI_UIDATABIND_HPP diff --git a/premake4.lua b/premake4.lua index 3e85452f4..1d31b82fa 100644 --- a/premake4.lua +++ b/premake4.lua @@ -1177,15 +1177,13 @@ solution "eepp" set_kind() language "C++" includedirs { "src/thirdparty/efsw/include", "src/thirdparty" } - + links { "efsw-static", "pugixml-static" } if not os.is_real("windows") and not os.is_real("haiku") then links { "pthread" } end if os.is_real("macosx") then links { "CoreFoundation.framework", "CoreServices.framework" } end - - links { "efsw-static", "pugixml-static" } files { "src/tools/uieditor/*.cpp" } build_link_configuration( "eepp-UIEditor", true ) diff --git a/src/eepp/ui/tools/uidocfindreplace.cpp b/src/eepp/ui/tools/uidocfindreplace.cpp index ac01d182e..5ed4b0e73 100644 --- a/src/eepp/ui/tools/uidocfindreplace.cpp +++ b/src/eepp/ui/tools/uidocfindreplace.cpp @@ -296,12 +296,12 @@ UIDocFindReplace::UIDocFindReplace( UIWidget* parent, const std::shared_ptraddEventListener( Event::OnTabNavigate, [&]( const Event* ) { mFindInput->setFocus(); } ); - mDataBinds.emplace_back( std::unique_ptr>( - new UIDataBind( &mSearchState.caseSensitive, mCaseSensitive ) ) ); - mDataBinds.emplace_back( std::unique_ptr>( - new UIDataBind( &mSearchState.wholeWord, mWholeWord ) ) ); - mDataBinds.emplace_back( std::unique_ptr>( - new UIDataBind( &mSearchState.escapeSequences, mEscapeSequences ) ) ); + mDataBinds.emplace_back( std::unique_ptr( + new UIDataBindBool( &mSearchState.caseSensitive, mCaseSensitive ) ) ); + mDataBinds.emplace_back( std::unique_ptr( + new UIDataBindBool( &mSearchState.wholeWord, mWholeWord ) ) ); + mDataBinds.emplace_back( std::unique_ptr( + new UIDataBindBool( &mSearchState.escapeSequences, mEscapeSequences ) ) ); UIDataBind::Converter luaPatternConverter( []( const UIDataBind* databind, TextDocument::FindReplaceType& val, const std::string& str ) -> bool {