static char THIS_FILE[] = __FILE__;
#endif
-/**
- * @brief Size of empty frame above and below bars (in pixels)
- */
+/** @brief Size of empty frame above and below bars (in pixels). */
static const DWORD Y_OFFSET = 5;
-/**
- * @brief Size of y-margin for visible area indicator (in pixels)
- */
+/** @brief Size of y-margin for visible area indicator (in pixels). */
static const long INDICATOR_MARGIN = 2;
-/**
- * @brief Max pixels in view per line in file
- */
+/** @brief Max pixels in view per line in file. */
static const double MAX_LINEPIX = 4.0;
+/** @brief Top of difference marker, relative to difference start. */
+static const int DIFFMARKER_TOP = 3;
+
+/** @brief Bottom of difference marker, relative to difference start. */
+static const int DIFFMARKER_BOTTOM = 3;
+
+/** @brief Width of difference marker. */
+static const int DIFFMARKER_WIDTH = 6;
+
/**
* @brief Bars in location pane
*/
, m_bIgnoreTrivials(true)
, m_hwndFrame(NULL)
, m_nPrevPaneWidth(0)
+ , m_DiffMarkerCoord(-1)
{
// NB: set m_bIgnoreTrivials to false to see trivial diffs in the LocationView
// There is no GUI to do this
int nEndY = (int) ((blockHeight + nstart0) * LineInPix + Y_OFFSET);
BOOL bInsideDiff = m_view[MERGE_VIEW_LEFT]->IsLineInCurrentDiff(nstart0);
+ // If no selected diff, remove diff marker
+ if (pDoc->GetCurrentDiff() == -1)
+ DrawDiffMarker(pDC, -1);
+
// Draw left side block
m_view[MERGE_VIEW_LEFT]->GetLineColors2(nstart0, ignoreFlags, cr0, crt, bwh);
CRect r0(m_nLeftBarLeft, nBeginY, m_nLeftBarRight, nEndY);
/**
* @brief Draw one block of map.
+ * @param [in] pDC Draw context.
+ * @param [in] r Rectangle to draw.
+ * @param [in] cr Color for rectange.
+ * @param [in] bSelected Is rectangle for selected difference?
*/
-void CLocationView::DrawRect(CDC* pDC, const CRect& r, COLORREF cr, BOOL border)
+void CLocationView::DrawRect(CDC* pDC, const CRect& r, COLORREF cr, BOOL bSelected)
{
// Draw only colored blocks
if (cr != CLR_NONE && cr != GetSysColor(COLOR_WINDOW))
CRect drawRect(r);
drawRect.DeflateRect(1, 0);
pDC->FillSolidRect(drawRect, cr);
+
+ if (bSelected)
+ {
+ DrawDiffMarker(pDC, r.top);
+ }
}
}
rcVisibleArea.left = m_nRightBarRight + 2;
rcVisibleArea.right = rc.Width() - 2;
pClientDC->FillSolidRect(rcVisibleArea, GetSysColor(COLOR_WINDOW));
+ if (((m_DiffMarkerCoord - DIFFMARKER_TOP >= m_visibleTop) &&
+ (m_DiffMarkerCoord - DIFFMARKER_TOP <= m_visibleBottom)) ||
+ ((m_DiffMarkerCoord + DIFFMARKER_BOTTOM >= m_visibleTop) &&
+ (m_DiffMarkerCoord + DIFFMARKER_BOTTOM <= m_visibleBottom)))
+ {
+ DrawDiffMarker(pClientDC, m_DiffMarkerCoord);
+ }
ReleaseDC(pClientDC);
}
rcVisibleArea.left = m_nRightBarRight + 2;
rcVisibleArea.right = rc.Width() - 2;
pClientDC->FillSolidRect(rcVisibleArea, GetSysColor(COLOR_SCROLLBAR));
+
+ if (((m_DiffMarkerCoord - DIFFMARKER_TOP >= m_visibleTop) &&
+ (m_DiffMarkerCoord - DIFFMARKER_TOP <= m_visibleBottom)) ||
+ ((m_DiffMarkerCoord + DIFFMARKER_BOTTOM >= m_visibleTop) &&
+ (m_DiffMarkerCoord + DIFFMARKER_BOTTOM <= m_visibleBottom)))
+ {
+ DrawDiffMarker(pClientDC, m_DiffMarkerCoord);
+ }
ReleaseDC(pClientDC);
}
::PostMessage(m_hwndFrame, MSG_STORE_PANESIZES, 0, 0);
}
}
+
+/**
+ * @brief Draw marker for top of currently selected difference.
+ * This function draws marker for top of currently selected difference.
+ * This marker makes it a lot easier to see where currently selected
+ * difference is in location bar. Especially when selected diffence is
+ * small and it is not easy to find it otherwise.
+ * @param [in] pDC Pointer to draw context.
+ * @param [in] yCoord Y-coord of top of difference, -1 if no difference.
+ */
+void CLocationView::DrawDiffMarker(CDC* pDC, int yCoord)
+{
+ // First erase marker from current position
+ if (m_DiffMarkerCoord != -1)
+ {
+ // If in visible area, use its background color
+ COLORREF cr;
+ if (m_DiffMarkerCoord > m_visibleTop && m_DiffMarkerCoord < m_visibleBottom)
+ cr = GetSysColor(COLOR_SCROLLBAR);
+ else
+ cr = GetSysColor(COLOR_WINDOW);
+
+ CRect rect;
+ rect.left = m_nLeftBarLeft - DIFFMARKER_WIDTH - 1;
+ rect.top = m_DiffMarkerCoord - DIFFMARKER_TOP;
+ rect.right = m_nLeftBarLeft;
+ rect.bottom = m_DiffMarkerCoord + DIFFMARKER_BOTTOM + 1;
+ pDC->FillSolidRect(rect, cr);
+
+ rect.left = m_nRightBarRight;
+ rect.right = m_nRightBarRight + 2 + DIFFMARKER_WIDTH;
+ pDC->FillSolidRect(rect, cr);
+ }
+
+ m_DiffMarkerCoord = yCoord;
+
+ // Then draw marker to new position
+ if (yCoord != -1)
+ {
+ CPoint points[3];
+ points[0].x = m_nLeftBarLeft - DIFFMARKER_WIDTH - 1;
+ points[0].y = yCoord - DIFFMARKER_TOP;
+ points[1].x = m_nLeftBarLeft - 1;
+ points[1].y = yCoord;
+ points[2].x = m_nLeftBarLeft - DIFFMARKER_WIDTH - 1;
+ points[2].y = yCoord + DIFFMARKER_BOTTOM;
+
+ CPen* oldObj = (CPen*)pDC->SelectStockObject(BLACK_PEN);
+ CBrush brushBlack(RGB(0, 0, 0));
+ CBrush* pOldBrush = pDC->SelectObject(&brushBlack);
+
+ pDC->SetPolyFillMode(WINDING);
+ pDC->Polygon(points, 3);
+
+ points[0].x = m_nRightBarRight + 1 + DIFFMARKER_WIDTH;
+ points[1].x = m_nRightBarRight + 1;
+ points[2].x = m_nRightBarRight + 1 + DIFFMARKER_WIDTH;
+ pDC->Polygon(points, 3);
+
+ pDC->SelectObject(pOldBrush);
+ pDC->SelectObject(oldObj);
+ }
+}
protected:
// Return end of block (diff/non-diff)
BOOL GetNextRect(int &nLineIndex);
- void DrawRect(CDC* pDC, const CRect& r, COLORREF cr, BOOL border = FALSE);
+ void DrawRect(CDC* pDC, const CRect& r, COLORREF cr, BOOL bSelected = FALSE);
BOOL GotoLocation(CPoint point, BOOL bRealLine = TRUE);
int GetLineFromYPos(int nYCoord, CRect rc, int bar, BOOL bRealLine = TRUE);
int IsInsideBar(CRect rc, POINT pt);
void DrawVisibleAreaRect(int nTopLine = -1, int nBottomLine = -1);
void DrawConnectLines();
+ void DrawDiffMarker(CDC* pDC, int yCoord);
private:
CMergeEditView* m_view[MERGE_VIEW_COUNT]; //*< Table for view pointers */
bool m_bIgnoreTrivials; //*< Whether to paint trivial blocks */
HWND m_hwndFrame; //*< Frame window handle */
UINT m_nPrevPaneWidth; //*< Previous pane width, used to track width changes */
+ int m_DiffMarkerCoord; //*< Y-Coord for active diff marker, -1 if no marker */
// Generated message map functions
protected: