OSDN Git Service

Merge QGit2.3 graphic tree
authorFrank Li <lznuaa@gmail.com>
Sat, 16 May 2009 06:55:20 +0000 (14:55 +0800)
committerFrank Li <lznuaa@gmail.com>
Sat, 16 May 2009 15:20:56 +0000 (23:20 +0800)
src/TortoiseProc/GitLogListBase.cpp
src/TortoiseProc/GitLogListBase.h
src/TortoiseProc/LogDlg.cpp

index 2f8cd2d..9dae894 100644 (file)
@@ -167,8 +167,25 @@ BEGIN_MESSAGE_MAP(CGitLogListBase, CHintListCtrl)
        ON_WM_CREATE()\r
        ON_WM_DESTROY()\r
        ON_MESSAGE(MSG_LOADED,OnLoad)\r
+       ON_WM_MEASUREITEM()\r
+       ON_WM_MEASUREITEM_REFLECT()\r
 END_MESSAGE_MAP()\r
 \r
+void CGitLogListBase::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct)\r
+{\r
+       // TODO: ÔÚ´ËÌí¼ÓÏûÏ¢´¦Àí³ÌÐò´úÂëºÍ/»òµ÷ÓÃĬÈÏÖµ\r
+\r
+       CListCtrl::OnMeasureItem(nIDCtl, lpMeasureItemStruct);\r
+}\r
+\r
+void CGitLogListBase::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)\r
+{\r
+       //if (m_nRowHeight>0)\r
+       {\r
+               lpMeasureItemStruct->itemHeight = 50;\r
+       }\r
+}\r
+\r
 int CGitLogListBase:: OnCreate(LPCREATESTRUCT lpCreateStruct)\r
 {\r
        PreSubclassWindow();\r
@@ -468,6 +485,18 @@ void CGitLogListBase::DrawTagBranch(HDC hdc,CRect &rect,INT_PTR index)
        \r
 }\r
 \r
+static COLORREF blend(const COLORREF& col1, const COLORREF& col2, int amount = 128) {\r
+\r
+       // Returns ((256 - amount)*col1 + amount*col2) / 256;\r
+       return RGB(((256 - amount)*GetRValue(col1)   + amount*GetRValue(col2)  ) / 256,\r
+                     ((256 - amount)*GetGValue(col1) + amount*GetGValue(col2) ) / 256,\r
+                     ((256 - amount)*GetBValue(col1)  + amount*GetBValue(col2) ) / 256);\r
+}\r
+\r
+Gdiplus::Color GetGdiColor(COLORREF col)\r
+{\r
+       return Gdiplus::Color(GetRValue(col),GetGValue(col),GetBValue(col));\r
+}\r
 void CGitLogListBase::paintGraphLane(HDC hdc, int laneHeight,int type, int x1, int x2,\r
                                       const COLORREF& col,const COLORREF& activeColor, int top\r
                                                                          )  \r
@@ -484,12 +513,97 @@ void CGitLogListBase::paintGraphLane(HDC hdc, int laneHeight,int type, int x1, i
        #define P_270    m , 2 * h+top\r
        #define R_CENTER m - r, h - r+top, m - r+d, h - r+top+d\r
 \r
+\r
+       #define DELTA_UR_B 2*(x1 - m), 2*h +top \r
+       #define DELTA_UR_E 0*16, 90*16 +top  // -,\r
+\r
+       #define DELTA_DR_B 2*(x1 - m), 2*-h +top\r
+       #define DELTA_DR_E 270*16, 90*16 +top  // -'\r
+\r
+       #define DELTA_UL_B 2*(x2 - m), 2*h +top\r
+       #define DELTA_UL_E 90*16, 90*16 +top //  ,-\r
+\r
+       #define DELTA_DL_B 2*(x2 - m),2*-h +top \r
+       #define DELTA_DL_E 180*16, 90*16  //  '-\r
+\r
+       #define CENTER_UR x1, 2*h, 225\r
+       #define CENTER_DR x1, 0  , 135\r
+       #define CENTER_UL x2, 2*h, 315\r
+       #define CENTER_DL x2, 0  ,  45\r
+\r
+\r
+       Gdiplus::Graphics graphics( hdc );\r
+\r
+       // arc\r
+       switch (type) {\r
+       case Lanes::JOIN:\r
+       case Lanes::JOIN_R:\r
+       case Lanes::HEAD:\r
+       case Lanes::HEAD_R: \r
+       {\r
+               Gdiplus::LinearGradientBrush gradient(\r
+                                                               Gdiplus::Point(x1-2, h+top-2),\r
+                                                               Gdiplus::Point(P_270),\r
+                                                               GetGdiColor(activeColor),GetGdiColor(col));\r
+\r
+               \r
+               Gdiplus::Pen mypen(&gradient,2);\r
+               //Gdiplus::Pen mypen(Gdiplus::Color(0,0,0),2);\r
+               \r
+               //graphics.DrawRectangle(&mypen,x1-(x2-x1)/2,top+h, x2-x1,laneHeight);\r
+               graphics.DrawArc(&mypen,x1-(x2-x1)/2-1,top+h-1, x2-x1+1,laneHeight+1,270,90);\r
+               //graphics.DrawLine(&mypen,x1-1,h+top,P_270);\r
+\r
+               break;\r
+       }\r
+       case Lanes::JOIN_L: \r
+       {\r
+       \r
+               Gdiplus::Pen mypen(Gdiplus::Color(0,0,0),2);\r
+\r
+               \r
+               graphics.DrawArc(&mypen,x1,top+h, x2-x1,laneHeight,270,90);\r
+\r
+               break;\r
+       }\r
+       case Lanes::TAIL:\r
+       case Lanes::TAIL_R: \r
+       {\r
+               \r
+               Gdiplus::LinearGradientBrush gradient(\r
+                                                               Gdiplus::Point(x1-2, h+top-2),\r
+                                                               Gdiplus::Point(P_90),\r
+                                                               GetGdiColor(activeColor),GetGdiColor(col));\r
+\r
+               \r
+               Gdiplus::Pen mypen(&gradient,2);\r
+\r
+               graphics.DrawArc(&mypen,x1-(x2-x1)/2-1,top-h-1, x2-x1+1,laneHeight+1,0,90);\r
+\r
+\r
+#if 0\r
+               QConicalGradient gradient(CENTER_DR);\r
+               gradient.setColorAt(0.375, activeCol);\r
+               gradient.setColorAt(0.625, col);\r
+               myPen.setBrush(gradient);\r
+               p->setPen(myPen);\r
+               p->drawArc(P_CENTER, DELTA_DR);\r
+#endif\r
+               break;\r
+       }\r
+       default:\r
+               break;\r
+       }\r
+\r
+\r
        //static QPen myPen(Qt::black, 2); // fast path here\r
        CPen pen;\r
        pen.CreatePen(PS_SOLID,2,col);\r
        //myPen.setColor(col);\r
        HPEN oldpen=(HPEN)::SelectObject(hdc,(HPEN)pen);\r
 \r
+       Gdiplus::Pen myPen(GetGdiColor(col),2);\r
+\r
        //p->setPen(myPen);\r
 \r
        // vertical line\r
@@ -502,31 +616,33 @@ void CGitLogListBase::paintGraphLane(HDC hdc, int laneHeight,int type, int x1, i
        case Lanes::JOIN:\r
        case Lanes::JOIN_R:\r
        case Lanes::JOIN_L:\r
-               DrawLine(hdc,P_90,P_270);\r
+       case Lanes::CROSS:\r
+               //DrawLine(hdc,P_90,P_270);\r
+               graphics.DrawLine(&myPen,P_90,P_270);\r
                //p->drawLine(P_90, P_270);\r
                break;\r
-       case Lanes::HEAD:\r
-       case Lanes::HEAD_R:\r
        case Lanes::HEAD_L:\r
        case Lanes::BRANCH:\r
-               DrawLine(hdc,P_CENTER,P_270);\r
+               //DrawLine(hdc,P_CENTER,P_270);\r
+               graphics.DrawLine(&myPen,P_CENTER,P_270);\r
                //p->drawLine(P_CENTER, P_270);\r
                break;\r
-       case Lanes::TAIL:\r
-       case Lanes::TAIL_R:\r
        case Lanes::TAIL_L:\r
        case Lanes::INITIAL:\r
        case Lanes::BOUNDARY:\r
        case Lanes::BOUNDARY_C:\r
        case Lanes::BOUNDARY_R:\r
        case Lanes::BOUNDARY_L:\r
-               DrawLine(hdc,P_90, P_CENTER);\r
+               //DrawLine(hdc,P_90, P_CENTER);\r
+               graphics.DrawLine(&myPen,P_90,P_CENTER);\r
                //p->drawLine(P_90, P_CENTER);\r
                break;\r
        default:\r
                break;\r
        }\r
 \r
+       myPen.SetColor(GetGdiColor(activeColor));\r
+\r
        // horizontal line\r
        switch (type) {\r
        case Lanes::MERGE_FORK:\r
@@ -536,23 +652,22 @@ void CGitLogListBase::paintGraphLane(HDC hdc, int laneHeight,int type, int x1, i
        case Lanes::CROSS:\r
        case Lanes::CROSS_EMPTY:\r
        case Lanes::BOUNDARY_C:\r
-               DrawLine(hdc,P_180,P_0);\r
+               //DrawLine(hdc,P_180,P_0);\r
+               graphics.DrawLine(&myPen,P_180,P_0);\r
                //p->drawLine(P_180, P_0);\r
                break;\r
        case Lanes::MERGE_FORK_R:\r
-       case Lanes::JOIN_R:\r
-       case Lanes::HEAD_R:\r
-       case Lanes::TAIL_R:\r
        case Lanes::BOUNDARY_R:\r
-               DrawLine(hdc,P_180,P_CENTER);\r
+               //DrawLine(hdc,P_180,P_CENTER);\r
+               graphics.DrawLine(&myPen,P_180,P_CENTER);\r
                //p->drawLine(P_180, P_CENTER);\r
                break;\r
        case Lanes::MERGE_FORK_L:\r
-       case Lanes::JOIN_L:\r
        case Lanes::HEAD_L:\r
        case Lanes::TAIL_L:\r
        case Lanes::BOUNDARY_L:\r
-               DrawLine(hdc,P_CENTER,P_0);\r
+               //DrawLine(hdc,P_CENTER,P_0);\r
+               graphics.DrawLine(&myPen,P_CENTER,P_0);\r
                //p->drawLine(P_CENTER, P_0);\r
                break;\r
        default:\r
index 40cd12e..9de0785 100644 (file)
@@ -70,6 +70,8 @@ public:
        BOOL m_IsOldFirst;\r
        BOOL m_IsRebaseReplaceGraph;\r
 \r
+       void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);\r
+       void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct);\r
 \r
        BOOL m_bStrictStopped;\r
        BOOL m_bShowBugtraqColumn;\r
index 7be01d9..52c1720 100644 (file)
@@ -170,7 +170,7 @@ BOOL CLogDlg::OnInitDialog()
 \r
        m_hAccel = LoadAccelerators(AfxGetResourceHandle(),MAKEINTRESOURCE(IDR_ACC_LOGDLG));\r
 \r
-       \r
+\r
        // use the state of the "stop on copy/rename" option from the last time\r
        UpdateData(FALSE);\r
        \r