MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / checkboxOrModifier

Function checkboxOrModifier

source/MRViewer/MRUIStyle.cpp:970–1006  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

968}
969
970bool checkboxOrModifier( const char* label, CheckboxOrModifierState& value, int modifiers, int respectedModifiers, std::optional<bool> valueOverride )
971{
972 assert( modifiers != 0 );
973
974 if ( respectedModifiers == -1 )
975 respectedModifiers = modifiers;
976
977 assert( ( respectedModifiers & modifiers ) == modifiers && "`respectedModifiers` must be a superset of `modifiers`." );
978
979 // Unsure if `!valueOverride &&` is a good idea here. Sounds good on the surface, to prevent silent value modifications via the modifier while
980 // the override is active. And delaying it until it becomes inactive would be weird too.
981 bool modHeld = !valueOverride && ( ImGui::GetIO().KeyMods & respectedModifiers ) == modifiers;
982
983 bool modChanged = value.modifierHeld != modHeld;
984 value.modifierHeld = modHeld;
985
986 bool ret = checkboxOrFixedValue( label, &value.baseValue, valueOverride ? valueOverride : modHeld ? std::optional( bool( value ) ) : std::nullopt );
987
988 { // Modifiers hint.
989 std::string modsText = modifiersToString( modifiers );
990 ImGui::SameLine();
991 // ImGui::SetCursorPosY( ImGui::GetCursorPosY() + cCheckboxPadding * ImGuiMenu::instance()->menu_scaling() );
992 // alignTextToCheckBox( ImGuiMenu::instance()->menu_scaling() );
993 // Neither of above is needed, the UI::checkbox... functions align the following text automatically
994 ImGui::TextDisabled( "[%s]", modsText.c_str() );
995 }
996
997 if ( modChanged )
998 {
999 ret = true;
1000 // Consider changes made with modifiers not permanent, IsItemDeactivatedAfterEdit() not affected
1001 // Actually, having two active elements (activated with mouse and with mods) confuses ImGui, better avoid it
1002 // detail::markItemEdited( ImGui::GetID( label ) );
1003 }
1004
1005 return ret;
1006}
1007
1008bool radioButton( const char* label, int* value, int valButton )
1009{

Callers

nothing calls this directly

Calls 2

checkboxOrFixedValueFunction · 0.85
modifiersToStringFunction · 0.85

Tested by

no test coverage detected