Files
Just-DataInspector/Utilities/Inc/Theme.hpp
T
DeepSeek V4.1 Flash 350538c634 命名审查与垃圾代码清理(纯重命名 / 死代码删除,无行为变更)
前提:加载完成后全部采样都已驻留内存,程序此后与源文件再无联系。
据此修正了一批会让人误以为"仍在读写文件"的命名:

- SampleFileAt → SampleSignalAt(取的是内存信号在给定时刻的采样值)。
- DataSet::AddPreparedFile → AddDataFile。
- PlotView::InvalidatePolylineCache → InvalidateDerivedCaches
  (它同时清空折线、边沿统计、中心平均值曲线、静态场景缓存与悬停引用)。
- PlotView::CursorColor(int which) → CursorColor()(两条光标同色,参数从未使用)。
- UiEllipsize(g,…) → UiEllipsize(…):纯测量不绘制,删掉被忽略的绘图上下文参数;
  同时删除与 UiMeasureTextWidth 完全重复的 UiTextWidth,调用点统一到 UiMeasureTextWidth。

清理残留参数((void)xxx;):
- TabConfig 的可见性/网格族(SetVisible / ToggleVisible / SetFileVisible / SetAllVisible /
  SoloSignal / SetMode / SyncLanes / FileHasVisible / FileAllVisible)去掉从未使用的
  const DataSet& 参数(仅 SyncToDataSet 真正需要数据层,保留)。
- PlotView::OnLButtonUp(int y)、OnMouseWheel(int delta, bool shift);PainterSignalHalo 去掉未用的 ref。
- BuildDataFile 中未使用的局部 rowCount。

删除无人调用的死函数:
  DataSet::Clear / AddFromTable;SignalColorCount;WideToUtf8 / StartsWith;
  PlotView::ViewMinTime / ViewMaxTime / EdgePanelRect / EdgePanelCloseRect /
  EdgeCenterPanelRect / ScaleLaneRange / BeginLaneValueEdit / LaneContentHeight;
  SignalPanel::NeedsScrollBar / IsFilterEditing / FilterText / ContentHeight;
  PopupMenu::EditingItemId;TabBar::IsDragging;TextEdit::PlaceCaret。

删除只写不读的死字段:CsvTable::sourceRowCount(与 rowCount 等义)与 skippedRowCount。

以 VERY_BIG_DATA.CSV 回归验证:加载与勾选、筛选框(含"无匹配的筛选信号")、
样式区线宽文案省略、选区放大(横向与纵向)、双光标读数与 Δt、右键菜单(Y 轴数值与
实验性功能子菜单)、合并/拆分网格、标签与信号重命名省略号,行为均与改动前一致;
make clean && make all 无任何警告。
2026-10-09 21:52:46 +08:00

127 lines
3.9 KiB
C++

#ifndef __THEME_HPP__
#define __THEME_HPP__
#include <windows.h>
#include <objidl.h>
#include <gdiplus.h>
#include <cstdint>
/// @brief GDI+ 命名空间短别名,便于在界面代码中引用绘图类型。
namespace gd = Gdiplus;
namespace jdi
{
/**
* @brief 将 0xAARRGGBB 颜色值转换为 GDI+ 颜色对象。
* @param [IN] argb 颜色值。
* @return GDI+ 颜色对象。
*/
inline gd::Color ToGdiColor(std::uint32_t argb)
{
return gd::Color(static_cast<BYTE>((argb >> 24) & 0xFFu), static_cast<BYTE>((argb >> 16) & 0xFFu),
static_cast<BYTE>((argb >> 8) & 0xFFu), static_cast<BYTE>(argb & 0xFFu));
}
/**
* @brief 由 0xRRGGBB 构造不透明的 0xAARRGGBB 颜色值。
* @param [IN] rgb RGB 颜色值。
* @return 不透明颜色值。
*/
inline std::uint32_t MakeArgb(std::uint32_t rgb)
{
return 0xFF000000u | (rgb & 0x00FFFFFFu);
}
/**
* @brief 替换颜色值的 Alpha 通道。
* @param [IN] argb 原颜色值。
* @param [IN] alpha 新的 Alpha 值(0-255)。
* @return 新的颜色值。
*/
inline std::uint32_t WithAlpha(std::uint32_t argb, unsigned int alpha)
{
return (argb & 0x00FFFFFFu) | ((static_cast<std::uint32_t>(alpha) & 0xFFu) << 24);
}
/**
* @brief 在两个颜色之间做线性插值。
* @param [IN] fromColor 起始颜色。
* @param [IN] toColor 结束颜色。
* @param [IN] ratio 插值比例,0 返回起始色,1 返回结束色。
* @return 插值后的颜色值。
*/
inline std::uint32_t MixColor(std::uint32_t fromColor, std::uint32_t toColor, double ratio)
{
if (ratio < 0.0)
{
ratio = 0.0;
}
if (ratio > 1.0)
{
ratio = 1.0;
}
std::uint32_t result = 0;
for (int shift = 0; shift <= 24; shift += 8)
{
const double a = static_cast<double>((fromColor >> shift) & 0xFFu);
const double b = static_cast<double>((toColor >> shift) & 0xFFu);
const std::uint32_t mixed = static_cast<std::uint32_t>(a + (b - a) * ratio + 0.5);
result |= ((mixed & 0xFFu) << shift);
}
return result;
}
/**
* @brief 界面主题色板(Solarised Light 派生)。
*/
struct Theme
{
std::uint32_t windowBg = 0; /**< 窗口底色。 */
std::uint32_t toolbarBg = 0; /**< 顶部工具栏底色。 */
std::uint32_t panelBg = 0; /**< 侧边面板底色。 */
std::uint32_t cardBg = 0; /**< 面板内卡片底色。 */
std::uint32_t statusBg = 0; /**< 底部状态栏底色。 */
std::uint32_t plotBg = 0; /**< 绘图区底色。 */
std::uint32_t border = 0; /**< 常规描边色。 */
std::uint32_t borderStrong = 0; /**< 强调描边色。 */
std::uint32_t text = 0; /**< 正文文字色。 */
std::uint32_t textStrong = 0; /**< 强调文字色。 */
std::uint32_t textMuted = 0; /**< 次要文字色。 */
std::uint32_t textOnAccent = 0; /**< 强调色之上的文字色。 */
std::uint32_t accent = 0; /**< 主题强调色。 */
std::uint32_t accentSoft = 0; /**< 强调色的浅色版本。 */
std::uint32_t hover = 0; /**< 悬停底色。 */
std::uint32_t pressed = 0; /**< 按下底色。 */
std::uint32_t selection = 0; /**< 选中底色。 */
std::uint32_t gridWeak = 0; /**< 次级网格线颜色。 */
std::uint32_t gridStrong = 0; /**< 主要网格线颜色。 */
std::uint32_t axisLine = 0; /**< 坐标轴线颜色。 */
std::uint32_t cursor = 0; /**< 时间光标颜色(单/双光标共用同一样式)。 */
std::uint32_t readoutBg = 0; /**< 数值读数底色。 */
std::uint32_t danger = 0; /**< 警示色。 */
std::uint32_t warning = 0; /**< 提示色。 */
};
/**
* @brief 获取当前使用的主题(Solarised Light)。
* @return 主题常引用。
*/
const Theme& SolarizedLight();
/**
* @brief 获取波形默认配色表。
* @param [OUT] count 配色数量输出。
* @return 颜色数组首地址。
*/
const std::uint32_t* SignalPalette(int& count);
} // namespace jdi
#endif // __THEME_HPP__