Comments (1)
You can make wrappers to construct your own versions of those widgets. When you do, try to mimic the original parameters to make them interchangeable. To get you started:
bool CustomCheckbox( const char* label, bool* v )
{
ImVec2 cursorPos = ImGui::GetCursorPos();
ImVec2 screenPos = ImGui::GetCursorScreenPos();
float availableX = ImGui::GetContentRegionAvail().x;
float checkboxSize = ImGui::GetFrameHeight();
float innerSpacing = ImGui::GetStyle().ItemInnerSpacing.x;
ImGui::PushID( label );
ImGui::AlignTextToFramePadding();
ImGui::PushClipRect( screenPos, ImVec2( screenPos.x + availableX - checkboxSize - innerSpacing, screenPos.y + checkboxSize ), true );
ImGui::TextUnformatted( label );
ImGui::PopClipRect();
ImGui::SameLine( 0.0f, innerSpacing );
ImGui::SetCursorPosX( cursorPos.x + availableX - checkboxSize );
bool result = ImGui::Checkbox( "", v );
ImGui::PopID();
return result;
}
This code basically puts an explicit label and a checkbox without a label into the same line, manipulates the id stack to avoid id conflicts and uses a clip rect for the label so that it doesn't overlap the checkbox. What is missing is that the label can be clicked to toggle the checkbox, but you can add that functionality too if you want/need it.
from imgui.
Related Issues (20)
- multiply defined sscanf error in example_glfw_opengl3 HOT 5
- Random Intermittent Crash - perhaps triggered by imgui reading outside of viewport buffer? HOT 6
- How to setup hardware mouse cursor ? HOT 6
- InputText is not working HOT 1
- `PushStyleVar(StyleVar_DockingSeparatorSize)` mid-frame has no effect on docked windows
- Help! Program crashes after ImGui panel is dragged slightly off screen HOT 1
- Android 13+ DisplayFramebufferScale 渲染不正常
- Clicking an empty Window area to lose keyboard focus from InputText widget. HOT 1
- imgui_impl_metal: resource leak when using thread-local GImGui HOT 2
- Crash after creating second viewport (docking branch, Vulkan+GLFW impl) HOT 13
- The buttons inside the table do not work HOT 2
- How to rename browser's tab? HOT 4
- Table range select HOT 17
- Integrating a libuv loop HOT 2
- Not an issue, just a perf profiling of InputTextMultiline on 4 million lines of text HOT 7
- ImGui::InputText not rendering key press using opengl HOT 4
- Missing right & bottom table outer borders when inside a window without padding (1.90 regression)
- Question: PushStyleColor HOT 2
- Clear InputText box after pressing Enter HOT 2
- impossible to compile a directx12 or any other example on windows 11, vs code, mingw, gcc for windows installed. does someone manage to launch the example_win32_directx12 for instance ? 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.