Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] render password as text symbol #316

Closed
namaek2 opened this issue May 6, 2024 · 5 comments · Fixed by #510
Closed

[Feature Request] render password as text symbol #316

namaek2 opened this issue May 6, 2024 · 5 comments · Fixed by #510

Comments

@namaek2
Copy link

namaek2 commented May 6, 2024

image

I want to render password dots as asterisk like this image.

I looked up code little bit and find out dots are rendered by CRenderer::renderRect function. Is there any plan to render password as text?

@namaek2 namaek2 changed the title [Feature Request] [Feature Request] render password as text symbol May 6, 2024
@vaxerski
Copy link
Member

vaxerski commented May 6, 2024

MRs welcome

@HarshNarayanJha
Copy link

Hey, I would like to work on this. I am quite new to C++, and digging down, here's what I found

The exact line which is drawing the dots

g_pRenderer->renderRect(box, fontCol, dots.rounding);

So I might try to use a CLabel to draw the * (or whatever is set in config). Right?

@PaideiaDilemma
Copy link
Collaborator

Hey @HarshNarayanJha

FYI, I implemented this. Just wanted to wait for #508 until i create the MR.
You are welcome to look at my current implementation here: PaideiaDilemma@057b6b8

Let me know what you think the config option should be named like.

@HarshNarayanJha
Copy link

Didn't see that one! 😓

Your implementation looks great! So you basically check if textFormat and textAsset exists and then draw it, otherwise dots are drawn.
What I think (if I am not wrong), say textAsset did get allocate, in this case dots must be drawn as fallback option

// say this failed
dots.textAsset = g_pRenderer->asyncResourceGatherer->getAssetByID(dots.textResourceID);

src/renderer/widgets/PasswordInputField.cpp

if (!dots.textFormat.empty()) {
    if (!dots.textAsset)
+		g_pRenderer->renderRect(box, fontCol, dots.rounding);
        break;
    g_pRenderer->renderTexture(box, dots.textAsset->texture, fontCol.a, dots.rounding);
} else {
    g_pRenderer->renderRect(box, fontCol, dots.rounding);
}

As (per my understanding) this case would result in nothing being typed in the input field.

For the name of the config option, dots_text_format is good, but dots_mask_character sound better to me. You choose!

@PaideiaDilemma
Copy link
Collaborator

Didn't see that one! 😓

Yeah sorry, I could have posted that i am going to implement that.

What I think (if I am not wrong), say textAsset did get allocate, in this case dots must be drawn as fallback option

Yeah so this is intended. We set forceReload to true as long as the asset is not ready yet. So we relay on the asyncResourceGatherer to successfully render that asset at some point. Otherwise we will busy render forever.
That works the same as the background widget for example.
I am not 100% happy with the break in the loop though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants