X-Git-Url: http://git.sourceforge.jp/view?p=tortoisegit%2FTortoiseGitJp.git;a=blobdiff_plain;f=src%2FTortoiseProc%2FGitLogListBase.cpp;h=f4e23143ff2f404ee1ac6acaca4a1a84101a4c05;hp=e61f6a2984257045996be9d122f1ae85d5a15b9b;hb=bde4c52c53f390bd9f1672916e5bba47cf55db95;hpb=a24e038e202c920955448351a6aa78cc566fd605 diff --git a/src/TortoiseProc/GitLogListBase.cpp b/src/TortoiseProc/GitLogListBase.cpp index e61f6a2..f4e2314 100644 --- a/src/TortoiseProc/GitLogListBase.cpp +++ b/src/TortoiseProc/GitLogListBase.cpp @@ -57,6 +57,8 @@ CGitLogListBase::CGitLogListBase():CHintListCtrl() , m_bStrictStopped(false) , m_pStoreSelection(NULL) , m_nSelectedFilter(LOGFILTER_ALL) + , m_bVista(false) + , m_bShowWC(false) { // use the default GUI font, create a copy of it and // change the copy to BOLD (leave the rest of the font @@ -72,7 +74,11 @@ CGitLogListBase::CGitLogListBase():CHintListCtrl() m_IsIDReplaceAction=FALSE; m_wcRev.m_CommitHash=GIT_REV_ZERO; - m_wcRev.m_Subject=_T("Working Copy"); + m_wcRev.m_Subject=_T("Working dir changes"); + m_wcRev.m_ParentHash.clear(); + m_wcRev.m_Mark=_T('-'); + m_wcRev.m_IsUpdateing=FALSE; + m_wcRev.m_IsFull = TRUE; m_hModifiedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONMODIFIED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE); m_hReplacedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONREPLACED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE); @@ -119,6 +125,13 @@ CGitLogListBase::CGitLogListBase():CHintListCtrl() m_ContextMenuMask &= ~GetContextMenuBit(ID_REBASE_EDIT); m_ContextMenuMask &= ~GetContextMenuBit(ID_REBASE_SKIP); + OSVERSIONINFOEX inf; + SecureZeroMemory(&inf, sizeof(OSVERSIONINFOEX)); + inf.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); + GetVersionEx((OSVERSIONINFO *)&inf); + WORD fullver = MAKEWORD(inf.dwMinorVersion, inf.dwMajorVersion); + m_bVista = (fullver >= 0x0600); + m_ColumnRegKey=_T("log"); } @@ -159,8 +172,25 @@ BEGIN_MESSAGE_MAP(CGitLogListBase, CHintListCtrl) ON_WM_CREATE() ON_WM_DESTROY() ON_MESSAGE(MSG_LOADED,OnLoad) + ON_WM_MEASUREITEM() + ON_WM_MEASUREITEM_REFLECT() END_MESSAGE_MAP() +void CGitLogListBase::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct) +{ + // TODO: ÔÚ´ËÌí¼ÓÏûÏ¢´¦Àí³ÌÐò´úÂëºÍ/»òµ÷ÓÃĬÈÏÖµ + + CListCtrl::OnMeasureItem(nIDCtl, lpMeasureItemStruct); +} + +void CGitLogListBase::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct) +{ + //if (m_nRowHeight>0) + { + lpMeasureItemStruct->itemHeight = 50; + } +} + int CGitLogListBase:: OnCreate(LPCREATESTRUCT lpCreateStruct) { PreSubclassWindow(); @@ -171,7 +201,9 @@ void CGitLogListBase::PreSubclassWindow() { SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES); // load the icons for the action columns - m_Theme.SetWindowTheme(GetSafeHwnd(), L"Explorer", NULL); +// m_Theme.Open(m_hWnd, L"ListView"); + m_Theme.Open(m_hWnd, L"Explorer::ListView;ListView"); + m_Theme.SetWindowTheme(m_hWnd, L"Explorer", NULL); CHintListCtrl::PreSubclassWindow(); } @@ -179,7 +211,7 @@ void CGitLogListBase::InsertGitColumn() { CString temp; - int c = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1; + int c = GetHeaderCtrl()->GetItemCount()-1; while (c>=0) DeleteColumn(c--); @@ -298,6 +330,7 @@ BOOL CGitLogListBase::GetShortName(CString ref, CString &shortname,CString prefi } return FALSE; } + void CGitLogListBase::FillBackGround(HDC hdc, int Index,CRect &rect) { // HBRUSH brush; @@ -309,10 +342,11 @@ void CGitLogListBase::FillBackGround(HDC hdc, int Index,CRect &rect) GetItem(&rItem); GitRev* pLogEntry = (GitRev*)m_arShownList.GetAt(Index); + HBRUSH brush = NULL; + if (m_Theme.IsAppThemed() && m_bVista) { - m_Theme.Open(m_hWnd, L"Explorer"); int state = LISS_NORMAL; if (rItem.state & LVIS_SELECTED) { @@ -323,34 +357,34 @@ void CGitLogListBase::FillBackGround(HDC hdc, int Index,CRect &rect) } else { -#if 0 - if (pLogEntry->bCopiedSelf) - { - // unfortunately, the pLVCD->nmcd.uItemState does not contain valid - // information at this drawing stage. But we can check the whether the - // previous stage changed the background color of the item - if (pLVCD->clrTextBk == GetSysColor(COLOR_MENU)) - { - HBRUSH brush; - brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU)); - if (brush) - { - ::FillRect(pLVCD->nmcd.hdc, &rect, brush); - ::DeleteObject(brush); - } - } - } -#endif + if(pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_SQUASH) + brush = ::CreateSolidBrush(RGB(156,156,156)); + else if(pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_EDIT) + brush = ::CreateSolidBrush(RGB(200,200,128)); } - if (m_Theme.IsBackgroundPartiallyTransparent(LVP_LISTDETAIL, state)) - m_Theme.DrawParentBackground(m_hWnd, hdc, &rect); + if (brush != NULL) + { + ::FillRect(hdc, &rect, brush); + ::DeleteObject(brush); + } + else + { + if (m_Theme.IsBackgroundPartiallyTransparent(LVP_LISTITEM, state)) + m_Theme.DrawParentBackground(m_hWnd, hdc, &rect); + + CRect rectDraw = rect; + if(rItem.state & LVIS_SELECTED) + rectDraw.InflateRect(1,0); + else + rectDraw.InflateRect(1,1); - m_Theme.DrawBackground(hdc, LVP_LISTDETAIL, state, &rect, NULL); + m_Theme.DrawBackground(hdc, LVP_LISTITEM, state, rectDraw, &rect); + } } else { - HBRUSH brush; + if (rItem.state & LVIS_SELECTED) { if (::GetFocus() == m_hWnd) @@ -367,7 +401,7 @@ void CGitLogListBase::FillBackGround(HDC hdc, int Index,CRect &rect) brush = ::CreateSolidBrush(RGB(156,156,156)); else if(pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_EDIT) brush = ::CreateSolidBrush(RGB(200,200,128)); - else + else brush = ::CreateSolidBrush(::GetSysColor(COLOR_WINDOW)); } if (brush == NULL) @@ -396,28 +430,38 @@ void CGitLogListBase::DrawTagBranch(HDC hdc,CRect &rect,INT_PTR index) str=m_HashMap[data->m_CommitHash][i]; CString shortname; - HBRUSH brush=0; - shortname=_T(""); + HBRUSH brush = 0; + shortname = _T(""); + COLORREF colRef = 0; + + //Determine label color if(GetShortName(str,shortname,_T("refs/heads/"))) { if( shortname == m_CurrentBranch ) - brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::CurrentBranch)); + colRef = m_Colors.GetColor(CColors::CurrentBranch); else - brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::LocalBranch)); + colRef = m_Colors.GetColor(CColors::LocalBranch); }else if(GetShortName(str,shortname,_T("refs/remotes/"))) { - brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::RemoteBranch)); + colRef = m_Colors.GetColor(CColors::RemoteBranch); } else if(GetShortName(str,shortname,_T("refs/tags/"))) { - brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::Tag)); + colRef = m_Colors.GetColor(CColors::Tag); } else if(GetShortName(str,shortname,_T("refs/stash"))) { - brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::Stash)); + colRef = m_Colors.GetColor(CColors::Stash); shortname=_T("stash"); } + + //When row selected, ajust label color + if (!(m_Theme.IsAppThemed() && m_bVista)) + if (rItem.state & LVIS_SELECTED) + colRef = CColors::MixColors(colRef, ::GetSysColor(COLOR_HIGHLIGHT), 150); + + brush = ::CreateSolidBrush(colRef); if(!shortname.IsEmpty()) @@ -427,46 +471,97 @@ void CGitLogListBase::DrawTagBranch(HDC hdc,CRect &rect,INT_PTR index) GetTextExtentPoint32(hdc, shortname,shortname.GetLength(),&size); rt.SetRect(rt.left,rt.top,rt.left+size.cx,rt.bottom); - rt.right+=4; + rt.right+=8; + + //Fill interior of ref label ::FillRect(hdc, &rt, brush); - if (rItem.state & LVIS_SELECTED) + + //Draw edge of label + CDC W_Dc; + W_Dc.Attach(hdc); + + CRect rectEdge = rt; + + W_Dc.Draw3dRect(rectEdge, m_Colors.Lighten(colRef,100), m_Colors.Darken(colRef,100)); + rectEdge.DeflateRect(1,1); + W_Dc.Draw3dRect(rectEdge, m_Colors.Lighten(colRef,50), m_Colors.Darken(colRef,50)); + + W_Dc.Detach(); + + //Draw text inside label + if (m_Theme.IsAppThemed() && m_bVista) { - COLORREF clrOld = ::SetTextColor(hdc,::GetSysColor(COLOR_HIGHLIGHTTEXT)); - ::DrawText(hdc,shortname,shortname.GetLength(),&rt,DT_CENTER); - ::SetTextColor(hdc,clrOld); - }else + int txtState = LISS_NORMAL; + if (rItem.state & LVIS_SELECTED) + txtState = LISS_SELECTED; + + m_Theme.DrawText(hdc, LVP_LISTITEM, txtState, shortname, -1, DT_CENTER | DT_SINGLELINE | DT_VCENTER, 0, &rt); + } + else { - ::DrawText(hdc,shortname,shortname.GetLength(),&rt,DT_CENTER); + if (rItem.state & LVIS_SELECTED) + { + COLORREF clrNew = ::GetSysColor(COLOR_HIGHLIGHTTEXT); + COLORREF clrOld = ::SetTextColor(hdc,clrNew); + ::DrawText(hdc,shortname,shortname.GetLength(),&rt,DT_CENTER | DT_SINGLELINE | DT_VCENTER); + ::SetTextColor(hdc,clrOld); + }else + { + ::DrawText(hdc,shortname,shortname.GetLength(),&rt,DT_CENTER | DT_SINGLELINE | DT_VCENTER); + } } - ::MoveToEx(hdc,rt.left,rt.top,NULL); - ::LineTo(hdc,rt.right,rt.top); - ::LineTo(hdc,rt.right,rt.bottom); - ::LineTo(hdc,rt.left,rt.bottom); - ::LineTo(hdc,rt.left,rt.top); + //::MoveToEx(hdc,rt.left,rt.top,NULL); + //::LineTo(hdc,rt.right,rt.top); + //::LineTo(hdc,rt.right,rt.bottom); + //::LineTo(hdc,rt.left,rt.bottom); + //::LineTo(hdc,rt.left,rt.top); + - rt.left=rt.right+3; + rt.left=rt.right+1; } if(brush) ::DeleteObject(brush); } rt.right=rect.right; - if (rItem.state & LVIS_SELECTED) + if (m_Theme.IsAppThemed() && m_bVista) { - COLORREF clrOld = ::SetTextColor(hdc,::GetSysColor(COLOR_HIGHLIGHTTEXT)); - ::DrawText(hdc,data->m_Subject,data->m_Subject.GetLength(),&rt,DT_LEFT); - ::SetTextColor(hdc,clrOld); - }else + int txtState = LISS_NORMAL; + if (rItem.state & LVIS_SELECTED) + txtState = LISS_SELECTED; + + m_Theme.DrawText(hdc, LVP_LISTITEM, txtState, data->m_Subject, -1, DT_LEFT | DT_SINGLELINE | DT_VCENTER, 0, &rt); + } + else { - ::DrawText(hdc,data->m_Subject,data->m_Subject.GetLength(),&rt,DT_LEFT); + if (rItem.state & LVIS_SELECTED) + { + COLORREF clrOld = ::SetTextColor(hdc,::GetSysColor(COLOR_HIGHLIGHTTEXT)); + ::DrawText(hdc,data->m_Subject,data->m_Subject.GetLength(),&rt,DT_LEFT | DT_SINGLELINE | DT_VCENTER); + ::SetTextColor(hdc,clrOld); + }else + { + ::DrawText(hdc,data->m_Subject,data->m_Subject.GetLength(),&rt,DT_LEFT | DT_SINGLELINE | DT_VCENTER); + } } - } +static COLORREF blend(const COLORREF& col1, const COLORREF& col2, int amount = 128) { + + // Returns ((256 - amount)*col1 + amount*col2) / 256; + return RGB(((256 - amount)*GetRValue(col1) + amount*GetRValue(col2) ) / 256, + ((256 - amount)*GetGValue(col1) + amount*GetGValue(col2) ) / 256, + ((256 - amount)*GetBValue(col1) + amount*GetBValue(col2) ) / 256); +} + +Gdiplus::Color GetGdiColor(COLORREF col) +{ + return Gdiplus::Color(GetRValue(col),GetGValue(col),GetBValue(col)); +} void CGitLogListBase::paintGraphLane(HDC hdc, int laneHeight,int type, int x1, int x2, - const COLORREF& col,int top + const COLORREF& col,const COLORREF& activeColor, int top ) { int h = laneHeight / 2; @@ -481,12 +576,97 @@ void CGitLogListBase::paintGraphLane(HDC hdc, int laneHeight,int type, int x1, i #define P_270 m , 2 * h+top #define R_CENTER m - r, h - r+top, m - r+d, h - r+top+d + + #define DELTA_UR_B 2*(x1 - m), 2*h +top + #define DELTA_UR_E 0*16, 90*16 +top // -, + + #define DELTA_DR_B 2*(x1 - m), 2*-h +top + #define DELTA_DR_E 270*16, 90*16 +top // -' + + #define DELTA_UL_B 2*(x2 - m), 2*h +top + #define DELTA_UL_E 90*16, 90*16 +top // ,- + + #define DELTA_DL_B 2*(x2 - m),2*-h +top + #define DELTA_DL_E 180*16, 90*16 // '- + + #define CENTER_UR x1, 2*h, 225 + #define CENTER_DR x1, 0 , 135 + #define CENTER_UL x2, 2*h, 315 + #define CENTER_DL x2, 0 , 45 + + + Gdiplus::Graphics graphics( hdc ); + + // arc + switch (type) { + case Lanes::JOIN: + case Lanes::JOIN_R: + case Lanes::HEAD: + case Lanes::HEAD_R: + { + Gdiplus::LinearGradientBrush gradient( + Gdiplus::Point(x1-2, h+top-2), + Gdiplus::Point(P_270), + GetGdiColor(activeColor),GetGdiColor(col)); + + + Gdiplus::Pen mypen(&gradient,2); + //Gdiplus::Pen mypen(Gdiplus::Color(0,0,0),2); + + //graphics.DrawRectangle(&mypen,x1-(x2-x1)/2,top+h, x2-x1,laneHeight); + graphics.DrawArc(&mypen,x1-(x2-x1)/2-1,top+h-1, x2-x1+1,laneHeight+1,270,90); + //graphics.DrawLine(&mypen,x1-1,h+top,P_270); + + break; + } + case Lanes::JOIN_L: + { + + Gdiplus::Pen mypen(Gdiplus::Color(0,0,0),2); + + + graphics.DrawArc(&mypen,x1,top+h, x2-x1,laneHeight,270,90); + + break; + } + case Lanes::TAIL: + case Lanes::TAIL_R: + { + + Gdiplus::LinearGradientBrush gradient( + Gdiplus::Point(x1-2, h+top-2), + Gdiplus::Point(P_90), + GetGdiColor(activeColor),GetGdiColor(col)); + + + Gdiplus::Pen mypen(&gradient,2); + + graphics.DrawArc(&mypen,x1-(x2-x1)/2-1,top-h-1, x2-x1+1,laneHeight+1,0,90); + + +#if 0 + QConicalGradient gradient(CENTER_DR); + gradient.setColorAt(0.375, activeCol); + gradient.setColorAt(0.625, col); + myPen.setBrush(gradient); + p->setPen(myPen); + p->drawArc(P_CENTER, DELTA_DR); +#endif + break; + } + default: + break; + } + + //static QPen myPen(Qt::black, 2); // fast path here CPen pen; pen.CreatePen(PS_SOLID,2,col); //myPen.setColor(col); HPEN oldpen=(HPEN)::SelectObject(hdc,(HPEN)pen); + Gdiplus::Pen myPen(GetGdiColor(col),2); + //p->setPen(myPen); // vertical line @@ -499,31 +679,33 @@ void CGitLogListBase::paintGraphLane(HDC hdc, int laneHeight,int type, int x1, i case Lanes::JOIN: case Lanes::JOIN_R: case Lanes::JOIN_L: - DrawLine(hdc,P_90,P_270); + case Lanes::CROSS: + //DrawLine(hdc,P_90,P_270); + graphics.DrawLine(&myPen,P_90,P_270); //p->drawLine(P_90, P_270); break; - case Lanes::HEAD: - case Lanes::HEAD_R: case Lanes::HEAD_L: case Lanes::BRANCH: - DrawLine(hdc,P_CENTER,P_270); + //DrawLine(hdc,P_CENTER,P_270); + graphics.DrawLine(&myPen,P_CENTER,P_270); //p->drawLine(P_CENTER, P_270); break; - case Lanes::TAIL: - case Lanes::TAIL_R: case Lanes::TAIL_L: case Lanes::INITIAL: case Lanes::BOUNDARY: case Lanes::BOUNDARY_C: case Lanes::BOUNDARY_R: case Lanes::BOUNDARY_L: - DrawLine(hdc,P_90, P_CENTER); + //DrawLine(hdc,P_90, P_CENTER); + graphics.DrawLine(&myPen,P_90,P_CENTER); //p->drawLine(P_90, P_CENTER); break; default: break; } + myPen.SetColor(GetGdiColor(activeColor)); + // horizontal line switch (type) { case Lanes::MERGE_FORK: @@ -533,23 +715,22 @@ void CGitLogListBase::paintGraphLane(HDC hdc, int laneHeight,int type, int x1, i case Lanes::CROSS: case Lanes::CROSS_EMPTY: case Lanes::BOUNDARY_C: - DrawLine(hdc,P_180,P_0); + //DrawLine(hdc,P_180,P_0); + graphics.DrawLine(&myPen,P_180,P_0); //p->drawLine(P_180, P_0); break; case Lanes::MERGE_FORK_R: - case Lanes::JOIN_R: - case Lanes::HEAD_R: - case Lanes::TAIL_R: case Lanes::BOUNDARY_R: - DrawLine(hdc,P_180,P_CENTER); + //DrawLine(hdc,P_180,P_CENTER); + graphics.DrawLine(&myPen,P_180,P_CENTER); //p->drawLine(P_180, P_CENTER); break; case Lanes::MERGE_FORK_L: - case Lanes::JOIN_L: case Lanes::HEAD_L: case Lanes::TAIL_L: case Lanes::BOUNDARY_L: - DrawLine(hdc,P_CENTER,P_0); + //DrawLine(hdc,P_CENTER,P_0); + graphics.DrawLine(&myPen,P_CENTER,P_0); //p->drawLine(P_CENTER, P_0); break; default: @@ -625,6 +806,9 @@ void CGitLogListBase::DrawGraph(HDC hdc,CRect &rect,INT_PTR index) //todo unfinished // return; GitRev* data = (GitRev*)m_arShownList.GetAt(index); + if(data->m_CommitHash.IsEmpty()) + return; + CRect rt=rect; LVITEM rItem; SecureZeroMemory(&rItem, sizeof(LVITEM)); @@ -643,16 +827,37 @@ void CGitLogListBase::DrawGraph(HDC hdc,CRect &rect,INT_PTR index) std::vector& lanes=data->m_Lanes; UINT laneNum = lanes.size(); - UINT mergeLane = 0; + UINT activeLane = 0; for (UINT i = 0; i < laneNum; i++) if (Lanes::isMerge(lanes[i])) { - mergeLane = i; + activeLane = i; break; } int x1 = 0, x2 = 0; int maxWidth = rect.Width(); int lw = 3 * rect.Height() / 4; //laneWidth() + + COLORREF activeColor = m_LineColors[activeLane % Lanes::COLORS_NUM]; + //if (opt.state & QStyle::State_Selected) + // activeColor = blend(activeColor, opt.palette.highlightedText().color(), 208); + + + for (unsigned int i = 0; i < laneNum && x2 < maxWidth; i++) + { + + x1 = x2; + x2 += lw; + + int ln = lanes[i]; + if (ln == Lanes::EMPTY) + continue; + + COLORREF color = i == activeLane ? activeColor : m_LineColors[i % Lanes::COLORS_NUM]; + paintGraphLane(hdc, rect.Height(),ln, x1+rect.left, x2+rect.left, color,activeColor, rect.top); + } + +#if 0 for (UINT i = 0; i < laneNum && x2 < maxWidth; i++) { x1 = x2; @@ -663,16 +868,16 @@ void CGitLogListBase::DrawGraph(HDC hdc,CRect &rect,INT_PTR index) continue; UINT col = ( Lanes:: isHead(ln) ||Lanes:: isTail(ln) || Lanes::isJoin(ln) - || ln ==Lanes:: CROSS_EMPTY) ? mergeLane : i; + || ln ==Lanes:: CROSS_EMPTY) ? activeLane : i; if (ln == Lanes::CROSS) { paintGraphLane(hdc, rect.Height(),Lanes::NOT_ACTIVE, x1, x2, m_LineColors[col % Lanes::COLORS_NUM],rect.top); - paintGraphLane(hdc, rect.Height(),Lanes::CROSS, x1, x2, m_LineColors[mergeLane % Lanes::COLORS_NUM],rect.top); + paintGraphLane(hdc, rect.Height(),Lanes::CROSS, x1, x2, m_LineColors[activeLane % Lanes::COLORS_NUM],rect.top); } else paintGraphLane(hdc, rect.Height(),ln, x1, x2, m_LineColors[col % Lanes::COLORS_NUM],rect.top); } +#endif - TRACE(_T("index %d %d\r\n"),index,data->m_Lanes.size()); } void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult) @@ -728,7 +933,7 @@ void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult) pLVCD->clrTextBk = RGB(156,156,156); else if(data->m_Action&CTGitPath::LOGACTIONS_REBASE_EDIT) pLVCD->clrTextBk = RGB(200,200,128); - else + else pLVCD->clrTextBk = ::GetSysColor(COLOR_WINDOW); if(data->m_Action&CTGitPath::LOGACTIONS_REBASE_CURRENT) @@ -745,13 +950,15 @@ void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult) // if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end())) // crText = GetSysColor(COLOR_GRAYTEXT); -// if (data->Rev == m_wcRev) -// { -// SelectObject(pLVCD->nmcd.hdc, m_boldFont); +// + if (data->m_CommitHash == GIT_REV_ZERO) + { + //crText = GetSysColor(RGB(200,200,0)); + //SelectObject(pLVCD->nmcd.hdc, m_boldFont); // We changed the font, so we're returning CDRF_NEWFONT. This // tells the control to recalculate the extent of the text. -// *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT; -// } + *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT; + } } } if (m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec) @@ -777,9 +984,19 @@ void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult) { CRect rect; GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect); + if(pLVCD->iSubItem == 0) + { + CRect second; + GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem+1, LVIR_BOUNDS, second); + rect.right=second.left; + } + TRACE(_T("A Graphic left %d right %d\r\n"),rect.left,rect.right); FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect); - DrawGraph(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec); + + GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec); + if( data ->m_CommitHash != GIT_REV_ZERO) + DrawGraph(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec); *pResult = CDRF_SKIPDEFAULT; return; @@ -812,7 +1029,8 @@ void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult) return; } - } + + } } if (pLVCD->iSubItem == 1) @@ -834,6 +1052,7 @@ void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult) GitRev* pLogEntry = reinterpret_cast(m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec)); CRect rect; GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect); + TRACE(_T("Action left %d right %d\r\n"),rect.left,rect.right); // Get the selected state of the // item being drawn. @@ -932,7 +1151,7 @@ void CGitLogListBase::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult) lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorName, pItem->cchTextMax); break; case this->LOGLIST_DATE: //Date - if (pLogEntry) + if (pLogEntry && pLogEntry->m_CommitHash != GIT_REV_ZERO) lstrcpyn(pItem->pszText, CAppUtils::FormatDateAndTime( pLogEntry->m_AuthorDate, m_DateFormat, true, m_bRelativeTimes ), pItem->cchTextMax); @@ -1033,11 +1252,12 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point) } //entry is selected, now show the popup menu CIconMenu popup; + CIconMenu submenu; if (popup.CreatePopupMenu()) { if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_PICK)) - popup.AppendMenuIcon(ID_REBASE_PICK, IDS_REBASE_SKIP, IDI_PICK); + popup.AppendMenuIcon(ID_REBASE_PICK, IDS_REBASE_PICK, IDI_PICK); if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_SQUASH)) popup.AppendMenuIcon(ID_REBASE_SQUASH,IDS_REBASE_SQUASH, IDI_SQUASH); @@ -1054,8 +1274,9 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point) if (GetSelectedCount() == 1) { + { - if (m_hasWC) + if(pSelLogEntry->m_CommitHash != GIT_REV_ZERO) { if(m_ContextMenuMask&GetContextMenuBit(ID_COMPARE)) popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF); @@ -1066,6 +1287,10 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point) // But until that's implemented, the context menu entry for // this feature is commented out. //popup.AppendMenu(ID_BLAMECOMPARE, IDS_LOG_POPUP_BLAMECOMPARE, IDI_BLAME); + }else + { + if(m_ContextMenuMask&GetContextMenuBit(ID_COMMIT)) + popup.AppendMenuIcon(ID_COMMIT, IDS_LOG_POPUP_COMMIT, IDI_COMMIT); } if(m_ContextMenuMask&GetContextMenuBit(ID_GNUDIFF1)) popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF); @@ -1101,32 +1326,42 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point) format.LoadString(IDS_RESET_TO_THIS_FORMAT); str.Format(format,g_Git.GetCurrentBranch()); - if(m_ContextMenuMask&GetContextMenuBit(ID_RESET)) - popup.AppendMenuIcon(ID_RESET,str,IDI_REVERT); + if(pSelLogEntry->m_CommitHash != GIT_REV_ZERO) + { + if(m_ContextMenuMask&GetContextMenuBit(ID_RESET)) + popup.AppendMenuIcon(ID_RESET,str,IDI_REVERT); - if(m_ContextMenuMask&GetContextMenuBit(ID_SWITCHTOREV)) - popup.AppendMenuIcon(ID_SWITCHTOREV, IDS_SWITCH_TO_THIS , IDI_SWITCH); + if(m_ContextMenuMask&GetContextMenuBit(ID_SWITCHTOREV)) + popup.AppendMenuIcon(ID_SWITCHTOREV, IDS_SWITCH_TO_THIS , IDI_SWITCH); - if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_BRANCH)) - popup.AppendMenuIcon(ID_CREATE_BRANCH, IDS_CREATE_BRANCH_AT_THIS , IDI_COPY); + if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_BRANCH)) + popup.AppendMenuIcon(ID_CREATE_BRANCH, IDS_CREATE_BRANCH_AT_THIS , IDI_COPY); - if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_TAG)) - popup.AppendMenuIcon(ID_CREATE_TAG,IDS_CREATE_TAG_AT_THIS , IDI_COPY); + if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_TAG)) + popup.AppendMenuIcon(ID_CREATE_TAG,IDS_CREATE_TAG_AT_THIS , IDI_COPY); - format.LoadString(IDS_REBASE_THIS_FORMAT); - str.Format(format,g_Git.GetCurrentBranch()); + format.LoadString(IDS_REBASE_THIS_FORMAT); + str.Format(format,g_Git.GetCurrentBranch()); - if(pSelLogEntry->m_CommitHash != m_HeadHash) - if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_TO_VERSION)) - popup.AppendMenuIcon(ID_REBASE_TO_VERSION, str , IDI_REBASE); + if(pSelLogEntry->m_CommitHash != m_HeadHash) + if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_TO_VERSION)) + popup.AppendMenuIcon(ID_REBASE_TO_VERSION, str , IDI_REBASE); - if(m_ContextMenuMask&GetContextMenuBit(ID_EXPORT)) - popup.AppendMenuIcon(ID_EXPORT,IDS_EXPORT_TO_THIS, IDI_EXPORT); + if(m_ContextMenuMask&GetContextMenuBit(ID_EXPORT)) + popup.AppendMenuIcon(ID_EXPORT,IDS_EXPORT_TO_THIS, IDI_EXPORT); - popup.AppendMenu(MF_SEPARATOR, NULL); + popup.AppendMenu(MF_SEPARATOR, NULL); + } } + + if(!pSelLogEntry->m_Ref.IsEmpty() && GetSelectedCount() == 1) + { + popup.AppendMenuIcon(ID_REFLOG_DEL, IDS_REFLOG_DEL, IDI_DELETE); + popup.AppendMenuIcon(ID_STASH_APPLY,IDS_MENUSTASHAPPLY, IDI_RELOCATE); + popup.AppendMenu(MF_SEPARATOR, NULL); + } if (GetSelectedCount() >= 2) { @@ -1156,7 +1391,7 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point) popup.AppendMenu(MF_SEPARATOR, NULL); } - if ( GetSelectedCount() >0 ) + if ( GetSelectedCount() >0 && pSelLogEntry->m_CommitHash != GIT_REV_ZERO) { if ( IsSelectionContinuous() && GetSelectedCount() >= 2 ) { @@ -1178,6 +1413,11 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point) } if(m_ContextMenuMask&GetContextMenuBit(ID_CHERRY_PICK)) popup.AppendMenuIcon(ID_CHERRY_PICK, IDS_CHERRY_PICK_VERSION, IDI_EXPORT); + + if(GetSelectedCount()<=2 || (IsSelectionContinuous() && GetSelectedCount() > 0)) + if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_PATCH)) + popup.AppendMenuIcon(ID_CREATE_PATCH, IDS_CREATE_PATCH, IDI_PATCH); + popup.AppendMenu(MF_SEPARATOR, NULL); } @@ -1211,6 +1451,38 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point) if(m_ContextMenuMask&GetContextMenuBit(ID_FINDENTRY)) popup.AppendMenuIcon(ID_FINDENTRY, IDS_LOG_POPUP_FIND); + + if (GetSelectedCount() == 1) + { + if(m_ContextMenuMask &GetContextMenuBit(ID_DELETE)) + { + if( this->m_HashMap.find(pSelLogEntry->m_CommitHash) != m_HashMap.end() ) + { + CString str; + str.LoadString(IDS_DELETE_BRANCHTAG); + if( m_HashMap[pSelLogEntry->m_CommitHash].size() == 1 ) + { + str+=_T(" "); + str+=m_HashMap[pSelLogEntry->m_CommitHash].at(0); + popup.AppendMenuIcon(ID_DELETE,str+_T("..."),IDI_DELETE); + } + else if( m_HashMap[pSelLogEntry->m_CommitHash].size() > 1 ) + { + + submenu.CreatePopupMenu(); + for(int i=0;im_CommitHash].size();i++) + { + submenu.AppendMenuIcon(ID_DELETE+(i<<16),m_HashMap[pSelLogEntry->m_CommitHash][i]+_T("...")); + } + + popup.AppendMenu(MF_BYPOSITION|MF_POPUP|MF_STRING,(UINT) submenu.m_hMenu,str); + + } + + } + } + } + int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0); // DialogEnableWindow(IDOK, FALSE); // SetPromptApp(&theApp); @@ -1489,20 +1761,29 @@ int CGitLogListBase::FillGitShortLog() mask = CGit::LOG_INFO_ONLY_HASH | CGit::LOG_INFO_BOUNDARY; // if(this->m_bAllBranch) mask |= m_ShowMask; - - this->m_logEntries.ParserShortLog(path,hash,-1,mask); + if(m_bShowWC) + this->m_logEntries.insert(m_logEntries.begin(),this->m_wcRev); + + this->m_logEntries.FetchShortLog(path,m_StartRef,-1,mask,m_bShowWC?1:0); //this->m_logEntries.ParserFromLog(); if(IsInWorkingThread()) + { PostMessage(LVM_SETITEMCOUNT, (WPARAM) this->m_logEntries.size(),(LPARAM) LVSICF_NOINVALIDATEALL); + } else + { SetItemCountEx(this->m_logEntries.size()); + } this->m_arShownList.RemoveAll(); for(unsigned int i=0;i0 || m_logEntries[i].m_CommitHash != GIT_REV_ZERO) + m_logEntries[i].m_Subject=_T("parser..."); + if(this->m_IsOldFirst) { this->m_arShownList.Add(&m_logEntries[m_logEntries.size()-1-i]); @@ -1612,8 +1893,8 @@ public: m_ByteCollector.append(data,size); //Find loginfo endmarker - static const BYTE dataToFind[]={0,0}; - int found=m_ByteCollector.findData(dataToFind,2); + static const BYTE dataToFind[]={0,0,'#','<'}; + int found=m_ByteCollector.findData(dataToFind,4); if(found<0) return m_ploglist->m_bExitThread;//Not found found+=2;//Position after loginfo end-marker @@ -1651,9 +1932,21 @@ public: GitRev* revInVector=&m_ploglist->m_logEntries[rev]; + if(revInVector->m_IsFull) + return; + + if(!m_ploglist->m_LogCache.GetCacheData(m_ploglist->m_logEntries[rev])) + { + ++m_CollectedCount; + InterlockedExchange(&m_ploglist->m_logEntries[rev].m_IsUpdateing,FALSE); + InterlockedExchange(&m_ploglist->m_logEntries[rev].m_IsFull,TRUE); + ::PostMessage(m_ploglist->m_hWnd,MSG_LOADED,(WPARAM)rev,0); + return; + } + // fullRev.m_IsUpdateing=TRUE; // fullRev.m_IsFull=TRUE; - + if(InterlockedExchange(&revInVector->m_IsUpdateing,TRUE)) return;//Cannot update this row now. Ignore. @@ -1669,6 +1962,9 @@ public: //So we need keep old bound mark. revInVector->m_ParentHash=oldlist; + //update cache + m_ploglist->m_LogCache.AddCacheEntry(*revInVector); + //Reset updating InterlockedExchange(&revInVector->m_IsFull,TRUE); InterlockedExchange(&revInVector->m_IsUpdateing,FALSE); @@ -1678,7 +1974,7 @@ public: ::PostMessage(m_ploglist->m_hWnd,MSG_LOADED,(WPARAM)rev,0); - DWORD percent=m_CollectedCount*98/m_ploglist->m_logEntries.size() + GITLOG_START+1; + DWORD percent=m_CollectedCount*68/m_ploglist->m_logEntries.size() + GITLOG_START+1+30; if(percent == GITLOG_END) percent = GITLOG_END -1; @@ -1691,26 +1987,37 @@ public: }; -void CGitLogListBase::FetchFullLogInfo() +void CGitLogListBase::FetchFullLogInfo(CString &from, CString &to) { CGitCall_FetchFullLogInfo fetcher(this); int mask= + CGit::LOG_INFO_FULL_DIFF| CGit::LOG_INFO_STAT| CGit::LOG_INFO_FILESTATE| CGit::LOG_INFO_DETECT_COPYRENAME| + CGit::LOG_INFO_SHOW_MERGEDFILE | m_ShowMask; - g_Git.GetLog(&fetcher,CString(),NULL,-1,mask); + + CTGitPath *path; + if(this->m_Path.IsEmpty()) + path=NULL; + else + path=&this->m_Path; + + g_Git.GetLog(&fetcher,CString(),path,-1,mask,&from,&to); } -void CGitLogListBase::FetchFullLogInfoOrig() +void CGitLogListBase::FetchLastLogInfo() { unsigned int updated=0; int percent=0; CRect rect; - while(1) { for(unsigned int i=0;iGetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) percent,0); - - + } } - if(updated==m_logEntries.size()) - break; } } @@ -1773,6 +2070,66 @@ UINT CGitLogListBase::LogThread() InterlockedExchange(&m_bNoDispUpdates, FALSE); return 0; } + InterlockedExchange(&m_bNoDispUpdates, FALSE); + ::PostMessage(GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_START_ALL, 0); + + int start=0; CString firstcommit,lastcommit; + int update=0; + for(int i=0;im_HeadHash,m_logEntries[i].m_Files); + m_logEntries[i].m_Action =0; + for(int j=0;j< m_logEntries[i].m_Files.GetCount();j++) + m_logEntries[i].m_Action |= m_logEntries[i].m_Files[j].m_Action; + + m_logEntries[i].m_Body.Format(_T("%d files changed"),m_logEntries[i].m_Files.GetCount()); + ::PostMessage(m_hWnd,MSG_LOADED,(WPARAM)0,0); + continue; + } + + start=this->m_logEntries[i].ParserFromLog(m_logEntries.m_RawlogData,start); + m_logEntries.m_HashMap[m_logEntries[i].m_CommitHash]=i; + + if(m_LogCache.GetCacheData(m_logEntries[i])) + { + if(firstcommit.IsEmpty()) + firstcommit=m_logEntries[i].m_CommitHash; + lastcommit=m_logEntries[i].m_CommitHash; + + }else + { + InterlockedExchange(&m_logEntries[i].m_IsUpdateing,FALSE); + InterlockedExchange(&m_logEntries[i].m_IsFull,TRUE); + update++; + } + ::PostMessage(m_hWnd,MSG_LOADED,(WPARAM) i, 0); + + if(start<0) + break; + if(start>=m_logEntries.m_RawlogData.size()) + break; + + int percent=i*30/m_logEntries.size() + GITLOG_START+1; + + ::PostMessage(GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) percent, 0); + + if(this->m_bExitThread) + { + InterlockedExchange(&m_bThreadRunning, FALSE); + InterlockedExchange(&m_bNoDispUpdates, FALSE); + return 0; + } + } + if(!lastcommit.IsEmpty()) + FetchFullLogInfo(lastcommit,firstcommit); + + this->FetchLastLogInfo(); + #if 0 RedrawItems(0, m_arShownList.GetCount()); // SetRedraw(false); @@ -1797,11 +2154,11 @@ UINT CGitLogListBase::LogThread() } } #endif - InterlockedExchange(&m_bNoDispUpdates, FALSE); + //FetchFullLogInfo(); - FetchFullLogInfoOrig(); + //FetchFullLogInfoOrig(); //RefreshCursor(); // make sure the filter is applied (if any) now, after we refreshed/fetched // the log messages @@ -1822,7 +2179,8 @@ void CGitLogListBase::Refresh() if(ret == WAIT_TIMEOUT) TerminateThread(); } - + + this->SetItemCountEx(0); this->Clear(); //Update branch and Tag info @@ -1830,7 +2188,7 @@ void CGitLogListBase::Refresh() //Assume Thread have exited //if(!m_bThreadRunning) { - this->SetItemCountEx(0); + m_logEntries.clear(); m_bExitThread=FALSE; InterlockedExchange(&m_bThreadRunning, TRUE); @@ -2115,13 +2473,9 @@ void CGitLogListBase::RemoveFilter() void CGitLogListBase::Clear() { m_arShownList.RemoveAll(); - m_logEntries.clear(); - m_logEntries.m_HashMap.clear(); DeleteAllItems(); - m_logEntries.m_Lns.clear(); - m_logEntries.m_FirstFreeLane=0; - m_logEntries.m_Lns.clear(); + m_logEntries.ClearAll(); } @@ -2152,6 +2506,11 @@ LRESULT CGitLogListBase::OnLoad(WPARAM wParam,LPARAM lParam) int i=(int)wParam; this->GetItemRect(i,&rect,LVIR_BOUNDS); this->InvalidateRect(rect); + + if(this->GetItemState(i,LVIF_STATE) & LVIS_SELECTED) + { + int i=0; + } return 0; }