Skip to content

Specify button label start and end#5307

Closed
Trider12 wants to merge 2 commits into
ocornut:masterfrom
Trider12:features/button_label_start_end
Closed

Specify button label start and end#5307
Trider12 wants to merge 2 commits into
ocornut:masterfrom
Trider12:features/button_label_start_end

Conversation

@Trider12
Copy link
Copy Markdown

This is a tiny PR that allows users to specify the start and the end of a label for Button and SmallButton. It eases integrating buttons into text without making a copy of the labels.

I can also add the same functionality to Checkbox and RadioButton in this PR if needed.

@rokups
Copy link
Copy Markdown
Contributor

rokups commented May 13, 2022

We have a feature in the works that would add same thing to most APIs. #3038

@ocornut
Copy link
Copy Markdown
Owner

ocornut commented May 13, 2022

Hello @Trider12,

As answered, even though this is a valid need, this will be best answered by the https://github.com/ocornut/imgui/tree/features/string_view branch without adding extra API entry point. Therefore we cannot take a PR for this.

PS:
While this is orthogonal to dear imgui, I've noticed many people using underwhelming string helpers making their life harder than it should. With my mini library https://github.com/ocornut/Str I would do something like:

ImGui::Button(Str64f("%.*s", label_end - label, label).c_str());

For a similar result. Clearly not ideal it would still require a copy, but no heap allocation involved.

@ocornut ocornut closed this May 13, 2022
@Trider12
Copy link
Copy Markdown
Author

Oh, I see. Looking forward to that feature being merged then.

Hi @ocornut, thanks for the tip, but I'll stick to the non-copying solution for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants