setOverrideColor does not work like expected

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
yvanvds
Posts: 9
Joined: Sun Feb 15, 2009 12:55 pm
Contact:

setOverrideColor does not work like expected

Post by yvanvds »

Hello people, I try to make a modest gui for my application. I got an editbox on the screen but do not succeed in changing the color. I am able to change the color for the whole skin, but not for my editbox as such. As seen below:

Code: Select all

void guiClass::drawChat() {
	chatHist = gui->addEditBox(L"", rect<s32>(20 ,700 ,300 ,990), true, 0 ,CHAT_HIST_BOX);
	chatHist->setMultiLine(true);
	chatHist->setAutoScroll(true);
	chatHist->setEnabled(false);
	chatHist->setWordWrap(true);
	
	video::SColor col;
	col.setBlue(30);
	col.setRed(30);
	col.setGreen(255);
	col.setAlpha(20);
	// this should work but it does not
	chatHist->setOverrideColor(col);
	// this should not even be needed since it's included in the previous function
	chatHist->enableOverrideColor(true);
	
	// it works if i comment out this, but then it's the whole gui that changes
	//for (u32 i = 0; i < EGDC_COUNT; ++i) {
	//	gui->getSkin()->setColor((EGUI_DEFAULT_COLOR)i, col);
	//}
	chatEdit = gui->addEditBox(L"", rect<s32>(20 ,1000 ,300 ,1020), true, 0 ,CHAT_EDIT_BOX);
}
Perhaps i forgot something really obvious, but i can't imagine what that could be.

Many thanks for your time!
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

well, you only change the color of the 1st (large) edit box (chatHist) and not the input box (chatEdit)... ;)
also you set it's alpha to 20, what's pretty transparent so it can't be seen...
maybe do something like this:

Code: Select all

void guiClass::drawChat() {
   chatHist = gui->addEditBox(L"", rect<s32>(20 ,700 ,300 ,990), true, 0 ,CHAT_HIST_BOX);
   chatHist->setMultiLine(true);
   chatHist->setAutoScroll(true);
   chatHist->setEnabled(false);
   chatHist->setWordWrap(true);
   
   video::SColor col(255, 30,255,30); // remember it's (A, R,G,B) and A = 255 is solid
   chatHist->setOverrideColor(col);
   chatHist->enableOverrideColor(true);
   
   chatEdit = gui->addEditBox(L"", rect<s32>(20,1000,300,1020), true, 0 ,CHAT_EDIT_BOX);

   video::SColor col2(255, 255,30,30); // just an example color
   chatEdit->setOverrideColor(col2);
   chatEdit->enableOverrideColor(true);
}
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
yvanvds
Posts: 9
Joined: Sun Feb 15, 2009 12:55 pm
Contact:

Post by yvanvds »

well thank you for the tip about setting the color in one step :-) That's a timesaver too.

As for the other remarks, the second box was intentionally kept in the original color, so i can see a clear difference. Which i don't. Both boxes are still a standard gray.

Same about transparancy, even with alpha 0 the gui has its standard transparancy (which is almost nothing). The value was that low because i was experimenting with different values, but none gave any difference.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

yvanvds wrote:well thank you for the tip about setting the color in one step :-) That's a timesaver too.
yes, I saw how you did it and thought I'll give you this hint... :lol:

wait, you want to change the color of the box itself !?!?! :shock:
but setOverrideColor() is for the text and not for the box itself !!! :lol:

to change the color/transparency of a gui element you'll have to use the skin (so you where right to use it)...
but unfortunately you can't change the color of a specific element, like you want to...
if you change it in the skin, then all (e.g.) edit boxes will change to this color...

the only way would be to change the source of the edit box and add this feature on your own (and then maybe put a patch to the tracker for further releases)... ;)

and about the transparency value, always remember Alpha = 0 is full transparent and Alpha = 255 is full solid... ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
yvanvds
Posts: 9
Joined: Sun Feb 15, 2009 12:55 pm
Contact:

Post by yvanvds »

Thanks a lot! I indeed tried to change the color of the box itself. To bad that it's not possible. I don't feel confident enough to write patches and stuff.

So for now i'll have to stick to the standards, i guess. Anyway, I should be caring about cosmetics AFTER i get everything else right :-)

Thanks for the help.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

well thank you for the tip about setting the color in one step Smile That's a timesaver too.

Code: Select all

video::SColor col(0xff1eff1e);
8)
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Post Reply