Skip to content

Commit

Permalink
Foreground and background title bars are distinguishable
Browse files Browse the repository at this point in the history
  • Loading branch information
lededev committed Oct 27, 2024
1 parent d8d4695 commit ffed6ce
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
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
20 changes: 19 additions & 1 deletion Src/MainFrm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
ON_MESSAGE(WMU_CHILDFRAMEACTIVATE, &CMainFrame::OnChildFrameActivate)
ON_MESSAGE(WMU_CHILDFRAMEACTIVATED, &CMainFrame::OnChildFrameActivated)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
ON_WM_ACTIVATE()
END_MESSAGE_MAP()

/**
* @brief MainFrame statusbar panels/indicators
Expand Down Expand Up @@ -366,6 +367,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 @@ -3704,3 +3706,19 @@ LRESULT CMainFrame::OnChildFrameActivated(WPARAM wParam, LPARAM lParam)

return 1;
}


void CMainFrame::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
__super::OnActivate(nState, pWndOther, bMinimized);

const bool bActivate = (nState != WA_INACTIVE);
if (bActivate != m_bActivate)
{
m_bActivate = bActivate;

CRect titleBarRect;
m_wndTabBar.GetClientRect(&titleBarRect);
InvalidateRect(&titleBarRect, TRUE);
}
}
3 changes: 3 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 @@ -430,6 +431,7 @@ class CMainFrame : public CMDIFrameWnd
afx_msg void OnTimer(UINT_PTR nIDEvent);
afx_msg void OnDestroy();
afx_msg void OnAccelQuit();
afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
afx_msg LRESULT OnChildFrameAdded(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnChildFrameRemoved(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnChildFrameActivate(WPARAM wParam, LPARAM lParam);
Expand All @@ -454,4 +456,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 ffed6ce

Please sign in to comment.