TextArea GUI Element [v1.0]

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

Re: Textarea (Chatbox etc)

Post by Cube_ »

O_O
This is really nice.....
"this is not the bottleneck you are looking for"
Ovan
Posts: 70
Joined: Thu Dec 18, 2008 12:41 am
Contact:

Re: Textarea (Chatbox etc)

Post by Ovan »

first why separate position and dimension ? core::recti can be use for it (but you can use protected variable from IGUIElement ex: AbsoluteRect)
second can you think rtt are most optimized ?
-create an rtt from size and ECF_A8R8G8B8
-set an boolean to true on calculateVisibleLine
-if this boolen is true update rtt and set it to false
-render rtt texture to position...
third i think irr::core::list are most optimized between array

juste think ;)
RdR
Competition winner
Posts: 273
Joined: Tue Mar 29, 2011 2:58 pm
Contact:

Re: Textarea (Chatbox etc)

Post by RdR »

Ovan wrote:first why separate position and dimension ? core::recti can be use for it (but you can use protected variable from IGUIElement ex: AbsoluteRect)
second can you think rtt are most optimized ?
-create an rtt from size and ECF_A8R8G8B8
-set an boolean to true on calculateVisibleLine
-if this boolen is true update rtt and set it to false
-render rtt texture to position...
third i think irr::core::list are most optimized between array

juste think ;)
Using position and dimension is just a choice we made,
but using the AbsoluteRect and setRelativePosition() might be better indeed. (Especially when implementing OnEvent() )
Using a RTT is a good idea!
Ovan
Posts: 70
Joined: Thu Dec 18, 2008 12:41 am
Contact:

Re: Textarea (Chatbox etc)

Post by Ovan »

thank, just an idea from my engine concept to optimize general gui componment but nice for other ...
RdR
Competition winner
Posts: 273
Joined: Tue Mar 29, 2011 2:58 pm
Contact:

Re: Textarea (Chatbox etc)

Post by RdR »

Updated TextArea with RTT to improve the performance.
It boosted my test project from ~800 to ! 1400 FPS :D

Ovan thanks for the tip btw.

