输入框鼠标编辑、图例省略、信号跨视图共享选择与网格菜单布局修复
- 输入框:支持鼠标左键点击定位插入符、拖拽框选区域,并且不再限制字符长度 - 输入框:长文本使用 ETO_CLIPPED 裁剪绘制,避免字符溢出到编辑区域之外 - 图例:信号名称超过 200px 时省略号截断,不再挤压标尺区域 - 选中状态从 TabConfig 迁移到 DataSet,切换视图后信号选中状态保持一致 - 网格右键菜单:Y 轴最大值/最小值直接显示当前值,点击后原位置弹出内联编辑框 - 标尺数值改为绘制在图例下层,不再因避让图例而隐藏 - 移除已无用的 LegendBandRect,新增共享的编辑框布局与命中检测工具 - .gitignore 忽略 TestData 测试数据目录
This commit is contained in:
1 parent
e3744f3eff
commit
12b3531485
19 files changed
+790
-186
No files matched your search
@@ -188,6 +188,27 @@ namespace jdi
|
||||
*/
|
||||
bool CollapseEditSelectionToEnd();
|
||||
|
||||
/**
|
||||
* @brief 编辑态下在输入框内按下鼠标左键:定位插入符并开始拖拽框选。
|
||||
* @param [IN] x 客户区横坐标。
|
||||
* @param [IN] y 客户区纵坐标。
|
||||
* @return 命中输入框返回 true。
|
||||
*/
|
||||
bool OnEditMouseDown(int x, int y);
|
||||
|
||||
/**
|
||||
* @brief 编辑态下拖拽鼠标:扩展选区。
|
||||
* @param [IN] x 客户区横坐标。
|
||||
* @return 选区发生变化返回 true。
|
||||
*/
|
||||
bool OnEditMouseMove(int x);
|
||||
|
||||
/**
|
||||
* @brief 编辑态下松开鼠标左键:结束拖拽框选。
|
||||
* @return 之前处于拖拽中返回 true。
|
||||
*/
|
||||
bool OnEditMouseUp();
|
||||
|
||||
/**
|
||||
* @brief 获取指定信号的显示外观(只读,全局共享)。
|
||||
* @param [IN] ref 信号引用。
|
||||
@@ -202,6 +223,18 @@ namespace jdi
|
||||
*/
|
||||
SignalStyle* StyleOf(const SignalRef& ref);
|
||||
|
||||
/**
|
||||
* @brief 获取当前选中信号(跨标签页共享,因此切换视图后选中项保持一致)。
|
||||
* @return 信号引用。
|
||||
*/
|
||||
const SignalRef& SelectedRef() const;
|
||||
|
||||
/**
|
||||
* @brief 设置当前选中信号(跨标签页共享)。
|
||||
* @param [IN] ref 信号引用。
|
||||
*/
|
||||
void SelectSignal(const SignalRef& ref);
|
||||
|
||||
/**
|
||||
* @brief 将浮动拾色器的取色结果应用到当前选中信号。
|
||||
* @param [IN] color 0xAARRGGBB 颜色值。
|
||||
|
||||
@@ -715,7 +715,7 @@ namespace jdi
|
||||
}
|
||||
|
||||
const gd::RectF rect = RowRect(row);
|
||||
const bool selected = (m_tab->Selected() == ref);
|
||||
const bool selected = (SelectedRef() == ref);
|
||||
const bool hovered = (m_hoverRow == row);
|
||||
|
||||
if (selected)
|
||||
@@ -818,8 +818,8 @@ namespace jdi
|
||||
|
||||
UiFillRect(g, m_styleRect, m_theme->panelBg);
|
||||
|
||||
const SignalStyle* style = (m_tab == nullptr) ? nullptr : StyleOf(m_tab->Selected());
|
||||
if (style == nullptr || m_tab->Selected().IsValid() == false)
|
||||
const SignalStyle* style = (m_tab == nullptr) ? nullptr : StyleOf(SelectedRef());
|
||||
if (style == nullptr || SelectedRef().IsValid() == false)
|
||||
{
|
||||
UiText(g, L"请选择信号以编辑样式", m_fonts->uiSmall, m_styleRect, m_theme->textMuted,
|
||||
TextAlign::CENTER);
|
||||
@@ -964,7 +964,7 @@ namespace jdi
|
||||
{
|
||||
return false;
|
||||
}
|
||||
SignalStyle* style = StyleOf(m_tab->Selected());
|
||||
SignalStyle* style = StyleOf(SelectedRef());
|
||||
if (style == nullptr)
|
||||
{
|
||||
return false;
|
||||
@@ -1043,7 +1043,7 @@ namespace jdi
|
||||
{
|
||||
case StyleEditField::WIDTH:
|
||||
{
|
||||
const SignalStyle* style = StyleOf(m_tab->Selected());
|
||||
const SignalStyle* style = StyleOf(SelectedRef());
|
||||
if (style == nullptr)
|
||||
{
|
||||
return false;
|
||||
@@ -1053,7 +1053,7 @@ namespace jdi
|
||||
}
|
||||
case StyleEditField::OPACITY:
|
||||
{
|
||||
const SignalStyle* style = StyleOf(m_tab->Selected());
|
||||
const SignalStyle* style = StyleOf(SelectedRef());
|
||||
if (style == nullptr)
|
||||
{
|
||||
return false;
|
||||
@@ -1100,8 +1100,8 @@ namespace jdi
|
||||
// 名称类字段可输入任意字符,数值类字段限制为数字与小数点。
|
||||
const bool nameField =
|
||||
(field == StyleEditField::SIGNAL_NAME) || (field == StyleEditField::FILE_NAME);
|
||||
m_edit.Begin(std::move(initial), true, nameField ? EditFilter::ANY : EditFilter::NUMBER,
|
||||
nameField ? 64u : 6u);
|
||||
// 不限长度:名称与数值都由各自的提交逻辑处理超长内容。
|
||||
m_edit.Begin(std::move(initial), true, nameField ? EditFilter::ANY : EditFilter::NUMBER, 0u);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1140,7 +1140,7 @@ namespace jdi
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (SignalStyle* style = StyleOf(m_tab->Selected()))
|
||||
if (SignalStyle* style = StyleOf(SelectedRef()))
|
||||
{
|
||||
const float value = ClampFloat(static_cast<float>(parsed), kWidthMin, kWidthMax);
|
||||
style->lineWidth = std::round(value * 10.0f) / 10.0f;
|
||||
@@ -1159,7 +1159,7 @@ namespace jdi
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (SignalStyle* style = StyleOf(m_tab->Selected()))
|
||||
if (SignalStyle* style = StyleOf(SelectedRef()))
|
||||
{
|
||||
style->opacity = ClampFloat(static_cast<float>(parsed) / 100.0f, 0.0f, 1.0f);
|
||||
}
|
||||
@@ -1299,6 +1299,34 @@ namespace jdi
|
||||
return m_edit.DeselectToEnd();
|
||||
}
|
||||
|
||||
bool SignalPanel::OnEditMouseDown(int x, int y)
|
||||
{
|
||||
if (m_editField == StyleEditField::NONE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return UiEditFieldMouseDown(m_fonts->ui, EditFieldRect(), m_edit, m_scale, x, y);
|
||||
}
|
||||
|
||||
bool SignalPanel::OnEditMouseMove(int x)
|
||||
{
|
||||
if (m_editField == StyleEditField::NONE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return UiEditFieldMouseMove(m_fonts->ui, EditFieldRect(), m_edit, m_scale, x);
|
||||
}
|
||||
|
||||
bool SignalPanel::OnEditMouseUp()
|
||||
{
|
||||
if (!m_edit.Dragging())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
m_edit.EndDrag();
|
||||
return true;
|
||||
}
|
||||
|
||||
const SignalStyle* SignalPanel::StyleOf(const SignalRef& ref) const
|
||||
{
|
||||
return (m_dataSet != nullptr) ? m_dataSet->Style(ref) : nullptr;
|
||||
@@ -1309,13 +1337,27 @@ namespace jdi
|
||||
return (m_dataSetWritable != nullptr) ? m_dataSetWritable->Style(ref) : nullptr;
|
||||
}
|
||||
|
||||
const SignalRef& SignalPanel::SelectedRef() const
|
||||
{
|
||||
static const SignalRef fallback;
|
||||
return (m_dataSet != nullptr) ? m_dataSet->Selected() : fallback;
|
||||
}
|
||||
|
||||
void SignalPanel::SelectSignal(const SignalRef& ref)
|
||||
{
|
||||
if (m_dataSetWritable != nullptr)
|
||||
{
|
||||
m_dataSetWritable->SetSelected(ref);
|
||||
}
|
||||
}
|
||||
|
||||
bool SignalPanel::ApplyColor(std::uint32_t color)
|
||||
{
|
||||
if (m_tab == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
SignalStyle* style = StyleOf(m_tab->Selected());
|
||||
SignalStyle* style = StyleOf(SelectedRef());
|
||||
if (style == nullptr)
|
||||
{
|
||||
return false;
|
||||
@@ -1334,7 +1376,7 @@ namespace jdi
|
||||
{
|
||||
return false;
|
||||
}
|
||||
SignalStyle* style = StyleOf(m_tab->Selected());
|
||||
SignalStyle* style = StyleOf(SelectedRef());
|
||||
if (style == nullptr)
|
||||
{
|
||||
return false;
|
||||
@@ -1415,7 +1457,7 @@ namespace jdi
|
||||
{
|
||||
hoverStyle = StyleHit::TOGGLE_ALL;
|
||||
}
|
||||
else if (m_tab != nullptr && StyleOf(m_tab->Selected()) != nullptr)
|
||||
else if (m_tab != nullptr && StyleOf(SelectedRef()) != nullptr)
|
||||
{
|
||||
for (int index = 0; index < m_colorCount; ++index)
|
||||
{
|
||||
@@ -1528,7 +1570,7 @@ namespace jdi
|
||||
}
|
||||
|
||||
// 样式编辑区。
|
||||
if (SignalStyle* style = StyleOf(m_tab->Selected()))
|
||||
if (SignalStyle* style = StyleOf(SelectedRef()))
|
||||
{
|
||||
int paletteCount = 0;
|
||||
const std::uint32_t* palette = SignalPalette(paletteCount);
|
||||
@@ -1612,7 +1654,7 @@ namespace jdi
|
||||
}
|
||||
|
||||
const SignalRef ref{item.fileIndex, item.signalIndex};
|
||||
m_tab->SetSelected(ref);
|
||||
SelectSignal(ref);
|
||||
|
||||
if (part == RowPart::CHECK)
|
||||
{
|
||||
@@ -1656,7 +1698,7 @@ namespace jdi
|
||||
const float fy = static_cast<float>(y);
|
||||
if (UiPointInRect(m_customChipRect, fx, fy) && m_tab != nullptr)
|
||||
{
|
||||
if (const SignalStyle* style = StyleOf(m_tab->Selected()))
|
||||
if (const SignalStyle* style = StyleOf(SelectedRef()))
|
||||
{
|
||||
changed = OpenColorPickerPopup(*style) || changed;
|
||||
}
|
||||
@@ -1739,7 +1781,7 @@ namespace jdi
|
||||
}
|
||||
|
||||
const SignalRef ref{item.fileIndex, item.signalIndex};
|
||||
m_tab->SetSelected(ref);
|
||||
SelectSignal(ref);
|
||||
m_rowsDirty = true;
|
||||
return BeginEdit(StyleEditField::SIGNAL_NAME, row);
|
||||
}
|
||||
@@ -1766,7 +1808,7 @@ namespace jdi
|
||||
}
|
||||
|
||||
const SignalRef ref{item.fileIndex, item.signalIndex};
|
||||
m_tab->SetSelected(ref);
|
||||
SelectSignal(ref);
|
||||
OpenSignalMenu(ref, x, y);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user