From 5085a13c214db03cf29ed60df3da32fc304f6ec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Wed, 11 Feb 2026 21:17:16 -0300 Subject: [PATCH] Added a few models. --- bin/assets/plugins/aiassistant.json | 14 +- src/tests/ui_perf_test/ui_perf_test.cpp | 582 ++++++++++++------------ 2 files changed, 305 insertions(+), 291 deletions(-) diff --git a/bin/assets/plugins/aiassistant.json b/bin/assets/plugins/aiassistant.json index 5e2cc7a3a..79e6a7dd5 100644 --- a/bin/assets/plugins/aiassistant.json +++ b/bin/assets/plugins/aiassistant.json @@ -434,7 +434,19 @@ }, { "name": "stepfun/step-3.5-flash:free", - "display_name": "StepFun: Step 3.5 Flash" + "display_name": "StepFun: Step 3.5 Flash (free)" + }, + { + "name": "z-ai/glm-4.7", + "display_name": "GLM 4.7" + }, + { + "name": "z-ai/glm-5", + "display_name": "GLM 5" + }, + { + "name": "qwen/qwen3-coder:free", + "display_name": "Qwen3 Coder 480B A35B (free)" } ] }, diff --git a/src/tests/ui_perf_test/ui_perf_test.cpp b/src/tests/ui_perf_test/ui_perf_test.cpp index 52ea79e67..8790d7d93 100644 --- a/src/tests/ui_perf_test/ui_perf_test.cpp +++ b/src/tests/ui_perf_test/ui_perf_test.cpp @@ -1,6 +1,10 @@ #include #include +// This file is used to test some UI related stuffs. +// It's not a benchmark or a real test suite. +// It's just used to test whatever I need to test at any given moment. + using namespace EE::UI::Abstract; class TestModel : public Model { @@ -98,10 +102,6 @@ class TestModel : public Model { virtual void update() {} }; -// This file is used to test some UI related stuffs. -// It's not a benchmark or a real test suite. -// It's just used to test whatever I need to test at any given moment. - EE::Window::Window* win = NULL; void mainLoop() { @@ -151,303 +151,305 @@ void mainLoop() { } } -EE_MAIN_FUNC int main( int, char*[] ) { - { - // Text::TextShaperEnabled = true; - // Text::TextShaperOptimizations = false; - UIApplication app( WindowSettings( 1024, 650, "eepp - TextEdit", WindowStyle::Default, - WindowBackend::Default, 32, {}, 1, false, true ), - UIApplication::Settings( {}, 1.5f ) ); - FileSystem::changeWorkingDirectory( Sys::getProcessPath() ); - auto ll = UILinearLayout::NewVertical(); - ll->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent ); - auto editor = UITextView::New(); - /* - auto editor = UITextEdit::New(); - editor->setShowLineNumber( false ); - */ - editor->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent ); - editor->setParent( ll ); - // editor->setFontSize( PixelDensity::dpToPx( 12 ) ); - FontManager::instance()->addFallbackFont( - FontTrueType::New( "arabic", "unit_tests/assets/fonts/NotoNaskhArabic-Regular.ttf" ) ); - FontManager::instance()->addFallbackFont( FontTrueType::New( - "NotoSerifBengali-Regular", "unit_tests/assets/fonts/NotoSansBengali-Regular.ttf" ) ); - editor->setWordWrap( true ); - // editor->setLineWrapMode( LineWrapMode::Word ); - // editor->setFont( FontManager::instance()->getByName( "monospace" ) ); - // editor->loadFromFile( "unit_tests/assets/textfiles/test-arabic-simple.uext" ); - // editor->loadFromFile( "unit_tests/assets/textfiles/test-arabic.uext" ); - // editor->loadFromFile( "unit_tests/assets/textfiles/test-bengali.uext" ); - // editor->loadFromFile( "unit_tests/assets/textfiles/test-flags.uext" ); - // editor->loadFromFile( "unit_tests/assets/textformat/english.utf8.lf.nobom.txt" ); - // editor->loadFromFile( "unit_tests/assets/textfiles/test-arabic-mixed.uext" ); - // editor->loadFromFile( "unit_tests/assets/textfiles/test-mixed-text.uext" ); - // editor->loadFromFile( "unit_tests/assets/textfiles/lorem-ipsum.uext" ); - std::string buffer; - FileSystem::fileGet( "unit_tests/assets/textfiles/quota.uext", buffer ); - editor->setText( buffer ); - editor->setTextSelectionEnabled( true ); - editor->setTextSelectionRange( { 51, 286 } ); +int testTextRendering() { + // Text::TextShaperEnabled = true; + // Text::TextShaperOptimizations = false; + UIApplication app( WindowSettings( 1024, 650, "eepp - TextEdit", WindowStyle::Default, + WindowBackend::Default, 32, {}, 1, false, true ), + UIApplication::Settings( {}, 1.5f ) ); + FileSystem::changeWorkingDirectory( Sys::getProcessPath() ); + auto ll = UILinearLayout::NewVertical(); + ll->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent ); + auto editor = UITextView::New(); + /* + auto editor = UITextEdit::New(); + editor->setShowLineNumber( false ); + */ + editor->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent ); + editor->setParent( ll ); + // editor->setFontSize( PixelDensity::dpToPx( 12 ) ); + FontManager::instance()->addFallbackFont( + FontTrueType::New( "arabic", "unit_tests/assets/fonts/NotoNaskhArabic-Regular.ttf" ) ); + FontManager::instance()->addFallbackFont( FontTrueType::New( + "NotoSerifBengali-Regular", "unit_tests/assets/fonts/NotoSansBengali-Regular.ttf" ) ); + editor->setWordWrap( true ); + // editor->setLineWrapMode( LineWrapMode::Word ); + // editor->setFont( FontManager::instance()->getByName( "monospace" ) ); + // editor->loadFromFile( "unit_tests/assets/textfiles/test-arabic-simple.uext" ); + // editor->loadFromFile( "unit_tests/assets/textfiles/test-arabic.uext" ); + // editor->loadFromFile( "unit_tests/assets/textfiles/test-bengali.uext" ); + // editor->loadFromFile( "unit_tests/assets/textfiles/test-flags.uext" ); + // editor->loadFromFile( "unit_tests/assets/textformat/english.utf8.lf.nobom.txt" ); + // editor->loadFromFile( "unit_tests/assets/textfiles/test-arabic-mixed.uext" ); + // editor->loadFromFile( "unit_tests/assets/textfiles/test-mixed-text.uext" ); + // editor->loadFromFile( "unit_tests/assets/textfiles/lorem-ipsum.uext" ); + std::string buffer; + FileSystem::fileGet( "unit_tests/assets/textfiles/quota.uext", buffer ); + editor->setText( buffer ); + editor->setTextSelectionEnabled( true ); + editor->setTextSelectionRange( { 51, 286 } ); - editor->setFont( app.getUI()->getUIThemeManager()->getDefaultFont() ); - editor->on( Event::KeyUp, [&]( const Event* event ) { - if ( event->asKeyEvent()->getKeyCode() == KEY_F1 ) { - // Text::TextShaperEnabled = !Text::TextShaperEnabled; - // Text::TextShaperOptimizations = !Text::TextShaperOptimizations; - app.getUI()->getRoot()->invalidateDraw(); - } - } ); - return app.run(); - } + editor->setFont( app.getUI()->getUIThemeManager()->getDefaultFont() ); + editor->on( Event::KeyUp, [&]( const Event* event ) { + if ( event->asKeyEvent()->getKeyCode() == KEY_F1 ) { + // Text::TextShaperEnabled = !Text::TextShaperEnabled; + // Text::TextShaperOptimizations = !Text::TextShaperOptimizations; + app.getUI()->getRoot()->invalidateDraw(); + } + } ); + return app.run(); +} + +EE_MAIN_FUNC int main( int, char*[] ) { + return testTextRendering(); win = Engine::instance()->createWindow( WindowSettings( 1366, 768, "eepp - UI Perf Test" ) ); - if ( win->isOpen() ) { - FileSystem::changeWorkingDirectory( Sys::getProcessPath() ); - PixelDensity::setPixelDensity( - Engine::instance()->getDisplayManager()->getDisplayIndex( 0 )->getPixelDensity() ); - FontTrueType* font = - FontTrueType::New( "NotoSans-Regular", "assets/fonts/NotoSans-Regular.ttf" ); - FontTrueType* iconFont = FontTrueType::New( "icon", "assets/fonts/remixicon.ttf" ); - UIIconTheme* iconTheme = UIIconTheme::New( "remixicon" ); - auto addIcon = [iconTheme, iconFont]( const std::string& name, - const Uint32& codePoint ) -> UIIcon* { - auto* icon = UIGlyphIcon::New( name, iconFont, codePoint ); - iconTheme->add( icon ); - return icon; - }; - addIcon( "folder", 0xed6a ); - addIcon( "folder-open", 0xed70 ); - addIcon( "tree-expanded", 0xea50 ); - addIcon( "tree-contracted", 0xea54 ); - addIcon( "file", 0xecc3 ); - // addIcon( "arrow-up", 0xea78 ); - // addIcon( "arrow-down", 0xea4e ); - UISceneNode* uiSceneNode = UISceneNode::New(); - SceneManager::instance()->add( uiSceneNode ); - uiSceneNode->getUIThemeManager()->setDefaultFont( font ); - uiSceneNode->getUIIconThemeManager()->setCurrentTheme( iconTheme ); - /*StyleSheetParser styleSheetParser; - styleSheetParser.loadFromFile( "assets/ui/breeze.css" ); - uiSceneNode->setStyleSheet( styleSheetParser.getStyleSheet() );*/ - std::string pd; - if ( PixelDensity::getPixelDensity() >= 1.5f ) - pd = "1.5x"; - else if ( PixelDensity::getPixelDensity() >= 2.f ) - pd = "2x"; - /*UITheme* theme = - UITheme::load( "uitheme" + pd, "uitheme" + pd, "assets/ui/uitheme" + pd + ".eta", font, - "assets/ui/uitheme.css" );*/ - UITheme* theme = UITheme::load( "breeze", "breeze", "", font, "assets/ui/breeze.css" ); - uiSceneNode->setStyleSheet( theme->getStyleSheet() ); - uiSceneNode->getUIThemeManager() - ->setDefaultEffectsEnabled( true ) - ->setDefaultTheme( theme ) - ->setDefaultFont( font ) - ->add( theme ); + if ( !win->isOpen() ) + return EXIT_FAILURE; - /* - auto* vlay = UILinearLayout::NewVertical(); - vlay->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent ); + FileSystem::changeWorkingDirectory( Sys::getProcessPath() ); + PixelDensity::setPixelDensity( + Engine::instance()->getDisplayManager()->getDisplayIndex( 0 )->getPixelDensity() ); + FontTrueType* font = + FontTrueType::New( "NotoSans-Regular", "assets/fonts/NotoSans-Regular.ttf" ); + FontTrueType* iconFont = FontTrueType::New( "icon", "assets/fonts/remixicon.ttf" ); + UIIconTheme* iconTheme = UIIconTheme::New( "remixicon" ); + auto addIcon = [iconTheme, iconFont]( const std::string& name, + const Uint32& codePoint ) -> UIIcon* { + auto* icon = UIGlyphIcon::New( name, iconFont, codePoint ); + iconTheme->add( icon ); + return icon; + }; + addIcon( "folder", 0xed6a ); + addIcon( "folder-open", 0xed70 ); + addIcon( "tree-expanded", 0xea50 ); + addIcon( "tree-contracted", 0xea54 ); + addIcon( "file", 0xecc3 ); + // addIcon( "arrow-up", 0xea78 ); + // addIcon( "arrow-down", 0xea4e ); + UISceneNode* uiSceneNode = UISceneNode::New(); + SceneManager::instance()->add( uiSceneNode ); + uiSceneNode->getUIThemeManager()->setDefaultFont( font ); + uiSceneNode->getUIIconThemeManager()->setCurrentTheme( iconTheme ); + /*StyleSheetParser styleSheetParser; + styleSheetParser.loadFromFile( "assets/ui/breeze.css" ); + uiSceneNode->setStyleSheet( styleSheetParser.getStyleSheet() );*/ + std::string pd; + if ( PixelDensity::getPixelDensity() >= 1.5f ) + pd = "1.5x"; + else if ( PixelDensity::getPixelDensity() >= 2.f ) + pd = "2x"; + /*UITheme* theme = + UITheme::load( "uitheme" + pd, "uitheme" + pd, "assets/ui/uitheme" + pd + ".eta", font, + "assets/ui/uitheme.css" );*/ + UITheme* theme = UITheme::load( "breeze", "breeze", "", font, "assets/ui/breeze.css" ); + uiSceneNode->setStyleSheet( theme->getStyleSheet() ); + uiSceneNode->getUIThemeManager() + ->setDefaultEffectsEnabled( true ) + ->setDefaultTheme( theme ) + ->setDefaultFont( font ) + ->add( theme ); - Clock clock; - auto model = FileSystemModel::New( "." ); // std::make_shared(); - // UITreeView* view = UITreeView::New(); - UITableView* view = UITableView::New(); - // view->setExpanderIconSize( PixelDensity::dpToPx( 20 ) ); - view->setId( "treeview" ); - view->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent ); - view->setParent( vlay ); - view->setModel( SortingProxyModel::New( model ) ); - Log::notice( "Total time: %.2fms", clock.getElapsedTime().asMilliseconds() ); - */ + /* + auto* vlay = UILinearLayout::NewVertical(); + vlay->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent ); - /* ListBox test */ - /* - std::vector strings; - for ( size_t i = 0; i < 10000; i++ ) - strings.emplace_back( String::format( - "This is a very long string number %ld. Cover the full width of the - listbox.", i ) ); auto* lbox = UIListBox::New(); std::cout << "Time New: " << - clock.getElapsedTime().asMilliseconds() << " ms" << std::endl; lbox->setParent( vlay ); - std::cout << "Time setParent: " << clock.getElapsedTime().asMilliseconds() << " ms" - << std::endl; - lbox->setLayoutMargin( Rectf( 4, 4, 4, 4 ) ); - std::cout << "Time setLayoutMargin: " << clock.getElapsedTime().asMilliseconds() << - " ms" - << std::endl; - lbox->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent ); - std::cout << "Time setLayoutSizePolicy: " << clock.getElapsedTime().asMilliseconds() - << " ms" << std::endl; - for ( size_t i = 0; i < 10; i++ ) - lbox->addListBoxItem( String::format( - "This is a very long string number %ld. Cover the full width of the - listbox.", i ) ); std::cout << "Time addListBoxItem: " << - clock.getElapsedTime().asMilliseconds() << " ms" - << std::endl; - lbox->addListBoxItems( strings ); - std::cout << "Time addListBoxItems: " << clock.getElapsedTime().asMilliseconds() << - " ms" - << std::endl; - */ + Clock clock; + auto model = FileSystemModel::New( "." ); // std::make_shared(); + // UITreeView* view = UITreeView::New(); + UITableView* view = UITableView::New(); + // view->setExpanderIconSize( PixelDensity::dpToPx( 20 ) ); + view->setId( "treeview" ); + view->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent ); + view->setParent( vlay ); + view->setModel( SortingProxyModel::New( model ) ); + Log::notice( "Total time: %.2fms", clock.getElapsedTime().asMilliseconds() ); + */ - Clock total; - /* Create Widget test */ + /* ListBox test */ + /* + std::vector strings; + for ( size_t i = 0; i < 10000; i++ ) + strings.emplace_back( String::format( + "This is a very long string number %ld. Cover the full width of the + listbox.", i ) ); auto* lbox = UIListBox::New(); std::cout << "Time New: " << + clock.getElapsedTime().asMilliseconds() << " ms" << std::endl; lbox->setParent( vlay ); + std::cout << "Time setParent: " << clock.getElapsedTime().asMilliseconds() << " ms" + << std::endl; + lbox->setLayoutMargin( Rectf( 4, 4, 4, 4 ) ); + std::cout << "Time setLayoutMargin: " << clock.getElapsedTime().asMilliseconds() << + " ms" + << std::endl; + lbox->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent ); + std::cout << "Time setLayoutSizePolicy: " << clock.getElapsedTime().asMilliseconds() + << " ms" << std::endl; + for ( size_t i = 0; i < 10; i++ ) + lbox->addListBoxItem( String::format( + "This is a very long string number %ld. Cover the full width of the + listbox.", i ) ); std::cout << "Time addListBoxItem: " << + clock.getElapsedTime().asMilliseconds() << " ms" + << std::endl; + lbox->addListBoxItems( strings ); + std::cout << "Time addListBoxItems: " << clock.getElapsedTime().asMilliseconds() << + " ms" + << std::endl; + */ - for ( size_t i = 0; i < 10000; i++ ) { - UINode::New(); - } - std::cout << "Time 10k UINode total: " << total.getElapsedTime().toString() << std::endl; - uiSceneNode->getRoot()->closeAllChildren(); + Clock total; + /* Create Widget test */ - total.restart(); - for ( size_t i = 0; i < 10000; i++ ) { - UIWidget::New(); - } - std::cout << "Time 10k UIWidget total: " << total.getElapsedTime().toString() << std::endl; - uiSceneNode->getRoot()->closeAllChildren(); - - auto* rl = UIRelativeLayout::New(); - rl->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent ); - - auto* sv = UIScrollView::New(); - sv->setParent( rl ); - sv->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent ); - auto* parent = UILinearLayout::NewVertical(); - parent->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ); - parent->setParent( sv ); - - total.restart(); - for ( size_t i = 0; i < 10000; i++ ) { - auto* but = UIPushButton::New(); - but->setText( String::format( "Button %zu", i ) ); - but->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ); - but->setParent( parent )->clipEnable(); - } - std::cout << "Time 10k UIPushButton total: " << total.getElapsedTime().toString() - << std::endl; - - // uiSceneNode->getRoot()->closeAllChildren(); - total.restart(); - SceneManager::instance()->update(); - std::cout << "SceneManager::instance()->update(): " << total.getElapsedTime().toString() - << std::endl; - - /* - auto* main = UIRelativeLayout::New(); - main->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent ); - auto* sv = UIScrollView::New(); - sv->setParent( main ); - sv->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent ); - sv->setPixelsSize( win->getSize().asFloat() ); - auto* vlay = UILinearLayout::NewVertical(); - vlay->setParent( sv ); - vlay->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ); - - total.restart(); - for ( size_t i = 0; i < 100000; i++ ) { - auto* widget = UIWidget::New(); - widget->setParent( vlay ); - widget->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::Fixed ); - widget->setSize( Sizef( 0, 4 ) ); - Colorf col; - col.hsv.h = Math::randf( 0, 360 ); - col.hsv.s = 1; - col.hsv.v = 1; - col.hsv.a = 1; - widget->setBackgroundColor( Color::fromHsv( col ) ); - } - std::cout << "Time UIWidget total: " << total.getElapsedTime().asMilliseconds() << " - ms" - << std::endl; - */ - /* - UIWindow* wind = UIWindow::New(); - wind->setSize( 500, 500 ); - wind->setWindowFlags( UI_WIN_DEFAULT_FLAGS | UI_WIN_RESIZEABLE | - UI_WIN_MAXIMIZE_BUTTON ); - - UILinearLayout* layWin = UILinearLayout::NewVertical(); - layWin->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent ); - layWin->setParent( wind ); - - UILinearLayout* layPar = UILinearLayout::NewHorizontal(); - layPar->setParent( layWin ); - layPar->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ); - layPar->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ); - layPar->setLayoutGravity( UI_VALIGN_CENTER | UI_HALIGN_CENTER ); - layPar->setBackgroundColor( 0x999999FF ); - - UILinearLayout* lay = UILinearLayout::NewVertical(); - lay->setLayoutGravity( UI_HALIGN_CENTER | UI_VALIGN_CENTER ); - lay->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ); - lay->setBackgroundColor( 0x333333FF ); - lay->setLayoutWeight( 0.7f ); - - UITextView::New() - ->setText( "Text on test 1" ) - ->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) - ->setLayoutSizePolicy( SizePolicy::WrapContent, SizePolicy::WrapContent ) - ->setParent( lay ); - UITextView::New() - ->setText( "Text on test 2" ) - ->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) - ->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) - ->setParent( lay ); - UICheckBox::New() - ->setText( "Checkbox" ) - ->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) - ->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) - ->setParent( lay ); - UITextView::New() - ->setText( "Text on test 3" ) - ->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) - ->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) - ->setParent( lay ); - UITextView::New() - ->setText( "Text on test 4" ) - ->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) - ->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) - ->setParent( lay ); - UITextInput::New() - ->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) - ->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) - ->setParent( lay ); - - UILinearLayout* lay2 = UILinearLayout::NewVertical(); - lay2->setId( "hardlay" ); - lay2->setLayoutGravity( UI_HALIGN_CENTER | UI_VALIGN_CENTER ); - lay2->setLayoutSizePolicy( SizePolicy::Fixed, SizePolicy::WrapContent ); - lay2->setBackgroundColor( Color::Black ); - lay2->setLayoutWeight( 0.3f ); - - UIPushButton::New() - ->setText( "PushButton" ) - ->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) - ->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) - ->setLayoutGravity( UI_VALIGN_CENTER ) - ->setParent( lay2 ); - UIListBox* lbox = UIListBox::New(); - lbox->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) - ->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::Fixed ) - ->setSize( 0, 105 ) - ->setParent( lay2 ); - lbox->addListBoxItems( { "This", "is", "a", "ListBox" } ); - lay2->setParent( layPar ); - lay->setParent( layPar ); - - UIDropDownList* drop = UIDropDownList::New(); - drop->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) - ->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) - ->setParent( layWin ); - drop->getListBox()->addListBoxItems( { "Car", "Bus", "Plane", "Submarine" } ); - drop->getListBox()->setSelected( 0 ); - wind->show(); - */ - - win->runMainLoop( &mainLoop ); + for ( size_t i = 0; i < 10000; i++ ) { + UINode::New(); } + std::cout << "Time 10k UINode total: " << total.getElapsedTime().toString() << std::endl; + uiSceneNode->getRoot()->closeAllChildren(); + + total.restart(); + for ( size_t i = 0; i < 10000; i++ ) { + UIWidget::New(); + } + std::cout << "Time 10k UIWidget total: " << total.getElapsedTime().toString() << std::endl; + uiSceneNode->getRoot()->closeAllChildren(); + + auto* rl = UIRelativeLayout::New(); + rl->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent ); + + auto* sv = UIScrollView::New(); + sv->setParent( rl ); + sv->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent ); + auto* parent = UILinearLayout::NewVertical(); + parent->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ); + parent->setParent( sv ); + + total.restart(); + for ( size_t i = 0; i < 10000; i++ ) { + auto* but = UIPushButton::New(); + but->setText( String::format( "Button %zu", i ) ); + but->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ); + but->setParent( parent )->clipEnable(); + } + std::cout << "Time 10k UIPushButton total: " << total.getElapsedTime().toString() << std::endl; + + // uiSceneNode->getRoot()->closeAllChildren(); + total.restart(); + SceneManager::instance()->update(); + std::cout << "SceneManager::instance()->update(): " << total.getElapsedTime().toString() + << std::endl; + + /* + auto* main = UIRelativeLayout::New(); + main->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent ); + auto* sv = UIScrollView::New(); + sv->setParent( main ); + sv->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent ); + sv->setPixelsSize( win->getSize().asFloat() ); + auto* vlay = UILinearLayout::NewVertical(); + vlay->setParent( sv ); + vlay->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ); + + total.restart(); + for ( size_t i = 0; i < 100000; i++ ) { + auto* widget = UIWidget::New(); + widget->setParent( vlay ); + widget->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::Fixed ); + widget->setSize( Sizef( 0, 4 ) ); + Colorf col; + col.hsv.h = Math::randf( 0, 360 ); + col.hsv.s = 1; + col.hsv.v = 1; + col.hsv.a = 1; + widget->setBackgroundColor( Color::fromHsv( col ) ); + } + std::cout << "Time UIWidget total: " << total.getElapsedTime().asMilliseconds() << " + ms" + << std::endl; + */ + /* + UIWindow* wind = UIWindow::New(); + wind->setSize( 500, 500 ); + wind->setWindowFlags( UI_WIN_DEFAULT_FLAGS | UI_WIN_RESIZEABLE | + UI_WIN_MAXIMIZE_BUTTON ); + + UILinearLayout* layWin = UILinearLayout::NewVertical(); + layWin->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent ); + layWin->setParent( wind ); + + UILinearLayout* layPar = UILinearLayout::NewHorizontal(); + layPar->setParent( layWin ); + layPar->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ); + layPar->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ); + layPar->setLayoutGravity( UI_VALIGN_CENTER | UI_HALIGN_CENTER ); + layPar->setBackgroundColor( 0x999999FF ); + + UILinearLayout* lay = UILinearLayout::NewVertical(); + lay->setLayoutGravity( UI_HALIGN_CENTER | UI_VALIGN_CENTER ); + lay->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ); + lay->setBackgroundColor( 0x333333FF ); + lay->setLayoutWeight( 0.7f ); + + UITextView::New() + ->setText( "Text on test 1" ) + ->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) + ->setLayoutSizePolicy( SizePolicy::WrapContent, SizePolicy::WrapContent ) + ->setParent( lay ); + UITextView::New() + ->setText( "Text on test 2" ) + ->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) + ->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) + ->setParent( lay ); + UICheckBox::New() + ->setText( "Checkbox" ) + ->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) + ->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) + ->setParent( lay ); + UITextView::New() + ->setText( "Text on test 3" ) + ->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) + ->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) + ->setParent( lay ); + UITextView::New() + ->setText( "Text on test 4" ) + ->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) + ->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) + ->setParent( lay ); + UITextInput::New() + ->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) + ->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) + ->setParent( lay ); + + UILinearLayout* lay2 = UILinearLayout::NewVertical(); + lay2->setId( "hardlay" ); + lay2->setLayoutGravity( UI_HALIGN_CENTER | UI_VALIGN_CENTER ); + lay2->setLayoutSizePolicy( SizePolicy::Fixed, SizePolicy::WrapContent ); + lay2->setBackgroundColor( Color::Black ); + lay2->setLayoutWeight( 0.3f ); + + UIPushButton::New() + ->setText( "PushButton" ) + ->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) + ->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) + ->setLayoutGravity( UI_VALIGN_CENTER ) + ->setParent( lay2 ); + UIListBox* lbox = UIListBox::New(); + lbox->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) + ->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::Fixed ) + ->setSize( 0, 105 ) + ->setParent( lay2 ); + lbox->addListBoxItems( { "This", "is", "a", "ListBox" } ); + lay2->setParent( layPar ); + lay->setParent( layPar ); + + UIDropDownList* drop = UIDropDownList::New(); + drop->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) + ->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) + ->setParent( layWin ); + drop->getListBox()->addListBoxItems( { "Car", "Bus", "Plane", "Submarine" } ); + drop->getListBox()->setSelected( 0 ); + wind->show(); + */ + + // win->runMainLoop( &mainLoop ); Engine::destroySingleton(); MemoryManager::showResults();