OSDN Git Service

PATCH: [ 1165515 ] Improve drawing location pane moved block lines
authorKimmo Varis <kimmov@gmail.com>
Sun, 20 Mar 2005 21:17:54 +0000 (21:17 +0000)
committerKimmo Varis <kimmov@gmail.com>
Sun, 20 Mar 2005 21:17:54 +0000 (21:17 +0000)
Src/LocationView.cpp
Src/LocationView.h
Src/readme.txt

index bce719c..266ee3c 100644 (file)
@@ -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);
+}
index aa1ccbf..97c33c2 100644 (file)
 /**
  * @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, MovedLine&> 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:
index e821545..95dce70 100644 (file)
@@ -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