There is still a small bug when using fonts with alpha, but thats an Irrlicht issue. :(
See this topic: http://irrlicht.sourceforge.net/forum/v ... =7&t=45901

If your using an old version of this TextArea, update!
gerdb
Posts: 194
Joined: Wed Dec 02, 2009 8:21 pm
Location: Dresden, Germany

Re: Textarea (Chatbox etc)

Post by gerdb »

looks very nice, thx
pepeshka
Posts: 29
Joined: Wed Jul 02, 2008 8:42 pm

Re: Textarea (Chatbox etc)

Post by pepeshka »

Here's wishing this forum had some kind of "thank" or "like" feature ;) cool project RdR!
REDDemon
Developer
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Re: Textarea (Chatbox etc)

Post by REDDemon »

I tried a workaround for get correct alpha fonts on RTT

http://irrlicht.sourceforge.net/forum/v ... =7&t=45901

This will work only for 1 layer of images. But is better than nothing for now. (so can't be used for the whole GUI). but now you can have fonts also with alpha channel using RTT :)
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
RdR
Competition winner
Posts: 273
Joined: Tue Mar 29, 2011 2:58 pm
Contact:

Re: Textarea (Chatbox etc)

Post by RdR »

Added support for temporary lines.
Temporary lines will be removed automaticly when they are expired.

Code: Select all

 
u32 lifeTime = 5; // Lifetime of the line
Line* line = new Line(lifeTime);
 
RVM
Posts: 13
Joined: Sun Mar 27, 2011 6:14 pm
Location: France
Contact:

Re: TextArea GUI Element [v1.0]

Post by RVM »

Hello,

I have some error when I compile my project with this code (Irr v1.7.3):

Code: Select all

 
Text_Zone = new TextArea(GuiEnv,GuiEnv->getRootGUIElement());
Text_Zone->setDimension(irr::core::rect<irr::s32>(5,deskres.Height-65, 105,deskres.Height));
Text_Zone->setMaxLines(6);
Text_Zone->setAlignment(TextArea::LEFT);
 
Did I miss something ?
obj\Release\Client\GUI\TextArea.o||In function `ZN8TextArea11updateLinesEv':|
GUI\TextArea.cpp|428|undefined reference to `Line::isTemporary()'|
GUI\TextArea.cpp|428|undefined reference to `Line::isExpired()'|
GUI\TextArea.o||In function `ZN8TextArea13createBatchesEv':|
GUI\TextArea.cpp|630|undefined reference to `Line::getFont() const'|
GUI\TextArea.cpp|631|undefined reference to `Line::getFont() const'|
GUI\TextArea.cpp|637|undefined reference to `Line::getStrings() const'|
GUI\TextArea.cpp|638|undefined reference to `Line::getColors() const'|
GUI\TextArea.cpp|639|undefined reference to `Line::getImages() const'|
GUI\TextArea.o||In function `ZN8TextArea18updateVisibleLinesEb':|
\TextArea.cpp|468|undefined reference to `Line::isTemporary()'|
GUI\TextArea.cpp|468|undefined reference to `Line::isExpired()'|
GUI\TextArea.cpp|486|undefined reference to `Line::Line(unsigned int)'|
GUI\TextArea.cpp|489|undefined reference to `Line::getFont() const'|
GUI\TextArea.cpp|490|undefined reference to `Line::getFont() const'|
GUI\TextArea.cpp|491|undefined reference to `Line::setFont(irr::gui::IGUIFont*)'|
GUI\TextArea.cpp|497|undefined reference to `Line::getStrings() const'|
\GUI\TextArea.cpp|498|undefined reference to `Line::getColors() const'|
GUI\TextArea.cpp|499|undefined reference to `Line::getImages() const'|
GUI\TextArea.cpp|550|undefined reference to `Line::addImage(irr::video::ITexture*)'|
Client\GUI\TextArea.cpp|539|undefined reference to `Line::Line(unsigned int)'|
Client\GUI\TextArea.cpp|540|undefined reference to `Line::getFont() const'|
GUI\TextArea.cpp|540|undefined reference to `Line::setFont(irr::gui::IGUIFont*)'|
GUI\TextArea.cpp|555|undefined reference to `Line::addString(irr::core::string<wchar_t, irr::core::irrAllocator<wchar_t> >, irr::video::SColor)'|
GUI\TextArea.cpp|575|undefined reference to `Line::Line(unsigned int)'|
TextArea.cpp|568|undefined reference to `Line::setStrings(std::vector<irr::core::string<wchar_t, irr::core::irrAllocator<wchar_t> >, std::allocator<irr::core::string<wchar_t, irr::core::irrAllocator<wchar_t> > > >)'|
GUI\TextArea.cpp|569|undefined reference to `Line::setColors(std::vector<irr::video::SColor, std::allocator<irr::video::SColor> >)'|
GUI\TextArea.cpp|570|undefined reference to `Line::setImages(std::vector<irr::video::ITexture*, std::allocator<irr::video::ITexture*> >)'|
||=== Build finished: 25 errors, 0 warnings (0 minutes, 3 seconds) ===|
Thanks,
RVM
//When I wrote this, only God and I understood what I was doing
//Now, God only knows
RdR
Competition winner
Posts: 273
Joined: Tue Mar 29, 2011 2:58 pm
Contact:

Re: TextArea GUI Element [v1.0]

Post by RdR »

Do you have Line.h and Line.cpp in your project?
Did you change anything in in the TextArea.h or .cpp ?
Can you build the example in the download? (main.cpp)
RVM
Posts: 13
Joined: Sun Mar 27, 2011 6:14 pm
Location: France
Contact:

Re: TextArea GUI Element [v1.0]

Post by RVM »

RdR wrote:Do you have Line.h and Line.cpp in your project?
Yes
RdR wrote:Did you change anything in in the TextArea.h or .cpp ?
No
RdR wrote:Can you build the example in the download? (main.cpp)
Yes and it run...
But you must change this line :

Code: Select all

TextArea* chatBox = new TextArea(Environment);
to :

Code: Select all

TextArea* chatBox = new TextArea(env,env->getRootGUIElement());
I think I have some build option that don't pass. I will see that.
Sorry for inconvenience,

RVM
//When I wrote this, only God and I understood what I was doing
//Now, God only knows
zerochen
Posts: 273
Joined: Wed Jan 07, 2009 1:17 am
Location: Germany

Re: TextArea GUI Element [v1.0]

Post by zerochen »

hi,

in TextArea.cpp line 575 you have a memleak.
just delete this line.

Code: Select all

tempLine = new Line();
RdR
Competition winner
Posts: 273
Joined: Tue Mar 29, 2011 2:58 pm
Contact:

Re: TextArea GUI Element [v1.0]

Post by RdR »

zerochen wrote:hi,

in TextArea.cpp line 575 you have a memleak.
just delete this line.

Code: Select all

tempLine = new Line();
Thanks for reporting!
fixed and reuploaded it
Nemain
Posts: 3
Joined: Thu Jul 26, 2012 12:11 pm

Re: TextArea GUI Element [v1.0]

Post by Nemain »

First of all thanks for this really nice piece of code :D

But i cant figure out why the background looks wrong (see picture)
Used this to fill my textarea

Code: Select all

    std::vector<Line*> lines;
 
    if((*currentObject)) 
    {
        Line* line = new Line();
        line->addString((*currentObject)->getName().c_str(), video::SColor(255, 255, 255, 255));
        lines.push_back(line);
    
        line = new Line();
        line->addString(L"", irr::video::SColor(255, 255, 255, 255));
        lines.push_back(line);
 
        line = new Line();
        line->addString((*currentObject)->getDescription().c_str(), video::SColor(255, 255, 255, 255));
        lines.push_back(line);
 
        line = new Line();
        line->addString(L"", irr::video::SColor(255, 255, 255, 255));
        lines.push_back(line);
 
        line = new Line();
        line->addString(doubleToString((*currentObject)->getPrice()).c_str(), video::SColor(255, 255, 255, 255));
        lines.push_back(line);
 
        objectPropBox->setLines(lines);
    }

Code: Select all

    // Create a new textarea
    const core::dimension2d<u32> screenSize = device->getVideoDriver()->getScreenSize();
 
    objectPropBox = new TextArea(GUIEnvironment, GUIEnvironment->getRootGUIElement(), GUI_ID_TEXT_AREA_OBJECT_PROP);
    objectPropBox->setMaxLines(8);
    objectPropBox->setAlignment(TextArea::LEFT);
    objectPropBox->setBackgroundColor(video::SColor(175, 0, 0, 0));
    objectPropBox->setPosition(irr::core::vector2di(screenSize.Width*0.7f, screenSize.Height*0.8f));
    objectPropBox->setDimension(400, 150);
    
Image
Post Reply