diff options
author | Mnikolenko Productengine <mnikolenko@productengine.com> | 2024-05-16 03:41:57 +0300 |
---|---|---|
committer | Mnikolenko Productengine <mnikolenko@productengine.com> | 2024-05-16 03:41:57 +0300 |
commit | 0212bae056419c10abdfac478188b52e61373609 (patch) | |
tree | 3a5809ba24b3253c016813204365bd97e305e25a /indra/llui | |
parent | b1098308428873e927cbf3c956ed0a7f17dc439b (diff) | |
parent | c808d849aa6aa17db95a7814e6eb6bc5162ba816 (diff) |
Merge branch 'lua-ui-callbacks' into release/luau-scripting
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/llmenugl.h | 11 | ||||
-rw-r--r-- | indra/llui/lluictrl.cpp | 8 | ||||
-rw-r--r-- | indra/llui/lluictrl.h | 23 |
3 files changed, 38 insertions, 4 deletions
diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h index e8d6043e54..708010a067 100644 --- a/indra/llui/llmenugl.h +++ b/indra/llui/llmenugl.h @@ -950,16 +950,19 @@ public: LLUICtrl::EnableCallbackRegistry::currentRegistrar().add(name, boost::bind(&view_listener_t::handleEvent, listener, _2)); } - static void addCommit(view_listener_t* listener, const std::string& name) + static void addCommit(view_listener_t *listener, const std::string &name, + LLUICtrl::LLCommitCallbackInfo::EUntrustedCall handle_untrusted = LLUICtrl::LLCommitCallbackInfo::UNTRUSTED_BLOCK) { - LLUICtrl::CommitCallbackRegistry::currentRegistrar().add(name, boost::bind(&view_listener_t::handleEvent, listener, _2)); + LLUICtrl::SharedCommitCallbackRegistry::currentRegistrar().add(name, + LLUICtrl::LLCommitCallbackInfo(boost::bind(&view_listener_t::handleEvent, listener, _2), handle_untrusted)); } - static void addMenu(view_listener_t* listener, const std::string& name) + static void addMenu(view_listener_t *listener, const std::string &name, + LLUICtrl::LLCommitCallbackInfo::EUntrustedCall handle_untrusted = LLUICtrl::LLCommitCallbackInfo::UNTRUSTED_BLOCK) { // For now, add to both click and enable registries addEnable(listener, name); - addCommit(listener, name); + addCommit(listener, name, handle_untrusted); } static void cleanup() diff --git a/indra/llui/lluictrl.cpp b/indra/llui/lluictrl.cpp index 69093393d9..0fa43081ba 100644 --- a/indra/llui/lluictrl.cpp +++ b/indra/llui/lluictrl.cpp @@ -284,6 +284,7 @@ LLUICtrl::commit_signal_t::slot_type LLUICtrl::initCommitCallback(const CommitCa std::string function_name = cb.function_name; setFunctionName(function_name); commit_callback_t* func = (CommitCallbackRegistry::getValue(function_name)); + LLUICtrl::LLCommitCallbackInfo *info = LLUICtrl::SharedCommitCallbackRegistry::getValue(function_name); if (func) { if (cb.parameter.isProvided()) @@ -291,6 +292,13 @@ LLUICtrl::commit_signal_t::slot_type LLUICtrl::initCommitCallback(const CommitCa else return commit_signal_t::slot_type(*func); } + else if (info && info->callback_func) + { + if (cb.parameter.isProvided()) + return boost::bind((info->callback_func), _1, cb.parameter); + else + return commit_signal_t::slot_type(info->callback_func); + } else if (!function_name.empty()) { LL_WARNS() << "No callback found for: '" << function_name << "' in control: " << getName() << LL_ENDL; diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h index d21e8dc1c6..790c483aee 100644 --- a/indra/llui/lluictrl.h +++ b/indra/llui/lluictrl.h @@ -284,6 +284,29 @@ public: LLSINGLETON_EMPTY_CTOR(EnableCallbackRegistry); }; + struct LLCommitCallbackInfo + { + enum EUntrustedCall + { + UNTRUSTED_ALLOW, + UNTRUSTED_BLOCK, + UNTRUSTED_THROTTLE + }; + + LLCommitCallbackInfo(commit_callback_t func = NULL, EUntrustedCall handle_untrusted = UNTRUSTED_ALLOW) + : callback_func(func), mHandleUntrusted(handle_untrusted) + {} + + public: + EUntrustedCall mHandleUntrusted; + commit_callback_t callback_func; + }; + + class SharedCommitCallbackRegistry : public CallbackRegistry<LLCommitCallbackInfo, SharedCommitCallbackRegistry> + { + LLSINGLETON_EMPTY_CTOR(SharedCommitCallbackRegistry); + }; + protected: static bool controlListener(const LLSD& newvalue, LLHandle<LLUICtrl> handle, std::string type); |