Manual_UI.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. //
  2. // Copyright (c) 2008-2020 the Urho3D project.
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #include "../Precompiled.h"
  23. #include "../AngelScript/APITemplates.h"
  24. #include "../AngelScript/Manual_UI.h"
  25. namespace Urho3D
  26. {
  27. // This function is called before ASRegisterGenerated()
  28. void ASRegisterManualFirst_UI(asIScriptEngine* engine)
  29. {
  30. }
  31. // ========================================================================================
  32. // template <class T> T* Context::GetSubsystem() const | File: ../Core/Context.h
  33. static UI* GetUI()
  34. {
  35. return GetScriptContext()->GetSubsystem<UI>();
  36. }
  37. // This function is called after ASRegisterGenerated()
  38. void ASRegisterManualLast_UI(asIScriptEngine* engine)
  39. {
  40. // template <class T> T* Context::GetSubsystem() const | File: ../Core/Context.h
  41. engine->RegisterGlobalFunction("UI@+ get_ui()", AS_FUNCTION(GetUI), AS_CALL_CDECL);
  42. }
  43. // ========================================================================================
  44. // SharedPtr<UIElement> UI::LoadLayout(Deserializer& source, XMLFile* styleFile = nullptr) | File: ../UI/UI.h
  45. UIElement* UI_LoadLayout_File(File* file, UI* ptr)
  46. {
  47. if (file)
  48. {
  49. SharedPtr<UIElement> root = ptr->LoadLayout(*file);
  50. if (root)
  51. root->AddRef();
  52. return root.Get();
  53. }
  54. else
  55. return nullptr;
  56. }
  57. // SharedPtr<UIElement> UI::LoadLayout(Deserializer& source, XMLFile* styleFile = nullptr) | File: ../UI/UI.h
  58. UIElement* UI_LoadLayout_VectorBuffer(VectorBuffer& buffer, UI* ptr)
  59. {
  60. SharedPtr<UIElement> root = ptr->LoadLayout(buffer);
  61. if (root)
  62. root->AddRef();
  63. return root.Get();
  64. }
  65. // SharedPtr<UIElement> UI::LoadLayout(Deserializer& source, XMLFile* styleFile = nullptr) | File: ../UI/UI.h
  66. UIElement* UI_LoadLayout_File_Style(File* file, XMLFile* styleFile, UI* ptr)
  67. {
  68. if (file)
  69. {
  70. SharedPtr<UIElement> root = ptr->LoadLayout(*file, styleFile);
  71. if (root)
  72. root->AddRef();
  73. return root.Get();
  74. }
  75. else
  76. return nullptr;
  77. }
  78. // SharedPtr<UIElement> UI::LoadLayout(Deserializer& source, XMLFile* styleFile = nullptr) | File: ../UI/UI.h
  79. UIElement* UI_LoadLayout_VectorBuffer_Style(VectorBuffer& buffer, XMLFile* styleFile, UI* ptr)
  80. {
  81. SharedPtr<UIElement> root = ptr->LoadLayout(buffer, styleFile);
  82. if (root)
  83. root->AddRef();
  84. return root.Get();
  85. }
  86. // bool UI::SaveLayout(Serializer& dest, UIElement* element) | File: ../UI/UI.h
  87. bool UI_SaveLayout_File(File* file, UIElement* element, UI* ptr)
  88. {
  89. return file && ptr->SaveLayout(*file, element);
  90. }
  91. // bool UI::SaveLayout(Serializer& dest, UIElement* element) | File: ../UI/UI.h
  92. bool UI_SaveLayout_VectorBuffer(VectorBuffer& buffer, UIElement* element, UI* ptr)
  93. {
  94. return ptr->SaveLayout(buffer, element);
  95. }
  96. // const Vector<UIElement*> UI::GetDragElements() | File: ../UI/UI.h
  97. CScriptArray* UI_GetDragElements(UI* ptr)
  98. {
  99. return VectorToHandleArray(ptr->GetDragElements(), "const Array<UIElement@>@");
  100. }
  101. // void UI::SetFocusElement(UIElement* element, bool byKey = false) | File: ../UI/UI.h
  102. void UI_SetFocusElement(UIElement* element, UI* ptr)
  103. {
  104. ptr->SetFocusElement(element);
  105. }
  106. }