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

Method updateItemStatus

source/MRViewer/MRRibbonMenu.cpp:225–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

223}
224
225void RibbonMenu::updateItemStatus( const std::string& itemName )
226{
227 auto itemIt = RibbonSchemaHolder::schema().items.find( itemName );
228 if ( itemIt == RibbonSchemaHolder::schema().items.end() )
229 return;
230
231 auto& item = itemIt->second.item;
232 assert( item );
233 if ( item->isActive() )
234 {
235 if ( item->blocking() )
236 {
237 // disable old blocking first
238 if ( activeBlockingItem_.item && activeBlockingItem_.item != item )
239 itemPressed_( activeBlockingItem_.item );
240 activeBlockingItem_ = { item,false };
241 }
242 else
243 {
244 auto nonBlockingIt =
245 std::find_if( activeNonBlockingItems_.begin(), activeNonBlockingItems_.end(), [&] ( const auto& it )
246 {
247 return it.item == item;
248 } );
249 // add if it is not already in the list
250 if ( nonBlockingIt == activeNonBlockingItems_.end() )
251 activeNonBlockingItems_.push_back( { item,false } );
252 }
253 }
254 else
255 {
256 if ( item->blocking() )
257 {
258 if ( activeBlockingItem_.item && activeBlockingItem_.item == item )
259 activeBlockingItem_ = {};
260 }
261 else
262 {
263 for ( auto& it : activeNonBlockingItems_ )
264 if ( it.item == item )
265 it.item = {}; // do not erase while we could be iterating over this item right now, it will be removed from list after it
266 }
267 }
268}
269
270void RibbonMenu::drawActiveBlockingDialog_()
271{

Callers 1

enableMethod · 0.80

Calls 5

push_backMethod · 0.80
findMethod · 0.45
endMethod · 0.45
blockingMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected