OSDN Git Service

Logview: Ref label borders
authorJohan 't Hart <johanthart@gmail.com>
Mon, 15 Jun 2009 21:05:58 +0000 (23:05 +0200)
committerJohan 't Hart <johanthart@gmail.com>
Tue, 16 Jun 2009 21:51:09 +0000 (23:51 +0200)
src/TortoiseProc/Colors.cpp
src/TortoiseProc/Colors.h
src/TortoiseProc/GitLogListBase.cpp

index cc98a5f..ecc3e87 100644 (file)
@@ -99,3 +99,31 @@ void CColors::SetColor(Colors col, COLORREF cr)
                i++;\r
        }\r
 }\r
+\r
+\r
+COLORREF CColors::MixColors(COLORREF baseColor, COLORREF newColor, unsigned char mixFactor)\r
+{\r
+       short colRed;\r
+       short colGreen;\r
+       short colBlue;\r
+       colRed   = ((float)( baseColor&0x000000FF)     -(float)( newColor&0x000000FF)     )*mixFactor/0xFF;//red\r
+       colGreen = ((float)((baseColor&0x0000FF00)>>8) -(float)((newColor&0x0000FF00)>>8 ))*mixFactor/0xFF;//green\r
+       colBlue  = ((float)((baseColor&0x00FF0000)>>16)-(float)((newColor&0x00FF0000)>>16))*mixFactor/0xFF;//blue\r
+       \r
+       colRed   = ( baseColor&0x000000FF)              -colRed;\r
+       colGreen = ((baseColor&0x0000FF00)>>8)  -colGreen;\r
+       colBlue  = ((baseColor&0x00FF0000)>>16) -colBlue;\r
+       baseColor=(int)colRed|((int)colGreen<<8)|((int)colBlue<<16);\r
+       return baseColor;\r
+}\r
+\r
+COLORREF CColors::Lighten(COLORREF baseColor, unsigned char amount)\r
+{\r
+       return MixColors(baseColor, RGB(255,255,255), amount);\r
+}\r
+\r
+COLORREF CColors::Darken(COLORREF baseColor, unsigned char amount)\r
+{\r
+       return MixColors(baseColor, RGB(0,0,0), amount);\r
+}\r
+\r
index 3a2a7fb..b90c207 100644 (file)
@@ -63,6 +63,12 @@ public:
        COLORREF GetColor(Colors col, bool bDefault = false);\r
        void SetColor(Colors col, COLORREF cr);\r
 \r
+       //mixFactor: 0 -> baseColor, 255 -> newColor\r
+       COLORREF MixColors(COLORREF baseColor, COLORREF newColor, unsigned char mixFactor);\r
+\r
+       COLORREF Lighten(COLORREF baseColor, unsigned char amount = 100);\r
+       COLORREF Darken(COLORREF baseColor, unsigned char amount = 100);\r
+\r
        struct COLOR_DATA\r
        {\r
                Colors          Color;\r
index 1760744..eca5524 100644 (file)
@@ -425,28 +425,31 @@ void CGitLogListBase::DrawTagBranch(HDC hdc,CRect &rect,INT_PTR index)
                str=m_HashMap[data->m_CommitHash][i];\r
                \r
                CString shortname;\r
-               HBRUSH brush=0;\r
-               shortname=_T("");\r
+               HBRUSH brush = 0;\r
+               shortname = _T("");\r
+               COLORREF colRef = 0;\r
+\r
                if(GetShortName(str,shortname,_T("refs/heads/")))\r
                {\r
                        if( shortname == m_CurrentBranch )\r
-                               brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::CurrentBranch));\r
+                               colRef = m_Colors.GetColor(CColors::CurrentBranch);\r
                        else\r
-                               brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::LocalBranch));\r
+                               colRef = m_Colors.GetColor(CColors::LocalBranch);\r
 \r
                }else if(GetShortName(str,shortname,_T("refs/remotes/")))\r
                {\r
-                       brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::RemoteBranch));\r
+                       colRef = m_Colors.GetColor(CColors::RemoteBranch);\r
                }\r
                else if(GetShortName(str,shortname,_T("refs/tags/")))\r
                {\r
-                       brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::Tag));\r
+                       colRef = m_Colors.GetColor(CColors::Tag);\r
                }\r
                else if(GetShortName(str,shortname,_T("refs/stash")))\r
                {\r
-                       brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::Stash));\r
+                       colRef = m_Colors.GetColor(CColors::Stash);\r
                        shortname=_T("stash");\r
                }\r
+               brush = ::CreateSolidBrush(colRef);\r
                \r
 \r
                if(!shortname.IsEmpty())\r
@@ -456,8 +459,24 @@ void CGitLogListBase::DrawTagBranch(HDC hdc,CRect &rect,INT_PTR index)
                        GetTextExtentPoint32(hdc, shortname,shortname.GetLength(),&size);\r
                \r
                        rt.SetRect(rt.left,rt.top,rt.left+size.cx,rt.bottom);\r
-                       rt.right+=4;\r
+                       rt.right+=8;\r
+\r
+                       //Fill interior of ref label\r
                        ::FillRect(hdc, &rt, brush);\r
+\r
+                       //Draw edge of label\r
+                       CDC W_Dc;\r
+                       W_Dc.Attach(hdc);\r
+\r
+                       CRect rectEdge = rt;\r
+\r
+                       W_Dc.Draw3dRect(rectEdge, m_Colors.Lighten(colRef,100), m_Colors.Darken(colRef,100));\r
+                       rectEdge.DeflateRect(1,1);\r
+                       W_Dc.Draw3dRect(rectEdge, m_Colors.Lighten(colRef,50), m_Colors.Darken(colRef,50));\r
+\r
+                       W_Dc.Detach();\r
+\r
+                       //Draw text inside label\r
                        if (m_Theme.IsAppThemed() && m_bVista)\r
                        {\r
                                int txtState = LISS_NORMAL;\r
@@ -481,13 +500,14 @@ void CGitLogListBase::DrawTagBranch(HDC hdc,CRect &rect,INT_PTR index)
                        }\r
 \r
                        \r
-                       ::MoveToEx(hdc,rt.left,rt.top,NULL);\r
-                       ::LineTo(hdc,rt.right,rt.top);\r
-                       ::LineTo(hdc,rt.right,rt.bottom);\r
-                       ::LineTo(hdc,rt.left,rt.bottom);\r
-                       ::LineTo(hdc,rt.left,rt.top);\r
+                       //::MoveToEx(hdc,rt.left,rt.top,NULL);\r
+                       //::LineTo(hdc,rt.right,rt.top);\r
+                       //::LineTo(hdc,rt.right,rt.bottom);\r
+                       //::LineTo(hdc,rt.left,rt.bottom);\r
+                       //::LineTo(hdc,rt.left,rt.top);\r
+\r
                                \r
-                       rt.left=rt.right+3;\r
+                       rt.left=rt.right+1;\r
                }\r
                if(brush)\r
                        ::DeleteObject(brush);\r