Save pre-batched-redraw snapshot
This commit is contained in:
+11
-9
@@ -276,9 +276,11 @@ bool Button::handleEvent(const ExMessage& msg)
|
||||
{
|
||||
if (!show)
|
||||
return false;
|
||||
resetEventVisualChanged();
|
||||
|
||||
bool oldHover = hover;// 注意:只在状态变化时记录,避免 WM_MOUSEMOVE 刷屏
|
||||
bool oldClick = click;
|
||||
const bool oldTipVisible = tipVisible;
|
||||
|
||||
bool consume = false;//是否消耗事件
|
||||
const bool isMouseMessage =
|
||||
@@ -312,12 +314,6 @@ bool Button::handleEvent(const ExMessage& msg)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (hover != oldHover)
|
||||
{
|
||||
SX_LOG_TRACE("Button") << SX_T("悬停变化: ","hover change: ") << "id=" << id
|
||||
<< " text= " << text
|
||||
<< " " << (oldHover ? 1 : 0) << "->" << (hover ? 1 : 0);
|
||||
}
|
||||
// 处理鼠标点击事件
|
||||
if (msg.message == WM_LBUTTONDOWN && hover && mode != StellarX::ButtonMode::DISABLED)
|
||||
{
|
||||
@@ -396,8 +392,6 @@ bool Button::handleEvent(const ExMessage& msg)
|
||||
// 到点就显示
|
||||
if (GetTickCount64() - tipHoverTick >= (ULONGLONG)tipDelayMs)
|
||||
{
|
||||
SX_LOG_TRACE("Button") << SX_T("提示信息显示: ","tooltip show:")<<" id = " << id <<SX_T("延时时间: ", " delayMs = ") << tipDelayMs;
|
||||
|
||||
tipVisible = true;
|
||||
|
||||
// 定位(跟随鼠标 or 相对按钮)
|
||||
@@ -424,8 +418,16 @@ bool Button::handleEvent(const ExMessage& msg)
|
||||
}
|
||||
|
||||
// 如果状态发生变化,标记需要重绘
|
||||
if (hover != oldHover || click != oldClick)
|
||||
const bool stateChanged = (hover != oldHover || click != oldClick);
|
||||
if (stateChanged)
|
||||
dirty = true;
|
||||
const bool tipVisibilityChanged = (tipVisible != oldTipVisible);
|
||||
|
||||
// 鼠标命中按钮区域,或按钮自身状态因此发生变化时,吞掉该事件。
|
||||
// 这样可以避免被遮挡/重叠的下层控件继续收到同一事件并把自己重绘到上层。
|
||||
if (isMouseMessage && (hover || oldHover || click != oldClick))
|
||||
consume = true;
|
||||
markEventVisualChanged(stateChanged || tipVisibilityChanged);
|
||||
|
||||
// 如果需要重绘,立即执行
|
||||
if (dirty)
|
||||
|
||||
Reference in New Issue
Block a user