fix: 自定义颜色色块与预设色块保持一致,拾色浮窗改为锚点定位并放行面板内点击

- 自定义颜色入口改为与预设色块完全一致的呈现:当前颜色不在预设中时,
  方格直接填充该自定义颜色(并自动选择浅色/深色加号图标以保证可读性),
  外框尺寸与选中样式与预设色块完全相同。
- 拾色浮窗改为以触发控件矩形为锚点定位:优先紧贴其下方展开,空间不足时改到上方,
  修复此前浮窗遮挡「加号」方格的问题。
- 拾色浮窗展开时点击面板内的其它控件(预设色、线宽、样式、透明度等)不再被吞掉,
  改为「先收起浮窗、再放行该次点击」,一次点击即可切换预设色;
  点击面板外或绘图区仍只收起浮窗。
This commit is contained in:
DeepSeek V4.1 Flash committed 2026-09-29 17:23:45 +08:00
1 parent 729494d1ec
commit 0f98dd9a85
4 files changed
+64 -31

No files matched your search

+15 -12
View File
@@ -111,27 +111,30 @@ namespace jdi
return true;
}
void ColorPickerPopup::BuildLayout(const gd::RectF& bounds, int x, int y)
void ColorPickerPopup::BuildLayout(const gd::RectF& bounds, const gd::RectF& anchor)
{
const float width = kPanelWidth * m_scale;
const float height = (kPadV * 2.0f + kTitleHeight + kTitleGap + kRowHeight * 3.0f + kRowGap * 2.0f +
kPreviewGap + kPreviewHeight) *
m_scale;
float left = static_cast<float>(x);
float top = static_cast<float>(y);
const float gap = 4.0f * m_scale;
// 优先向右下展开;越界时翻转,最后做边界收敛。
if (left + width > bounds.X + bounds.Width)
{
left = static_cast<float>(x) - width;
}
// 纵向:优先紧贴触发控件下方展开;空间不足时改到其上方,避免遮挡触发控件本身。
float top = anchor.Y + anchor.Height + gap;
if (top + height > bounds.Y + bounds.Height)
{
top = static_cast<float>(y) - height;
top = anchor.Y - height - gap;
}
top = std::max(bounds.Y + 2.0f, std::min(top, bounds.Y + bounds.Height - height - 2.0f));
// 横向:与触发控件左对齐,越界时再收敛。
float left = anchor.X;
if (left + width > bounds.X + bounds.Width)
{
left = anchor.X + anchor.Width - width;
}
left = std::max(bounds.X + 2.0f, std::min(left, bounds.X + bounds.Width - width - 2.0f));
top = std::max(bounds.Y + 2.0f, std::min(top, bounds.Y + bounds.Height - height - 2.0f));
m_rect = gd::RectF(left, top, width, height);
@@ -160,7 +163,7 @@ namespace jdi
96.0f * m_scale, 20.0f * m_scale);
}
void ColorPickerPopup::Open(const gd::RectF& bounds, int x, int y, std::uint32_t color)
void ColorPickerPopup::Open(const gd::RectF& bounds, const gd::RectF& anchor, std::uint32_t color)
{
m_channels[0] = static_cast<double>((color >> 16) & 0xFFu) / 255.0;
m_channels[1] = static_cast<double>((color >> 8) & 0xFFu) / 255.0;
@@ -171,7 +174,7 @@ namespace jdi
m_draggingSlider = -1;
m_hoverSlider = -1;
BuildLayout(bounds, x, y);
BuildLayout(bounds, anchor);
}
void ColorPickerPopup::Close()