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

Method DrawCommentNode

Code/EngineTools/NodeGraph/NodeGraph_View.cpp:823–926  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

821 {
822 outlineColor = AdjustColorBasedOnVisualState( outlineColor, visualState );
823 ImVec2 const activeBorderPadding( Style::s_activeBorderIndicatorPadding, Style::s_activeBorderIndicatorPadding );
824 ctx.m_pDrawList->AddRect( backgroundRectMin - activeBorderPadding, backgroundRectMax + activeBorderPadding, outlineColor, scaledCornerRounding, ImDrawFlags_RoundCornersAll, Style::s_activeBorderIndicatorThickness );
825 }
826
827 ctx.m_pDrawList->AddRectFilled( backgroundRectMin, backgroundRectMax, nodeBackgroundColor, scaledCornerRounding, ImDrawFlags_RoundCornersAll );
828 ctx.m_pDrawList->AddRectFilled( backgroundRectMin, rectTitleBarMax, nodeTitleBarColor, scaledCornerRounding, ImDrawFlags_RoundCornersTop);
829 ctx.m_pDrawList->AddRectFilled( backgroundRectMin, rectTitleBarColorItemMax, pNode->GetTitleBarColor(), scaledCornerRounding, ImDrawFlags_RoundCornersTopLeft );
830 ctx.m_pDrawList->AddRect( backgroundRectMin, backgroundRectMax, nodeBorderColor, scaledCornerRounding, ImDrawFlags_RoundCornersAll, scaledBorderThickness );
831
832 //-------------------------------------------------------------------------
833 // Merge Channels
834 //-------------------------------------------------------------------------
835
836 ctx.MergeDrawChannels();
837 ImGui::PopID();
838
839 //-------------------------------------------------------------------------
840
841 ImRect const nodeRect = pNode->GetRect();
842 pNode->m_isHovered = m_isViewHovered && nodeRect.Contains( ctx.m_mouseCanvasPos ) || pNode->m_pHoveredPin != nullptr;
843 }
844
845 void GraphView::DrawCommentNode( DrawContext const& ctx, CommentNode* pNode )
846 {
847 EE_ASSERT( pNode != nullptr );
848
849 if ( !pNode->IsVisible() )
850 {
851 return;
852 }
853
854 //-------------------------------------------------------------------------
855 // Split Channels
856 //-------------------------------------------------------------------------
857
858 ImGui::PushID( pNode );
859
860 ctx.SplitDrawChannels();
861
862 //-------------------------------------------------------------------------
863 // Draw contents
864 //-------------------------------------------------------------------------
865
866 ImVec2 const windowPosition = ctx.CanvasToWindowPosition( pNode->GetPosition() );
867 ImVec2 const textOffset = ctx.CanvasToWindow( ImGui::GetStyle().WindowPadding );
868 ImVec2 const textCursorStartPos = windowPosition + textOffset;
869
870 ctx.SetDrawChannel( (uint8_t) DrawChannel::Foreground );
871 ImGui::SetCursorPos( textCursorStartPos );
872 ImGui::BeginGroup();
873 {
874 ImGuiX::ScopedFont fontOverride( ImGuiX::Font::MediumBold );
875
876 float const nodeWindowWidth = ctx.CanvasToWindow( pNode->m_commentBoxSize.m_x );
877 ImGui::PushTextWrapPos( ImGui::GetCursorPosX() + nodeWindowWidth );
878 ImGui::Text( "%s %s", EE_ICON_COMMENT, pNode->GetName());
879 ImGuiX::TextTooltip( pNode->GetName() );
880 ImGui::PopTextWrapPos();

Callers

nothing calls this directly

Calls 15

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

Tested by

no test coverage detected