Skip to content

Commit

Permalink
Add menu different resolution comparison
Browse files Browse the repository at this point in the history
Signed-off-by: Kyuwon Kim <[email protected]>
  • Loading branch information
chammoru committed May 10, 2022
1 parent 862ee25 commit 402ff0a
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Comparer/Comparer.rc
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
ICON IDR_MAINFRAME,IDC_STATIC,14,14,21,20
LTEXT "Comparer, Version 1.0",IDC_STATIC,42,14,114,8,SS_NOPREFIX
LTEXT "Copyright (C) 2020 by Kim Kyuwon",IDC_STATIC,42,26,114,8
LTEXT "Copyright (C) 2020 by Kyuwon Kim",IDC_STATIC,42,26,114,8
DEFPUSHBUTTON "OK",IDOK,113,41,50,14,WS_GROUP
END

Expand Down
1 change: 1 addition & 0 deletions Comparer/ComparerDoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ CComparerDoc::CComparerDoc()
, mRgbFormat(mRgbDec)
, mFps(COMPARER_DEF_FPS)
, mInterpol(false)
, mDiffRes(false)
{
// TODO: add one-time construction code here
BITMAPINFOHEADER &bmiHeader = mBmi.bmiHeader;
Expand Down
1 change: 1 addition & 0 deletions Comparer/ComparerDoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class CComparerDoc : public CDocument
CString mRgbFormat;
double mFps;
bool mInterpol;
bool mDiffRes;

// Operations
public:
Expand Down
41 changes: 40 additions & 1 deletion Comparer/MainFrm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,16 @@

// CMainFrame

#define ID_OPTIONS_DIFF_RESOLUTION (ID_OPTIONS_START + 0)

IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
ON_COMMAND_RANGE(ID_RESOLUTION_START, ID_RESOLUTION_END, CMainFrame::OnResolutionChange)
ON_COMMAND_RANGE(ID_METRIC_START, ID_METRIC_END, CMainFrame::OnMetricChange)
ON_COMMAND_RANGE(ID_FPS_START, ID_FPS_END, &CMainFrame::OnFpsChange)
ON_COMMAND_RANGE(ID_VIEWS_START, ID_VIEWS_END, &CMainFrame::OnViewsChange)
ON_COMMAND_RANGE(ID_OPTIONS_START, ID_OPTIONS_END, &CMainFrame::OnOptionsChange)
ON_WM_SIZE()
ON_WM_TIMER()
ON_WM_DESTROY()
Expand All @@ -65,6 +68,7 @@ CMainFrame::CMainFrame()
mMetricMenu.CreatePopupMenu();
mFpsMenu.CreatePopupMenu();
mViewsMenu.CreatePopupMenu();
mOptionsMenu.CreatePopupMenu();
}

CMainFrame::~CMainFrame()
Expand All @@ -73,6 +77,7 @@ CMainFrame::~CMainFrame()
mFpsMenu.DestroyMenu();
mMetricMenu.DestroyMenu();
mResolutionMenu.DestroyMenu();
mOptionsMenu.DestroyMenu();
}

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
Expand Down Expand Up @@ -283,6 +288,7 @@ void CMainFrame::OnDestroy()
#define MENU_POS_METRIC 2
#define MENU_POS_FPS 3
#define MENU_POS_VIEWS 4
#define MENU_POS_OPTIONS 5

void CMainFrame::CheckResolutionRadio(int w, int h)
{
Expand Down Expand Up @@ -437,6 +443,21 @@ void CMainFrame::OnViewsChange(UINT nID)
firstView->AdjustWindowSize(preViews, mSplitBarW * (mViews - preViews));
}

void CMainFrame::OnOptionsChange(UINT nID)
{
CComparerDoc* pDoc = static_cast<CComparerDoc*>(GetActiveDocument());

switch (nID) {
case ID_OPTIONS_DIFF_RESOLUTION:
pDoc->mDiffRes = !pDoc->mDiffRes;
CheckOptionsRadio(nID, pDoc->mDiffRes);
break;
default:
LOGWRN("No matching nID for %x", nID);
break;
}
}

void CMainFrame::CheckMetricRadio()
{
CMenu *subMenu = GetMenu()->GetSubMenu(MENU_POS_METRIC);
Expand Down Expand Up @@ -486,6 +507,17 @@ void CMainFrame::CheckViewsRadio(int views)
id, MF_CHECKED | MF_BYCOMMAND);
}

void CMainFrame::CheckOptionsRadio(UINT nOptionID, bool checked)
{
if (GetMenu() == NULL)
return;

CMenu* subMenu = GetMenu()->GetSubMenu(MENU_POS_OPTIONS);

UINT checkFlag = checked ? MF_CHECKED : MF_UNCHECKED;
subMenu->CheckMenuItem(nOptionID, checkFlag | MF_BYCOMMAND);
}

void CMainFrame::UpdateMagnication(float n)
{
CString str;
Expand Down Expand Up @@ -526,7 +558,6 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
CA2W(q1::resolution_info_table[i]));

str.Format(_T("%d&x%d"), CANVAS_DEF_W, CANVAS_DEF_H);

GetMenu()->InsertMenu(MENU_POS_RESOLUTION, MF_BYPOSITION | MF_POPUP,
(UINT_PTR)mResolutionMenu.m_hMenu, str);

Expand Down Expand Up @@ -573,6 +604,14 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)

CheckViewsRadio(mViews);

// option menu
str.Format(_T("Allow Different Resolution"));
mOptionsMenu.AppendMenu(MF_STRING, (UINT_PTR)ID_OPTIONS_DIFF_RESOLUTION, str);

str.Format(_T("OPTIONS"));
GetMenu()->InsertMenu(MENU_POS_OPTIONS, MF_BYPOSITION | MF_POPUP,
(UINT_PTR)mOptionsMenu.m_hMenu, str);

return 0;
}

Expand Down
4 changes: 3 additions & 1 deletion Comparer/MainFrm.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class CMainFrame : public CFrameWnd
CQSplitterWnd mFrmInfoSplitter;
CQSplitterWnd mCompSplitter;
int mSplitMargin;
CMenu mResolutionMenu, mMetricMenu, mFpsMenu, mViewsMenu;
CMenu mResolutionMenu, mMetricMenu, mFpsMenu, mViewsMenu, mOptionsMenu;

public:
int mMetricIdx;
Expand All @@ -60,6 +60,7 @@ class CMainFrame : public CFrameWnd
void UpdateMetricLabel();
void CheckFpsRadio(double fps);
void CheckViewsRadio(int views);
void CheckOptionsRadio(UINT nOptionID, bool checked);
void UpdateViewsLabel(int views);
void UpdateMagnication(float n);
void RefreshFrmsInfoView();
Expand Down Expand Up @@ -93,6 +94,7 @@ class CMainFrame : public CFrameWnd
afx_msg void OnMetricChange(UINT nID);
afx_msg void OnFpsChange(UINT nID);
afx_msg void OnViewsChange(UINT nID);
afx_msg void OnOptionsChange(UINT nID);
virtual void ActivateFrame(int nCmdShow = -1);
};

Expand Down
2 changes: 2 additions & 0 deletions Comparer/Resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#define ID_FPS_END 0x73ff
#define ID_VIEWS_START 0x7400
#define ID_VIEWS_END 0x74ff
#define ID_OPTIONS_START 0x7500
#define ID_OPTIONS_END 0x75ff
#define ID_MAGNIFY 32771

// Next default values for new objects
Expand Down

0 comments on commit 402ff0a

Please sign in to comment.