Comments (2)
Seems like you should be using TextUnformatted
instead of Text
?
const char *text { "100%" };
ImGui::CalcTextSize(text).x;
ImGui::TextUnformatted(text);
ImGui::Text("%s", text);
from imgui.
CalcTextSize()
does not take a format string.
As realistically you may want to dynamically format a string instead of always passing "100%" you should probably pre-format then call TextUnformatted()
.
char buf[64];
snprintf(buf, sizeof(buf), "%d%%", percentage);
ImGui::CalcTextSize(buf, ...);
ImGui::TextUnformatted(buf);
Some people use std:: facilities for formatting (because they dislike lightweight things), or the fmt library. I personally https://github.com/ocornut/Str as my own convenient wrapper, where it would become:
Str30f buf("%d%%", percentage");
from imgui.
Related Issues (20)
- Locked on 62 / 63 fps in dx11 without Vsync HOT 1
- Change cursor when hand whenTextLink is hovered - Common Style HOT 1
- Touchpad tap to click not captured when io.ConfigInputTrickleEventQueue is false HOT 5
- Position inside child window when border width changes HOT 7
- Left upper corner coordinates and child window dimensions for different border thicknesses HOT 3
- InputText display latency when trickling events HOT 4
- ImGui::Image tint_col doesn't allow amplifying texture color intensity HOT 1
- ImGuiListClipper for horizontal lists HOT 2
- 10 years of Dear ImGui (long post) HOT 37
- How can I render a large number of waveforms drawn using ImGui's drawList only once and then use it as a cached image for display to reduce drawing resource usage? Should I use a texture with DirectX 11 and Win32, or save it as an image? HOT 2
- Cannot draw inside a very small child window HOT 1
- Can't get ImGui::Shortcut to work HOT 18
- doc: mistake in comment HOT 1
- Support char 'x' for ImGuiInputTextFlags_CharsHexadecimal HOT 1
- SetCursorPos - does not work correctly! HOT 8
- Problem with `PushFont` and `PopFont` with menus HOT 4
- Persian / Arabic font support HOT 1
- New SDL3 callbacks example HOT 2
- Please add support for std::bitset in CheckboxFlags. HOT 3
- where is imgui_impl_glfw_gl3.cpp in the latest version HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from imgui.