feat: 重构信号样式区并统一主题化弹出菜单
样式编辑区: - 移除顶部「样式 + 信号名 + 文件名」标题行,选中信号即代表编辑目标。 - 绘制方式取消阶梯选项,仅保留线段/散点/点线,标签由「方式」改为「样式」。 - 线宽改为「最细预设 + 数值旋钮 + 最粗预设」:中间为带左右增减箭头的输入框, 步进 0.2px,取值范围 0.5-6.0px,并标注单位为 px。 - 颜色在 10 个预设色块后新增带加号图标的方格,点击展开 RGB 三通道滑块面板, 可实时预览并显示十六进制值;点击面板外任意位置收起。 - 移除网格归属下拉框,改由每条信号行末尾的 G 徽标承载,点击弹出网格归属菜单。 信号面板与菜单: - 文件分组行新增关闭按钮,可直接从工作区移除该文件,与整体风格保持一致。 - 新增 PopupMenu 组件:绘制在窗口后备缓冲区内的自绘菜单,含圆角、投影、悬停高亮、 单选对勾、色块行与分组标题,彻底替换系统默认弹出菜单; 菜单打开期间接管鼠标与键盘(Esc / 上下键 / 回车),失焦或在菜单外释放时自动关闭。 - 信号、文件、网格、标签页四类右键菜单全部改用该组件。 其他修复: - 信号名称不再保留尾部单位括号,避免名称后再重复显示单位。 - 数据模型移除 DrawMode::STEP 枚举。 - 标签栏与信号面板弹出菜单后补充重绘请求,修复菜单不显示的问题。
This commit is contained in:
1 parent
9c6c374cce
commit
eb868b2679
12 files changed
+2148
-531
No files matched your search
@@ -11,6 +11,7 @@
|
||||
#include "DataModel.hpp"
|
||||
#include "PaintUtil.hpp"
|
||||
#include "PlotView.hpp"
|
||||
#include "PopupMenu.hpp"
|
||||
#include "SignalPanel.hpp"
|
||||
#include "TabBar.hpp"
|
||||
#include "Theme.hpp"
|
||||
@@ -186,11 +187,17 @@ namespace jdi
|
||||
void OnTabBarResult(const TabBarResult& result);
|
||||
|
||||
/**
|
||||
* @brief 弹出标签页右键菜单。
|
||||
* @param [IN] result 上下文菜单请求。
|
||||
* @brief 弹出标签页右键菜单(主题化自绘菜单)。
|
||||
* @param [IN] result 标签栏交互结果。
|
||||
*/
|
||||
void ShowTabContextMenu(const TabBarResult& result);
|
||||
|
||||
/**
|
||||
* @brief 派发弹出菜单的选择结果。
|
||||
* @param [IN] result 菜单选择结果。
|
||||
*/
|
||||
void DispatchMenuResult(const MenuResult& result);
|
||||
|
||||
/**
|
||||
* @brief 弹出文件选择对话框并加载所选文件。
|
||||
*/
|
||||
@@ -250,8 +257,7 @@ namespace jdi
|
||||
bool m_gdiplusReady = false; /**< GDI+ 是否初始化成功。 */
|
||||
|
||||
Theme m_theme; /**< 主题配色。 */
|
||||
UiFonts m_fonts; /**< 界面字体。 */
|
||||
DataSet m_dataSet; /**< 全局共享的数据集合。 */
|
||||
UiFonts m_fonts; /**< 界面字体。 */ PopupMenu m_menu; /**< 与主题一致的自绘弹出菜单。 */ DataSet m_dataSet; /**< 全局共享的数据集合。 */
|
||||
std::vector<TabConfig> m_tabs; /**< 标签页配置集合。 */
|
||||
int m_activeTab = -1; /**< 当前激活标签页下标。 */
|
||||
int m_tabNameCounter = 0; /**< 标签页命名计数器。 */
|
||||
@@ -280,6 +286,7 @@ namespace jdi
|
||||
|
||||
Target m_activeTarget = Target::NONE; /**< 当前鼠标作用目标。 */
|
||||
bool m_trackingLeave = false; /**< 是否已注册鼠标离开通知。 */
|
||||
int m_tabMenuIndex = -1; /**< 标签栏右键菜单的目标标签页下标。 */
|
||||
std::wstring m_statusMessage; /**< 状态栏提示文本。 */
|
||||
bool m_statusIsError = false; /**< 状态提示是否为错误。 */
|
||||
|
||||
|
||||
@@ -195,7 +195,9 @@ namespace jdi
|
||||
m_tabBar.SetScale(m_scale);
|
||||
m_toolbar.Setup(&m_fonts, &m_theme);
|
||||
m_toolbar.SetScale(m_scale);
|
||||
m_panel.Setup(m_hwnd, &m_fonts, &m_theme);
|
||||
m_menu.Setup(&m_fonts, &m_theme);
|
||||
m_menu.SetScale(m_scale);
|
||||
m_panel.Setup(m_hwnd, &m_fonts, &m_theme, &m_menu);
|
||||
m_panel.SetScale(m_scale);
|
||||
m_plot.Setup(&m_fonts, &m_theme);
|
||||
m_plot.SetScale(m_scale);
|
||||
@@ -239,6 +241,7 @@ namespace jdi
|
||||
m_fonts.Create(dpi);
|
||||
m_tabBar.SetScale(m_scale);
|
||||
m_toolbar.SetScale(m_scale);
|
||||
m_menu.SetScale(m_scale);
|
||||
m_panel.SetScale(m_scale);
|
||||
m_plot.SetScale(m_scale);
|
||||
ReleaseBackBuffer();
|
||||
@@ -453,6 +456,7 @@ namespace jdi
|
||||
|
||||
m_tabBar.Layout(m_tabBarRect);
|
||||
m_toolbar.Layout(m_toolbarRect);
|
||||
m_panel.SetClientBounds(gd::RectF(0.0f, 0.0f, width, height));
|
||||
m_panel.Layout(m_panelRect);
|
||||
m_plot.Layout(m_plotRect);
|
||||
}
|
||||
@@ -528,6 +532,12 @@ namespace jdi
|
||||
return;
|
||||
}
|
||||
|
||||
// 面板内展开/收起自定义颜色面板等操作会改变面板所需高度。
|
||||
if (m_panel.TakeLayoutDirty())
|
||||
{
|
||||
Relayout();
|
||||
}
|
||||
|
||||
// 任何交互(勾选、移动网格、切换标签页)之后都在此统一收敛视图状态。
|
||||
SynchronizeView(false);
|
||||
|
||||
@@ -559,6 +569,9 @@ namespace jdi
|
||||
UiFillRect(g, m_splitterRect, m_theme.border);
|
||||
|
||||
PaintStatusBar(g);
|
||||
|
||||
// 弹出菜单始终绘制在最上层,保证与主界面风格一致。
|
||||
m_menu.Paint(g);
|
||||
}
|
||||
|
||||
HDC windowDc = GetDC(m_hwnd);
|
||||
@@ -701,6 +714,7 @@ namespace jdi
|
||||
{
|
||||
const DataFile* file = m_dataSet.FileAt(existing);
|
||||
SetStatusMessage(L"该文件已在工作区中:" + (file != nullptr ? file->fileName : path), true);
|
||||
InvalidateRect(m_hwnd, nullptr, FALSE);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -709,6 +723,7 @@ namespace jdi
|
||||
if (!LoadCsvTable(path, table, error))
|
||||
{
|
||||
SetStatusMessage(L"解析失败:" + error, true);
|
||||
InvalidateRect(m_hwnd, nullptr, FALSE);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -716,6 +731,7 @@ namespace jdi
|
||||
if (!m_dataSet.AddFromTable(table, path, error, fileIndex))
|
||||
{
|
||||
SetStatusMessage(L"解析失败:" + error, true);
|
||||
InvalidateRect(m_hwnd, nullptr, FALSE);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -968,45 +984,162 @@ namespace jdi
|
||||
return;
|
||||
}
|
||||
|
||||
HMENU menu = CreatePopupMenu();
|
||||
if (menu == nullptr)
|
||||
m_tabMenuIndex = result.index;
|
||||
|
||||
std::vector<MenuItem> items;
|
||||
|
||||
MenuItem header;
|
||||
header.kind = MenuItemKind::HEADER;
|
||||
header.label = m_tabs[static_cast<std::size_t>(result.index)].Name();
|
||||
items.push_back(header);
|
||||
|
||||
MenuItem create;
|
||||
create.label = L"新建标签页";
|
||||
create.id = kMenuTabNew;
|
||||
items.push_back(create);
|
||||
|
||||
MenuItem close;
|
||||
close.label = L"关闭该标签页";
|
||||
close.id = kMenuTabClose;
|
||||
close.enabled = (m_tabs.size() > 1);
|
||||
items.push_back(close);
|
||||
|
||||
MenuItem closeOthers;
|
||||
closeOthers.label = L"关闭其它标签页";
|
||||
closeOthers.id = kMenuTabCloseOthers;
|
||||
closeOthers.enabled = (m_tabs.size() > 1);
|
||||
items.push_back(closeOthers);
|
||||
|
||||
// 菜单绘制在客户区内,因此把屏幕坐标换算为客户区坐标。
|
||||
POINT anchor = {result.screenX, result.screenY};
|
||||
ScreenToClient(m_hwnd, &anchor);
|
||||
|
||||
RECT client = {};
|
||||
GetClientRect(m_hwnd, &client);
|
||||
const gd::RectF bounds(0.0f, 0.0f, static_cast<float>(client.right - client.left),
|
||||
static_cast<float>(client.bottom - client.top));
|
||||
|
||||
m_menu.Open(MenuScope::TAB_BAR, bounds, anchor.x, anchor.y, items);
|
||||
}
|
||||
|
||||
void Application::DispatchMenuResult(const MenuResult& result)
|
||||
{
|
||||
if (!result.valid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AppendMenuW(menu, MF_STRING, static_cast<UINT_PTR>(kMenuTabNew), L"新建标签页");
|
||||
AppendMenuW(menu, MF_STRING, static_cast<UINT_PTR>(kMenuTabClose), L"关闭该标签页");
|
||||
AppendMenuW(menu, MF_STRING, static_cast<UINT_PTR>(kMenuTabCloseOthers), L"关闭其它标签页");
|
||||
if (m_tabs.size() <= 1)
|
||||
switch (result.scope)
|
||||
{
|
||||
EnableMenuItem(menu, static_cast<UINT>(kMenuTabClose), MF_BYCOMMAND | MF_GRAYED);
|
||||
EnableMenuItem(menu, static_cast<UINT>(kMenuTabCloseOthers), MF_BYCOMMAND | MF_GRAYED);
|
||||
case MenuScope::SIGNAL_PANEL:
|
||||
{
|
||||
const bool needRelayout = m_panel.OnMenuCommand(result);
|
||||
if (needRelayout)
|
||||
{
|
||||
Relayout();
|
||||
}
|
||||
InvalidateRect(m_hwnd, nullptr, FALSE);
|
||||
break;
|
||||
}
|
||||
|
||||
SetForegroundWindow(m_hwnd);
|
||||
const int command = TrackPopupMenu(menu, TPM_RETURNCMD | TPM_LEFTALIGN | TPM_TOPALIGN,
|
||||
result.screenX, result.screenY, 0, m_hwnd, nullptr);
|
||||
DestroyMenu(menu);
|
||||
|
||||
if (command == kMenuTabNew)
|
||||
case MenuScope::TAB_BAR:
|
||||
{
|
||||
NewTab();
|
||||
const int index = m_tabMenuIndex;
|
||||
if (result.id == kMenuTabNew)
|
||||
{
|
||||
NewTab();
|
||||
}
|
||||
else if (result.id == kMenuTabClose)
|
||||
{
|
||||
CloseTab(index);
|
||||
}
|
||||
else if (result.id == kMenuTabCloseOthers)
|
||||
{
|
||||
if (index >= 0 && index < static_cast<int>(m_tabs.size()) && m_tabs.size() > 1)
|
||||
{
|
||||
const TabConfig keep = m_tabs[static_cast<std::size_t>(index)];
|
||||
m_tabs.clear();
|
||||
m_tabs.push_back(keep);
|
||||
SetActiveTab(0);
|
||||
}
|
||||
}
|
||||
m_tabMenuIndex = -1;
|
||||
InvalidateRect(m_hwnd, nullptr, TRUE);
|
||||
break;
|
||||
}
|
||||
else if (command == kMenuTabClose)
|
||||
{
|
||||
CloseTab(result.index);
|
||||
}
|
||||
else if (command == kMenuTabCloseOthers)
|
||||
{
|
||||
const TabConfig keep = m_tabs[static_cast<std::size_t>(result.index)];
|
||||
m_tabs.clear();
|
||||
m_tabs.push_back(keep);
|
||||
SetActiveTab(0);
|
||||
case MenuScope::NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT Application::HandleMessage(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
// 菜单打开时优先消费鼠标与键盘事件,形成模态交互。
|
||||
if (m_menu.IsOpen())
|
||||
{
|
||||
// 菜单接管输入后,取消底层组件可能仍在进行的拖拽。
|
||||
if (m_activeTarget != Target::NONE || m_draggingSplitter)
|
||||
{
|
||||
ReleaseCapture();
|
||||
m_activeTarget = Target::NONE;
|
||||
m_draggingSplitter = false;
|
||||
m_panel.OnLButtonUp(0, 0);
|
||||
m_plot.OnLButtonUp(0, 0);
|
||||
}
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_MOUSEMOVE:
|
||||
if (m_menu.OnMouseMove(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)))
|
||||
{
|
||||
InvalidateRect(hwnd, nullptr, FALSE);
|
||||
}
|
||||
return 0;
|
||||
case WM_LBUTTONDOWN:
|
||||
{
|
||||
MenuResult result;
|
||||
m_menu.OnLButtonDown(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), result);
|
||||
InvalidateRect(hwnd, nullptr, FALSE);
|
||||
return 0;
|
||||
}
|
||||
case WM_LBUTTONUP:
|
||||
{
|
||||
MenuResult result;
|
||||
m_menu.OnLButtonUp(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), result);
|
||||
InvalidateRect(hwnd, nullptr, FALSE);
|
||||
DispatchMenuResult(result);
|
||||
return 0;
|
||||
}
|
||||
case WM_RBUTTONDOWN:
|
||||
case WM_MBUTTONDOWN:
|
||||
case WM_MOUSEWHEEL:
|
||||
m_menu.Close();
|
||||
InvalidateRect(hwnd, nullptr, FALSE);
|
||||
return 0;
|
||||
case WM_KEYDOWN:
|
||||
{
|
||||
MenuResult result;
|
||||
m_menu.OnKeyDown(wParam, result);
|
||||
InvalidateRect(hwnd, nullptr, FALSE);
|
||||
if (result.valid)
|
||||
{
|
||||
DispatchMenuResult(result);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
case WM_KILLFOCUS:
|
||||
case WM_CANCELMODE:
|
||||
m_menu.Close();
|
||||
InvalidateRect(hwnd, nullptr, FALSE);
|
||||
return 0;
|
||||
case WM_SETCURSOR:
|
||||
SetCursor(LoadCursorW(nullptr, IDC_ARROW));
|
||||
return TRUE;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_SIZE:
|
||||
@@ -1087,6 +1220,15 @@ namespace jdi
|
||||
const int x = GET_X_LPARAM(lParam);
|
||||
const int y = GET_Y_LPARAM(lParam);
|
||||
|
||||
// 点击面板之外的位置时收起面板内展开的自定义颜色面板。
|
||||
if (!m_panel.HitTest(x, y))
|
||||
{
|
||||
if (m_panel.CloseTransientUi())
|
||||
{
|
||||
InvalidateRect(hwnd, nullptr, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
if (UiPointInRect(m_splitterRect, static_cast<float>(x), static_cast<float>(y)))
|
||||
{
|
||||
SetCapture(hwnd);
|
||||
@@ -1157,6 +1299,7 @@ namespace jdi
|
||||
m_tabBar.OnLButtonUp(x, y, result);
|
||||
m_activeTarget = Target::NONE;
|
||||
OnTabBarResult(result);
|
||||
InvalidateRect(hwnd, nullptr, FALSE);
|
||||
return 0;
|
||||
}
|
||||
case Target::TOOLBAR:
|
||||
@@ -1219,6 +1362,8 @@ namespace jdi
|
||||
if (m_tabBar.OnRButtonDown(x, y, cursor.x, cursor.y, result))
|
||||
{
|
||||
OnTabBarResult(result);
|
||||
// 自绘菜单会覆盖在客户区之上,必须请求重绘才能显示。
|
||||
InvalidateRect(hwnd, nullptr, FALSE);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -338,11 +338,10 @@ namespace jdi
|
||||
* @brief 构建单条信号在当前视图下的折线点序列。
|
||||
* @param [IN] resolved 已解析的信号视图。
|
||||
* @param [IN] lane 所属网格绘制信息。
|
||||
* @param [IN] stepMode 是否使用阶梯保持连线。
|
||||
* @param [OUT] points 输出点序列。
|
||||
* @param [OUT] breaks 输出每段折线的起始下标(用于处理缺失值断线)。
|
||||
*/
|
||||
void BuildPolyline(const ResolvedSignal& resolved, const LaneVisual& lane, bool stepMode,
|
||||
void BuildPolyline(const ResolvedSignal& resolved, const LaneVisual& lane,
|
||||
std::vector<gd::PointF>& points, std::vector<std::size_t>& breaks) const;
|
||||
|
||||
/**
|
||||
|
||||
@@ -864,7 +864,7 @@ namespace jdi
|
||||
return changed;
|
||||
}
|
||||
|
||||
void PlotView::BuildPolyline(const ResolvedSignal& resolved, const LaneVisual& lane, bool stepMode,
|
||||
void PlotView::BuildPolyline(const ResolvedSignal& resolved, const LaneVisual& lane,
|
||||
std::vector<gd::PointF>& points, std::vector<std::size_t>& breaks) const
|
||||
{
|
||||
points.clear();
|
||||
@@ -921,7 +921,6 @@ namespace jdi
|
||||
const float limitBottom = lane.rect.Y + lane.rect.Height * 5.0f;
|
||||
|
||||
bool inSegment = false;
|
||||
double previousY = 0.0;
|
||||
|
||||
for (std::size_t index = begin; index < end; index += stride)
|
||||
{
|
||||
@@ -943,17 +942,10 @@ namespace jdi
|
||||
points.push_back(gd::PointF(x, y));
|
||||
inSegment = true;
|
||||
}
|
||||
else if (stepMode)
|
||||
{
|
||||
points.push_back(gd::PointF(x, static_cast<float>(previousY)));
|
||||
points.push_back(gd::PointF(x, y));
|
||||
}
|
||||
else
|
||||
{
|
||||
points.push_back(gd::PointF(x, y));
|
||||
}
|
||||
|
||||
previousY = y;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1097,8 +1089,7 @@ namespace jdi
|
||||
}
|
||||
|
||||
const DrawMode mode = resolved.style->mode;
|
||||
const bool stepMode = (mode == DrawMode::STEP);
|
||||
BuildPolyline(resolved, lane, stepMode, points, breaks);
|
||||
BuildPolyline(resolved, lane, points, breaks);
|
||||
|
||||
const bool drawLine = (mode != DrawMode::SCATTER);
|
||||
const bool drawScatter = (mode == DrawMode::SCATTER || mode == DrawMode::LINE_SCATTER);
|
||||
@@ -1106,7 +1097,7 @@ namespace jdi
|
||||
if (drawLine && !breaks.empty())
|
||||
{
|
||||
gd::Pen pen(ToGdiColor(resolved.style->color), resolved.style->lineWidth * m_scale);
|
||||
pen.SetLineJoin(stepMode ? gd::LineJoinMiter : gd::LineJoinRound);
|
||||
pen.SetLineJoin(gd::LineJoinRound);
|
||||
pen.SetStartCap(gd::LineCapRound);
|
||||
pen.SetEndCap(gd::LineCapRound);
|
||||
|
||||
|
||||
@@ -6,21 +6,42 @@
|
||||
#include <gdiplus.h>
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "DataModel.hpp"
|
||||
#include "PaintUtil.hpp"
|
||||
#include "PopupMenu.hpp"
|
||||
#include "Theme.hpp"
|
||||
|
||||
namespace jdi
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief 信号面板弹出菜单的命令标识。
|
||||
*/
|
||||
enum MenuCommand : int
|
||||
{
|
||||
CMD_SIGNAL_TOGGLE = 1, /**< 切换该信号可见性。 */
|
||||
CMD_SIGNAL_SOLO = 2, /**< 仅显示该信号。 */
|
||||
CMD_SIGNAL_SHOW_ALL = 3, /**< 显示全部信号。 */
|
||||
CMD_SIGNAL_HIDE_ALL = 4, /**< 隐藏全部信号。 */
|
||||
CMD_FILE_SHOW_ALL = 10, /**< 选中该文件全部信号。 */
|
||||
CMD_FILE_HIDE_ALL = 11, /**< 取消该文件全部信号。 */
|
||||
CMD_FILE_REMOVE = 12, /**< 从工作区移除该文件。 */
|
||||
CMD_COLOR_BASE = 100, /**< 预设颜色基准(配合色块下标)。 */
|
||||
CMD_MODE_BASE = 200, /**< 绘制样式基准(配合下标)。 */
|
||||
CMD_LANE_BASE = 300, /**< 网格归属基准(配合下标)。 */
|
||||
CMD_LANE_NEW = 400 /**< 新建网格。 */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief 左侧信号面板:按文件分组的信号树、可见性勾选与样式编辑。
|
||||
*
|
||||
* 面板只读取数据层(DataSet),全部显示配置读写均落在当前标签页(TabConfig)上,
|
||||
* 因此不同标签页的信号勾选与样式互不影响。
|
||||
* 因此不同标签页的信号勾选与样式互不影响。所有弹出菜单均使用主题化自绘菜单,
|
||||
* 不出现系统默认菜单样式。
|
||||
*/
|
||||
class SignalPanel
|
||||
{
|
||||
@@ -28,12 +49,13 @@ namespace jdi
|
||||
SignalPanel();
|
||||
|
||||
/**
|
||||
* @brief 绑定宿主窗口、字体与主题资源。
|
||||
* @param [IN] host 宿主窗口句柄,用于弹出上下文菜单。
|
||||
* @brief 绑定宿主窗口、字体、主题与共用弹出菜单。
|
||||
* @param [IN] host 宿主窗口句柄。
|
||||
* @param [IN] fonts 字体集合,需在面板生命周期内保持有效。
|
||||
* @param [IN] theme 主题配色,需在面板生命周期内保持有效。
|
||||
* @param [IN] menu 共用的主题化弹出菜单,需在面板生命周期内保持有效。
|
||||
*/
|
||||
void Setup(HWND host, const UiFonts* fonts, const Theme* theme);
|
||||
void Setup(HWND host, const UiFonts* fonts, const Theme* theme, PopupMenu* menu);
|
||||
|
||||
/**
|
||||
* @brief 绑定数据层与当前标签页配置。
|
||||
@@ -42,6 +64,12 @@ namespace jdi
|
||||
*/
|
||||
void SetContext(const DataSet* dataSet, TabConfig* tab);
|
||||
|
||||
/**
|
||||
* @brief 设置宿主客户区矩形(用于约束弹出菜单位置)。
|
||||
* @param [IN] bounds 客户区矩形。
|
||||
*/
|
||||
void SetClientBounds(const gd::RectF& bounds) { m_clientBounds = bounds; }
|
||||
|
||||
/**
|
||||
* @brief 标记列表结构失效(数据或折叠状态变化后调用)。
|
||||
*/
|
||||
@@ -130,6 +158,25 @@ namespace jdi
|
||||
*/
|
||||
bool OnMouseLeave();
|
||||
|
||||
/**
|
||||
* @brief 处理弹出菜单的选择结果。
|
||||
* @param [IN] result 菜单选择结果。
|
||||
* @return 需要重新布局返回 true。
|
||||
*/
|
||||
bool OnMenuCommand(const MenuResult& result);
|
||||
|
||||
/**
|
||||
* @brief 关闭自定义颜色面板等临时展开的界面。
|
||||
* @return 界面状态发生变化返回 true。
|
||||
*/
|
||||
bool CloseTransientUi();
|
||||
|
||||
/**
|
||||
* @brief 取出并清除“需要重新布局”标记。
|
||||
* @return 需要重新布局返回 true。
|
||||
*/
|
||||
bool TakeLayoutDirty();
|
||||
|
||||
/**
|
||||
* @brief 判断坐标是否落在面板区域内。
|
||||
* @param [IN] x 客户区横坐标。
|
||||
@@ -159,10 +206,12 @@ namespace jdi
|
||||
*/
|
||||
enum class RowPart : int
|
||||
{
|
||||
NONE = 0, /**< 未命中。 */
|
||||
DISCLOSURE, /**< 折叠三角。 */
|
||||
CHECK, /**< 复选框。 */
|
||||
BODY /**< 行主体。 */
|
||||
NONE = 0, /**< 未命中。 */
|
||||
DISCLOSURE, /**< 折叠三角。 */
|
||||
CHECK, /**< 复选框。 */
|
||||
BODY, /**< 行主体。 */
|
||||
CLOSE, /**< 文件行的关闭按钮。 */
|
||||
LANE_BADGE /**< 信号行的网格徽标。 */
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -170,12 +219,15 @@ namespace jdi
|
||||
*/
|
||||
enum class StyleHit : int
|
||||
{
|
||||
NONE = 0, /**< 未命中。 */
|
||||
COLOR, /**< 颜色色块。 */
|
||||
WIDTH, /**< 线宽按钮。 */
|
||||
MODE, /**< 绘制方式按钮。 */
|
||||
LANE, /**< 网格选择按钮。 */
|
||||
TOGGLE_ALL /**< 全部显示/隐藏按钮。 */
|
||||
NONE = 0, /**< 未命中。 */
|
||||
COLOR, /**< 预设颜色色块。 */
|
||||
CUSTOM_CHIP, /**< 自定义颜色入口。 */
|
||||
WIDTH_PRESET, /**< 线宽预设按钮。 */
|
||||
WIDTH_MINUS, /**< 线宽减号。 */
|
||||
WIDTH_PLUS, /**< 线宽加号。 */
|
||||
MODE, /**< 绘制样式按钮。 */
|
||||
SLIDER, /**< 自定义颜色滑块。 */
|
||||
TOGGLE_ALL /**< 全部显示/隐藏按钮。 */
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -231,6 +283,20 @@ namespace jdi
|
||||
*/
|
||||
gd::RectF RowRect(int row) const;
|
||||
|
||||
/**
|
||||
* @brief 计算文件行关闭按钮矩形。
|
||||
* @param [IN] row 行下标。
|
||||
* @return 关闭按钮矩形。
|
||||
*/
|
||||
gd::RectF FileCloseRect(int row) const;
|
||||
|
||||
/**
|
||||
* @brief 计算信号行网格徽标矩形。
|
||||
* @param [IN] row 行下标。
|
||||
* @return 徽标矩形。
|
||||
*/
|
||||
gd::RectF SignalBadgeRect(int row) const;
|
||||
|
||||
/**
|
||||
* @brief 绘制文件分组标题行。
|
||||
* @param [IN,OUT] g 绘图上下文。
|
||||
@@ -251,6 +317,13 @@ namespace jdi
|
||||
*/
|
||||
void PaintStyleSection(gd::Graphics& g);
|
||||
|
||||
/**
|
||||
* @brief 绘制自定义颜色面板。
|
||||
* @param [IN,OUT] g 绘图上下文。
|
||||
* @param [IN] style 当前编辑的信号样式。
|
||||
*/
|
||||
void PaintColorPicker(gd::Graphics& g, const SignalStyle& style);
|
||||
|
||||
/**
|
||||
* @brief 绘制列表滚动条。
|
||||
* @param [IN,OUT] g 绘图上下文。
|
||||
@@ -263,26 +336,40 @@ namespace jdi
|
||||
*/
|
||||
gd::RectF ScrollThumbRect() const;
|
||||
|
||||
/**
|
||||
* @brief 布置样式编辑区内各控件的矩形。
|
||||
*/
|
||||
void LayoutStyleControls();
|
||||
|
||||
/**
|
||||
* @brief 取得当前样式编辑区所需高度。
|
||||
* @return 逻辑高度(未乘缩放比例)。
|
||||
*/
|
||||
float DesiredStyleHeight() const;
|
||||
|
||||
/**
|
||||
* @brief 弹出信号右键菜单。
|
||||
* @param [IN] ref 目标信号引用。
|
||||
* @param [IN] screenX 屏幕坐标横坐标。
|
||||
* @param [IN] screenY 屏幕坐标纵坐标。
|
||||
* @param [IN] x 客户区横坐标。
|
||||
* @param [IN] y 客户区纵坐标。
|
||||
*/
|
||||
void ShowSignalMenu(const SignalRef& ref, int screenX, int screenY);
|
||||
void OpenSignalMenu(const SignalRef& ref, int x, int y);
|
||||
|
||||
/**
|
||||
* @brief 弹出文件分组右键菜单。
|
||||
* @param [IN] fileIndex 目标文件下标。
|
||||
* @param [IN] screenX 屏幕坐标横坐标。
|
||||
* @param [IN] screenY 屏幕坐标纵坐标。
|
||||
* @param [IN] x 客户区横坐标。
|
||||
* @param [IN] y 客户区纵坐标。
|
||||
*/
|
||||
void ShowFileMenu(int fileIndex, int screenX, int screenY);
|
||||
void OpenFileMenu(int fileIndex, int x, int y);
|
||||
|
||||
/**
|
||||
* @brief 弹出网格分配菜单。
|
||||
* @brief 弹出网格归属菜单(由信号行的网格徽标触发)。
|
||||
* @param [IN] ref 目标信号引用。
|
||||
* @param [IN] x 客户区横坐标。
|
||||
* @param [IN] y 客户区纵坐标。
|
||||
*/
|
||||
void ShowLaneMenu();
|
||||
void OpenLaneMenu(const SignalRef& ref, int x, int y);
|
||||
|
||||
/**
|
||||
* @brief 判断当前标签页中全部信号是否均为可见状态。
|
||||
@@ -296,25 +383,53 @@ namespace jdi
|
||||
*/
|
||||
int TotalSignalCount() const;
|
||||
|
||||
/**
|
||||
* @brief 调整当前信号线宽。
|
||||
* @param [IN] delta 增量,正值加粗。
|
||||
* @return 取值发生变化返回 true。
|
||||
*/
|
||||
bool StepLineWidth(float delta);
|
||||
|
||||
/**
|
||||
* @brief 展开自定义颜色面板并同步初始取色。
|
||||
* @param [IN] style 当前信号样式。
|
||||
* @return 界面状态发生变化返回 true。
|
||||
*/
|
||||
bool OpenColorPicker(const SignalStyle& style);
|
||||
|
||||
HWND m_host = nullptr; /**< 宿主窗口句柄。 */
|
||||
const UiFonts* m_fonts = nullptr; /**< 字体资源。 */
|
||||
const Theme* m_theme = nullptr; /**< 主题资源。 */
|
||||
PopupMenu* m_menu = nullptr; /**< 共用弹出菜单。 */
|
||||
const DataSet* m_dataSet = nullptr; /**< 数据集合。 */
|
||||
TabConfig* m_tab = nullptr; /**< 当前标签页配置。 */
|
||||
float m_scale = 1.0f; /**< DPI 缩放比例。 */
|
||||
gd::RectF m_clientBounds; /**< 宿主客户区矩形。 */
|
||||
|
||||
gd::RectF m_area; /**< 面板整体区域。 */
|
||||
gd::RectF m_headerRect; /**< 标题区域。 */
|
||||
gd::RectF m_listRect; /**< 列表区域。 */
|
||||
gd::RectF m_styleRect; /**< 样式编辑区域。 */
|
||||
gd::RectF m_toggleAllRect; /**< 全部显示/隐藏按钮。 */
|
||||
gd::RectF m_laneButtonRect; /**< 网格选择按钮。 */
|
||||
gd::RectF m_scrollBarRect; /**< 滚动条区域。 */
|
||||
|
||||
std::array<gd::RectF, 12> m_colorRects; /**< 颜色色块矩形。 */
|
||||
std::array<gd::RectF, 4> m_widthRects; /**< 线宽按钮矩形。 */
|
||||
std::array<gd::RectF, 4> m_modeRects; /**< 绘制方式按钮矩形。 */
|
||||
int m_colorCount = 0; /**< 实际可用的颜色数量。 */
|
||||
std::array<gd::RectF, 12> m_colorRects; /**< 预设颜色色块矩形。 */
|
||||
int m_colorCount = 0; /**< 实际可用的预设颜色数量。 */
|
||||
gd::RectF m_customChipRect; /**< 自定义颜色入口矩形。 */
|
||||
|
||||
gd::RectF m_widthThinRect; /**< 最细线宽预设矩形。 */
|
||||
gd::RectF m_widthThickRect; /**< 最粗线宽预设矩形。 */
|
||||
gd::RectF m_widthMinusRect; /**< 线宽减号矩形。 */
|
||||
gd::RectF m_widthPlusRect; /**< 线宽加号矩形。 */
|
||||
gd::RectF m_widthValueRect; /**< 线宽数值显示矩形。 */
|
||||
gd::RectF m_widthSpinnerRect; /**< 线宽数值输入框整体矩形。 */
|
||||
|
||||
std::array<gd::RectF, 3> m_modeRects; /**< 绘制样式按钮矩形。 */
|
||||
|
||||
gd::RectF m_pickerRect; /**< 自定义颜色面板整体矩形。 */
|
||||
std::array<gd::RectF, 3> m_sliderRects; /**< RGB 滑块轨道矩形。 */
|
||||
gd::RectF m_pickerPreviewRect; /**< 自定义颜色预览矩形。 */
|
||||
std::array<double, 3> m_pickerChannels = {0.0, 0.0, 0.0}; /**< 自定义颜色的 RGB 分量(0-1)。 */
|
||||
|
||||
std::vector<ListRow> m_rows; /**< 列表行集合(惰性缓存)。 */
|
||||
bool m_rowsDirty = true; /**< 列表行集合是否需要重建。 */
|
||||
@@ -329,6 +444,13 @@ namespace jdi
|
||||
RowPart m_hoverPart = RowPart::NONE; /**< 当前悬停的行内区域。 */
|
||||
StyleHit m_hoverStyle = StyleHit::NONE; /**< 当前悬停的样式条目类型。 */
|
||||
int m_hoverStyleIndex = -1; /**< 当前悬停的样式条目下标。 */
|
||||
|
||||
bool m_colorPickerOpen = false; /**< 自定义颜色面板是否展开。 */
|
||||
int m_draggingSlider = -1; /**< 正在拖拽的滑块下标,-1 表示未拖拽。 */
|
||||
bool m_layoutDirty = false; /**< 是否需要重新布局。 */
|
||||
|
||||
SignalRef m_menuTargetSignal; /**< 菜单操作的目标信号。 */
|
||||
int m_menuTargetFile = -1; /**< 菜单操作的目标文件。 */
|
||||
};
|
||||
|
||||
} // namespace jdi
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user