增加调整配置项位置功能

This commit is contained in:
gb 2023-10-17 10:41:39 +08:00
parent 1ac5e55aa1
commit 101239518e
6 changed files with 78 additions and 10 deletions

View File

@ -274,9 +274,9 @@
"range": {
"min": 0.000000,
"max": "br-x",
"step": 21.000000
"step": 0.010000
},
"depend": "is-custom-area==true"
"depend": "is-custom-area==true && is-custom-area.enabled"
},
"br-x": {
"cat": "base",
@ -292,9 +292,9 @@
"range": {
"min": "tl-x",
"max": 210.000000,
"step": 21.000000
"step": 0.010000
},
"depend": "is-custom-area==true"
"depend": "is-custom-area==true && is-custom-area.enabled"
},
"tl-y": {
"cat": "base",
@ -310,9 +310,9 @@
"range": {
"min": 0.000000,
"max": "br-y",
"step": 29.700000
"step": 0.010000
},
"depend": "is-custom-area==true"
"depend": "is-custom-area==true && is-custom-area.enabled"
},
"br-y": {
"cat": "base",
@ -328,9 +328,9 @@
"range": {
"min": "tl-y",
"max": 297.000000,
"step": 29.700000
"step": 0.010000
},
"depend": "is-custom-area==true"
"depend": "is-custom-area==true && is-custom-area.enabled"
},
"is-size-check": {
"cat": "base",

View File

@ -207,6 +207,8 @@ namespace known_name
NAME_WITH_FIX_ID(TRANSFORM_IMAGE_FORMAT),
NAME_WITH_FIX_ID(FREE_BUFFER),
NAME_WITH_FIX_ID(PAPER_ON),
NAME_WITH_FIX_ID(PAPER_W),
NAME_WITH_FIX_ID(PAPER_H),
NAME_WITH_FIX_ID(GRAY_GAMMA),
NAME_WITH_FIX_ID(COLOR_GAMMA),
@ -1929,6 +1931,7 @@ BEGIN_MESSAGE_MAP(CDlgOptJson, CDialogEx)
ON_WM_CTLCOLOR()
ON_MESSAGE(WM_CTLCOLORSTATIC, &CDlgOptJson::OnStaticColor)
ON_BN_CLICKED(IDC_BUTTON_SET_VISIBLE, &CDlgOptJson::OnBnClickedButtonSetVisible)
ON_NOTIFY(TVN_KEYDOWN, IDC_TREE2, &CDlgOptJson::OnTvnKeydownTree2)
END_MESSAGE_MAP()
@ -2508,6 +2511,66 @@ void CDlgOptJson::OnTvnSelchangedTree2(NMHDR* pNMHDR, LRESULT* pResult)
}
#include "hgjsonDlg.h"
void CDlgOptJson::OnTvnKeydownTree2(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMTVKEYDOWN pTVKeyDown = reinterpret_cast<LPNMTVKEYDOWN>(pNMHDR);
// TODO: 在此添加控件通知处理程序代码
*pResult = 0;
if (pTVKeyDown->wVKey != VK_UP && pTVKeyDown->wVKey != VK_DOWN)
return;
if (GetKeyState(VK_CONTROL) >= 0)
return;
HTREEITEM sel = tree_.GetSelectedItem(), neighbour = NULL;
wchar_t *n = NULL;
std::wstring name(ChgjsonDlg::get_tree_selected_item_text(&tree_, (DWORD_PTR*)&n));
int ind = 0;
for (auto& v : opts_)
{
if (v.title == name)
break;
ind++;
}
if (ind >= opts_.size())
return;
if (pTVKeyDown->wVKey == VK_DOWN)
{
neighbour = tree_.GetNextSiblingItem(sel);
if (neighbour)
{
tree_.DeleteItem(sel);
sel = tree_.InsertItem(name.c_str(), TVI_ROOT, neighbour);
tree_.SetItemData(sel, (DWORD_PTR)n);
SANEOPT so = opts_[ind];
opts_.erase(opts_.begin() + ind);
opts_.insert(opts_.begin() + ind + 1, so);
tree_.SelectItem(sel);
}
}
else if (pTVKeyDown->wVKey == VK_UP)
{
neighbour = tree_.GetPrevSiblingItem(sel);
if (neighbour)
{
neighbour = tree_.GetPrevSiblingItem(neighbour);
if (!neighbour)
neighbour = TVI_FIRST;
tree_.DeleteItem(sel);
sel = tree_.InsertItem(name.c_str(), TVI_ROOT, neighbour);
tree_.SetItemData(sel, (DWORD_PTR)n);
SANEOPT so = opts_[ind];
opts_.erase(opts_.begin() + ind);
opts_.insert(opts_.begin() + ind - 1, so);
tree_.SelectItem(sel);
}
}
}
void CDlgOptJson::OnNMRClickTree2(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: 在此添加控件通知处理程序代码
@ -3554,3 +3617,4 @@ void CDlgOptJson::OnBnClickedButtonShowui()
}
}

View File

@ -201,4 +201,5 @@ public:
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
afx_msg LRESULT OnStaticColor(WPARAM wp, LPARAM lp);
afx_msg void OnBnClickedButtonSetVisible();
afx_msg void OnTvnKeydownTree2(NMHDR* pNMHDR, LRESULT* pResult);
};

View File

@ -6095,7 +6095,7 @@ int get_cur_sel(CListCtrl* lc)
return sel;
}
std::wstring get_tree_item_text(CTreeCtrl* tree, HTREEITEM root, DWORD_PTR* data = NULL)
std::wstring ChgjsonDlg::get_tree_item_text(CTreeCtrl* tree, HTREEITEM root, DWORD_PTR* data)
{
CString t(tree->GetItemText(root));
std::wstring ret(t.GetBuffer());
@ -6106,7 +6106,7 @@ std::wstring get_tree_item_text(CTreeCtrl* tree, HTREEITEM root, DWORD_PTR* data
return ret;
}
std::wstring get_tree_selected_item_text(CTreeCtrl* tree, DWORD_PTR* data)
std::wstring ChgjsonDlg::get_tree_selected_item_text(CTreeCtrl* tree, DWORD_PTR* data)
{
HTREEITEM sel = tree->GetSelectedItem();

View File

@ -106,6 +106,9 @@ public:
bool show_tree_tooltips_;
bool show_list_tooltips_;
static std::wstring get_tree_item_text(CTreeCtrl* tree, HTREEITEM root, DWORD_PTR* data = NULL);
static std::wstring get_tree_selected_item_text(CTreeCtrl* tree, DWORD_PTR* data = NULL);
// Implementation
protected:
CMenu tree_menu_;

Binary file not shown.