MCPcopy Create free account
hub / github.com/TankOs/SFGUI / SetState

Method SetState

src/SFGUI/Widget.cpp:455–486  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

453}
454
455void Widget::SetState( State state ) {
456 // Do nothing if state wouldn't change.
457 if( GetState() == state ) {
458 return;
459 }
460
461 auto old_state = GetState();
462
463 // Store the new state.
464 m_state = state;
465
466 auto emit_state_change = false;
467
468 // If HandleStateChange() changed the state, do not call observer, will be
469 // done from there too.
470 if( GetState() != old_state ) {
471 HandleStateChange( static_cast<State>( old_state ) );
472 emit_state_change = true;
473 }
474
475 if( state == State::ACTIVE ) {
476 GrabFocus( shared_from_this() );
477 SetActiveWidget( shared_from_this() );
478 }
479 else if( old_state == State::ACTIVE ) {
480 SetActiveWidget( Ptr() );
481 }
482
483 if( emit_state_change ) {
484 GetSignals().Emit( OnStateChange );
485 }
486}
487
488Widget::State Widget::GetState() const {
489 return m_state;

Callers

nothing calls this directly

Calls 1

EmitMethod · 0.80

Tested by

no test coverage detected