Fix a rare drag/drop issue

This commit is contained in:
Eduardo Bart 2012-07-31 06:34:45 -03:00
parent 6ef44d462d
commit f4641333f4
3 changed files with 14 additions and 11 deletions

View File

@ -42,10 +42,7 @@ protected:
};
/// Throws a generic exception
template<typename... T>
void throw_exception(const std::string& what) {
throw exception(what);
}
inline void throw_exception(const std::string& what) { throw exception(what); }
}

View File

@ -133,7 +133,7 @@ void UIManager::inputEvent(const InputEvent& event)
}
// mouse move can change hovered widgets
updateHoveredWidget();
updateHoveredWidget(true);
// first fire dragging move
if(m_draggingWidget) {
@ -209,12 +209,12 @@ bool UIManager::updateDraggingWidget(const UIWidgetPtr& draggingWidget, const Po
return accepted;
}
void UIManager::updateHoveredWidget()
void UIManager::updateHoveredWidget(bool now)
{
if(m_hoverUpdateScheduled)
if(m_hoverUpdateScheduled && !now)
return;
g_dispatcher.addEvent([this] {
auto func = [this] {
if(!m_rootWidget)
return;
@ -235,8 +235,14 @@ void UIManager::updateHoveredWidget()
hoveredWidget->onHoverChange(true);
}
}
});
};
if(now)
func();
else {
m_hoverUpdateScheduled = true;
g_dispatcher.addEvent(func);
}
}
void UIManager::onWidgetAppear(const UIWidgetPtr& widget)

View File

@ -41,7 +41,7 @@ public:
void updatePressedWidget(const UIWidgetPtr& newPressedWidget, const Point& clickedPos = Point());
bool updateDraggingWidget(const UIWidgetPtr& draggingWidget, const Point& clickedPos = Point());
void updateHoveredWidget();
void updateHoveredWidget(bool now = false);
void clearStyles();
bool importStyle(const std::string& file);