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.

Re: Textarea (Chatbox etc)

Postby Cube_ » Tue Jan 24, 2012 9:26 am

O_O
This is really nice.....
"this is not the bottleneck you are looking for"
User avatar
Cube_
 
Posts: 1011
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)

Postby Ovan » Sat Jan 28, 2012 12:09 pm

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 ;)
User avatar
Ovan
 
Posts: 67
Joined: Thu Dec 18, 2008 12:41 am

Re: Textarea (Chatbox etc)

Postby RdR » Sat Jan 28, 2012 12:56 pm

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!
User avatar
RdR
Competition winner
 
Posts: 273
Joined: Tue Mar 29, 2011 2:58 pm

Re: Textarea (Chatbox etc)

Postby Ovan » Sat Jan 28, 2012 1:31 pm

thank, just an idea from my engine concept to optimize general gui componment but nice for other ...
User avatar
Ovan
 
Posts: 67
Joined: Thu Dec 18, 2008 12:41 am

Re: Textarea (Chatbox etc)

Postby RdR » Mon Mar 05, 2012 5:38 pm

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: viewtopic.php?f=7&t=45901

If your using an old version of this TextArea, update!
User avatar
RdR
Competition winner
 
Posts: 273
Joined: Tue Mar 29, 2011 2:58 pm

Re: Textarea (Chatbox etc)

Postby gerdb » Tue Mar 06, 2012 8:54 pm

looks very nice, thx
gerdb
 
Posts: 194
Joined: Wed Dec 02, 2009 8:21 pm
Location: Dresden, Germany

Re: Textarea (Chatbox etc)

Postby pepeshka » Tue Mar 06, 2012 9:27 pm

Here's wishing this forum had some kind of "thank" or "like" feature ;) cool project RdR!
pepeshka
 
Posts: 29
Joined: Wed Jul 02, 2008 8:42 pm

Re: Textarea (Chatbox etc)

Postby REDDemon » Tue Mar 06, 2012 9:29 pm

I tried a workaround for get correct alpha fonts on RTT

viewtopic.php?f=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
User avatar
REDDemon
Developer
 
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Re: Textarea (Chatbox etc)

Postby RdR » Wed Mar 14, 2012 9:18 pm

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

cpp Code: Select all
 
u32 lifeTime = 5; // Lifetime of the line
Line* line = new Line(lifeTime);
 
User avatar
RdR
Competition winner
 
Posts: 273
Joined: Tue Mar 29, 2011 2:58 pm

Re: TextArea GUI Element [v1.0]

Postby RVM » Fri May 04, 2012 1:49 pm

Hello,

I have some error when I compile my project with this code (Irr v1.7.3):
cpp 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
User avatar
RVM
 
Posts: 13
Joined: Sun Mar 27, 2011 6:14 pm
Location: France

Re: TextArea GUI Element [v1.0]

Postby RdR » Fri May 04, 2012 4:19 pm

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)
User avatar
RdR
Competition winner
 
Posts: 273
Joined: Tue Mar 29, 2011 2:58 pm

Re: TextArea GUI Element [v1.0]

Postby RVM » Fri May 04, 2012 5:06 pm

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 :
cpp Code: Select all
TextArea* chatBox = new TextArea(Environment);

to :
cpp 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
User avatar
RVM
 
Posts: 13
Joined: Sun Mar 27, 2011 6:14 pm
Location: France

Re: TextArea GUI Element [v1.0]

Postby zerochen » Sat Jul 07, 2012 12:37 am

hi,

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

cpp Code: Select all
tempLine = new Line();
zerochen
 
Posts: 273
Joined: Wed Jan 07, 2009 1:17 am
Location: Germany

Re: TextArea GUI Element [v1.0]

Postby RdR » Sat Jul 07, 2012 10:47 am

zerochen wrote:hi,

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

cpp Code: Select all
tempLine = new Line();


Thanks for reporting!
fixed and reuploaded it
User avatar
RdR
Competition winner
 
Posts: 273
Joined: Tue Mar 29, 2011 2:58 pm

Re: TextArea GUI Element [v1.0]

Postby Nemain » Tue Sep 11, 2012 2:35 pm

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

cpp 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);
    }



cpp 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
Nemain
 
Posts: 3
Joined: Thu Jul 26, 2012 12:11 pm

PreviousNext

Return to Code Snippets

Who is online

Users browsing this forum: No registered users and 1 guest