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

Function createButton

source/MRViewer/MRUITestEngine.cpp:194–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192template std::optional<std::string> detail::createValueLow( std::string_view name, std::optional<BoundedValue<std::string>> value, bool consumeValueOverride, const EntryAttributes& attrs );
193
194bool createButton( std::string_view name, const EntryAttributes& attrs )
195{
196 #if MR_ENABLE_UI_TEST_ENGINE
197 checkForNewFrame();
198
199 auto& map = state.stack.back()->elems;
200 auto iter = map.find( name ); // I wish I could use `std::try_emplace` here directly...
201 if ( iter == map.end() )
202 {
203 iter = map.try_emplace( std::string( name ) ).first;
204 }
205 else
206 {
207 // If you see this assert, you likely have duplicate button names.
208 // If you truly have several buttons with the same name in one place, add unique `##...` suffixes to them.
209 // If the buttons are in different parts of the application and shouldn't collide,
210 // use `UI::TestEngine::pushTree("...")` and `popTree()` to group them into named groups, with unique names in each group.
211 assert( !iter->second.visitedOnThisFrame && "Registering the same entry more than once in a single frame!" );
212 }
213
214 ButtonEntry* button = std::get_if<ButtonEntry>( &iter->second.value );
215 if ( !button )
216 button = &iter->second.value.emplace<ButtonEntry>();
217
218 button->disabledReason = effectiveDisabledReason( attrs );
219
220 iter->second.visitedOnThisFrame = true;
221
222 // commented, because it is already logged in MRPythonUiInteraction.cpp/pressButton
223 // if ( button->simulateClick )
224 // spdlog::info( "Button {} click simulation", name );
225
226 const bool clicked = std::exchange( button->simulateClick, false );
227 if ( clicked )
228 state.frameTriggered = true;
229 return clicked;
230 #else
231 (void)attrs;
232 return false;
233 #endif
234}
235
236std::optional<std::string> createValue( std::string_view name, std::string value, bool consumeValueOverride, std::optional<std::vector<std::string>> allowedValues, const EntryAttributes& attrs )
237{

Callers 5

buttonExFunction · 0.85
radioButtonFunction · 0.85
drawCustomButtonItemMethod · 0.85
drawButtonDropItem_Method · 0.85
drawHeaderPannel_Method · 0.85

Calls 4

checkForNewFrameFunction · 0.85
effectiveDisabledReasonFunction · 0.85
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected