UI.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. #include <TurboBadger/tb_core.h>
  2. #include <TurboBadger/tb_system.h>
  3. #include <TurboBadger/tb_debug.h>
  4. #include <TurboBadger/animation/tb_widget_animation.h>
  5. #include <TurboBadger/renderers/tb_renderer_batcher.h>
  6. #include <TurboBadger/tb_font_renderer.h>
  7. #include <TurboBadger/tb_node_tree.h>
  8. #include <TurboBadger/tb_widgets_reader.h>
  9. #include <TurboBadger/tb_window.h>
  10. #include <TurboBadger/tb_message_window.h>
  11. #include <TurboBadger/tb_editfield.h>
  12. #include <TurboBadger/tb_select.h>
  13. #include <TurboBadger/tb_inline_select.h>
  14. #include <TurboBadger/tb_tab_container.h>
  15. #include <TurboBadger/tb_toggle_container.h>
  16. #include <TurboBadger/tb_scroll_container.h>
  17. #include <TurboBadger/image/tb_image_widget.h>
  18. void register_tbbf_font_renderer();
  19. void register_stb_font_renderer();
  20. void register_freetype_font_renderer();
  21. using namespace tb;
  22. #include "../Core/CoreEvents.h"
  23. #include "../IO/Log.h"
  24. #include "../Input/Input.h"
  25. #include "../Input/InputEvents.h"
  26. #include "../Resource/ResourceCache.h"
  27. #include "../Graphics/Graphics.h"
  28. #include "../Graphics/GraphicsEvents.h"
  29. #include "../Graphics/Texture2D.h"
  30. #include "../Graphics/VertexBuffer.h"
  31. #include "UIEvents.h"
  32. #include "UIRenderer.h"
  33. #include "UI.h"
  34. #include "UIButton.h"
  35. #include "UITextField.h"
  36. #include "UIEditField.h"
  37. #include "UILayout.h"
  38. #include "UIImageWidget.h"
  39. #include "UIClickLabel.h"
  40. #include "UICheckBox.h"
  41. #include "UISelectList.h"
  42. #include "UIMessageWindow.h"
  43. #include "UISkinImage.h"
  44. #include "UITabContainer.h"
  45. #include "UISceneView.h"
  46. #include "UIDragDrop.h"
  47. #include "UIContainer.h"
  48. #include "UISection.h"
  49. #include "UIInlineSelect.h"
  50. #include "UIScrollContainer.h"
  51. #include "UISeparator.h"
  52. #include "UIDimmer.h"
  53. #include "SystemUI/SystemUI.h"
  54. namespace tb
  55. {
  56. void TBSystem::RescheduleTimer(double fire_time)
  57. {
  58. }
  59. }
  60. namespace Atomic
  61. {
  62. WeakPtr<Context> UI::uiContext_;
  63. UI::UI(Context* context) :
  64. Object(context),
  65. rootWidget_(0),
  66. inputDisabled_(false),
  67. keyboardDisabled_(false),
  68. initialized_(false),
  69. skinLoaded_(false)
  70. {
  71. }
  72. UI::~UI()
  73. {
  74. if (initialized_)
  75. {
  76. tb::TBWidgetListener::RemoveGlobalListener(this);
  77. TBFile::SetReaderFunction(0);
  78. TBID::tbidRegisterCallback = 0;
  79. tb::TBWidgetsAnimationManager::Shutdown();
  80. widgetWrap_.Clear();
  81. delete rootWidget_;
  82. // leak
  83. //delete TBUIRenderer::renderer_;
  84. tb_core_shutdown();
  85. }
  86. uiContext_ = 0;
  87. }
  88. void UI::Shutdown()
  89. {
  90. SetInputDisabled(true);
  91. }
  92. void UI::Initialize(const String& languageFile)
  93. {
  94. Graphics* graphics = GetSubsystem<Graphics>();
  95. assert(graphics);
  96. assert(graphics->IsInitialized());
  97. graphics_ = graphics;
  98. vertexBuffer_ = new VertexBuffer(context_);
  99. uiContext_ = context_;
  100. TBFile::SetReaderFunction(TBFileReader);
  101. TBID::tbidRegisterCallback = UI::TBIDRegisterStringCallback;
  102. TBWidgetsAnimationManager::Init();
  103. renderer_ = new UIRenderer(graphics_->GetContext());
  104. tb_core_init(renderer_, languageFile.CString());
  105. //register_tbbf_font_renderer();
  106. //register_stb_font_renderer();
  107. register_freetype_font_renderer();
  108. rootWidget_ = new TBWidget();
  109. int width = graphics_->GetWidth();
  110. int height = graphics_->GetHeight();
  111. rootWidget_->SetSize(width, height);
  112. rootWidget_->SetVisibilility(tb::WIDGET_VISIBILITY_VISIBLE);
  113. // register the UIDragDrop subsystem
  114. context_->RegisterSubsystem(new UIDragDrop(context_));
  115. SubscribeToEvent(E_MOUSEBUTTONDOWN, HANDLER(UI, HandleMouseButtonDown));
  116. SubscribeToEvent(E_MOUSEBUTTONUP, HANDLER(UI, HandleMouseButtonUp));
  117. SubscribeToEvent(E_MOUSEMOVE, HANDLER(UI, HandleMouseMove));
  118. SubscribeToEvent(E_MOUSEWHEEL, HANDLER(UI, HandleMouseWheel));
  119. SubscribeToEvent(E_KEYDOWN, HANDLER(UI, HandleKeyDown));
  120. SubscribeToEvent(E_KEYUP, HANDLER(UI, HandleKeyUp));
  121. SubscribeToEvent(E_TEXTINPUT, HANDLER(UI, HandleTextInput));
  122. SubscribeToEvent(E_UPDATE, HANDLER(UI, HandleUpdate));
  123. SubscribeToEvent(E_RENDERUPDATE, HANDLER(UI, HandleRenderUpdate));
  124. tb::TBWidgetListener::AddGlobalListener(this);
  125. initialized_ = true;
  126. SystemUI::SystemUI* systemUI = new SystemUI::SystemUI(context_);
  127. context_->RegisterSubsystem(systemUI);
  128. systemUI->CreateConsoleAndDebugHud();
  129. //TB_DEBUG_SETTING(LAYOUT_BOUNDS) = 1;
  130. }
  131. void UI::LoadSkin(const String& skin, const String& overrideSkin)
  132. {
  133. // Load the default skin, and override skin (if any)
  134. tb::g_tb_skin->Load(skin.CString(), overrideSkin.CString());
  135. skinLoaded_ = true;
  136. }
  137. void UI::LoadDefaultPlayerSkin()
  138. {
  139. LoadSkin("DefaultUI/skin/skin.tb.txt");
  140. AddFont("DefaultUI/fonts/vera.ttf", "Vera");
  141. SetDefaultFont("Vera", 12);
  142. }
  143. void UI::SetDefaultFont(const String& name, int size)
  144. {
  145. tb::TBFontDescription fd;
  146. fd.SetID(tb::TBIDC(name.CString()));
  147. fd.SetSize(tb::g_tb_skin->GetDimensionConverter()->DpToPx(12));
  148. tb::g_font_manager->SetDefaultFontDescription(fd);
  149. // Create the font now.
  150. tb::TBFontFace *font = tb::g_font_manager->CreateFontFace(tb::g_font_manager->GetDefaultFontDescription());
  151. // Render some glyphs in one go now since we know we are going to use them. It would work fine
  152. // without this since glyphs are rendered when needed, but with some extra updating of the glyph bitmap.
  153. if (font)
  154. font->RenderGlyphs(" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~•·åäöÅÄÖ");
  155. }
  156. void UI::AddFont(const String& fontFile, const String& name)
  157. {
  158. tb::g_font_manager->AddFontInfo(fontFile.CString(), name.CString());
  159. }
  160. void UI::Render(VertexBuffer* buffer, const PODVector<UIBatch>& batches, unsigned batchStart, unsigned batchEnd)
  161. {
  162. if (batches.Empty())
  163. return;
  164. Vector2 invScreenSize(1.0f / (float)graphics_->GetWidth(), 1.0f / (float)graphics_->GetHeight());
  165. Vector2 scale(2.0f * invScreenSize.x_, -2.0f * invScreenSize.y_);
  166. Vector2 offset(-1.0f, 1.0f);
  167. Matrix4 projection(Matrix4::IDENTITY);
  168. projection.m00_ = scale.x_;
  169. projection.m03_ = offset.x_;
  170. projection.m11_ = scale.y_;
  171. projection.m13_ = offset.y_;
  172. projection.m22_ = 1.0f;
  173. projection.m23_ = 0.0f;
  174. projection.m33_ = 1.0f;
  175. graphics_->ClearParameterSources();
  176. graphics_->SetColorWrite(true);
  177. graphics_->SetCullMode(CULL_NONE);
  178. graphics_->SetDepthTest(CMP_ALWAYS);
  179. graphics_->SetDepthWrite(false);
  180. graphics_->SetFillMode(FILL_SOLID);
  181. graphics_->SetStencilTest(false);
  182. graphics_->ResetRenderTargets();
  183. graphics_->SetVertexBuffer(buffer);
  184. ShaderVariation* noTextureVS = graphics_->GetShader(VS, "Basic", "VERTEXCOLOR");
  185. ShaderVariation* diffTextureVS = graphics_->GetShader(VS, "Basic", "DIFFMAP VERTEXCOLOR");
  186. ShaderVariation* noTexturePS = graphics_->GetShader(PS, "Basic", "VERTEXCOLOR");
  187. ShaderVariation* diffTexturePS = graphics_->GetShader(PS, "Basic", "DIFFMAP VERTEXCOLOR");
  188. ShaderVariation* diffMaskTexturePS = graphics_->GetShader(PS, "Basic", "DIFFMAP ALPHAMASK VERTEXCOLOR");
  189. ShaderVariation* alphaTexturePS = graphics_->GetShader(PS, "Basic", "ALPHAMAP VERTEXCOLOR");
  190. unsigned alphaFormat = Graphics::GetAlphaFormat();
  191. for (unsigned i = batchStart; i < batchEnd; ++i)
  192. {
  193. const UIBatch& batch = batches[i];
  194. if (batch.vertexStart_ == batch.vertexEnd_)
  195. continue;
  196. ShaderVariation* ps;
  197. ShaderVariation* vs;
  198. if (!batch.texture_)
  199. {
  200. ps = noTexturePS;
  201. vs = noTextureVS;
  202. }
  203. else
  204. {
  205. // If texture contains only an alpha channel, use alpha shader (for fonts)
  206. vs = diffTextureVS;
  207. if (batch.texture_->GetFormat() == alphaFormat)
  208. ps = alphaTexturePS;
  209. else if (batch.blendMode_ != BLEND_ALPHA && batch.blendMode_ != BLEND_ADDALPHA && batch.blendMode_ != BLEND_PREMULALPHA)
  210. ps = diffMaskTexturePS;
  211. else
  212. ps = diffTexturePS;
  213. }
  214. graphics_->SetShaders(vs, ps);
  215. if (graphics_->NeedParameterUpdate(SP_OBJECT, this))
  216. graphics_->SetShaderParameter(VSP_MODEL, Matrix3x4::IDENTITY);
  217. if (graphics_->NeedParameterUpdate(SP_CAMERA, this))
  218. graphics_->SetShaderParameter(VSP_VIEWPROJ, projection);
  219. if (graphics_->NeedParameterUpdate(SP_MATERIAL, this))
  220. graphics_->SetShaderParameter(PSP_MATDIFFCOLOR, Color(1.0f, 1.0f, 1.0f, 1.0f));
  221. graphics_->SetBlendMode(batch.blendMode_);
  222. graphics_->SetScissorTest(true, batch.scissor_);
  223. graphics_->SetTexture(0, batch.texture_);
  224. graphics_->Draw(TRIANGLE_LIST, batch.vertexStart_ / UI_VERTEX_SIZE, (batch.vertexEnd_ - batch.vertexStart_) /
  225. UI_VERTEX_SIZE);
  226. }
  227. }
  228. void UI::SetVertexData(VertexBuffer* dest, const PODVector<float>& vertexData)
  229. {
  230. if (vertexData.Empty())
  231. return;
  232. // Update quad geometry into the vertex buffer
  233. // Resize the vertex buffer first if too small or much too large
  234. unsigned numVertices = vertexData.Size() / UI_VERTEX_SIZE;
  235. if (dest->GetVertexCount() < numVertices || dest->GetVertexCount() > numVertices * 2)
  236. dest->SetSize(numVertices, MASK_POSITION | MASK_COLOR | MASK_TEXCOORD1, true);
  237. dest->SetData(&vertexData[0]);
  238. }
  239. void UI::Render(bool resetRenderTargets)
  240. {
  241. SetVertexData(vertexBuffer_, vertexData_);
  242. Render(vertexBuffer_, batches_, 0, batches_.Size());
  243. GetSubsystem<SystemUI::SystemUI>()->Render();
  244. }
  245. void UI::HandleRenderUpdate(StringHash eventType, VariantMap& eventData)
  246. {
  247. // Get rendering batches from the non-modal UI elements
  248. batches_.Clear();
  249. vertexData_.Clear();
  250. tb::TBRect rect = rootWidget_->GetRect();
  251. IntRect currentScissor = IntRect(0, 0, rect.w, rect.h);
  252. GetBatches(batches_, vertexData_, currentScissor);
  253. }
  254. void UI::GetBatches(PODVector<UIBatch>& batches, PODVector<float>& vertexData, const IntRect& currentScissor)
  255. {
  256. //if (!initialized_)
  257. // return;
  258. TBAnimationManager::Update();
  259. rootWidget_->InvokeProcessStates();
  260. rootWidget_->InvokeProcess();
  261. tb::g_renderer->BeginPaint(rootWidget_->GetRect().w, rootWidget_->GetRect().h);
  262. renderer_->currentScissor_ = currentScissor;
  263. renderer_->batches_ = &batches;
  264. renderer_->vertexData_ = &vertexData;
  265. rootWidget_->InvokePaint(tb::TBWidget::PaintProps());
  266. tb::g_renderer->EndPaint();
  267. }
  268. void UI::SubmitBatchVertexData(Texture* texture, const PODVector<float>& vertexData)
  269. {
  270. UIBatch b(BLEND_ALPHA , renderer_->currentScissor_, texture, &vertexData_);
  271. unsigned begin = b.vertexData_->Size();
  272. b.vertexData_->Resize(begin + vertexData.Size());
  273. float* dest = &(b.vertexData_->At(begin));
  274. b.vertexEnd_ = b.vertexData_->Size();
  275. for (unsigned i = 0; i < vertexData.Size(); i++, dest++)
  276. {
  277. *dest = vertexData[i];
  278. }
  279. UIBatch::AddOrMerge(b, batches_);
  280. }
  281. void UI::TBFileReader(const char* filename, void** data, unsigned* length)
  282. {
  283. *data = 0;
  284. *length = 0;
  285. ResourceCache* cache = uiContext_->GetSubsystem<ResourceCache>();
  286. SharedPtr<File> file = cache->GetFile(filename);
  287. if (!file || !file->IsOpen())
  288. {
  289. LOGERRORF("UI::TBFileReader: Unable to load file: %s", filename);
  290. return;
  291. }
  292. unsigned size = file->GetSize();
  293. if (!size)
  294. return;
  295. void* _data = malloc(size);
  296. if (!_data)
  297. return;
  298. if (file->Read(_data, size) != size)
  299. {
  300. free(_data);
  301. return;
  302. }
  303. *length = size;
  304. *data = _data;
  305. }
  306. void UI::GetTBIDString(unsigned id, String& value)
  307. {
  308. if (!id)
  309. {
  310. value = "";
  311. }
  312. else
  313. {
  314. value = tbidToString_[id];
  315. }
  316. }
  317. void UI::TBIDRegisterStringCallback(unsigned id, const char* value)
  318. {
  319. uiContext_->GetSubsystem<UI>()->tbidToString_[id] = String(value);
  320. }
  321. bool UI::LoadResourceFile(TBWidget* widget, const String& filename)
  322. {
  323. tb::TBNode node;
  324. if (!node.ReadFile(filename.CString()))
  325. return false;
  326. tb::g_widgets_reader->LoadNodeTree(widget, &node);
  327. return true;
  328. }
  329. void UI::HandleScreenMode(StringHash eventType, VariantMap& eventData)
  330. {
  331. using namespace ScreenMode;
  332. rootWidget_->SetSize(eventData[P_WIDTH].GetInt(), eventData[P_HEIGHT].GetInt());
  333. //SetSize(eventData[P_WIDTH].GetInt(), eventData[P_HEIGHT].GetInt());
  334. }
  335. void UI::HandleUpdate(StringHash eventType, VariantMap& eventData)
  336. {
  337. TBMessageHandler::ProcessMessages();
  338. }
  339. bool UI::IsWidgetWrapped(tb::TBWidget* widget)
  340. {
  341. return widgetWrap_.Contains(widget);
  342. }
  343. bool UI::UnwrapWidget(tb::TBWidget* widget)
  344. {
  345. if (widgetWrap_.Contains(widget))
  346. {
  347. widgetWrap_.Erase(widget);
  348. return true;
  349. }
  350. return false;
  351. }
  352. void UI::PruneUnreachableWidgets()
  353. {
  354. HashMap<tb::TBWidget*, SharedPtr<UIWidget>>::Iterator itr;
  355. for (itr = widgetWrap_.Begin(); itr != widgetWrap_.End(); )
  356. {
  357. if ((*itr).first_->GetParent() || (*itr).second_->JSGetHeapPtr())
  358. {
  359. itr++;
  360. continue;
  361. }
  362. tb::TBWidget* toDelete = (*itr).first_;
  363. itr.GotoNext();
  364. delete toDelete;
  365. // this will likely be flagged by valgrind as accessing invalid memory
  366. assert(!widgetWrap_.Contains(toDelete));
  367. }
  368. }
  369. void UI::WrapWidget(UIWidget* widget, tb::TBWidget* tbwidget)
  370. {
  371. assert (!widgetWrap_.Contains(tbwidget));
  372. widgetWrap_[tbwidget] = widget;
  373. }
  374. UIWidget* UI::WrapWidget(tb::TBWidget* widget)
  375. {
  376. if (!widget)
  377. return NULL;
  378. if (widgetWrap_.Contains(widget))
  379. return widgetWrap_[widget];
  380. // switch this to use a factory?
  381. // this is order dependent as we're using IsOfType which also works if a base class
  382. if (widget->IsOfType<TBDimmer>())
  383. {
  384. UIDimmer* dimmer = new UIDimmer(context_, false);
  385. dimmer->SetWidget(widget);
  386. widgetWrap_[widget] = dimmer;
  387. return dimmer;
  388. }
  389. if (widget->IsOfType<TBScrollContainer>())
  390. {
  391. UIScrollContainer* container = new UIScrollContainer(context_, false);
  392. container->SetWidget(widget);
  393. widgetWrap_[widget] = container;
  394. return container;
  395. }
  396. if (widget->IsOfType<TBInlineSelect>())
  397. {
  398. UIInlineSelect* select = new UIInlineSelect(context_, false);
  399. select->SetWidget(widget);
  400. widgetWrap_[widget] = select;
  401. return select;
  402. }
  403. if (widget->IsOfType<TBSection>())
  404. {
  405. UISection* section = new UISection(context_, false);
  406. section->SetWidget(widget);
  407. widgetWrap_[widget] = section;
  408. return section;
  409. }
  410. if (widget->IsOfType<TBSeparator>())
  411. {
  412. UISeparator* sep = new UISeparator(context_, false);
  413. sep->SetWidget(widget);
  414. widgetWrap_[widget] = sep;
  415. return sep;
  416. }
  417. if (widget->IsOfType<TBContainer>())
  418. {
  419. UIContainer* container = new UIContainer(context_, false);
  420. container->SetWidget(widget);
  421. widgetWrap_[widget] = container;
  422. return container;
  423. }
  424. if (widget->IsOfType<TBButton>())
  425. {
  426. // don't wrap the close button of a TBWindow.close
  427. if (widget->GetID() == TBIDC("TBWindow.close"))
  428. return 0;
  429. UIButton* button = new UIButton(context_, false);
  430. button->SetWidget(widget);
  431. widgetWrap_[widget] = button;
  432. return button;
  433. }
  434. if (widget->IsOfType<TBTextField>())
  435. {
  436. UITextField* textfield = new UITextField(context_, false);
  437. textfield->SetWidget(widget);
  438. widgetWrap_[widget] = textfield;
  439. return textfield;
  440. }
  441. if (widget->IsOfType<TBEditField>())
  442. {
  443. UIEditField* editfield = new UIEditField(context_, false);
  444. editfield->SetWidget(widget);
  445. widgetWrap_[widget] = editfield;
  446. return editfield;
  447. }
  448. if (widget->IsOfType<TBSkinImage>())
  449. {
  450. UISkinImage* skinimage = new UISkinImage(context_, "", false);
  451. skinimage->SetWidget(widget);
  452. widgetWrap_[widget] = skinimage;
  453. return skinimage;
  454. }
  455. if (widget->IsOfType<TBImageWidget>())
  456. {
  457. UIImageWidget* imagewidget = new UIImageWidget(context_, false);
  458. imagewidget->SetWidget(widget);
  459. widgetWrap_[widget] = imagewidget;
  460. return imagewidget;
  461. }
  462. if (widget->IsOfType<TBClickLabel>())
  463. {
  464. UIClickLabel* nwidget = new UIClickLabel(context_, false);
  465. nwidget->SetWidget(widget);
  466. widgetWrap_[widget] = nwidget;
  467. return nwidget;
  468. }
  469. if (widget->IsOfType<TBCheckBox>())
  470. {
  471. UICheckBox* nwidget = new UICheckBox(context_, false);
  472. nwidget->SetWidget(widget);
  473. widgetWrap_[widget] = nwidget;
  474. return nwidget;
  475. }
  476. if (widget->IsOfType<TBSelectList>())
  477. {
  478. UISelectList* nwidget = new UISelectList(context_, false);
  479. nwidget->SetWidget(widget);
  480. widgetWrap_[widget] = nwidget;
  481. return nwidget;
  482. }
  483. if (widget->IsOfType<TBMessageWindow>())
  484. {
  485. UIMessageWindow* nwidget = new UIMessageWindow(context_, NULL, "", false);
  486. nwidget->SetWidget(widget);
  487. widgetWrap_[widget] = nwidget;
  488. return nwidget;
  489. }
  490. if (widget->IsOfType<TBTabContainer>())
  491. {
  492. UITabContainer* nwidget = new UITabContainer(context_, false);
  493. nwidget->SetWidget(widget);
  494. widgetWrap_[widget] = nwidget;
  495. return nwidget;
  496. }
  497. if (widget->IsOfType<SceneViewWidget>())
  498. {
  499. UISceneView* nwidget = new UISceneView(context_, false);
  500. nwidget->SetWidget(widget);
  501. widgetWrap_[widget] = nwidget;
  502. return nwidget;
  503. }
  504. if (widget->IsOfType<TBLayout>())
  505. {
  506. UILayout* layout = new UILayout(context_, (UI_AXIS) widget->GetAxis(), false);
  507. layout->SetWidget(widget);
  508. widgetWrap_[widget] = layout;
  509. return layout;
  510. }
  511. if (widget->IsOfType<TBWidget>())
  512. {
  513. UIWidget* nwidget = new UIWidget(context_, false);
  514. nwidget->SetWidget(widget);
  515. widgetWrap_[widget] = nwidget;
  516. return nwidget;
  517. }
  518. return 0;
  519. }
  520. void UI::OnWidgetDelete(tb::TBWidget *widget)
  521. {
  522. }
  523. bool UI::OnWidgetDying(tb::TBWidget *widget)
  524. {
  525. return false;
  526. }
  527. }