fix: 修复图例改名不同步、细化网格标尺并支持标签页重排与曲线实色跟随拖拽
- 图例跟随重命名:绘图区图例文本改用信号当前显示名(Title), 左侧列表改名后网格图例立即同步。 - 标签页重排与改名:新增拖拽排序(按住标签左右拖动并显示插入指示条, 重排后保持原激活页)与双击内联改名,新增 MoveTab 正确处理激活下标。 修复改名后未重新布局导致标签页整条消失的问题(SetTabs 会重置标签矩形)。 双击判定改为自行按双击时间识别,不再依赖系统 WM_LBUTTONDBLCLK。 - 信号拖拽:虚影改用原信号颜色与线宽(不再画成虚线),保持原有线段/散点样式; 横向与纵向均自由跟随鼠标位移;拖拽首帧位移为零,虚影始终贴合在鼠标下方。 - 网格与标尺细化:时间轴与幅值轴期望刻度数提高,并在相邻主刻度之间 补绘 5 等分细线,便于目视估读。 - 图例定位与交互:图例移到各网格左上角,与标尺数字冲突时优先显示图例 (标尺数值主动避让);图例条目支持单击选中信号(与左侧列表联动、 样式区随之切换目标)与双击重命名信号。 - 网格划分:合并网格后新勾选的信号不再被并入那个唯一的合并网格, 而是自动切换为自定义划分并独占一个新网格。 - 工具栏:「每信号一格」改名为「拆分信号网格」。 - 清理:移除已无引用的 UiDrawArrowIcon 与 m_styleContentRect。
This commit is contained in:
1 parent
261b8ac07d
commit
4e295a2a7d
12 files changed
+800
-109
No files matched your search
@@ -207,6 +207,19 @@ namespace jdi
|
||||
*/
|
||||
void DispatchMenuResult(const MenuResult& result);
|
||||
|
||||
/**
|
||||
* @brief 调整标签页顺序(拖拽重排)。
|
||||
* @param [IN] from 被移动的标签页下标。
|
||||
* @param [IN] target 目标插入位置(插入到该下标之前)。
|
||||
*/
|
||||
void MoveTab(int from, int target);
|
||||
|
||||
/**
|
||||
* @brief 应用绘图区提交的信号重命名请求。
|
||||
* @return 应用了重命名返回 true。
|
||||
*/
|
||||
bool ApplyPendingRename();
|
||||
|
||||
/**
|
||||
* @brief 弹出文件选择对话框并加载所选文件。
|
||||
*/
|
||||
|
||||
@@ -955,12 +955,94 @@ namespace jdi
|
||||
case TabBarResult::Type::CONTEXT:
|
||||
ShowTabContextMenu(result);
|
||||
break;
|
||||
case TabBarResult::Type::REORDER:
|
||||
MoveTab(result.index, result.targetIndex);
|
||||
break;
|
||||
case TabBarResult::Type::RENAME:
|
||||
if (result.index >= 0 && result.index < static_cast<int>(m_tabs.size()) && !result.text.empty())
|
||||
{
|
||||
m_tabs[static_cast<std::size_t>(result.index)].SetName(result.text);
|
||||
RefreshTabBar();
|
||||
// SetTabs 会重置各标签的矩形,必须重新布局才能把它们算回来。
|
||||
Relayout();
|
||||
InvalidateRect(m_hwnd, nullptr, TRUE);
|
||||
}
|
||||
break;
|
||||
case TabBarResult::Type::NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Application::MoveTab(int from, int target)
|
||||
{
|
||||
if (from < 0 || from >= static_cast<int>(m_tabs.size()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (target < 0 || target > static_cast<int>(m_tabs.size()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 拖拽语义:target 表示「插入到该下标之前」;向后拖时需扣除自身占位。
|
||||
int destination = target;
|
||||
if (destination > from)
|
||||
{
|
||||
--destination;
|
||||
}
|
||||
destination = std::max(0, std::min(destination, static_cast<int>(m_tabs.size()) - 1));
|
||||
if (destination == from)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 保持当前激活的标签页在重排后仍处于激活状态。
|
||||
TabConfig moved = m_tabs[static_cast<std::size_t>(from)];
|
||||
const int activeIndex = m_activeTab;
|
||||
|
||||
m_tabs.erase(m_tabs.begin() + from);
|
||||
m_tabs.insert(m_tabs.begin() + destination, std::move(moved));
|
||||
|
||||
int newActive = activeIndex;
|
||||
if (activeIndex == from)
|
||||
{
|
||||
newActive = destination;
|
||||
}
|
||||
else if (from < activeIndex && destination >= activeIndex)
|
||||
{
|
||||
--newActive;
|
||||
}
|
||||
else if (from > activeIndex && destination <= activeIndex)
|
||||
{
|
||||
++newActive;
|
||||
}
|
||||
|
||||
SetActiveTab(newActive);
|
||||
InvalidateRect(m_hwnd, nullptr, TRUE);
|
||||
}
|
||||
|
||||
bool Application::ApplyPendingRename()
|
||||
{
|
||||
SignalRef ref;
|
||||
std::wstring name;
|
||||
if (!m_plot.TakePendingRename(ref, name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_dataSet.SetSignalDisplayName(ref.fileIndex, ref.signalIndex, name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// 改名只影响显示,但需要刷新左侧列表与绘图区图例。
|
||||
m_panel.InvalidateRows();
|
||||
SetStatusMessage(L"信号已重命名为:" + name, false);
|
||||
InvalidateRect(m_hwnd, nullptr, TRUE);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Application::ShowTabContextMenu(const TabBarResult& result)
|
||||
{
|
||||
if (result.index < 0 || result.index >= static_cast<int>(m_tabs.size()))
|
||||
@@ -1388,6 +1470,7 @@ namespace jdi
|
||||
if (m_plot.IsEditing() && !m_plot.HitTest(x, y))
|
||||
{
|
||||
m_plot.OnEditKey(VK_RETURN);
|
||||
ApplyPendingRename();
|
||||
}
|
||||
|
||||
// 点击面板之外的位置时收起面板内展开的自定义颜色面板。
|
||||
@@ -1444,6 +1527,8 @@ namespace jdi
|
||||
m_activeTarget = Target::PLOT;
|
||||
if (m_plot.OnLButtonDown(x, y))
|
||||
{
|
||||
// 绘图区内的点击也可能提交图例改名,需要立刻落到数据层。
|
||||
ApplyPendingRename();
|
||||
InvalidateRect(hwnd, nullptr, FALSE);
|
||||
}
|
||||
return 0;
|
||||
@@ -1504,7 +1589,12 @@ namespace jdi
|
||||
const int x = GET_X_LPARAM(lParam);
|
||||
const int y = GET_Y_LPARAM(lParam);
|
||||
bool changed = false;
|
||||
if (m_panel.HitTest(x, y))
|
||||
if (m_tabBar.HitTest(x, y))
|
||||
{
|
||||
SetFocus(hwnd);
|
||||
changed = m_tabBar.OnDoubleClick(x, y);
|
||||
}
|
||||
else if (m_panel.HitTest(x, y))
|
||||
{
|
||||
changed = m_panel.OnDoubleClick(x, y);
|
||||
}
|
||||
@@ -1620,7 +1710,15 @@ namespace jdi
|
||||
break;
|
||||
}
|
||||
case WM_KEYDOWN:
|
||||
// 数值输入状态优先接管按键(回车提交、Esc 取消、退格删除)。
|
||||
// 标签栏重命名与数值输入优先接管按键(回车提交、Esc 取消、退格删除)。
|
||||
if (m_tabBar.IsEditing())
|
||||
{
|
||||
TabBarResult tabResult;
|
||||
m_tabBar.OnEditKey(wParam, tabResult);
|
||||
OnTabBarResult(tabResult);
|
||||
InvalidateRect(hwnd, nullptr, FALSE);
|
||||
return 0;
|
||||
}
|
||||
if (m_panel.IsEditing())
|
||||
{
|
||||
if (m_panel.OnEditKey(wParam))
|
||||
@@ -1631,10 +1729,9 @@ namespace jdi
|
||||
}
|
||||
if (m_plot.IsEditing())
|
||||
{
|
||||
if (m_plot.OnEditKey(wParam))
|
||||
{
|
||||
InvalidateRect(hwnd, nullptr, FALSE);
|
||||
}
|
||||
m_plot.OnEditKey(wParam);
|
||||
ApplyPendingRename();
|
||||
InvalidateRect(hwnd, nullptr, FALSE);
|
||||
return 0;
|
||||
}
|
||||
if (HandleKeyDown(wParam))
|
||||
@@ -1646,6 +1743,14 @@ namespace jdi
|
||||
case WM_CHAR:
|
||||
{
|
||||
// 输入状态由对应控件自行校验可接受的字符(数值仅收数字与小数点,名称可收任意可打印字符)。
|
||||
if (m_tabBar.IsEditing())
|
||||
{
|
||||
if (m_tabBar.OnEditChar(static_cast<wchar_t>(wParam)))
|
||||
{
|
||||
InvalidateRect(hwnd, nullptr, FALSE);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (m_panel.IsEditing())
|
||||
{
|
||||
if (m_panel.OnEditChar(static_cast<wchar_t>(wParam)))
|
||||
@@ -1658,6 +1763,7 @@ namespace jdi
|
||||
{
|
||||
if (m_plot.OnEditChar(static_cast<wchar_t>(wParam)))
|
||||
{
|
||||
ApplyPendingRename();
|
||||
InvalidateRect(hwnd, nullptr, FALSE);
|
||||
}
|
||||
return 0;
|
||||
|
||||
Reference in new issue
Block a user