From: Kimmo Varis Date: Sun, 20 Mar 2005 21:17:54 +0000 (+0000) Subject: PATCH: [ 1165515 ] Improve drawing location pane moved block lines X-Git-Tag: 2.16.5~6101 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=4b5586d3a5aefb04cdabd15d8c9ac3c256db40cb;p=winmerge-jp%2Fwinmerge-jp.git PATCH: [ 1165515 ] Improve drawing location pane moved block lines --- diff --git a/Src/LocationView.cpp b/Src/LocationView.cpp index bce719cae..266ee3c1f 100644 --- a/Src/LocationView.cpp +++ b/Src/LocationView.cpp @@ -156,6 +156,7 @@ void CLocationView::OnDraw(CDC* pDC) m_visibleTop = -1; m_visibleBottom = -1; DrawVisibleAreaRect(); + m_movedLines.RemoveAll(); while (true) { @@ -210,19 +211,21 @@ void CLocationView::OnDraw(CDC* pDC) int apparent1 = pDoc->RightLineInMovedBlock(apparent0); if (apparent1 != -1) { - // Draw connector between moved blocks - int nBeginY0 = (int) (apparent0 * LineInPix + Y_OFFSET); - int nEndY0 = (int) ((blockHeight + apparent0) * LineInPix + Y_OFFSET); - int nBeginY1 = (int) (apparent1 * LineInPix + Y_OFFSET); - int nEndY1 = (int) ((blockHeight + apparent1) * LineInPix + Y_OFFSET); - - CRect r0bis(m_nLeftBarLeft, nBeginY0, m_nLeftBarRight, nEndY0); - CRect r1bis(m_nRightBarLeft, nBeginY1, m_nRightBarRight, nEndY1); - - CPen* oldObj = (CPen*)pDC->SelectStockObject(BLACK_PEN); - pDC->MoveTo(r0bis.right, r0bis.CenterPoint().y); - pDC->LineTo(r1bis.left, r1bis.CenterPoint().y); - pDC->SelectObject(oldObj); + MovedLine line; + CPoint start; + CPoint end; + + start.x = m_nLeftBarRight; + int leftUpper = (int) (apparent0 * LineInPix + Y_OFFSET); + int leftLower = (int) ((blockHeight + apparent0) * LineInPix + Y_OFFSET); + start.y = leftUpper + (leftLower - leftUpper) / 2; + end.x = m_nRightBarLeft; + int rightUpper = (int) (apparent1 * LineInPix + Y_OFFSET); + int rightLower = (int) ((blockHeight + apparent1) * LineInPix + Y_OFFSET); + end.y = rightUpper + (rightLower - rightUpper) / 2; + line.ptLeft = start; + line.ptRight = end; + m_movedLines.AddTail(line); } } @@ -232,25 +235,30 @@ void CLocationView::OnDraw(CDC* pDC) int apparent0 = pDoc->LeftLineInMovedBlock(apparent1); if (apparent0 != -1) { - // Draw connector between moved blocks - int nBeginY0 = (int) (apparent0 * LineInPix + Y_OFFSET); - int nEndY0 = (int) ((blockHeight + apparent0) * LineInPix + Y_OFFSET); - int nBeginY1 = (int) (apparent1 * LineInPix + Y_OFFSET); - int nEndY1 = (int) ((blockHeight + apparent1) * LineInPix + Y_OFFSET); - - CRect r0bis(m_nLeftBarLeft, nBeginY0, m_nLeftBarRight, nEndY0); - CRect r1bis(m_nRightBarLeft, nBeginY1, m_nRightBarRight, nEndY1); - - CPen* oldObj = (CPen*)pDC->SelectStockObject(BLACK_PEN); - pDC->MoveTo(r0bis.right, r0bis.CenterPoint().y); - pDC->LineTo(r1bis.left, r1bis.CenterPoint().y); - pDC->SelectObject(oldObj); + MovedLine line; + CPoint start; + CPoint end; + + start.x = m_nLeftBarRight; + int leftUpper = (int) (apparent0 * LineInPix + Y_OFFSET); + int leftLower = (int) ((blockHeight + apparent0) * LineInPix + Y_OFFSET); + start.y = leftUpper + (leftLower - leftUpper) / 2; + end.x = m_nRightBarLeft; + int rightUpper = (int) (apparent1 * LineInPix + Y_OFFSET); + int rightLower = (int) ((blockHeight + apparent1) * LineInPix + Y_OFFSET); + end.y = rightUpper + (rightLower - rightUpper) / 2; + line.ptLeft = start; + line.ptRight = end; + m_movedLines.AddTail(line); } } nstart0 = nend0; } // blocks loop + + if (m_displayMovedBlocks != DISPLAY_MOVED_NONE) + DrawConnectLines(); } /** @@ -610,6 +618,8 @@ void CLocationView::DrawVisibleAreaRect(int nTopLine, int nBottomLine) void CLocationView::UpdateVisiblePos(int nTopLine, int nBottomLine) { DrawVisibleAreaRect(nTopLine, nBottomLine); + if (m_displayMovedBlocks != DISPLAY_MOVED_NONE) + DrawConnectLines(); } /** @@ -620,3 +630,23 @@ void CLocationView::OnClose() m_view0->m_pLocationView = NULL; m_view1->m_pLocationView = NULL; } + +/** + * @brief Draw lines connecting moved blocks. + */ +void CLocationView::DrawConnectLines() +{ + CDC *pClientDC = GetDC(); + CPen* oldObj = (CPen*)pClientDC->SelectStockObject(BLACK_PEN); + + POSITION pos = m_movedLines.GetHeadPosition(); + while (pos != NULL) + { + MovedLine line = m_movedLines.GetNext(pos); + pClientDC->MoveTo(line.ptLeft.x, line.ptLeft.y); + pClientDC->LineTo(line.ptRight.x, line.ptRight.y); + } + + pClientDC->SelectObject(oldObj); + ReleaseDC(pClientDC); +} diff --git a/Src/LocationView.h b/Src/LocationView.h index aa1ccbf39..97c33c2bd 100644 --- a/Src/LocationView.h +++ b/Src/LocationView.h @@ -13,13 +13,23 @@ /** * @brief Status for display moved block */ -enum +enum DISPLAY_MOVED_BLOCKS { DISPLAY_MOVED_NONE = 0, DISPLAY_MOVED_ALL, DISPLAY_MOVED_FOLLOW_DIFF, }; +/** + * @brief Endpoints of line connecting moved blocks + */ +struct MovedLine +{ + CPoint ptLeft; + CPoint ptRight; +}; + +typedef CList MOVEDLINE_LIST; /** * @brief Class showing map of files. @@ -53,6 +63,7 @@ protected: int GetLineFromYPos(int nYCoord, CRect rc, int bar); int IsInsideBar(CRect rc, POINT pt); void DrawVisibleAreaRect(int nTopLine = -1, int nBottomLine = -1); + void DrawConnectLines(); private: CMergeEditView* m_view0; @@ -65,6 +76,7 @@ private: UINT m_nRightBarRight; //*< Right edge of right-side bar */ int m_visibleTop; //*< Top visible line for visible area indicator */ int m_visibleBottom; //*< Bottom visible line for visible area indicator */ + MOVEDLINE_LIST m_movedLines; //*< List of moved block connecting lines */ // Generated message map functions protected: diff --git a/Src/readme.txt b/Src/readme.txt index e821545c3..95dce7067 100644 --- a/Src/readme.txt +++ b/Src/readme.txt @@ -1,3 +1,7 @@ +2005-03-20 Kimmo + PATCH: [ 1165515 ] Improve drawing location pane moved block lines + Src: LocationView.cpp LocationView.h + 2005-03-20 Jochen Update IDD_MERGE7ZMISMATCH resource in localized RC files Src/Languages: Merge*.rc