Skip to content

Commit

Permalink
Foreground and background title bars are distinguishable (#2497)
Browse files Browse the repository at this point in the history
* Foreground and background title bars are distinguishable

* Simplified to handle activation state at the application level
  • Loading branch information
lededev authored Oct 27, 2024
1 parent a2a6832 commit 9b2e966
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Src/Common/MDITabBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "IMDITab.h"
#include "cecolor.h"
#include "RoundedRectWithShadow.h"
#include "MainFrm.h"

#ifdef _DEBUG
#define new DEBUG_NEW
Expand Down Expand Up @@ -96,7 +97,10 @@ static COLORREF getBackColor(bool onTitleBar)
const COLORREF clr = GetSysColor(COLOR_3DFACE);
if (!onTitleBar)
return clr;
return RGB(GetRValue(clr), std::clamp(GetGValue(clr) + 8, 0, 255), std::clamp(GetBValue(clr) + 8, 0, 255));
const COLORREF bgclr = dynamic_cast<CMainFrame*>(AfxGetMainWnd())->IsActivate() ?
RGB(GetRValue(clr), std::clamp(GetGValue(clr) + 8, 0, 255), std::clamp(GetBValue(clr) + 8, 0, 255))
: clr;
return bgclr;
}

static inline bool IsHighContrastEnabled()
Expand Down
11 changes: 11 additions & 0 deletions Src/MainFrm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ CMainFrame::CMainFrame()
, m_lfDiff(Options::Font::Load(GetOptionsMgr(), OPT_FONT_FILECMP))
, m_lfDir(Options::Font::Load(GetOptionsMgr(), OPT_FONT_DIRCMP))
, m_pDirWatcher(new DirWatcher())
, m_bActivate(false)
{
}

Expand Down Expand Up @@ -2540,6 +2541,16 @@ void CMainFrame::OnActivateApp(BOOL bActive, DWORD dwThreadID)
if (IMergeDoc* pMergeDoc = GetActiveIMergeDoc())
PostMessage(WM_USER + 1);
}

const bool bActivate = static_cast<bool>(bActive);
if ( bActivate != m_bActivate)
{
m_bActivate = bActivate;

CRect titleBarRect;
m_wndTabBar.GetClientRect(&titleBarRect);
InvalidateRect(&titleBarRect, TRUE);
}
}

void CMainFrame::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp)
Expand Down
2 changes: 2 additions & 0 deletions Src/MainFrm.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ class CMainFrame : public CMDIFrameWnd
CMenuBar* GetMenuBar() { return &m_wndMenuBar; }
CToolBar* GetToolbar() { return &m_wndToolBar; }
static void WaitAndDoMessageLoop(bool& completed, int ms);
bool IsActivate() const { return m_bActivate; }

// Overrides
virtual void GetMessageString(UINT nID, CString& rMessage) const;
Expand Down Expand Up @@ -454,4 +455,5 @@ class CMainFrame : public CMDIFrameWnd
bool CompareFilesIfFilesAreLarge(IDirDoc* pDirDoc, int nFiles, const FileLocation ifileloc[]);
std::unique_ptr<WCHAR[]> m_upszLongTextW;
std::unique_ptr<CHAR[]> m_upszLongTextA;
bool m_bActivate;
};

0 comments on commit 9b2e966

Please sign in to comment.