Custom GUI Element

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.

Custom GUI Element

Postby Arclamp » Wed Jul 26, 2017 11:25 pm

So, beginning to explore further, without recompiling base library.



I have basically copied and renamed ICGUIButton.
I've incorporated a pointer to the device and swapped out getTime().

Then I create the a new instance of the element and set the device.
In the render loop I call draw() and it gets drawn, excellent!

Next I passed a pointer of the element to the event receiver, and in OnEvent() I pass on the call to the instance, but nothing happens when the button is pressed.


What needs to be added to get this fully working, and if possible, actually registered so not have to call draw() and OnEvent() manually?

Cheers
Last edited by Arclamp on Sun Jul 30, 2017 10:30 am, edited 2 times in total.
Arclamp
 
Posts: 46
Joined: Thu Oct 10, 2013 7:45 pm

Re: Custom GUI Element

Postby Arclamp » Wed Jul 26, 2017 11:42 pm

:D

So, I needed to add a parent instead of using 0!
Then remove my own call to OnEvent().
Also removed own call to draw().

Works brilliant!
Arclamp
 
Posts: 46
Joined: Thu Oct 10, 2013 7:45 pm

Re: Custom GUI Element

Postby CuteAlien » Wed Jul 26, 2017 11:46 pm

Guess you found out yourself while I was still typing the answer. I'll have to type faster :-)
IRC: #irrlicht on irc.freenode.net
Code snippets, patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Free racer created with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
User avatar
CuteAlien
Admin
 
Posts: 8365
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

Re: [SOLVED] Custom GUI Element

Postby Arclamp » Thu Jul 27, 2017 12:09 am

Thanks, you'll probably know this one though...

The only change I was playing with was to colourise a custom image, e.g.
cpp Code: Select all
 
driver->draw2DImage(Image,
                    ScaleImage? AbsoluteRect :
                        core::recti(pos, ImageRect.getSize()),
                    ImageRect, &AbsoluteClippingRect,
                    [b]img_color[/b], UseAlphaChannel);
 


which works fine, but how do I get rid of the button fade / gradient overlay please?
Arclamp
 
Posts: 46
Joined: Thu Oct 10, 2013 7:45 pm

Re: [SOLVED] Custom GUI Element

Postby CuteAlien » Thu Jul 27, 2017 9:40 am

@ Arclamp: Hm, maybe give me a screenshot so I know what you mean to clarify (you can put it on a service like imgur and link to it here). Do you mean maybe you draw that draw2DImage over the same position where you have a button and the image has alpha - so the button shows behind it? You can change skin-colors for gui with IGUISkin->setColor, you have to experiment a little which one affects buttons. Button has functions to use images directly by the way (even got more features if you use Irrlicht svn trunk version). What's missing is disabling skin-drawing completely if no image is set (I guess you could set an invisible image).
IRC: #irrlicht on irc.freenode.net
Code snippets, patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Free racer created with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
User avatar
CuteAlien
Admin
 
Posts: 8365
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

Re: [SOLVED] Custom GUI Element

Postby Arclamp » Thu Jul 27, 2017 5:19 pm

I will later...

So, if I use setTexture() on a standard button, its that texture as is, nice and clear.

Now I've ripped it out (and use new instead of create...()), the button gets another skin (yes, like window bg) layer once I add the texture. Seems odd, tried commenting out loads, but always comes???

I'll post image later, cheers
Arclamp
 
Posts: 46
Joined: Thu Oct 10, 2013 7:45 pm

Re: [SOLVED] Custom GUI Element

Postby CuteAlien » Thu Jul 27, 2017 7:11 pm

Arclamp wrote:So, if I use setTexture() on a standard button, its that texture as is, nice and clear.

Should be possible, I think...
IRC: #irrlicht on irc.freenode.net
Code snippets, patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Free racer created with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
User avatar
CuteAlien
Admin
 
Posts: 8365
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

Re: [SOLVED] Custom GUI Element

Postby Arclamp » Thu Jul 27, 2017 9:17 pm

Image

The full red is a tinted IGUIImage, original is a standard IGUIButton, and custom is basically a standard button but with only the following change:

cpp Code: Select all
 
void TestButton::draw()
{
            ...
           
            driver->draw2DImage(Image,
                    ScaleImage? AbsoluteRect :
                        core::recti(pos, ImageRect.getSize()),
                    ImageRect, &AbsoluteClippingRect,
                    img_color, UseAlphaChannel);
                    //0, UseAlphaChannel);
 


Oh, I also set image to scaled so can see easier...
Arclamp
 
Posts: 46
Joined: Thu Oct 10, 2013 7:45 pm

Re: [SOLVED] Custom GUI Element

Postby CuteAlien » Fri Jul 28, 2017 9:01 am

"Custom" looks strange. My guess would be that texture has that kind of alpha? Maybe compare how it looks when you disable alpha on drawing? Because that kind of gray doesn't look like the gray you would get for buttons (that one is uniform usually I think - unless you have a custom skin as well).
IRC: #irrlicht on irc.freenode.net
Code snippets, patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Free racer created with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
User avatar
CuteAlien
Admin
 
Posts: 8365
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

Re: [SOLVED] Custom GUI Element

Postby Arclamp » Fri Jul 28, 2017 1:43 pm

Its baffling, defies logic!

No custom skin, its basically just the GUI Demo.
Virtually the same with alpha, drawborder, etc...

I'll try again from scratch later n see if I did something I don't remember (was a late night off the cuff thing).

Oh, the texture is just "media/stones.jpg" and I not set any colorkey...
Arclamp
 
Posts: 46
Joined: Thu Oct 10, 2013 7:45 pm

Re: [SOLVED] Custom GUI Element

Postby CuteAlien » Fri Jul 28, 2017 4:14 pm

Sorry, don't know how alpha's look in that texture (alpha is hard to see in most tools...). And texture can have alpha without colorkey (in case someone put some alpha in there in the paint program).

So... try another texture.
IRC: #irrlicht on irc.freenode.net
Code snippets, patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Free racer created with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
User avatar
CuteAlien
Admin
 
Posts: 8365
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

Re: [SOLVED] Custom GUI Element

Postby Arclamp » Fri Jul 28, 2017 5:21 pm

As far I'm aware without checking is that it doesn't have any alpha, also it works on the others using exactly the same loaded texture.

cpp Code: Select all
 
void TestButton::draw()
{
            ...
            driver->draw2DImage(Image,
                    ScaleImage? AbsoluteRect :
                        core::recti(pos, ImageRect.getSize()),
                    ImageRect, &AbsoluteClippingRect,
                    img_color, UseAlphaChannel);
                    //0, UseAlphaChannel);
 

when I changed back to this (earlier), then it works as expected... (but without extra new colour)
cpp Code: Select all
 
void TestButton::draw()
{
            ...
            driver->draw2DImage(Image,
                    ScaleImage? AbsoluteRect :
                        core::recti(pos, ImageRect.getSize()),
                    ImageRect, &AbsoluteClippingRect,
                    //img_color, UseAlphaChannel);
                    0, UseAlphaChannel);
 


I couldn't see anything else that I'd changed in the button code.
I checked addButton() in env...cpp and saw nothing I wasn't doing...

also I tried swapping the lower draw method of:
cpp Code: Select all
 
//skin->draw3DButtonPaneStandard(this, AbsoluteRect, &AbsoluteClippingRect);
skin->draw2DRectangle()...
 



Good news, overriding font colour works fine... :D
Arclamp
 
Posts: 46
Joined: Thu Oct 10, 2013 7:45 pm


Return to Beginners Help

Who is online

Users browsing this forum: No registered users and 1 guest

cron