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
@@ -288,4 +288,136 @@ namespace jdi
|
||||
return ellipsis;
|
||||
}
|
||||
|
||||
void UiDrawPlusIcon(gd::Graphics& g, const gd::RectF& rect, std::uint32_t argb, float strokeWidth)
|
||||
{
|
||||
const float cx = rect.X + rect.Width * 0.5f;
|
||||
const float cy = rect.Y + rect.Height * 0.5f;
|
||||
const float arm = std::min(rect.Width, rect.Height) * 0.3f;
|
||||
UiDrawLine(g, cx - arm, cy, cx + arm, cy, argb, strokeWidth);
|
||||
UiDrawLine(g, cx, cy - arm, cx, cy + arm, argb, strokeWidth);
|
||||
}
|
||||
|
||||
void UiDrawCrossIcon(gd::Graphics& g, const gd::RectF& rect, std::uint32_t argb, float strokeWidth)
|
||||
{
|
||||
const float cx = rect.X + rect.Width * 0.5f;
|
||||
const float cy = rect.Y + rect.Height * 0.5f;
|
||||
const float arm = std::min(rect.Width, rect.Height) * 0.3f;
|
||||
UiDrawLine(g, cx - arm, cy - arm, cx + arm, cy + arm, argb, strokeWidth);
|
||||
UiDrawLine(g, cx + arm, cy - arm, cx - arm, cy + arm, argb, strokeWidth);
|
||||
}
|
||||
|
||||
void UiDrawArrowIcon(gd::Graphics& g, const gd::RectF& rect, std::uint32_t argb, float strokeWidth,
|
||||
IconDirection direction)
|
||||
{
|
||||
const float cx = rect.X + rect.Width * 0.5f;
|
||||
const float cy = rect.Y + rect.Height * 0.5f;
|
||||
const float arm = std::min(rect.Width, rect.Height) * 0.26f;
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
case IconDirection::LEFT:
|
||||
UiDrawLine(g, cx + arm * 0.6f, cy - arm, cx - arm * 0.6f, cy, argb, strokeWidth);
|
||||
UiDrawLine(g, cx - arm * 0.6f, cy, cx + arm * 0.6f, cy + arm, argb, strokeWidth);
|
||||
break;
|
||||
case IconDirection::RIGHT:
|
||||
UiDrawLine(g, cx - arm * 0.6f, cy - arm, cx + arm * 0.6f, cy, argb, strokeWidth);
|
||||
UiDrawLine(g, cx + arm * 0.6f, cy, cx - arm * 0.6f, cy + arm, argb, strokeWidth);
|
||||
break;
|
||||
case IconDirection::UP:
|
||||
UiDrawLine(g, cx - arm, cy + arm * 0.6f, cx, cy - arm * 0.6f, argb, strokeWidth);
|
||||
UiDrawLine(g, cx, cy - arm * 0.6f, cx + arm, cy + arm * 0.6f, argb, strokeWidth);
|
||||
break;
|
||||
case IconDirection::DOWN:
|
||||
default:
|
||||
UiDrawLine(g, cx - arm, cy - arm * 0.6f, cx, cy + arm * 0.6f, argb, strokeWidth);
|
||||
UiDrawLine(g, cx, cy + arm * 0.6f, cx + arm, cy - arm * 0.6f, argb, strokeWidth);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void UiDrawTriangleIcon(gd::Graphics& g, const gd::RectF& rect, std::uint32_t argb, IconDirection direction)
|
||||
{
|
||||
const float cx = rect.X + rect.Width * 0.5f;
|
||||
const float cy = rect.Y + rect.Height * 0.5f;
|
||||
const float arm = std::min(rect.Width, rect.Height) * 0.28f;
|
||||
|
||||
gd::PointF points[3];
|
||||
switch (direction)
|
||||
{
|
||||
case IconDirection::LEFT:
|
||||
points[0] = gd::PointF(cx + arm * 0.7f, cy - arm);
|
||||
points[1] = gd::PointF(cx - arm * 0.7f, cy);
|
||||
points[2] = gd::PointF(cx + arm * 0.7f, cy + arm);
|
||||
break;
|
||||
case IconDirection::RIGHT:
|
||||
points[0] = gd::PointF(cx - arm * 0.7f, cy - arm);
|
||||
points[1] = gd::PointF(cx + arm * 0.7f, cy);
|
||||
points[2] = gd::PointF(cx - arm * 0.7f, cy + arm);
|
||||
break;
|
||||
case IconDirection::UP:
|
||||
points[0] = gd::PointF(cx - arm, cy + arm * 0.7f);
|
||||
points[1] = gd::PointF(cx, cy - arm * 0.7f);
|
||||
points[2] = gd::PointF(cx + arm, cy + arm * 0.7f);
|
||||
break;
|
||||
case IconDirection::DOWN:
|
||||
default:
|
||||
points[0] = gd::PointF(cx - arm, cy - arm * 0.7f);
|
||||
points[1] = gd::PointF(cx, cy + arm * 0.7f);
|
||||
points[2] = gd::PointF(cx + arm, cy - arm * 0.7f);
|
||||
break;
|
||||
}
|
||||
|
||||
gd::SolidBrush brush(ToGdiColor(argb));
|
||||
g.FillPolygon(&brush, points, 3);
|
||||
}
|
||||
|
||||
double UiSliderRatioFromX(const gd::RectF& trackRect, float x)
|
||||
{
|
||||
if (trackRect.Width <= 0.0f)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
const double ratio = static_cast<double>(x - trackRect.X) / static_cast<double>(trackRect.Width);
|
||||
if (ratio < 0.0)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
if (ratio > 1.0)
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
return ratio;
|
||||
}
|
||||
|
||||
void UiDrawCheckBox(gd::Graphics& g, const gd::RectF& rect, int state, float radius)
|
||||
{
|
||||
const Theme& theme = SolarizedLight();
|
||||
const float centerY = rect.Y + rect.Height * 0.5f;
|
||||
|
||||
if (state == 1)
|
||||
{
|
||||
UiFillRoundRect(g, rect, radius, theme.accent);
|
||||
gd::Pen pen(ToGdiColor(theme.textOnAccent), std::max(1.4f, rect.Height * 0.11f));
|
||||
pen.SetStartCap(gd::LineCapRound);
|
||||
pen.SetEndCap(gd::LineCapRound);
|
||||
g.DrawLine(&pen, rect.X + rect.Width * 0.22f, centerY, rect.X + rect.Width * 0.42f,
|
||||
rect.Y + rect.Height * 0.72f);
|
||||
g.DrawLine(&pen, rect.X + rect.Width * 0.42f, rect.Y + rect.Height * 0.72f,
|
||||
rect.X + rect.Width * 0.78f, rect.Y + rect.Height * 0.28f);
|
||||
}
|
||||
else if (state == 2)
|
||||
{
|
||||
UiFillRoundRect(g, rect, radius, theme.accentSoft);
|
||||
UiDrawRoundRect(g, rect, radius, theme.accent, 1.0f);
|
||||
UiFillRect(g, gd::RectF(rect.X + rect.Width * 0.22f, centerY - rect.Height * 0.08f,
|
||||
rect.Width * 0.56f, rect.Height * 0.16f),
|
||||
theme.accent);
|
||||
}
|
||||
else
|
||||
{
|
||||
UiFillRoundRect(g, rect, radius, theme.cardBg);
|
||||
UiDrawRoundRect(g, rect, radius, theme.borderStrong, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace jdi
|
||||
Reference in new issue
Block a user