| 1921 | } |
| 1922 | |
| 1923 | void GraphView::StartDraggingConnection( DrawContext const& ctx ) |
| 1924 | { |
| 1925 | EE_ASSERT( !m_isReadOnly ); |
| 1926 | EE_ASSERT( m_dragState.m_mode == DragMode::None ); |
| 1927 | EE_ASSERT( m_dragState.m_pNode != nullptr ); |
| 1928 | |
| 1929 | m_dragState.m_mode = DragMode::Connection; |
| 1930 | |
| 1931 | if ( IsViewingStateMachineGraph() ) |
| 1932 | { |
| 1933 | m_dragState.m_startValue = ctx.CanvasToScreenPosition( m_dragState.m_pNode->GetPosition() ); |
| 1934 | } |
| 1935 | else |
| 1936 | { |
| 1937 | m_dragState.m_startValue = m_dragState.m_pPin->m_position; |
| 1938 | } |
| 1939 | } |
| 1940 | |
| 1941 | void GraphView::OnDragConnection( DrawContext const& ctx ) |
| 1942 | { |
| 1943 | EE_ASSERT( !m_isReadOnly ); |
| 1944 | EE_ASSERT( m_dragState.m_mode == DragMode::Connection ); |
| 1945 | |
| 1946 | auto const& IO = ImGui::GetIO(); |
| 1947 | |
| 1948 | if ( !ImGui::IsMouseDown( ImGuiMouseButton_Left ) ) |
| 1949 | { |
| 1950 | StopDraggingConnection( ctx ); |
| 1951 | return; |
| 1952 | } |
| 1953 | |
| 1954 | //------------------------------------------------------------------------- |
| 1955 | |
| 1956 | if ( IsViewingStateMachineGraph() ) |
| 1957 | { |
| 1958 | auto pStateMachineGraph = GetStateMachineGraph(); |
| 1959 | auto pEndState = TryCast<StateNode>( m_pHoveredNode ); |
| 1960 | |
| 1961 | bool const isValidConnection = pEndState != nullptr && pStateMachineGraph->CanCreateTransitionConduit( Cast<StateNode>( m_dragState.m_pNode ), pEndState ); |
| 1962 | Color const connectionColor = isValidConnection ? Style::s_connectionColorValid : Style::s_connectionColorInvalid; |
| 1963 | ImGuiX::DrawArrow( ctx.m_pDrawList, ctx.CanvasToScreenPosition( m_dragState.m_pNode->GetRect().GetCenter() ), ctx.m_mouseScreenPos, connectionColor, Style::s_transitionArrowWidth ); |
| 1964 | } |
| 1965 | else |
| 1966 | { |
| 1967 | auto pFlowGraph = GetFlowGraph(); |
| 1968 | auto pDraggedFlowNode = m_dragState.GetAsFlowNode(); |
| 1969 | Color connectionColor = pDraggedFlowNode->GetPinColor( *m_dragState.m_pPin ); |
| 1970 | |
| 1971 | // Auto connection |
| 1972 | //------------------------------------------------------------------------- |
| 1973 | |
| 1974 | if ( IO.KeyAlt ) |
| 1975 | { |
| 1976 | FlowNode* pAutoConnectNode = nullptr; |
| 1977 | Pin* pAutoConnectPin = nullptr; |
| 1978 | TryGetAutoConnectionNodeAndPin( ctx, pAutoConnectNode, pAutoConnectPin ); |
| 1979 | |
| 1980 | if ( pAutoConnectPin != nullptr ) |
nothing calls this directly
no test coverage detected