| 921 | } |
| 922 | |
| 923 | void DebuggerPlugin::openExpressionMenu( ModelIndex idx ) { |
| 924 | UIPopUpMenu* menu = UIPopUpMenu::New(); |
| 925 | auto context = getPluginContext(); |
| 926 | |
| 927 | if ( idx.isValid() ) { |
| 928 | menu->add( context->i18n( "debugger_remove_expression", "Remove Expression" ), |
| 929 | context->findIcon( "remove" ) ) |
| 930 | ->setId( "debugger_remove_expression" ); |
| 931 | } |
| 932 | |
| 933 | menu->add( context->i18n( "debugger_add_expression", "Add Expression..." ), |
| 934 | context->findIcon( "add" ) ) |
| 935 | ->setId( "debugger_add_expression" ); |
| 936 | |
| 937 | menu->on( Event::OnItemClicked, [this, context, idx]( const Event* event ) { |
| 938 | UIMenuItem* item = event->getNode()->asType<UIMenuItem>(); |
| 939 | std::string id( item->getId() ); |
| 940 | if ( id == "debugger_remove_expression" ) { |
| 941 | ModelVariableNode* node = static_cast<ModelVariableNode*>( idx.internalData() ); |
| 942 | if ( mExpressionsHolder && node->getParent() == nullptr ) |
| 943 | removeExpression( node->var.name ); |
| 944 | } else if ( id == "debugger_add_expression" ) { |
| 945 | auto msgBox = |
| 946 | UIMessageBox::New( UIMessageBox::INPUT, context->i18n( "debugger_add_expression", |
| 947 | "Add Expression..." ) ); |
| 948 | msgBox->setCloseShortcut( { KEY_ESCAPE, KEYMOD_NONE } ); |
| 949 | msgBox->showWhenReady(); |
| 950 | msgBox->on( Event::OnConfirm, [this, msgBox]( const Event* ) { |
| 951 | std::string expression( msgBox->getTextInput()->getText().toUtf8() ); |
| 952 | if ( std::find( mExpressions.begin(), mExpressions.end(), expression ) == |
| 953 | mExpressions.end() ) { |
| 954 | mExpressions.push_back( expression ); |
| 955 | mExpressionsHolder->addChild( |
| 956 | std::make_shared<ModelVariableNode>( expression, 0 ) ); |
| 957 | msgBox->closeWindow(); |
| 958 | |
| 959 | if ( mDebuggingState == StatusDebuggerController::State::Paused && mListener ) { |
| 960 | mListener->evaluateExpression( expression ); |
| 961 | } |
| 962 | } |
| 963 | } ); |
| 964 | } |
| 965 | } ); |
| 966 | |
| 967 | Vector2f pos( context->getWindow()->getInput()->getMousePos().asFloat() ); |
| 968 | menu->nodeToWorldTranslation( pos ); |
| 969 | UIMenu::findBestMenuPos( pos, menu ); |
| 970 | menu->setPixelsPosition( pos ); |
| 971 | menu->show(); |
| 972 | } |
| 973 | void DebuggerPlugin::buildStatusBar() { |
| 974 | if ( mProjectPath.empty() ) { |
| 975 | hideStatusBarElement(); |
nothing calls this directly
no test coverage detected