ScriptableImGui.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. /*
  2. * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
  3. * its licensors.
  4. *
  5. * For complete copyright and license terms please see the LICENSE at the root of this
  6. * distribution (the "License"). All use of this software is governed by the License,
  7. * or, if provided, by the license below or the license accompanying this file. Do not
  8. * remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
  9. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. *
  11. */
  12. #include <Automation/ScriptableImGui.h>
  13. #include <Automation/ScriptRepeaterBus.h>
  14. #include <AzFramework/StringFunc/StringFunc.h>
  15. #include <Utils/Utils.h>
  16. namespace AtomSampleViewer
  17. {
  18. ScriptableImGui* ScriptableImGui::s_instance = nullptr;
  19. void ScriptableImGui::Create()
  20. {
  21. AZ_Assert(s_instance == nullptr, "instance already called");
  22. s_instance = aznew ScriptableImGui();
  23. }
  24. void ScriptableImGui::Destory()
  25. {
  26. AZ_Assert(s_instance != nullptr, "instance is null");
  27. delete s_instance;
  28. s_instance = nullptr;
  29. }
  30. void ScriptableImGui::CheckAllActionsConsumed()
  31. {
  32. AZ_DEBUG_STATIC_MEMEBER(instance, s_instance);
  33. AZ_Error("Automation", s_instance->m_scriptedActions.empty(), "Not all scripted ImGui actions were consumed");
  34. for (auto iter : s_instance->m_scriptedActions)
  35. {
  36. AZ_Error("Automation", false, "Scripted action for '%s' not consumed", iter.first.c_str());
  37. }
  38. AZ_Error("Automation", s_instance->m_nameContextStack.empty(), "PushNameContext and PopNameContext calls didn't match");
  39. }
  40. void ScriptableImGui::ClearActions()
  41. {
  42. AZ_DEBUG_STATIC_MEMEBER(instance, s_instance);
  43. s_instance->m_scriptedActions.clear();
  44. s_instance->m_nameContextStack.clear();
  45. }
  46. void ScriptableImGui::PushNameContext(const AZStd::string& nameContext)
  47. {
  48. AZ_DEBUG_STATIC_MEMEBER(instance, s_instance);
  49. s_instance->m_nameContextStack.push_back(nameContext);
  50. }
  51. void ScriptableImGui::PopNameContext()
  52. {
  53. AZ_DEBUG_STATIC_MEMEBER(instance, s_instance);
  54. AZ_Assert(!s_instance->m_nameContextStack.empty(), "Called PopNameContext too many times");
  55. s_instance->m_nameContextStack.pop_back();
  56. }
  57. ScriptableImGui::ActionItem ScriptableImGui::FindAndRemoveAction(const AZStd::string& pathToImGuiItem)
  58. {
  59. AZ_DEBUG_STATIC_MEMEBER(instance, s_instance);
  60. auto iter = s_instance->m_scriptedActions.find(pathToImGuiItem);
  61. if (iter != s_instance->m_scriptedActions.end())
  62. {
  63. ScriptableImGui::ActionItem item = AZStd::move(iter->second);
  64. s_instance->m_scriptedActions.erase(iter);
  65. return AZStd::move(item);
  66. }
  67. return ScriptableImGui::ActionItem{};
  68. }
  69. AZStd::string ScriptableImGui::MakeFullPath(const AZStd::string& forLabel)
  70. {
  71. static constexpr char Delimiter[] = "/";
  72. AZStd::string fullPath;
  73. if (!s_instance->m_nameContextStack.empty())
  74. {
  75. AzFramework::StringFunc::Join(fullPath, s_instance->m_nameContextStack.begin(), s_instance->m_nameContextStack.end(), Delimiter);
  76. fullPath += Delimiter;
  77. }
  78. fullPath += forLabel;
  79. return fullPath;
  80. }
  81. void ScriptableImGui::ReportScriptError([[maybe_unused]] const char* message)
  82. {
  83. AZ_Error("Automation", false, "Script: %s", message);
  84. }
  85. void ScriptableImGui::SetBool(const AZStd::string& pathToImGuiItem, bool value)
  86. {
  87. AZ_DEBUG_STATIC_MEMEBER(instance, s_instance);
  88. s_instance->m_scriptedActions[pathToImGuiItem] = value;
  89. }
  90. void ScriptableImGui::SetNumber(const AZStd::string& pathToImGuiItem, float value)
  91. {
  92. AZ_DEBUG_STATIC_MEMEBER(instance, s_instance);
  93. s_instance->m_scriptedActions[pathToImGuiItem] = value;
  94. }
  95. void ScriptableImGui::SetVector(const AZStd::string& pathToImGuiItem, const AZ::Vector2& value)
  96. {
  97. AZ_DEBUG_STATIC_MEMEBER(instance, s_instance);
  98. s_instance->m_scriptedActions[pathToImGuiItem] = value;
  99. }
  100. void ScriptableImGui::SetVector(const AZStd::string& pathToImGuiItem, const AZ::Vector3& value)
  101. {
  102. AZ_DEBUG_STATIC_MEMEBER(instance, s_instance);
  103. s_instance->m_scriptedActions[pathToImGuiItem] = value;
  104. }
  105. void ScriptableImGui::SetString(const AZStd::string& pathToImGuiItem, const AZStd::string& value)
  106. {
  107. AZ_DEBUG_STATIC_MEMEBER(instance, s_instance);
  108. s_instance->m_scriptedActions[pathToImGuiItem] = value;
  109. }
  110. template<typename ActionDataT>
  111. bool ScriptableImGui::ActionHelper(
  112. const char* label,
  113. AZStd::function<bool()> imguiAction,
  114. AZStd::function<void(const AZStd::string& /*pathToImGuiItem*/)> reportScriptableAction,
  115. AZStd::function<bool(ActionDataT /*scriptArg*/)> handleScriptedAction,
  116. bool shouldReportScriptableActionAfterAnyChange)
  117. {
  118. bool imResult = imguiAction();
  119. const AZStd::string pathToImGuiItem = MakeFullPath(label);
  120. if (ImGui::IsItemDeactivatedAfterEdit() || (shouldReportScriptableActionAfterAnyChange && imResult))
  121. {
  122. reportScriptableAction(pathToImGuiItem);
  123. }
  124. bool scriptResult = false;
  125. ActionItem actionItem = FindAndRemoveAction(pathToImGuiItem);
  126. bool foundAction = !AZStd::holds_alternative<InvalidActionItem>(actionItem);
  127. if (foundAction)
  128. {
  129. if (AZStd::holds_alternative<ActionDataT>(actionItem))
  130. {
  131. scriptResult = handleScriptedAction(AZStd::get<ActionDataT>(actionItem));
  132. }
  133. else
  134. {
  135. ReportScriptError(AZStd::string::format("Wrong data type used to set '%s'", pathToImGuiItem.c_str()).c_str());
  136. }
  137. }
  138. return imResult || scriptResult;
  139. }
  140. bool ScriptableImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
  141. {
  142. PushNameContext(name);
  143. return ImGui::Begin(name, p_open, flags);
  144. }
  145. void ScriptableImGui::End()
  146. {
  147. ImGui::End();
  148. PopNameContext();
  149. }
  150. bool ScriptableImGui::Checkbox(const char* label, bool* v)
  151. {
  152. auto imguiAction = [&]()
  153. {
  154. return ImGui::Checkbox(label, v);
  155. };
  156. auto reportScriptableAction = [&](const AZStd::string& pathToImGuiItem)
  157. {
  158. Utils::ReportScriptableAction("SetImguiValue('%s', %s)", pathToImGuiItem.c_str(), (*v ? "true" : "false"));
  159. };
  160. auto handleScriptedAction = [&](bool scriptArg)
  161. {
  162. if (*v != scriptArg)
  163. {
  164. *v = scriptArg;
  165. return true;
  166. }
  167. return false;
  168. };
  169. return ActionHelper<bool>(label, imguiAction, reportScriptableAction, handleScriptedAction);
  170. }
  171. bool ScriptableImGui::Button(const char* label, const ImVec2& size_arg)
  172. {
  173. auto imguiAction = [&]()
  174. {
  175. return ImGui::Button(label, size_arg);
  176. };
  177. auto reportScriptableAction = [&](const AZStd::string& pathToImGuiItem)
  178. {
  179. Utils::ReportScriptableAction("SetImguiValue('%s', true)", pathToImGuiItem.c_str());
  180. };
  181. auto handleScriptedAction = [](bool scriptArg)
  182. {
  183. return scriptArg;
  184. };
  185. return ActionHelper<bool>(label, imguiAction, reportScriptableAction, handleScriptedAction);
  186. }
  187. bool ScriptableImGui::ListBox(const char* label, int* current_item, bool(*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int height_in_items)
  188. {
  189. auto imguiAction = [&]()
  190. {
  191. return ImGui::ListBox(label, current_item, items_getter, data, items_count, height_in_items);
  192. };
  193. auto reportScriptableAction = [&](const AZStd::string& pathToImGuiItem)
  194. {
  195. const char* itemText = nullptr;
  196. if (items_getter(data, *current_item, &itemText) && itemText)
  197. {
  198. Utils::ReportScriptableAction("SetImguiValue('%s', '%s')", pathToImGuiItem.c_str(), itemText);
  199. }
  200. };
  201. auto handleScriptedAction = [&](AZStd::string scriptArg)
  202. {
  203. for (int i = 0; i < items_count; ++i)
  204. {
  205. const char* itemText = nullptr;
  206. if (items_getter(data, i, &itemText) && itemText && scriptArg == itemText)
  207. {
  208. *current_item = i;
  209. return true;
  210. }
  211. }
  212. ReportScriptError(AZStd::string::format("List '%s' does not contain item '%s'", label, scriptArg.c_str()).c_str());
  213. return false;
  214. };
  215. return ActionHelper<AZStd::string>(label, imguiAction, reportScriptableAction, handleScriptedAction);
  216. }
  217. bool ScriptableImGui::Combo(const char* label, int* current_item, const char* const items[], int items_count, int height_in_items)
  218. {
  219. auto imguiAction = [&]()
  220. {
  221. return ImGui::Combo(label, current_item, items, items_count, height_in_items);
  222. };
  223. auto reportScriptableAction = [&](const AZStd::string& pathToImGuiItem)
  224. {
  225. Utils::ReportScriptableAction("SetImguiValue('%s', '%s')", pathToImGuiItem.c_str(), items[*current_item]);
  226. };
  227. auto handleScriptedAction = [&](AZStd::string scriptArg)
  228. {
  229. for (int i = 0; i < items_count; ++i)
  230. {
  231. if (items[i] == scriptArg)
  232. {
  233. *current_item = i;
  234. return true;
  235. }
  236. }
  237. ReportScriptError(AZStd::string::format("Combo box '%s' does not contain item '%s'", label, scriptArg.c_str()).c_str());
  238. return false;
  239. };
  240. return ActionHelper<AZStd::string>(label, imguiAction, reportScriptableAction, handleScriptedAction,
  241. true /* It seems ImGui::Combo doesn't work with IsItemDeactivatedAfterChange() */);
  242. }
  243. bool ScriptableImGui::RadioButton(const char* label, int* v, int v_button)
  244. {
  245. auto imguiAction = [&]()
  246. {
  247. return ImGui::RadioButton(label, v, v_button);
  248. };
  249. auto reportScriptableAction = [&](const AZStd::string& pathToImGuiItem)
  250. {
  251. Utils::ReportScriptableAction("SetImguiValue('%s', true)", pathToImGuiItem.c_str());
  252. };
  253. auto handleScriptedAction = [&](bool scriptArg)
  254. {
  255. if (scriptArg)
  256. {
  257. *v = v_button;
  258. return true;
  259. }
  260. return false;
  261. };
  262. return ActionHelper<bool>(label, imguiAction, reportScriptableAction, handleScriptedAction);
  263. }
  264. bool ScriptableImGui::SliderInt(const char* label, int* v, int v_min, int v_max, const char* format)
  265. {
  266. auto imguiAction = [&]()
  267. {
  268. return ImGui::SliderInt(label, v, v_min, v_max, format);
  269. };
  270. auto reportScriptableAction = [&](const AZStd::string& pathToImGuiItem)
  271. {
  272. Utils::ReportScriptableAction("SetImguiValue('%s', %d)", pathToImGuiItem.c_str(), *v);
  273. };
  274. auto handleScriptedAction = [&](float scriptArg)
  275. {
  276. *v = aznumeric_cast<int>(scriptArg);
  277. return true;
  278. };
  279. return ActionHelper<float>(label, imguiAction, reportScriptableAction, handleScriptedAction);
  280. }
  281. bool ScriptableImGui::SliderFloat(const char* label, float* v, float v_min, float v_max, const char* format, float power)
  282. {
  283. auto imguiAction = [&]()
  284. {
  285. return ImGui::SliderFloat(label, v, v_min, v_max, format, power);
  286. };
  287. auto reportScriptableAction = [&](const AZStd::string& pathToImGuiItem)
  288. {
  289. Utils::ReportScriptableAction("SetImguiValue('%s', %f)", pathToImGuiItem.c_str(), *v);
  290. };
  291. auto handleScriptedAction = [&](float scriptArg)
  292. {
  293. *v = scriptArg;
  294. return true;
  295. };
  296. return ActionHelper<float>(label, imguiAction, reportScriptableAction, handleScriptedAction);
  297. }
  298. bool ScriptableImGui::SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* format, float power)
  299. {
  300. auto imguiAction = [&]()
  301. {
  302. return ImGui::SliderFloat2(label, v, v_min, v_max, format, power);
  303. };
  304. auto reportScriptableAction = [&](const AZStd::string& pathToImGuiItem)
  305. {
  306. Utils::ReportScriptableAction("SetImguiValue('%s', Vector2(%f, %f))", pathToImGuiItem.c_str(), v[0], v[1]);
  307. };
  308. auto handleScriptedAction = [&](AZ::Vector2 scriptArg)
  309. {
  310. v[0] = scriptArg.GetX();
  311. v[1] = scriptArg.GetY();
  312. return true;
  313. };
  314. return ActionHelper<AZ::Vector2>(label, imguiAction, reportScriptableAction, handleScriptedAction);
  315. }
  316. template <typename ImGuiActionType>
  317. bool ScriptableImGui::ThreeComponentHelper(const char* label, float v[3], ImGuiActionType& imguiAction)
  318. {
  319. auto reportScriptableAction = [&](const AZStd::string& pathToImGuiItem)
  320. {
  321. Utils::ReportScriptableAction("SetImguiValue('%s', Vector3(%f, %f, %f))", pathToImGuiItem.c_str(), v[0], v[1], v[2]);
  322. };
  323. auto handleScriptedAction = [&](AZ::Vector3 scriptArg)
  324. {
  325. v[0] = scriptArg.GetX();
  326. v[1] = scriptArg.GetY();
  327. v[2] = scriptArg.GetZ();
  328. return true;
  329. };
  330. return ActionHelper<AZ::Vector3>(label, imguiAction, reportScriptableAction, handleScriptedAction);
  331. }
  332. bool ScriptableImGui::SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* format, float power)
  333. {
  334. auto imguiAction = [&]()
  335. {
  336. return ImGui::SliderFloat3(label, v, v_min, v_max, format, power);
  337. };
  338. return ThreeComponentHelper(label, v, imguiAction);
  339. }
  340. bool ScriptableImGui::ColorEdit3(const char* label, float v[3], ImGuiColorEditFlags flags)
  341. {
  342. auto imguiAction = [&]()
  343. {
  344. return ImGui::ColorEdit3(label, v, flags);
  345. };
  346. return ThreeComponentHelper(label, v, imguiAction);
  347. }
  348. bool ScriptableImGui::ColorPicker3(const char* label, float v[3], ImGuiColorEditFlags flags)
  349. {
  350. auto imguiAction = [&]()
  351. {
  352. return ImGui::ColorPicker3(label, v, flags);
  353. };
  354. return ThreeComponentHelper(label, v, imguiAction);
  355. }
  356. bool ScriptableImGui::SliderAngle(const char* label, float* v, float v_min, float v_max, const char* format)
  357. {
  358. auto imguiAction = [&]()
  359. {
  360. return ImGui::SliderAngle(label, v, v_min, v_max, format);
  361. };
  362. auto reportScriptableAction = [&](const AZStd::string& pathToImGuiItem)
  363. {
  364. Utils::ReportScriptableAction("SetImguiValue('%s', %f)", pathToImGuiItem.c_str(), *v);
  365. };
  366. auto handleScriptedAction = [&](float scriptArg)
  367. {
  368. *v = scriptArg;
  369. return true;
  370. };
  371. return ActionHelper<float>(label, imguiAction, reportScriptableAction, handleScriptedAction);
  372. }
  373. bool ScriptableImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags flags, const ImVec2& size)
  374. {
  375. auto imguiAction = [&]()
  376. {
  377. return ImGui::Selectable(label, selected, flags, size);
  378. };
  379. auto reportScriptableAction = [&](const AZStd::string& pathToImGuiItem)
  380. {
  381. // The "selected" value that's passed determines if the selectable is *currently* selected, and clicking the selectable toggles its state.
  382. // So when someone clicks the selectable to change its state, we need to report the opposite of what the original state was.
  383. Utils::ReportScriptableAction("SetImguiValue('%s', %s)", pathToImGuiItem.c_str(), (selected ? "false" : "true"));
  384. };
  385. auto handleScriptedAction = [&](bool scriptArg)
  386. {
  387. return scriptArg != selected;
  388. };
  389. return ActionHelper<bool>(label, imguiAction, reportScriptableAction, handleScriptedAction);
  390. }
  391. bool ScriptableImGui::Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags, const ImVec2& size)
  392. {
  393. auto imguiAction = [&]()
  394. {
  395. return ImGui::Selectable(label, p_selected, flags, size);
  396. };
  397. auto reportScriptableAction = [&](const AZStd::string& pathToImGuiItem)
  398. {
  399. // The "selected" value that's passed determines if the selectable is *currently* selected, and clicking the selectable toggles its state.
  400. // So when someone clicks the selectable to change its state, we need to report the opposite of what the original state was.
  401. Utils::ReportScriptableAction("SetImguiValue('%s', %s)", pathToImGuiItem.c_str(), (*p_selected ? "false" : "true"));
  402. };
  403. auto handleScriptedAction = [&](bool scriptArg)
  404. {
  405. if (scriptArg != *p_selected)
  406. {
  407. *p_selected = scriptArg;
  408. return true;
  409. }
  410. return false;
  411. };
  412. return ActionHelper<bool>(label, imguiAction, reportScriptableAction, handleScriptedAction);
  413. }
  414. bool ScriptableImGui::TreeNodeEx(const char* label, ImGuiSelectableFlags flags)
  415. {
  416. AZ_DEBUG_STATIC_MEMEBER(instance, s_instance);
  417. if (ImGui::TreeNodeEx(label, flags))
  418. {
  419. PushNameContext(label);
  420. return true;
  421. }
  422. return false;
  423. }
  424. void ScriptableImGui::TreePop()
  425. {
  426. ImGui::TreePop();
  427. PopNameContext();
  428. }
  429. bool ScriptableImGui::BeginCombo(const char* label, const char* preview_value, ImGuiComboFlags flags)
  430. {
  431. AZ_DEBUG_STATIC_MEMEBER(instance, s_instance);
  432. const AZStd::string pathToImGuiItem = MakeFullPath(label);
  433. if (ImGui::BeginCombo(label, preview_value, flags))
  434. {
  435. PushNameContext(label);
  436. return true;
  437. }
  438. else if (!s_instance->m_scriptedActions.empty())
  439. {
  440. // If a script is running, we return true so that imgui controls inside the combo box are checked.
  441. // We also have to set a flag to prevent ScriptableImGui::EndCombo() from calling ImGui::EndCombo()
  442. // because that is only allowed when ImGui::BeginCombo() returns true.
  443. s_instance->m_isInScriptedComboPopup = true;
  444. PushNameContext(label);
  445. return true;
  446. }
  447. return false;
  448. }
  449. void ScriptableImGui::EndCombo()
  450. {
  451. if (s_instance->m_isInScriptedComboPopup)
  452. {
  453. s_instance->m_isInScriptedComboPopup = false;
  454. // ScriptableImGui::BeginCombo() returned true even though ImGui::BeginCombo() didn't, so we aren't allowed
  455. // to call ImGui::EndCombo() here.
  456. }
  457. else
  458. {
  459. ImGui::EndCombo();
  460. }
  461. PopNameContext();
  462. }
  463. bool ScriptableImGui::BeginMenu(const char* label, bool enabled)
  464. {
  465. // We don't use ActionHelper here because BeginMenu has to do things a bit different since there is a persistent popup.
  466. // It has to run the script code before the ImGui code, and if there is a scripted action then force the menu to open.
  467. // Also, we don't include a "scriptResult", just the "imResult", because we need to ensure that ImGui is in the actual
  468. // state we are reporting back to the caller. Otherwise the internal state of ImGui could become invalid and crash.
  469. const AZStd::string pathToImGuiItem = MakeFullPath(label);
  470. ActionItem actionItem = FindAndRemoveAction(pathToImGuiItem);
  471. bool foundAction = !AZStd::holds_alternative<InvalidActionItem>(actionItem);
  472. if (foundAction)
  473. {
  474. if (AZStd::holds_alternative<bool>(actionItem))
  475. {
  476. if (AZStd::get<bool>(actionItem))
  477. {
  478. // Here we force the menu to open before arriving at ImGui::BeginMenu
  479. ImGui::OpenPopup(label);
  480. }
  481. }
  482. else
  483. {
  484. ReportScriptError(AZStd::string::format("Wrong data type used to set '%s'", label).c_str());
  485. }
  486. }
  487. bool wasPopupOpen = ImGui::IsPopupOpen(label);
  488. bool isPopupOpen = ImGui::BeginMenu(label, enabled);
  489. if (isPopupOpen)
  490. {
  491. PushNameContext(label);
  492. if (!wasPopupOpen && isPopupOpen)
  493. {
  494. Utils::ReportScriptableAction("SetImguiValue('%s', true)", pathToImGuiItem.c_str());
  495. }
  496. }
  497. return isPopupOpen;
  498. }
  499. void ScriptableImGui::EndMenu()
  500. {
  501. ImGui::EndMenu();
  502. PopNameContext();
  503. }
  504. bool ScriptableImGui::MenuItem(const char* label, const char* shortcut, bool selected, bool enabled)
  505. {
  506. auto imguiAction = [&]()
  507. {
  508. return ImGui::MenuItem(label, shortcut, selected, enabled);
  509. };
  510. auto reportScriptableAction = [&](const AZStd::string& pathToImGuiItem)
  511. {
  512. Utils::ReportScriptableAction("SetImguiValue('%s', true)", pathToImGuiItem.c_str());
  513. };
  514. auto handleScriptedAction = [](bool scriptArg)
  515. {
  516. return scriptArg;
  517. };
  518. return ActionHelper<bool>(label, imguiAction, reportScriptableAction, handleScriptedAction);
  519. }
  520. } // namespace AtomSampleViewer