diff --git a/.ecode/project_build.json b/.ecode/project_build.json index aa2d9a75c..b276eed4f 100644 --- a/.ecode/project_build.json +++ b/.ecode/project_build.json @@ -318,6 +318,12 @@ "command": "${project_root}/bin/eepp-test-debug", "name": "eepp-test-debug", "working_dir": "${project_root}/bin" + }, + { + "args": "", + "command": "${project_root}/bin/eepp-ui-perf-test-debug", + "name": "eepp-ui-perf-test-debug", + "working_dir": "${project_root}/bin" } ], "var": { diff --git a/include/eepp/graphics/blendmode.hpp b/include/eepp/graphics/blendmode.hpp index b6f7f1136..3a90deadf 100644 --- a/include/eepp/graphics/blendmode.hpp +++ b/include/eepp/graphics/blendmode.hpp @@ -8,7 +8,7 @@ namespace EE { namespace Graphics { class EE_API BlendMode { public: - enum class Factor { + enum class Factor : Uint8 { Zero, /// (0, 0, 0, 0) One, /// (1, 1, 1, 1) SrcColor, /// (src.r, src.g, src.b, src.a) @@ -21,28 +21,60 @@ class EE_API BlendMode { OneMinusDstAlpha /// (1, 1, 1, 1) - (dst.a, dst.a, dst.a, dst.a) }; - enum class Equation { + enum class Equation : Uint8 { Add, /// Pixel = Src * SrcFactor + Dst * DstFactor Subtract, /// Pixel = Src * SrcFactor - Dst * DstFactor ReverseSubtract /// Pixel = Dst * DstFactor - Src * SrcFactor }; - static BlendMode Alpha(); /// Blend source and dest according to dest alpha - static BlendMode Add(); /// Add source to dest - static BlendMode Multiply(); /// Multiply source and dest - static BlendMode None(); /// Overwrite dest with source + /// Blend source and dest according to dest alpha + static constexpr BlendMode Alpha() { + return { Factor::SrcAlpha, Factor::OneMinusSrcAlpha, Equation::Add, + Factor::One, Factor::OneMinusSrcAlpha, Equation::Add }; + } + + /// Add source to dest + static constexpr BlendMode Add() { + return { Factor::SrcAlpha, Factor::One, Equation::Add, + Factor::One, Factor::One, Equation::Add }; + } + + /// Multiply source and dest + static constexpr BlendMode Multiply() { return { Factor::DstColor, Factor::Zero }; } + + /// Overwrite dest with source + static constexpr BlendMode None() { return { Factor::One, Factor::Zero }; } static std::string equationToString( const Equation& eq ); static std::string factorToString( const Factor& fc ); - BlendMode(); + constexpr BlendMode() : + colorSrcFactor( Factor::SrcAlpha ), + colorDstFactor( Factor::OneMinusSrcAlpha ), + colorEquation( Equation::Add ), + alphaSrcFactor( Factor::One ), + alphaDstFactor( Factor::OneMinusSrcAlpha ), + alphaEquation( Equation::Add ) {} - BlendMode( Factor sourceFactor, Factor destinationFactor, Equation blendEquation = BlendMode::Equation::Add ); + constexpr BlendMode( Factor sourceFactor, Factor destinationFactor, + Equation blendEquation = Equation::Add ) : + colorSrcFactor( sourceFactor ), + colorDstFactor( destinationFactor ), + colorEquation( blendEquation ), + alphaSrcFactor( sourceFactor ), + alphaDstFactor( destinationFactor ), + alphaEquation( blendEquation ) {} - BlendMode( Factor colorSourceFactor, Factor colorDestinationFactor, Equation colorBlendEquation, - Factor alphaSourceFactor, Factor alphaDestinationFactor, - Equation alphaBlendEquation ); + constexpr BlendMode( Factor colorSourceFactor, Factor colorDestinationFactor, + Equation colorBlendEquation, Factor alphaSourceFactor, + Factor alphaDestinationFactor, Equation alphaBlendEquation ) : + colorSrcFactor( colorSourceFactor ), + colorDstFactor( colorDestinationFactor ), + colorEquation( colorBlendEquation ), + alphaSrcFactor( alphaSourceFactor ), + alphaDstFactor( alphaDestinationFactor ), + alphaEquation( alphaBlendEquation ) {} /** Set a Predefined Blend Function * @param mode The Blend Mode @@ -66,8 +98,18 @@ class EE_API BlendMode { static BlendMode sLastBlend; }; -EE_API bool operator==( const BlendMode& left, const BlendMode& right ); -EE_API bool operator!=( const BlendMode& left, const BlendMode& right ); +constexpr bool operator==( const BlendMode& left, const BlendMode& right ) { + return ( left.colorSrcFactor == right.colorSrcFactor ) && + ( left.colorDstFactor == right.colorDstFactor ) && + ( left.colorEquation == right.colorEquation ) && + ( left.alphaSrcFactor == right.alphaSrcFactor ) && + ( left.alphaDstFactor == right.alphaDstFactor ) && + ( left.alphaEquation == right.alphaEquation ); +} + +constexpr bool operator!=( const BlendMode& left, const BlendMode& right ) { + return !( left == right ); +} }} // namespace EE::Graphics diff --git a/include/eepp/graphics/primitives.hpp b/include/eepp/graphics/primitives.hpp index 785239c74..a3a8bcbe6 100644 --- a/include/eepp/graphics/primitives.hpp +++ b/include/eepp/graphics/primitives.hpp @@ -149,7 +149,7 @@ class EE_API Primitives { * result in a smoother corner. */ void drawSoftShadow( const Rectf& boxRect, const Vector2f& shadowOffset, Float shadowSize, - const Color& shadowColor, Uint32 cornerSegments = 8 ); + Uint32 cornerSegments = 8 ); /** Set the current color for drawing primitives */ void setColor( const Color& Color ); diff --git a/include/eepp/scene/node.hpp b/include/eepp/scene/node.hpp index 73ed3cbdb..6bc161938 100644 --- a/include/eepp/scene/node.hpp +++ b/include/eepp/scene/node.hpp @@ -479,21 +479,24 @@ class EE_API Node : public Transformable { friend class EventDispatcher; std::string mId; - String::HashType mIdHash; + String::HashType mIdHash{ 0 }; Vector2f mScreenPos; Vector2i mScreenPosi; Sizef mSize; - UintPtr mData; - Node* mParentNode; - SceneNode* mSceneNode; - Node* mNodeDrawInvalidator; - Node* mChild; //! Pointer to the first child of the node - Node* mChildLast; //! Pointer to the last child added - Node* mNext; //! Pointer to the next child of the father - Node* mPrev; //! Pointer to the prev child of the father - Uint32 mNodeFlags; - BlendMode mBlend; - Uint32 mNumCallBacks; + Float mAlpha{ 255.f }; + UintPtr mData{ 0 }; + Node* mParentNode{ nullptr }; + SceneNode* mSceneNode{ nullptr }; + Node* mNodeDrawInvalidator{ nullptr }; + Node* mChild{ nullptr }; //! Pointer to the first child of the node + Node* mChildLast{ nullptr }; //! Pointer to the last child added + Node* mNext{ nullptr }; //! Pointer to the next child of the father + Node* mPrev{ nullptr }; //! Pointer to the prev child of the father + Uint32 mNodeFlags{ NODE_FLAG_POSITION_DIRTY | NODE_FLAG_POLYGON_DIRTY }; + BlendMode mBlend{ BlendMode::Alpha() }; + bool mVisible{ true }; + bool mEnabled{ true }; + Uint32 mNumCallBacks{ 0 }; mutable Polygon2f mPoly; mutable Rectf mWorldBounds; @@ -501,12 +504,9 @@ class EE_API Node : public Transformable { EventsMap mEvents; - bool mVisible; - bool mEnabled; OriginPoint mRotationOriginPoint; OriginPoint mScaleOriginPoint; - Float mAlpha; virtual Uint32 onMessage( const NodeMessage* msg ); diff --git a/include/eepp/ui/uiwidget.hpp b/include/eepp/ui/uiwidget.hpp index 097296af2..067debaea 100644 --- a/include/eepp/ui/uiwidget.hpp +++ b/include/eepp/ui/uiwidget.hpp @@ -308,9 +308,9 @@ class EE_API UIWidget : public UINode { PositionPolicy mLayoutPositionPolicy; UIWidget* mLayoutPositionPolicyWidget; int mAttributesTransactionCount; + Uint32 mPseudoClasses{ 0 }; std::string mSkinName; std::vector mClasses; - Uint32 mPseudoClasses{ 0 }; String mTooltipText; explicit UIWidget( const std::string& tag ); diff --git a/src/eepp/graphics/blendmode.cpp b/src/eepp/graphics/blendmode.cpp index c8be819e9..1039cf007 100644 --- a/src/eepp/graphics/blendmode.cpp +++ b/src/eepp/graphics/blendmode.cpp @@ -49,33 +49,6 @@ Uint32 equationToGlConstant( BlendMode::Equation blendEquation ) { return GL_FUNC_ADD; } -BlendMode BlendMode::Alpha() { - static const BlendMode BlendAlpha{ BlendMode::Factor::SrcAlpha, - BlendMode::Factor::OneMinusSrcAlpha, - BlendMode::Equation::Add, - BlendMode::Factor::One, - BlendMode::Factor::OneMinusSrcAlpha, - BlendMode::Equation::Add }; - return BlendAlpha; -} - -BlendMode BlendMode::Add() { - static const BlendMode BlendAdd{ BlendMode::Factor::SrcAlpha, BlendMode::Factor::One, - BlendMode::Equation::Add, BlendMode::Factor::One, - BlendMode::Factor::One, BlendMode::Equation::Add }; - return BlendAdd; -} - -BlendMode BlendMode::Multiply() { - static const BlendMode BlendMultiply{ BlendMode::Factor::DstColor, BlendMode::Factor::Zero }; - return BlendMultiply; -} - -BlendMode BlendMode::None() { - static const BlendMode BlendNone{ BlendMode::Factor::One, BlendMode::Factor::Zero }; - return BlendNone; -} - BlendMode BlendMode::sLastBlend = BlendMode::Add(); std::string BlendMode::equationToString( const Equation& eq ) { @@ -116,45 +89,6 @@ std::string BlendMode::factorToString( const Factor& fc ) { return ""; } -BlendMode::BlendMode() : - colorSrcFactor( BlendMode::Factor::SrcAlpha ), - colorDstFactor( BlendMode::Factor::OneMinusSrcAlpha ), - colorEquation( BlendMode::Equation::Add ), - alphaSrcFactor( BlendMode::Factor::One ), - alphaDstFactor( BlendMode::Factor::OneMinusSrcAlpha ), - alphaEquation( BlendMode::Equation::Add ) {} - -BlendMode::BlendMode( Factor sourceFactor, Factor destinationFactor, Equation blendEquation ) : - colorSrcFactor( sourceFactor ), - colorDstFactor( destinationFactor ), - colorEquation( blendEquation ), - alphaSrcFactor( sourceFactor ), - alphaDstFactor( destinationFactor ), - alphaEquation( blendEquation ) {} - -BlendMode::BlendMode( Factor colorSourceFactor, Factor colorDestinationFactor, - Equation colorBlendEquation, Factor alphaSourceFactor, - Factor alphaDestinationFactor, Equation alphaBlendEquation ) : - colorSrcFactor( colorSourceFactor ), - colorDstFactor( colorDestinationFactor ), - colorEquation( colorBlendEquation ), - alphaSrcFactor( alphaSourceFactor ), - alphaDstFactor( alphaDestinationFactor ), - alphaEquation( alphaBlendEquation ) {} - -bool operator==( const BlendMode& left, const BlendMode& right ) { - return ( left.colorSrcFactor == right.colorSrcFactor ) && - ( left.colorDstFactor == right.colorDstFactor ) && - ( left.colorEquation == right.colorEquation ) && - ( left.alphaSrcFactor == right.alphaSrcFactor ) && - ( left.alphaDstFactor == right.alphaDstFactor ) && - ( left.alphaEquation == right.alphaEquation ); -} - -bool operator!=( const BlendMode& left, const BlendMode& right ) { - return !( left == right ); -} - void BlendMode::setMode( const BlendMode& mode, bool force ) { if ( sLastBlend != mode || force ) { GLi->enable( GL_BLEND ); diff --git a/src/eepp/graphics/primitives.cpp b/src/eepp/graphics/primitives.cpp index f215adda6..6a1c5ff10 100644 --- a/src/eepp/graphics/primitives.cpp +++ b/src/eepp/graphics/primitives.cpp @@ -466,8 +466,7 @@ const Float& Primitives::getLineWidth() const { } void Primitives::drawSoftShadow( const Rectf& boxRect, const Vector2f& shadowOffset, - Float shadowSize, const Color& shadowColor, - Uint32 cornerSegments ) { + Float shadowSize, Uint32 cornerSegments ) { if ( shadowSize <= 0.f ) return; @@ -477,8 +476,8 @@ void Primitives::drawSoftShadow( const Rectf& boxRect, const Vector2f& shadowOff setForceDraw( false ); // Define the start (opaque) and end (transparent) colors for the gradient - Color beginC = shadowColor; - Color endC( shadowColor.r, shadowColor.g, shadowColor.b, 0 ); + Color beginC = mColor; + Color endC( mColor.r, mColor.g, mColor.b, 0 ); // Calculate the position of the main, solid part of the shadow Rectf shadowBox = boxRect; diff --git a/src/eepp/scene/node.cpp b/src/eepp/scene/node.cpp index 5c3b8011b..35b6336ac 100644 --- a/src/eepp/scene/node.cpp +++ b/src/eepp/scene/node.cpp @@ -17,6 +17,7 @@ Node* Node::New() { Node::Node() : mIdHash( 0 ), mSize( 0, 0 ), + mAlpha( 255.f ), mData( 0 ), mParentNode( NULL ), mSceneNode( NULL ), @@ -27,10 +28,9 @@ Node::Node() : mPrev( NULL ), mNodeFlags( NODE_FLAG_POSITION_DIRTY | NODE_FLAG_POLYGON_DIRTY ), mBlend( BlendMode::Alpha() ), - mNumCallBacks( 0 ), mVisible( true ), mEnabled( true ), - mAlpha( 255.f ) {} + mNumCallBacks( 0 ) {} Node::~Node() { if ( !SceneManager::instance()->isShuttingDown() && NULL != mSceneNode ) { diff --git a/src/eepp/ui/uiwindow.cpp b/src/eepp/ui/uiwindow.cpp index 387e40d0a..be5f5d7bc 100644 --- a/src/eepp/ui/uiwindow.cpp +++ b/src/eepp/ui/uiwindow.cpp @@ -375,18 +375,14 @@ void UIWindow::drawHighlightInvalidation() { } void UIWindow::drawShadow() { - if ( !( mStyleConfig.WinFlags & UI_WIN_SHADOW ) ) - return; - UIWidget::matrixSet(); - - Primitives P; + Primitives p; Color shadowColor( 0, 0, 0, 25 * ( getAlpha() / 255.f ) ); Float shadowSize = PixelDensity::dpToPx( 16.f ); Vector2f shadowOffset( 0, shadowSize ); Rectf windowRect( mScreenPos, mSize ); - P.drawSoftShadow( windowRect, shadowOffset, shadowSize, shadowColor, shadowSize / 2 ); - + p.setColor( shadowColor ); + p.drawSoftShadow( windowRect, shadowOffset, shadowSize, shadowSize / 2 ); UIWidget::matrixUnset(); } @@ -1231,7 +1227,8 @@ void UIWindow::nodeDraw() { preDraw(); - drawShadow(); + if ( mStyleConfig.WinFlags & UI_WIN_SHADOW ) + drawShadow(); ClippingMask* clippingMask = GLi->getClippingMask(); diff --git a/src/tests/ui_perf_test/ui_perf_test.cpp b/src/tests/ui_perf_test/ui_perf_test.cpp index d10296b9c..0cb3ac5b0 100644 --- a/src/tests/ui_perf_test/ui_perf_test.cpp +++ b/src/tests/ui_perf_test/ui_perf_test.cpp @@ -1,4 +1,5 @@ #include +#include using namespace EE::UI::Abstract; @@ -21,13 +22,13 @@ class TestModel : public Model { size_t getRows() const { return 10000; } size_t getCols() const { return 4; } - size_t getChilds() const { return 50; } + size_t getChildren() const { return 50; } TestModel() : Model() { for ( size_t row = 0; row < getRows(); ++row ) { NodeT* n = new NodeT(); n->parent = &mRoot; - for ( size_t i = 0; i < getChilds(); i++ ) { + for ( size_t i = 0; i < getChildren(); i++ ) { NodeT* c = new NodeT(); c->parent = n; n->children.push_back( c ); @@ -133,7 +134,7 @@ void mainLoop() { SceneManager::instance()->update(); // Check if the UI has been invalidated ( needs redraw ). - if ( true || SceneManager::instance()->getUISceneNode()->invalidated() ) { + if ( SceneManager::instance()->getUISceneNode()->invalidated() ) { win->clear(); // Redraw the UI scene. @@ -146,7 +147,7 @@ void mainLoop() { win->display(); } else { - // win->getInput()->waitEvent( Milliseconds( win->hasFocus() ? 16 : 100 ) ); + win->getInput()->waitEvent( Milliseconds( win->hasFocus() ? 16 : 100 ) ); } } @@ -198,7 +199,7 @@ EE_MAIN_FUNC int main( int, char*[] ) { ->setDefaultFont( font ) ->add( theme ); - auto* vlay = UILinearLayout::NewVertical(); + auto* vlay = UILinearLayout::NewVertical(); vlay->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent ); Clock clock; @@ -212,49 +213,52 @@ EE_MAIN_FUNC int main( int, char*[] ) { view->setModel( SortingProxyModel::New( model ) ); Log::notice( "Total time: %.2fms", clock.getElapsedTime().asMilliseconds() ); - /* 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.getElapsed().asMilliseconds() << " ms" << std::endl; - lbox->setParent( vlay ); - std::cout << "Time setParent: " << clock.getElapsed().asMilliseconds() << " ms" - << std::endl; - lbox->setLayoutMargin( Rectf( 4, 4, 4, 4 ) ); - std::cout << "Time setLayoutMargin: " << clock.getElapsed().asMilliseconds() << " ms" - << std::endl; - lbox->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent ); - std::cout << "Time setLayoutSizePolicy: " << clock.getElapsed().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.getElapsed().asMilliseconds() << " ms" - << std::endl; - lbox->addListBoxItems( strings ); - std::cout << "Time addListBoxItems: " << clock.getElapsed().asMilliseconds() << " ms" - << std::endl;*/ + /* 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; + */ - /* Create Widget test */ Clock total; - /*for ( size_t i = 0; i < 10000; i++ ) { + /* Create Widget test */ +/* + for ( size_t i = 0; i < 10000; i++ ) { UINode::New(); } - std::cout << "Time UINode total: " << total.getElapsedTime().toString() << std::endl; - uiSceneNode->getRoot()->childsCloseAll(); + 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 UIWidget total: " << total.getElapsedTime().toString() << std::endl; - uiSceneNode->getRoot()->childsCloseAll();*/ + std::cout << "Time 10k UIWidget total: " << total.getElapsedTime().toString() << std::endl; + uiSceneNode->getRoot()->closeAllChildren(); - /*auto* rl = UIRelativeLayout::New(); + auto* rl = UIRelativeLayout::New(); rl->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent ); auto* sv = UIScrollView::New(); @@ -271,15 +275,26 @@ EE_MAIN_FUNC int main( int, char*[] ) { but->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ); but->setParent( parent )->clipEnable(); } - std::cout << "Time UIPushButton total: " << total.getElapsedTime().toString() << std::endl; + std::cout << "Time 10k UIPushButton total: " << total.getElapsedTime().toString() << std::endl; - // uiSceneNode->getRoot()->childsCloseAll(); + // uiSceneNode->getRoot()->closeAllChildren(); total.restart(); SceneManager::instance()->update(); std::cout << "SceneManager::instance()->update(): " << total.getElapsedTime().toString() - << std::endl;*/ + << 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(); + total.restart(); for ( size_t i = 0; i < 100000; i++ ) { auto* widget = UIWidget::New(); widget->setParent( vlay ); @@ -293,11 +308,12 @@ EE_MAIN_FUNC int main( int, char*[] ) { widget->setBackgroundColor( Color::fromHsv( col ) ); } std::cout << "Time UIWidget total: " << total.getElapsedTime().asMilliseconds() << " ms" - << std::endl;*/ - - /*UIWindow* wind = UIWindow::New(); + << std::endl; + */ +/* + UIWindow* wind = UIWindow::New(); wind->setSize( 500, 500 ); - wind->setWinFlags( UI_WIN_DEFAULT_FLAGS | UI_WIN_RESIZEABLE | UI_WIN_MAXIMIZE_BUTTON ); + wind->setWindowFlags( UI_WIN_DEFAULT_FLAGS | UI_WIN_RESIZEABLE | UI_WIN_MAXIMIZE_BUTTON ); UILinearLayout* layWin = UILinearLayout::NewVertical(); layWin->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent ); @@ -305,7 +321,7 @@ EE_MAIN_FUNC int main( int, char*[] ) { UILinearLayout* layPar = UILinearLayout::NewHorizontal(); layPar->setParent( layWin ); - layPar->setLayoutMargin( Rect( 10, 10, 10, 10 ) ); + layPar->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ); layPar->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ); layPar->setLayoutGravity( UI_VALIGN_CENTER | UI_HALIGN_CENTER ); layPar->setBackgroundColor( 0x999999FF ); @@ -318,31 +334,31 @@ EE_MAIN_FUNC int main( int, char*[] ) { UITextView::New() ->setText( "Text on test 1" ) - ->setLayoutMargin( Rect( 10, 10, 10, 10 ) ) + ->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) ->setLayoutSizePolicy( SizePolicy::WrapContent, SizePolicy::WrapContent ) ->setParent( lay ); UITextView::New() ->setText( "Text on test 2" ) - ->setLayoutMargin( Rect( 10, 10, 10, 10 ) ) + ->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) ->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) ->setParent( lay ); UICheckBox::New() ->setText( "Checkbox" ) - ->setLayoutMargin( Rect( 10, 10, 10, 10 ) ) + ->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) ->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) ->setParent( lay ); UITextView::New() ->setText( "Text on test 3" ) - ->setLayoutMargin( Rect( 10, 10, 10, 10 ) ) + ->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) ->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) ->setParent( lay ); UITextView::New() ->setText( "Text on test 4" ) - ->setLayoutMargin( Rect( 10, 10, 10, 10 ) ) + ->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) ->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) ->setParent( lay ); UITextInput::New() - ->setLayoutMargin( Rect( 10, 10, 10, 10 ) ) + ->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) ->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) ->setParent( lay ); @@ -355,26 +371,27 @@ EE_MAIN_FUNC int main( int, char*[] ) { UIPushButton::New() ->setText( "PushButton" ) - ->setLayoutMargin( Rect( 10, 10, 10, 10 ) ) + ->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) ->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) ->setLayoutGravity( UI_VALIGN_CENTER ) ->setParent( lay2 ); UIListBox* lbox = UIListBox::New(); - lbox->setLayoutMargin( Rect( 10, 10, 10, 10 ) ) + lbox->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) ->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::Fixed ) ->setSize( 0, 105 ) ->setParent( lay2 ); - lbox->addListBoxItems( {"This", "is", "a", "ListBox"} ); + lbox->addListBoxItems( { "This", "is", "a", "ListBox" } ); lay2->setParent( layPar ); lay->setParent( layPar ); UIDropDownList* drop = UIDropDownList::New(); - drop->setLayoutMargin( Rect( 10, 10, 10, 10 ) ) + drop->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) ->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) ->setParent( layWin ); - drop->getListBox()->addListBoxItems( {"Car", "Bus", "Plane", "Submarine"} ); + drop->getListBox()->addListBoxItems( { "Car", "Bus", "Plane", "Submarine" } ); drop->getListBox()->setSelected( 0 ); - wind->show();*/ + wind->show(); + */ win->runMainLoop( &mainLoop ); } diff --git a/src/tools/ecode/plugins/aiassistant/chatui.cpp b/src/tools/ecode/plugins/aiassistant/chatui.cpp index f1d99362c..337d7674d 100644 --- a/src/tools/ecode/plugins/aiassistant/chatui.cpp +++ b/src/tools/ecode/plugins/aiassistant/chatui.cpp @@ -358,7 +358,10 @@ LLMChatUI::LLMChatUI( PluginManager* manager ) : setCmd( "ai-chat-history", [this] { showChatHistory(); } ); - setCmd( "ai-attach-file", [this] { showAttachFile(); } ); + setCmd( "ai-attach-file", [this] { + showAttachFile(); + mLocateInput->getDocument().selectAll(); + } ); setCmd( "ai-toggle-private-chat", [this] { mChatPrivate->toggleSelection(); } ); @@ -1452,14 +1455,8 @@ void LLMChatUI::initAttachFile() { auto cdoc = mChatInput->getDocumentRef(); cdoc->resetSelection(); cdoc->moveToEndOfLine(); - const auto& lineComment = doc.getSyntaxDefinition().getComment(); - if ( lineComment.empty() ) { - cdoc->textInput( "\n" + nameToDisplay + ":\n" ); - } - cdoc->textInput( "\n```" + doc.getSyntaxDefinition().getLSPName() ); - if ( !lineComment.empty() ) { - cdoc->textInput( String::format( " %s %s", lineComment, nameToDisplay ) ); - } + cdoc->textInput( "\n`" + nameToDisplay + "`:\n" ); + cdoc->textInput( "```" + doc.getSyntaxDefinition().getLSPName() ); auto lineToFold = cdoc->getSelection().end().line(); if ( doc.linesCount() >= 1 && !String::startsWith( doc.line( 0 ).getText(), "\n" ) ) {