fix: 统一输入框编辑行为、外观跨视图同步并优化标尺与网格可读性
输入框(TextEdit,全组件共用): - 修复退格一次删除两个字符:WM_CHAR 与 WM_KEYDOWN 重复处理了退格/删除, 现统一由 OnEditKey 处理,WM_CHAR 忽略全部控制字符。 - 进入编辑(整段选中)后按右键:取消全选并把插入符移到文本最右侧。 - 存在选区时松开 Shift 再按左右方向键,插入符收拢到选区的左/右端。 - 修复整段选中后按 Home/End 不收拢选区的问题。 标签页: - 按加粗字体测量宽度,避免激活页长名称被提前省略(预览过短)。 - 重命名过程中按正在输入的文本测量并加宽上限(320px),标签随输入增长, 解决长内容绘制错误;输入溢出时整体等比收缩,保证「+」始终可见。 信号显示外观跨标签页同步: - 外观(颜色/自定义色记忆/透明度/线宽/样式)从 TabConfig 上移到 DataSet 的 SignalData,成为信号的全局属性;可见性仍按标签页独立保存。 - 因此任一视图中修改某信号的颜色/线宽/透明度/样式,其它视图自动一致。 工具栏: - 移除「全选信号」按钮;「清空勾选」改为「清空网格」, 「拆分信号网格」改为「拆分网格」。 自适应: - 无可见信号(未勾选/全部取消/清空网格)时复位 ViewInitialized, 下次勾选第一个信号会重新自适应,而不是停留在旧视图范围。 绘图区标尺与网格: - 幅值刻度密度按网格高度自适应(3-8 档),各网格刻度数量一致; 网格较矮时同步收紧标签行距,提高可读密度。 - 网格线与五等分估读线加深,与网格边界(蓝灰)保持明显区分。 - 时间轴列名补上单位,显示为 time (s)。
This commit is contained in:
1 parent
53768b8b25
commit
e3744f3eff
16 files changed
+462
-340
No files matched your search
@@ -356,21 +356,23 @@ namespace jdi
|
||||
{
|
||||
return EndEdit(true);
|
||||
}
|
||||
if (character == L'\b')
|
||||
{
|
||||
return m_edit.Backspace();
|
||||
}
|
||||
if (character == 0x7F)
|
||||
{
|
||||
return m_edit.DeleteForward();
|
||||
}
|
||||
if (character < 0x20)
|
||||
// 退格/删除已由 WM_KEYDOWN 的 OnKeyDown 处理,此处忽略控制字符避免重复删除。
|
||||
if (character < 0x20 || character == 0x7F)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return m_edit.Insert(character);
|
||||
}
|
||||
|
||||
bool ColorPickerPopup::CollapseEditSelectionToEnd()
|
||||
{
|
||||
if (m_editField == EditField::NONE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return m_edit.DeselectToEnd();
|
||||
}
|
||||
|
||||
bool ColorPickerPopup::ContainsPoint(int x, int y) const
|
||||
{
|
||||
if (!m_open)
|
||||
|
||||
+117
-189
@@ -74,22 +74,6 @@ namespace jdi
|
||||
return inner;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 依据全局信号序号从调色板取色,保证跨标签页配色一致。
|
||||
* @param [IN] globalIndex 全局信号序号。
|
||||
* @return 0xAARRGGBB 颜色值。
|
||||
*/
|
||||
std::uint32_t PaletteColor(std::size_t globalIndex)
|
||||
{
|
||||
int paletteCount = 0;
|
||||
const std::uint32_t* palette = SignalPalette(paletteCount);
|
||||
if (palette == nullptr || paletteCount <= 0)
|
||||
{
|
||||
return 0xFF268BD2;
|
||||
}
|
||||
return palette[globalIndex % static_cast<std::size_t>(paletteCount)];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 为网格范围补充留白,避免波形紧贴边界。
|
||||
* @param [IN, OUT] yMin 范围下限。
|
||||
@@ -120,35 +104,50 @@ namespace jdi
|
||||
|
||||
/**
|
||||
* @brief 依据全部可见信号重新生成网格划分。
|
||||
* @param [IN] styles 显示配置。
|
||||
* @param [IN] visible 各信号的可见性(按 [文件][信号] 索引)。
|
||||
* @param [IN] lanes 网格集合(原地更新)。
|
||||
* @param [IN] mode 网格划分策略。
|
||||
*/
|
||||
void RebuildLanes(const std::vector<std::vector<SignalStyle>>& styles, std::vector<Lane>& lanes,
|
||||
void RebuildLanes(const std::vector<std::vector<bool>>& visible, std::vector<Lane>& lanes,
|
||||
LaneMode mode)
|
||||
{
|
||||
// 收集全部可见信号引用。
|
||||
std::vector<SignalRef> visible;
|
||||
for (std::size_t fileIndex = 0; fileIndex < styles.size(); ++fileIndex)
|
||||
std::vector<SignalRef> visibleRefs;
|
||||
for (std::size_t fileIndex = 0; fileIndex < visible.size(); ++fileIndex)
|
||||
{
|
||||
for (std::size_t signalIndex = 0; signalIndex < styles[fileIndex].size(); ++signalIndex)
|
||||
for (std::size_t signalIndex = 0; signalIndex < visible[fileIndex].size(); ++signalIndex)
|
||||
{
|
||||
if (styles[fileIndex][signalIndex].visible)
|
||||
if (visible[fileIndex][signalIndex])
|
||||
{
|
||||
SignalRef ref;
|
||||
ref.fileIndex = static_cast<int>(fileIndex);
|
||||
ref.signalIndex = static_cast<int>(signalIndex);
|
||||
visible.push_back(ref);
|
||||
visibleRefs.push_back(ref);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 判断某引用对应的信号是否可见(越界视为不可见)。
|
||||
const auto isVisibleRef = [&visible](const SignalRef& ref)
|
||||
{
|
||||
if (ref.fileIndex < 0 || static_cast<std::size_t>(ref.fileIndex) >= visible.size())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
const std::vector<bool>& fileVisible = visible[static_cast<std::size_t>(ref.fileIndex)];
|
||||
if (ref.signalIndex < 0 || static_cast<std::size_t>(ref.signalIndex) >= fileVisible.size())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return fileVisible[static_cast<std::size_t>(ref.signalIndex)];
|
||||
};
|
||||
|
||||
if (mode == LaneMode::PER_SIGNAL)
|
||||
{
|
||||
// 每条可见信号独占一个网格:网格数量严格跟随可见信号数量。
|
||||
lanes.clear();
|
||||
lanes.reserve(visible.size());
|
||||
for (const SignalRef& ref : visible)
|
||||
lanes.reserve(visibleRefs.size());
|
||||
for (const SignalRef& ref : visibleRefs)
|
||||
{
|
||||
Lane lane;
|
||||
lane.autoRange = true;
|
||||
@@ -170,13 +169,13 @@ namespace jdi
|
||||
}
|
||||
|
||||
lanes.clear();
|
||||
if (!visible.empty())
|
||||
if (!visibleRefs.empty())
|
||||
{
|
||||
Lane lane;
|
||||
lane.autoRange = previousAutoRange;
|
||||
lane.yMin = previousYMin;
|
||||
lane.yMax = previousYMax;
|
||||
lane.signals = visible;
|
||||
lane.signals = visibleRefs;
|
||||
lanes.push_back(std::move(lane));
|
||||
}
|
||||
}
|
||||
@@ -187,22 +186,8 @@ namespace jdi
|
||||
{
|
||||
std::vector<SignalRef>& refs = lane.signals;
|
||||
refs.erase(std::remove_if(refs.begin(), refs.end(),
|
||||
[&styles](const SignalRef& ref)
|
||||
{
|
||||
if (ref.fileIndex < 0 ||
|
||||
static_cast<std::size_t>(ref.fileIndex) >= styles.size())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
const std::vector<SignalStyle>& fileStyles =
|
||||
styles[static_cast<std::size_t>(ref.fileIndex)];
|
||||
if (ref.signalIndex < 0 ||
|
||||
static_cast<std::size_t>(ref.signalIndex) >= fileStyles.size())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return !fileStyles[static_cast<std::size_t>(ref.signalIndex)].visible;
|
||||
}),
|
||||
[&isVisibleRef](const SignalRef& ref)
|
||||
{ return !isVisibleRef(ref); }),
|
||||
refs.end());
|
||||
}
|
||||
|
||||
@@ -213,7 +198,7 @@ namespace jdi
|
||||
// 未分配网格的可见信号各自独占一个新网格。
|
||||
// 注意:不能把它们塞进已有的第一个网格——那会导致“拖拽合并后新勾选的信号
|
||||
// 被悄悄并入合并网格”,用户看不到新增的独立泳道。
|
||||
for (const SignalRef& ref : visible)
|
||||
for (const SignalRef& ref : visibleRefs)
|
||||
{
|
||||
bool placed = false;
|
||||
for (const Lane& lane : lanes)
|
||||
@@ -379,6 +364,22 @@ namespace jdi
|
||||
}
|
||||
signal.finiteCount = finiteCount;
|
||||
|
||||
// 显示外观随信号一起初始化:调色板按「全局信号序号」取色,
|
||||
// 使同一信号在任意标签页中都保持同一默认颜色。
|
||||
{
|
||||
int paletteCount = 0;
|
||||
const std::uint32_t* palette = SignalPalette(paletteCount);
|
||||
const std::size_t globalIndex = SignalCount() + file.signals.size();
|
||||
signal.style.color =
|
||||
(palette != nullptr && paletteCount > 0)
|
||||
? palette[globalIndex % static_cast<std::size_t>(paletteCount)]
|
||||
: 0xFF268BD2u;
|
||||
signal.style.customColor = signal.style.color;
|
||||
signal.style.opacity = 1.0f;
|
||||
signal.style.lineWidth = 1.6f;
|
||||
signal.style.mode = DrawMode::LINE;
|
||||
}
|
||||
|
||||
file.signals.push_back(std::move(signal));
|
||||
}
|
||||
|
||||
@@ -500,6 +501,29 @@ namespace jdi
|
||||
return &file->signals[static_cast<std::size_t>(ref.signalIndex)];
|
||||
}
|
||||
|
||||
const SignalStyle* DataSet::Style(const SignalRef& ref) const
|
||||
{
|
||||
const SignalData* signal = Resolve(ref);
|
||||
return (signal != nullptr) ? &signal->style : nullptr;
|
||||
}
|
||||
|
||||
SignalStyle* DataSet::Style(const SignalRef& ref)
|
||||
{
|
||||
const DataFile* file = FileAt(ref.fileIndex);
|
||||
if (file == nullptr)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
if (ref.signalIndex < 0 || ref.signalIndex >= static_cast<int>(file->signals.size()))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// 这里需要写入,因此借助非 const 路径重新定位信号。
|
||||
DataFile& mutableFile = m_files[static_cast<std::size_t>(ref.fileIndex)];
|
||||
return &mutableFile.signals[static_cast<std::size_t>(ref.signalIndex)].style;
|
||||
}
|
||||
|
||||
double DataSet::MinTime() const
|
||||
{
|
||||
double value = std::numeric_limits<double>::infinity();
|
||||
@@ -643,46 +667,10 @@ namespace jdi
|
||||
{
|
||||
}
|
||||
|
||||
void TabConfig::EnsureStyle(const DataSet& dataSet, int fileIndex, int signalIndex)
|
||||
{
|
||||
(void)dataSet;
|
||||
if (fileIndex < 0 || signalIndex < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const std::size_t fileSlot = static_cast<std::size_t>(fileIndex);
|
||||
if (fileSlot >= m_styles.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
std::vector<SignalStyle>& fileStyles = m_styles[fileSlot];
|
||||
if (static_cast<std::size_t>(signalIndex) >= fileStyles.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 若样式仍为默认状态且颜色为默认色,则按全局序号重新取色。
|
||||
SignalStyle& style = fileStyles[static_cast<std::size_t>(signalIndex)];
|
||||
|
||||
std::size_t globalIndex = 0;
|
||||
for (std::size_t index = 0; index < fileSlot; ++index)
|
||||
{
|
||||
if (index < m_styles.size())
|
||||
{
|
||||
globalIndex += m_styles[index].size();
|
||||
}
|
||||
}
|
||||
globalIndex += static_cast<std::size_t>(signalIndex);
|
||||
|
||||
style.color = PaletteColor(globalIndex);
|
||||
style.lineWidth = static_cast<float>(kDefaultLineWidth);
|
||||
}
|
||||
|
||||
void TabConfig::SyncToDataSet(const DataSet& dataSet)
|
||||
{
|
||||
const std::size_t fileCount = dataSet.FileCount();
|
||||
m_styles.resize(fileCount);
|
||||
m_visible.resize(fileCount);
|
||||
m_collapsed.resize(fileCount, false);
|
||||
|
||||
for (std::size_t fileIndex = 0; fileIndex < fileCount; ++fileIndex)
|
||||
@@ -693,15 +681,9 @@ namespace jdi
|
||||
continue;
|
||||
}
|
||||
|
||||
std::vector<SignalStyle>& fileStyles = m_styles[fileIndex];
|
||||
const std::size_t previousSize = fileStyles.size();
|
||||
fileStyles.resize(file->signals.size());
|
||||
|
||||
// 新增信号补默认配置(默认不可见,颜色取自调色板)。
|
||||
for (std::size_t signalIndex = previousSize; signalIndex < file->signals.size(); ++signalIndex)
|
||||
{
|
||||
EnsureStyle(dataSet, static_cast<int>(fileIndex), static_cast<int>(signalIndex));
|
||||
}
|
||||
// 新增信号默认为未勾选(由用户自行决定查看哪些信号),
|
||||
// 其显示外观已在 DataSet 中初始化完毕。
|
||||
m_visible[fileIndex].resize(file->signals.size(), false);
|
||||
}
|
||||
|
||||
// 清理已失效的选中状态与网格引用。
|
||||
@@ -732,9 +714,9 @@ namespace jdi
|
||||
}
|
||||
|
||||
const std::size_t slot = static_cast<std::size_t>(fileIndex);
|
||||
if (slot < m_styles.size())
|
||||
if (slot < m_visible.size())
|
||||
{
|
||||
m_styles.erase(m_styles.begin() + fileIndex);
|
||||
m_visible.erase(m_visible.begin() + fileIndex);
|
||||
}
|
||||
if (slot < m_collapsed.size())
|
||||
{
|
||||
@@ -770,43 +752,36 @@ namespace jdi
|
||||
}
|
||||
}
|
||||
|
||||
const SignalStyle* TabConfig::Style(const SignalRef& ref) const
|
||||
{
|
||||
if (ref.fileIndex < 0 || static_cast<std::size_t>(ref.fileIndex) >= m_styles.size())
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
const std::vector<SignalStyle>& fileStyles = m_styles[static_cast<std::size_t>(ref.fileIndex)];
|
||||
if (ref.signalIndex < 0 || static_cast<std::size_t>(ref.signalIndex) >= fileStyles.size())
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
return &fileStyles[static_cast<std::size_t>(ref.signalIndex)];
|
||||
}
|
||||
|
||||
SignalStyle* TabConfig::Style(const SignalRef& ref)
|
||||
{
|
||||
return const_cast<SignalStyle*>(static_cast<const TabConfig*>(this)->Style(ref));
|
||||
}
|
||||
|
||||
bool TabConfig::IsVisible(const SignalRef& ref) const
|
||||
{
|
||||
const SignalStyle* style = Style(ref);
|
||||
return (style != nullptr) && style->visible;
|
||||
if (ref.fileIndex < 0 || static_cast<std::size_t>(ref.fileIndex) >= m_visible.size())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
const std::vector<bool>& fileVisible = m_visible[static_cast<std::size_t>(ref.fileIndex)];
|
||||
if (ref.signalIndex < 0 || static_cast<std::size_t>(ref.signalIndex) >= fileVisible.size())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return fileVisible[static_cast<std::size_t>(ref.signalIndex)];
|
||||
}
|
||||
|
||||
void TabConfig::SetVisible(const DataSet& dataSet, const SignalRef& ref, bool visible)
|
||||
{
|
||||
SignalStyle* style = Style(ref);
|
||||
if (style == nullptr)
|
||||
if (ref.fileIndex < 0 || static_cast<std::size_t>(ref.fileIndex) >= m_visible.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (style->visible == visible)
|
||||
std::vector<bool>& fileVisible = m_visible[static_cast<std::size_t>(ref.fileIndex)];
|
||||
if (ref.signalIndex < 0 || static_cast<std::size_t>(ref.signalIndex) >= fileVisible.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
style->visible = visible;
|
||||
if (fileVisible[static_cast<std::size_t>(ref.signalIndex)] == visible)
|
||||
{
|
||||
return;
|
||||
}
|
||||
fileVisible[static_cast<std::size_t>(ref.signalIndex)] = visible;
|
||||
|
||||
// 合并模式下新勾选的信号独占一个新网格:切到自定义划分后,
|
||||
// RebuildLanes 会把尚未分配网格的可见信号各自放入新网格。
|
||||
@@ -820,104 +795,71 @@ namespace jdi
|
||||
|
||||
void TabConfig::ToggleVisible(const DataSet& dataSet, const SignalRef& ref)
|
||||
{
|
||||
const SignalStyle* style = Style(ref);
|
||||
if (style == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
SetVisible(dataSet, ref, !style->visible);
|
||||
SetVisible(dataSet, ref, !IsVisible(ref));
|
||||
}
|
||||
|
||||
void TabConfig::SetFileVisible(const DataSet& dataSet, int fileIndex, bool visible)
|
||||
{
|
||||
if (fileIndex < 0 || static_cast<std::size_t>(fileIndex) >= m_styles.size())
|
||||
if (fileIndex < 0 || static_cast<std::size_t>(fileIndex) >= m_visible.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (SignalStyle& style : m_styles[static_cast<std::size_t>(fileIndex)])
|
||||
{
|
||||
style.visible = visible;
|
||||
}
|
||||
std::vector<bool>& fileVisible = m_visible[static_cast<std::size_t>(fileIndex)];
|
||||
std::fill(fileVisible.begin(), fileVisible.end(), visible);
|
||||
SyncLanes(dataSet);
|
||||
}
|
||||
|
||||
void TabConfig::SetAllVisible(const DataSet& dataSet, bool visible)
|
||||
{
|
||||
for (std::vector<SignalStyle>& fileStyles : m_styles)
|
||||
for (std::vector<bool>& fileVisible : m_visible)
|
||||
{
|
||||
for (SignalStyle& style : fileStyles)
|
||||
{
|
||||
style.visible = visible;
|
||||
}
|
||||
std::fill(fileVisible.begin(), fileVisible.end(), visible);
|
||||
}
|
||||
SyncLanes(dataSet);
|
||||
}
|
||||
|
||||
void TabConfig::SoloSignal(const DataSet& dataSet, const SignalRef& ref)
|
||||
{
|
||||
for (std::vector<SignalStyle>& fileStyles : m_styles)
|
||||
for (std::vector<bool>& fileVisible : m_visible)
|
||||
{
|
||||
for (SignalStyle& style : fileStyles)
|
||||
{
|
||||
style.visible = false;
|
||||
}
|
||||
std::fill(fileVisible.begin(), fileVisible.end(), false);
|
||||
}
|
||||
if (SignalStyle* style = Style(ref); style != nullptr)
|
||||
{
|
||||
style->visible = true;
|
||||
}
|
||||
SyncLanes(dataSet);
|
||||
SetVisible(dataSet, ref, true);
|
||||
}
|
||||
|
||||
bool TabConfig::FileHasVisible(const DataSet& dataSet, int fileIndex) const
|
||||
{
|
||||
(void)dataSet;
|
||||
if (fileIndex < 0 || static_cast<std::size_t>(fileIndex) >= m_styles.size())
|
||||
if (fileIndex < 0 || static_cast<std::size_t>(fileIndex) >= m_visible.size())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (const SignalStyle& style : m_styles[static_cast<std::size_t>(fileIndex)])
|
||||
{
|
||||
if (style.visible)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
const std::vector<bool>& fileVisible = m_visible[static_cast<std::size_t>(fileIndex)];
|
||||
return std::find(fileVisible.begin(), fileVisible.end(), true) != fileVisible.end();
|
||||
}
|
||||
|
||||
bool TabConfig::FileAllVisible(const DataSet& dataSet, int fileIndex) const
|
||||
{
|
||||
(void)dataSet;
|
||||
if (fileIndex < 0 || static_cast<std::size_t>(fileIndex) >= m_styles.size())
|
||||
if (fileIndex < 0 || static_cast<std::size_t>(fileIndex) >= m_visible.size())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
const std::vector<SignalStyle>& fileStyles = m_styles[static_cast<std::size_t>(fileIndex)];
|
||||
if (fileStyles.empty())
|
||||
const std::vector<bool>& fileVisible = m_visible[static_cast<std::size_t>(fileIndex)];
|
||||
if (fileVisible.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (const SignalStyle& style : fileStyles)
|
||||
{
|
||||
if (!style.visible)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return std::find(fileVisible.begin(), fileVisible.end(), false) == fileVisible.end();
|
||||
}
|
||||
|
||||
bool TabConfig::AnyVisible() const
|
||||
{
|
||||
for (const std::vector<SignalStyle>& fileStyles : m_styles)
|
||||
for (const std::vector<bool>& fileVisible : m_visible)
|
||||
{
|
||||
for (const SignalStyle& style : fileStyles)
|
||||
if (std::find(fileVisible.begin(), fileVisible.end(), true) != fileVisible.end())
|
||||
{
|
||||
if (style.visible)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -926,15 +868,9 @@ namespace jdi
|
||||
int TabConfig::VisibleCount() const
|
||||
{
|
||||
int count = 0;
|
||||
for (const std::vector<SignalStyle>& fileStyles : m_styles)
|
||||
for (const std::vector<bool>& fileVisible : m_visible)
|
||||
{
|
||||
for (const SignalStyle& style : fileStyles)
|
||||
{
|
||||
if (style.visible)
|
||||
{
|
||||
++count;
|
||||
}
|
||||
}
|
||||
count += static_cast<int>(std::count(fileVisible.begin(), fileVisible.end(), true));
|
||||
}
|
||||
return count;
|
||||
}
|
||||
@@ -948,7 +884,7 @@ namespace jdi
|
||||
void TabConfig::SyncLanes(const DataSet& dataSet)
|
||||
{
|
||||
(void)dataSet;
|
||||
RebuildLanes(m_styles, m_lanes, m_laneMode);
|
||||
RebuildLanes(m_visible, m_lanes, m_laneMode);
|
||||
}
|
||||
|
||||
int TabConfig::LaneOfSignal(const SignalRef& ref) const
|
||||
@@ -1117,18 +1053,10 @@ namespace jdi
|
||||
double low = std::numeric_limits<double>::infinity();
|
||||
double high = -std::numeric_limits<double>::infinity();
|
||||
|
||||
for (std::size_t fileIndex = 0; fileIndex < m_styles.size(); ++fileIndex)
|
||||
for (std::size_t fileIndex = 0; fileIndex < m_visible.size(); ++fileIndex)
|
||||
{
|
||||
bool fileUsed = false;
|
||||
for (const SignalStyle& style : m_styles[fileIndex])
|
||||
{
|
||||
if (style.visible)
|
||||
{
|
||||
fileUsed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!fileUsed)
|
||||
const std::vector<bool>& fileVisible = m_visible[fileIndex];
|
||||
if (std::find(fileVisible.begin(), fileVisible.end(), true) == fileVisible.end())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
+57
-10
@@ -211,6 +211,17 @@ namespace jdi
|
||||
return false;
|
||||
}
|
||||
|
||||
// 未按 Shift 且存在选区时,左右键先「收拢」到选区的对应边缘(常规输入框行为):
|
||||
// 左键跳到选区左端、右键跳到选区右端,而不是在光标处再移动一格。
|
||||
if (!extendSelection && HasSelection())
|
||||
{
|
||||
const std::size_t target = (delta < 0) ? SelectionBegin() : SelectionEnd();
|
||||
m_caret = target;
|
||||
m_anchor = target;
|
||||
m_fresh = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::size_t offset = m_caret;
|
||||
const int steps = (delta > 0) ? delta : -delta;
|
||||
for (int index = 0; index < steps; ++index)
|
||||
@@ -239,30 +250,52 @@ namespace jdi
|
||||
|
||||
bool TextEdit::MoveHome(bool extendSelection)
|
||||
{
|
||||
if (!m_active || m_caret == 0)
|
||||
if (!m_active)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// 未按 Shift 时 Home 必须收拢已有选区(例如整段选中后按 Home 应取消全选)。
|
||||
if (!extendSelection)
|
||||
{
|
||||
const bool changed = HasSelection() || (m_caret != 0);
|
||||
m_caret = 0;
|
||||
m_anchor = 0;
|
||||
m_fresh = false;
|
||||
return changed;
|
||||
}
|
||||
|
||||
if (m_caret == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
m_caret = 0;
|
||||
if (!extendSelection)
|
||||
{
|
||||
m_anchor = 0;
|
||||
}
|
||||
m_fresh = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TextEdit::MoveEnd(bool extendSelection)
|
||||
{
|
||||
if (!m_active || m_caret == m_text.size())
|
||||
if (!m_active)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// 同上:End 在未按 Shift 时收拢到行尾。
|
||||
if (!extendSelection)
|
||||
{
|
||||
const bool changed = HasSelection() || (m_caret != m_text.size());
|
||||
m_caret = m_text.size();
|
||||
m_anchor = m_caret;
|
||||
m_fresh = false;
|
||||
return changed;
|
||||
}
|
||||
|
||||
if (m_caret == m_text.size())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
m_caret = m_text.size();
|
||||
if (!extendSelection)
|
||||
{
|
||||
m_anchor = m_caret;
|
||||
}
|
||||
m_fresh = false;
|
||||
return true;
|
||||
}
|
||||
@@ -274,6 +307,20 @@ namespace jdi
|
||||
m_fresh = !m_text.empty();
|
||||
}
|
||||
|
||||
bool TextEdit::DeselectToEnd()
|
||||
{
|
||||
if (!m_active)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const bool changed = HasSelection() || (m_caret != m_text.size());
|
||||
m_caret = m_text.size();
|
||||
m_anchor = m_caret;
|
||||
m_fresh = false;
|
||||
return changed;
|
||||
}
|
||||
|
||||
bool TextEdit::CopyToClipboard(HWND owner) const
|
||||
{
|
||||
if (m_text.empty())
|
||||
|
||||
@@ -56,8 +56,10 @@ namespace jdi
|
||||
theme.pressed = MakeArgb(0xD8CFB6u);
|
||||
theme.selection = MakeArgb(0xDCEAF6u);
|
||||
|
||||
theme.gridWeak = MakeArgb(0xECE5D1u);
|
||||
theme.gridStrong = MakeArgb(0xDCD4BEu);
|
||||
// 网格线需要在绘图区底色(kBase3)上清晰可辨,同时又要与网格边界
|
||||
// (axisLine/borderStrong 的蓝灰)明显区分——因此采用偏暖的加深米色。
|
||||
theme.gridWeak = MakeArgb(0xDDD3B8u);
|
||||
theme.gridStrong = MakeArgb(0xC3B896u);
|
||||
theme.axisLine = MakeArgb(kBase1);
|
||||
theme.cursor = MakeArgb(kOrange);
|
||||
theme.readoutBg = MakeArgb(0xF6EFDCu);
|
||||
|
||||
Reference in new issue
Block a user