| 928 | // Broad hit-test |
| 929 | ImRect commentNodeRect = pNode->GetRect(); |
| 930 | commentNodeRect.Expand( dilationRadius ); |
| 931 | if ( commentNodeRect.Contains( ctx.m_mouseCanvasPos ) ) |
| 932 | { |
| 933 | // Test title region |
| 934 | ImRect commentNodeTitleRect( pNode->GetRect().Min, ctx.ScreenToCanvasPosition( titleRectMax ) ); |
| 935 | commentNodeTitleRect.Expand( dilationRadius ); |
| 936 | if ( commentNodeTitleRect.Contains( ctx.m_mouseCanvasPos ) ) |
| 937 | { |
| 938 | pNode->m_isHovered = true; |
| 939 | } |
| 940 | // Test Edges |
| 941 | else if ( pNode->GetHoveredResizeHandle( ctx ) != ResizeHandle::None ) |
| 942 | { |
| 943 | pNode->m_isHovered = true; |
| 944 | } |
| 945 | } |
| 946 | } |
| 947 | } |
| 948 | |
| 949 | //------------------------------------------------------------------------- |
| 950 | |
| 951 | void GraphView::UpdateAndDraw( TypeSystem::TypeRegistry const& typeRegistry, float childHeightOverride ) |
| 952 | { |
| 953 | EE_ASSERT( m_pUserContext != nullptr ); |
| 954 | |
| 955 | // Update context |
| 956 | //------------------------------------------------------------------------- |
| 957 | |
| 958 | m_pUserContext->m_isAltDown = ImGui::GetIO().KeyAlt; |
| 959 | m_pUserContext->m_isCtrlDown = ImGui::GetIO().KeyCtrl; |
| 960 | m_pUserContext->m_isShiftDown = ImGui::GetIO().KeyShift; |
| 961 | m_pUserContext->m_isReadOnly = m_isReadOnly; |
| 962 | |
| 963 | // Node visual update |
| 964 | //------------------------------------------------------------------------- |
| 965 | |
| 966 | if ( m_pGraph != nullptr ) |
| 967 | { |
| 968 | for ( TTypeInstance<BaseNode>& nodeInstance : m_pGraph->m_nodes ) |
| 969 | { |
| 970 | nodeInstance->PreDrawUpdate( m_pUserContext ); |
| 971 | } |
| 972 | } |
| 973 | |
| 974 | // Draw Graph |
| 975 | //------------------------------------------------------------------------- |
| 976 | |
| 977 | DrawContext drawingContext; |
| 978 | drawingContext.m_isReadOnly = m_isReadOnly; |
| 979 | |
| 980 | if ( BeginDrawCanvas( childHeightOverride ) ) |
| 981 | { |
| 982 | auto pWindow = ImGui::GetCurrentWindow(); |
| 983 | ImVec2 const mousePos = ImGui::GetMousePos(); |
| 984 | |
| 985 | drawingContext.SetViewScaleFactor( m_pGraph != nullptr ? m_pGraph->m_viewScaleFactor : 1.0f ); |
| 986 | drawingContext.m_pDrawList = ImGui::GetWindowDrawList(); |
| 987 | drawingContext.m_viewOffset = *m_pViewOffset; |
no test coverage detected