MCPcopy Create free account
hub / github.com/SpartanJ/eepp / displayTooltip

Method displayTooltip

src/tools/ecode/plugins/debugger/debuggerplugin.cpp:2419–2499  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2417}
2418
2419void DebuggerPlugin::displayTooltip( UICodeEditor* editor, const std::string& expression,
2420 const EvaluateInfo& info, const Vector2f& position ) {
2421 if ( mHoverTooltip == nullptr ) {
2422 UIWindow* win = UIWindow::New();
2423 win->setId( "debugger_hover_window" );
2424 win->setMinWindowSize( 400, 250 );
2425 win->setKeyBindingCommand( "closeWindow", [this, win, editor] {
2426 win->closeWindow();
2427 if ( getPluginContext()->getSplitter() &&
2428 getPluginContext()->getSplitter()->editorExists( editor ) )
2429 editor->setFocus();
2430 } );
2431 win->getKeyBindings().addKeybind( { KEY_ESCAPE }, "closeWindow" );
2432 win->setWindowFlags( UI_WIN_CLOSE_BUTTON | UI_WIN_USE_DEFAULT_BUTTONS_ACTIONS |
2433 UI_WIN_SHADOW | UI_WIN_EPHEMERAL | UI_WIN_RESIZEABLE |
2434 UI_WIN_DRAGGABLE_CONTAINER | UI_WIN_SHARE_ALPHA_WITH_CHILDREN );
2435 win->center();
2436 win->on( Event::OnWindowClose, [this]( auto ) { mHoverTooltip = nullptr; } );
2437 win->on( Event::OnWindowReady, [win]( auto ) { win->setFocus(); } );
2438
2439 UILinearLayout* vbox = UILinearLayout::NewVertical();
2440 vbox->setParent( win->getContainer() );
2441 vbox->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent );
2442
2443 UITreeView* tv = UITreeView::New();
2444 tv->setId( "debugger_hover_treeview" );
2445 tv->setHeadersVisible( false );
2446 tv->setAutoColumnsWidth( true );
2447 tv->setFitAllColumnsToWidget( true );
2448 tv->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::Fixed );
2449 tv->setLayoutWeight( 1 );
2450 tv->setParent( vbox );
2451 tv->setModel( mHoverExpressionsHolder->getModel() );
2452 tv->setFocusOnSelection( false );
2453
2454 tv->on( Event::OnModelEvent, [this]( const Event* event ) {
2455 if ( !mDebugger || !mListener )
2456 return;
2457 const ModelEvent* modelEvent = static_cast<const ModelEvent*>( event );
2458 auto idx( modelEvent->getModelIndex() );
2459 if ( modelEvent->getModelEventType() == Abstract::ModelEventType::OpenTree ) {
2460 ModelVariableNode* node =
2461 static_cast<ModelVariableNode*>( modelEvent->getModelIndex().internalData() );
2462 mDebugger->variables(
2463 node->var.variablesReference, Variable::Type::Both,
2464 [this]( const int variablesReference, std::vector<Variable>&& vars ) {
2465 mHoverExpressionsHolder->addVariables( variablesReference,
2466 std::move( vars ) );
2467 } );
2468 } else if ( modelEvent->getModelEventType() == Abstract::ModelEventType::OpenMenu &&
2469 idx.isValid() ) {
2470 mListener->createAndShowVariableMenu( idx );
2471 }
2472 } );
2473
2474 mHoverTooltip = win;
2475 }
2476

Callers

nothing calls this directly

Calls 15

hashFunction · 0.85
setMinWindowSizeMethod · 0.80
closeWindowMethod · 0.80
addKeybindMethod · 0.80
setWindowFlagsMethod · 0.80
centerMethod · 0.80
setParentMethod · 0.80
setLayoutSizePolicyMethod · 0.80
setAutoColumnsWidthMethod · 0.80
setLayoutWeightMethod · 0.80
setFocusOnSelectionMethod · 0.80

Tested by

no test coverage detected