flamendless / Slab

An immediate mode GUI for the Love2D framework.
MIT License
286 stars 25 forks source link

Reset color after draw command and improve hidding chars for password input #169

Closed ArekMiszcz closed 4 months ago

ArekMiszcz commented 4 months ago

I had a problem when I was trying to draw smth next to Slab.draw() into render function, because Slab draw command was overwriting my colors. I've realised that draw command not reset its color so I did it into this PR.

flamendless commented 4 months ago

Hi. Are you calling Slab.draw() before or after your own draw codes?

ArekMiszcz commented 4 months ago

Hi, I'm calling Slab.draw() after, because I want to set the background image (not color) to the window so I have to draw it before I call Slab.draw().

ArekMiszcz commented 4 months ago

image

ArekMiszcz commented 4 months ago

I've also improved hiding chars behind password char because it was working only on unfocus event. It was problematic especially when I wanted to record the screen to show to someone what I've did. After those changes password is always hidden behind password char so there is no risk to share the password.

flamendless commented 4 months ago

You should set the color before you draw your background image

Miszczu2137 commented 4 months ago

But then Slab changing the alfa to the different value which hiding my background as well. Its working like that for select box which changing the alfa for scrollbar.

flamendless commented 4 months ago

Are you trying to change the color of the slab widget(s)?

What i meant was do this:

lg.setBackgroundColor lg.setColor lg.drawImage

lg.setColor Slab.Draw

Miszczu2137 commented 4 months ago

It won't help because Slab.Draw will overwrite it. By my changes I basically restoring back the colora after slab widget rendering. Thanks to that it don't impacting other drawings.

flamendless commented 4 months ago

May I ask for more information? ( Either a screenshot or small reproduction of the issue or perhaps provide a code snippet reflecting your actual code in your rendering function (the previous code snippet lacks the setting of colors)

Miszczu2137 commented 4 months ago

We can even make a quick call if that works for you :) if not I'll try to send you a movie on discord

flamendless commented 4 months ago

Minimal code or love file would be better so i can run it on my machine as well

Miszczu2137 commented 4 months ago

Ok, I'll do it

ArekMiszcz commented 4 months ago

Here is the example of this problem. Just clone the Slab into slab_colors directory. You should be able to see black screen and when you hover over scrollbar then background should fade in.

flamendless commented 4 months ago

Yeah the issue is you're not calling any love.graphics.setColor anywhere in your love.draw as I've said previously

Miszczu2137 commented 4 months ago

Hmm, let me check this but do you think that it's a proper behavior that Slab influence on different drawings? Isn't better to pretend by doing this by reset this color?

ArekMiszcz commented 4 months ago

And what do you think about the password? If this reset color isn't smth what you would like to implement I can move this password changes into different branch if you like it.

PS: sorry for using different accounts but on my mobile phone I'm logged in on company account.

flamendless commented 4 months ago

Well the issue is not exclusive to slab at all. but as the user, you should correctly color and draw your stuff.

flamendless commented 4 months ago

The password issue should be a different issue/pr

ArekMiszcz commented 4 months ago

Ok, so I gonna close this PR and create new one for password issue