| 192 | template std::optional<std::string> detail::createValueLow( std::string_view name, std::optional<BoundedValue<std::string>> value, bool consumeValueOverride, const EntryAttributes& attrs ); |
| 193 | |
| 194 | bool 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 | |
| 236 | std::optional<std::string> createValue( std::string_view name, std::string value, bool consumeValueOverride, std::optional<std::vector<std::string>> allowedValues, const EntryAttributes& attrs ) |
| 237 | { |
no test coverage detected