MCPcopy Create free account
hub / github.com/BobbyAnguelov/Esoterica / DrawStateMachineNode

Method DrawStateMachineNode

Code/EngineTools/NodeGraph/NodeGraph_View.cpp:329–462  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

327 }
328
329 void GraphView::DrawStateMachineNode( DrawContext const& ctx, StateMachineNode* pNode )
330 {
331 EE_ASSERT( pNode != nullptr );
332
333 if ( !pNode->IsVisible() )
334 {
335 return;
336 }
337
338 //-------------------------------------------------------------------------
339 // Split Channels
340 //-------------------------------------------------------------------------
341
342 ImGui::PushID( pNode );
343
344 ctx.SplitDrawChannels();
345
346 //-------------------------------------------------------------------------
347 // Draw contents
348 //-------------------------------------------------------------------------
349
350 ctx.SetDrawChannel( (uint8_t) DrawChannel::Foreground );
351
352 ImVec2 newNodeWindowSize( 0, 0 );
353 ImVec2 const windowPosition = ctx.CanvasToWindowPosition( pNode->GetPosition() );
354 ImVec2 const scaledNodeMargin = ctx.CanvasToWindow( pNode->GetNodeMargin() );
355 ImVec2 const scaledColorItemSpacing( ( Style::s_titleBarColorItemWidth * ctx.m_viewScaleFactor ) - scaledNodeMargin.x, 0 );
356
357 ImGui::SetCursorPos( windowPosition );
358 ImGui::BeginGroup();
359 {
360 // Draw Title
361 //-------------------------------------------------------------------------
362
363 ImGuiX::ScopedFont fontOverride( ImGuiX::Font::Medium, Colors::White );
364 ImGui::BeginGroup();
365 ImGui::Dummy( scaledColorItemSpacing );
366 ImGui::SameLine();
367 if ( pNode->GetIcon() != nullptr )
368 {
369 ImGui::Text( pNode->GetIcon() );
370 ImGui::SameLine();
371 }
372 ImGui::Text( pNode->GetName() );
373 ImGui::EndGroup();
374
375 newNodeWindowSize = ImGui::GetItemRectSize();
376 pNode->m_titleRectSize = ctx.WindowToCanvas( newNodeWindowSize );
377
378 float const scaledSpacing = ctx.CanvasToWindow( Style::s_spacingBetweenTitleAndNodeContents );
379 ImGui::SetCursorPosY( ImGui::GetCursorPos().y + scaledSpacing );
380 newNodeWindowSize.y += scaledSpacing;
381
382 // Draw Extra Controls
383 //-------------------------------------------------------------------------
384
385 {
386 ImGuiX::ScopedFont const sf( ImGuiX::Font::Tiny );

Callers

nothing calls this directly

Calls 15

MaxFunction · 0.85
IsNodeSelectedFunction · 0.85
ImVec2Function · 0.85
SplitDrawChannelsMethod · 0.80
SetDrawChannelMethod · 0.80
CanvasToWindowMethod · 0.80
WindowToCanvasMethod · 0.80
AddRectMethod · 0.80
AddRectFilledMethod · 0.80

Tested by

no test coverage detected