-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Support for a real Checkmark in the Checkbox? #593
Comments
FYI if you use 3 "`" you can keep the formatting: if (*v) {
const float check_sz = ImMin(check_bb.GetWidth(), check_bb.GetHeight());
const float pad = ImMax(1.0f, (float)(int)(check_sz / 6.0f));
//window->DrawList->AddRectFilled(check_bb.Min+ImVec2(pad,pad), check_bb.Max-ImVec2(pad,pad), GetColorU32(ImGuiCol_CheckMark), style.FrameRounding);
const ImRect check_mark_bb(check_bb.Min + ImVec2(pad, pad), check_bb.Max - ImVec2(pad, pad));
const ImVec2 poitns[3] = { ImVec2(check_mark_bb.GetCenter().x - check_mark_bb.GetWidth()/2, check_mark_bb.GetCenter().y), ImVec2(check_mark_bb.GetCenter().x, check_mark_bb.GetCenter().y + check_mark_bb.GetHeight() / 2), ImVec2(check_mark_bb.GetTR()) };
window->DrawList->AddPolyline(poitns, 3, GetColorU32(ImGuiCol_CheckMark), false, 3.0f, true);
} You can even set it to add higlighting by adding the language |
I didn't have thick polyline with proper connections back then. There's still a bug with thick polyline normal merging in the non-antialiased path which would need to be fixed before we can use that (see it here: #288 (comment) ) Ideally we'd want a) a symbol library b) those would rasterized in the font atlas so they would cost 2 triangles, same principle would apply for rounded corners which is the primary reason for rasterizing stuff into the atlas. Of course we don't need to do any of that to add that check symbol, just need to fix the non-AA path to match the normal merging of the AA-path. |
FYI if you're prepared to load a font like Font Awesome you can use the CheckBoxTick from this gist: https://gist.github.com/dougbinks/8089b4bbaccaaf6fa204236978d165a9 |
This is already merged on bf778eb -- unless I'm missing something of course :) |
Correct, it's now in imgui (with the exact issue I described if anti-aliasing is disabled, need to fix the non-AA path). I'll close this issue as it is in the TODO to fix them and notably RenderCheckmark(). Down the line, the imgui_internal.h functions such as RenderCheckMark(), RenderTriangle(dir), RenderBullet() should be refactored as e.g. RenderSymbol(enum). Would like to see how we could leverage the recent CustomRect API of ImFontAtlas to have an already-rasterized path for them too. |
I was wondering if an actual checkmark will be added to the checkbox? Is there a reason it was not added in the first place? Its pretty easy to do so. Here is an example code that replaces the exsisting part in the code
And here is how it looks:
The text was updated successfully, but these errors were encountered: