X-Git-Url: http://git.sourceforge.jp/view?p=tortoisegit%2FTortoiseGitJp.git;a=blobdiff_plain;f=src%2FTortoiseProc%2FGitLogListBase.cpp;h=f4e23143ff2f404ee1ac6acaca4a1a84101a4c05;hp=2f8cd2d3bbcf1833df2e955f7b4d2492480304c5;hb=bde4c52c53f390bd9f1672916e5bba47cf55db95;hpb=f41c550c62b5256aa6238e91b3711d7607c80f42 diff --git a/src/TortoiseProc/GitLogListBase.cpp b/src/TortoiseProc/GitLogListBase.cpp index 2f8cd2d..f4e2314 100644 --- a/src/TortoiseProc/GitLogListBase.cpp +++ b/src/TortoiseProc/GitLogListBase.cpp @@ -58,6 +58,7 @@ CGitLogListBase::CGitLogListBase():CHintListCtrl() , 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 @@ -73,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); @@ -167,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(); @@ -179,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(); } @@ -187,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--); @@ -306,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; @@ -317,12 +342,11 @@ void CGitLogListBase::FillBackGround(HDC hdc, int Index,CRect &rect) GetItem(&rItem); GitRev* pLogEntry = (GitRev*)m_arShownList.GetAt(Index); - HBRUSH brush; + 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) { @@ -337,19 +361,26 @@ 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)); + } - if (brush == NULL) - return; - + if (brush != NULL) + { ::FillRect(hdc, &rect, brush); ::DeleteObject(brush); - } - - if (m_Theme.IsBackgroundPartiallyTransparent(LVP_LISTDETAIL, state)) - m_Theme.DrawParentBackground(m_hWnd, hdc, &rect); else - m_Theme.DrawBackground(hdc, LVP_LISTDETAIL, state, &rect, NULL); + { + 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_LISTITEM, state, rectDraw, &rect); + } } else { @@ -370,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) @@ -399,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()) @@ -430,44 +471,95 @@ 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,const COLORREF& activeColor, int top ) @@ -484,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 @@ -502,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: @@ -536,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: @@ -676,7 +854,7 @@ void CGitLogListBase::DrawGraph(HDC hdc,CRect &rect,INT_PTR index) continue; COLORREF color = i == activeLane ? activeColor : m_LineColors[i % Lanes::COLORS_NUM]; - paintGraphLane(hdc, rect.Height(),ln, x1, x2, color,activeColor, rect.top); + paintGraphLane(hdc, rect.Height(),ln, x1+rect.left, x2+rect.left, color,activeColor, rect.top); } #if 0 @@ -700,7 +878,6 @@ void CGitLogListBase::DrawGraph(HDC hdc,CRect &rect,INT_PTR index) } #endif - TRACE(_T("index %d %d\r\n"),index,data->m_Lanes.size()); } void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult) @@ -756,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) @@ -773,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) @@ -805,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; @@ -840,7 +1029,8 @@ void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult) return; } - } + + } } if (pLVCD->iSubItem == 1) @@ -862,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. @@ -960,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); @@ -1066,7 +1257,7 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point) { 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); @@ -1083,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); @@ -1095,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); @@ -1130,30 +1326,33 @@ 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); + } } @@ -1192,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 ) { @@ -1215,7 +1414,7 @@ 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) + if(GetSelectedCount()<=2 || (IsSelectionContinuous() && GetSelectedCount() > 0)) if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_PATCH)) popup.AppendMenuIcon(ID_CREATE_PATCH, IDS_CREATE_PATCH, IDI_PATCH); @@ -1562,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.FetchShortLog(path,m_StartRef,-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]); @@ -1783,6 +1991,7 @@ 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| @@ -1868,6 +2077,21 @@ UINT CGitLogListBase::LogThread() 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; @@ -1883,6 +2107,8 @@ UINT CGitLogListBase::LogThread() 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()) @@ -1891,7 +2117,6 @@ UINT CGitLogListBase::LogThread() int percent=i*30/m_logEntries.size() + GITLOG_START+1; ::PostMessage(GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) percent, 0); - ::PostMessage(m_hWnd,MSG_LOADED,(WPARAM) i, 0); if(this->m_bExitThread) { @@ -1954,7 +2179,8 @@ void CGitLogListBase::Refresh() if(ret == WAIT_TIMEOUT) TerminateThread(); } - + + this->SetItemCountEx(0); this->Clear(); //Update branch and Tag info @@ -1962,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); @@ -2280,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; }