Custom GUI Element
Custom GUI Element
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
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.
Re: Custom GUI Element
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!
Re: Custom GUI Element
Guess you found out yourself while I was still typing the answer. I'll have to type faster :-)
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: [SOLVED] Custom GUI Element
Thanks, you'll probably know this one though...
The only change I was playing with was to colourise a custom image, e.g.
which works fine, but how do I get rid of the button fade / gradient overlay please?
The only change I was playing with was to colourise a custom image, e.g.
Code: Select all
driver->draw2DImage(Image,
ScaleImage? AbsoluteRect :
core::recti(pos, ImageRect.getSize()),
ImageRect, &AbsoluteClippingRect,
[b]img_color[/b], UseAlphaChannel);
Re: [SOLVED] Custom GUI Element
@ 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.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: [SOLVED] Custom GUI Element
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
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
Re: [SOLVED] Custom GUI Element
Should be possible, I think...Arclamp wrote:So, if I use setTexture() on a standard button, its that texture as is, nice and clear.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: [SOLVED] Custom GUI Element
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:
Code: Select all
void TestButton::draw()
{
...
driver->draw2DImage(Image,
ScaleImage? AbsoluteRect :
core::recti(pos, ImageRect.getSize()),
ImageRect, &AbsoluteClippingRect,
img_color, UseAlphaChannel);
//0, UseAlphaChannel);
Re: [SOLVED] Custom GUI Element
"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.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: [SOLVED] Custom GUI Element
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...
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...
Re: [SOLVED] Custom GUI Element
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.
So... try another texture.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: [SOLVED] Custom GUI Element
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.
when I changed back to this (earlier), then it works as expected... (but without extra new colour)
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:
Good news, overriding font colour works fine...
Code: Select all
void TestButton::draw()
{
...
driver->draw2DImage(Image,
ScaleImage? AbsoluteRect :
core::recti(pos, ImageRect.getSize()),
ImageRect, &AbsoluteClippingRect,
img_color, UseAlphaChannel);
//0, UseAlphaChannel);
Code: Select all
void TestButton::draw()
{
...
driver->draw2DImage(Image,
ScaleImage? AbsoluteRect :
core::recti(pos, ImageRect.getSize()),
ImageRect, &AbsoluteClippingRect,
//img_color, UseAlphaChannel);
0, UseAlphaChannel);
I checked addButton() in env...cpp and saw nothing I wasn't doing...
also I tried swapping the lower draw method of:
Code: Select all
//skin->draw3DButtonPaneStandard(this, AbsoluteRect, &AbsoluteClippingRect);
skin->draw2DRectangle()...
Good news, overriding font colour works fine...