From d7a9c9bf04347ca69295bffb5053a77394c4d18a Mon Sep 17 00:00:00 2001 From: Johan 't Hart Date: Mon, 15 Jun 2009 23:05:58 +0200 Subject: [PATCH] Logview: Ref label borders --- src/TortoiseProc/Colors.cpp | 28 ++++++++++++++++++++++ src/TortoiseProc/Colors.h | 6 +++++ src/TortoiseProc/GitLogListBase.cpp | 48 ++++++++++++++++++++++++++----------- 3 files changed, 68 insertions(+), 14 deletions(-) diff --git a/src/TortoiseProc/Colors.cpp b/src/TortoiseProc/Colors.cpp index cc98a5f..ecc3e87 100644 --- a/src/TortoiseProc/Colors.cpp +++ b/src/TortoiseProc/Colors.cpp @@ -99,3 +99,31 @@ void CColors::SetColor(Colors col, COLORREF cr) i++; } } + + +COLORREF CColors::MixColors(COLORREF baseColor, COLORREF newColor, unsigned char mixFactor) +{ + short colRed; + short colGreen; + short colBlue; + colRed = ((float)( baseColor&0x000000FF) -(float)( newColor&0x000000FF) )*mixFactor/0xFF;//red + colGreen = ((float)((baseColor&0x0000FF00)>>8) -(float)((newColor&0x0000FF00)>>8 ))*mixFactor/0xFF;//green + colBlue = ((float)((baseColor&0x00FF0000)>>16)-(float)((newColor&0x00FF0000)>>16))*mixFactor/0xFF;//blue + + colRed = ( baseColor&0x000000FF) -colRed; + colGreen = ((baseColor&0x0000FF00)>>8) -colGreen; + colBlue = ((baseColor&0x00FF0000)>>16) -colBlue; + baseColor=(int)colRed|((int)colGreen<<8)|((int)colBlue<<16); + return baseColor; +} + +COLORREF CColors::Lighten(COLORREF baseColor, unsigned char amount) +{ + return MixColors(baseColor, RGB(255,255,255), amount); +} + +COLORREF CColors::Darken(COLORREF baseColor, unsigned char amount) +{ + return MixColors(baseColor, RGB(0,0,0), amount); +} + diff --git a/src/TortoiseProc/Colors.h b/src/TortoiseProc/Colors.h index 3a2a7fb..b90c207 100644 --- a/src/TortoiseProc/Colors.h +++ b/src/TortoiseProc/Colors.h @@ -63,6 +63,12 @@ public: COLORREF GetColor(Colors col, bool bDefault = false); void SetColor(Colors col, COLORREF cr); + //mixFactor: 0 -> baseColor, 255 -> newColor + COLORREF MixColors(COLORREF baseColor, COLORREF newColor, unsigned char mixFactor); + + COLORREF Lighten(COLORREF baseColor, unsigned char amount = 100); + COLORREF Darken(COLORREF baseColor, unsigned char amount = 100); + struct COLOR_DATA { Colors Color; diff --git a/src/TortoiseProc/GitLogListBase.cpp b/src/TortoiseProc/GitLogListBase.cpp index 1760744..eca5524 100644 --- a/src/TortoiseProc/GitLogListBase.cpp +++ b/src/TortoiseProc/GitLogListBase.cpp @@ -425,28 +425,31 @@ 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; + 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"); } + brush = ::CreateSolidBrush(colRef); if(!shortname.IsEmpty()) @@ -456,8 +459,24 @@ 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); + + //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) { int txtState = LISS_NORMAL; @@ -481,13 +500,14 @@ void CGitLogListBase::DrawTagBranch(HDC hdc,CRect &rect,INT_PTR index) } - ::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); -- 2.11.0