fixing bugs with widgets
This commit is contained in:
parent
edbae32ba7
commit
1e6eeb7e44
@ -140,7 +140,7 @@ protected:
|
||||
public:
|
||||
|
||||
boost::signal<void(int)> KeyPressedSignal;
|
||||
boost::signal<void()> PostUpdateSignal;
|
||||
//boost::signal<void()> PostUpdateSignal;
|
||||
|
||||
~TGUIManager();
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "include/Engine.h"
|
||||
|
||||
|
||||
namespace SE
|
||||
{
|
||||
|
||||
@ -65,12 +66,14 @@ void TGUIManager::DeleteWidgetGroup(std::string groupName)
|
||||
|
||||
void TGUIManager::DeleteWidgetOnUpdate(const std::string& name)
|
||||
{
|
||||
PostUpdateSignal.connect(boost::bind(&TGUIManager::DeleteWidget, this, name));
|
||||
PerformInMainThreadAsync(boost::bind(&TGUIManager::DeleteWidget, this, name));
|
||||
//PostUpdateSignal.connect(boost::bind(&TGUIManager::DeleteWidget, this, name));
|
||||
}
|
||||
|
||||
void TGUIManager::DeleteWidgetGroupOnUpdate(const std::string& groupName)
|
||||
{
|
||||
PostUpdateSignal.connect(boost::bind(&TGUIManager::DeleteWidgetGroup, this, groupName));
|
||||
PerformInMainThreadAsync(boost::bind(&TGUIManager::DeleteWidgetGroup, this, groupName));
|
||||
//PostUpdateSignal.connect(boost::bind(&TGUIManager::DeleteWidgetGroup, this, groupName));
|
||||
}
|
||||
|
||||
|
||||
@ -82,8 +85,9 @@ void TGUIManager::AddWidgetTransformTask(TWidgetTransformTask widgetTransformTas
|
||||
|
||||
void TGUIManager::Update(cardinal dt)
|
||||
{
|
||||
boost::lock_guard<boost::mutex> guard(WidgetListMutex);
|
||||
|
||||
WidgetListMutex.lock();
|
||||
std::vector<std::shared_ptr<boost::signal<void (TSignalParam)>>> signalMap;
|
||||
|
||||
for (TWidgetArr::iterator i = WidgetArr.begin(); i != WidgetArr.end(); ++i)
|
||||
{
|
||||
@ -91,11 +95,16 @@ void TGUIManager::Update(cardinal dt)
|
||||
|
||||
if (i->IsMouseDown)
|
||||
{
|
||||
(*(i->SignalMap[CONST_HOLD_SIGNAL_NAME]))(TSignalParam(dt));
|
||||
|
||||
signalMap.push_back((i->SignalMap[CONST_HOLD_SIGNAL_NAME]));
|
||||
}
|
||||
}
|
||||
|
||||
//Keep this outside since signal may affect WidgetArr
|
||||
BOOST_FOREACH(auto signalPtr, signalMap)
|
||||
{
|
||||
(*signalPtr)(TSignalParam(dt));
|
||||
}
|
||||
|
||||
for (TWidgetTrasfromTaskList::iterator i = WidgetTrasfromTaskList.begin(); i != WidgetTrasfromTaskList.end(); )
|
||||
{
|
||||
int prevCurrentTime = i->CurrentTime;
|
||||
@ -150,11 +159,9 @@ void TGUIManager::Update(cardinal dt)
|
||||
}
|
||||
}
|
||||
|
||||
WidgetListMutex.unlock();
|
||||
//PostUpdateSignal();
|
||||
|
||||
PostUpdateSignal();
|
||||
|
||||
PostUpdateSignal.disconnect_all_slots();
|
||||
//PostUpdateSignal.disconnect_all_slots();
|
||||
}
|
||||
|
||||
void TGUIManager::Draw()
|
||||
@ -242,7 +249,7 @@ void TGUIManager::OnMouseDown(vec2 pos)
|
||||
{
|
||||
//Xperimental - need to call widget methods and signals NOT IN "FOR" LOOP
|
||||
|
||||
WidgetListMutex.lock();
|
||||
boost::lock_guard<boost::mutex> guard(WidgetListMutex);
|
||||
|
||||
TWidgetArr::reverse_iterator i;
|
||||
|
||||
@ -260,23 +267,23 @@ void TGUIManager::OnMouseDown(vec2 pos)
|
||||
|
||||
if (! isTransparentForInput)
|
||||
{
|
||||
WidgetListMutex.unlock();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WidgetListMutex.unlock();
|
||||
}
|
||||
|
||||
void TGUIManager::OnMouseUp(vec2 pos)
|
||||
{
|
||||
//Xperimental - need to call widget methods and signals NOT IN "FOR" LOOP
|
||||
|
||||
WidgetListMutex.lock();
|
||||
boost::lock_guard<boost::mutex> guard(WidgetListMutex);
|
||||
|
||||
TWidgetArr::reverse_iterator i;
|
||||
|
||||
std::vector<std::shared_ptr<boost::signal<void (TSignalParam)>>> signalMap;
|
||||
|
||||
for (i = WidgetArr.rbegin(); i != WidgetArr.rend(); ++i)
|
||||
{
|
||||
if (i->Widget->CheckClick(pos))
|
||||
@ -284,17 +291,23 @@ void TGUIManager::OnMouseUp(vec2 pos)
|
||||
bool isTransparentForInput = i->Widget->IsTransparentForInput();
|
||||
i->Widget->OnTapUp(pos);
|
||||
i->IsMouseDown = false;
|
||||
(*(i->SignalMap[CONST_CLICK_SIGNAL_NAME]))(TSignalParam(pos));
|
||||
|
||||
signalMap.push_back((i->SignalMap[CONST_CLICK_SIGNAL_NAME]));
|
||||
|
||||
if (! isTransparentForInput)
|
||||
{
|
||||
WidgetListMutex.unlock();
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WidgetListMutex.unlock();
|
||||
|
||||
//Keep this outside since signal may affect WidgetArr
|
||||
BOOST_FOREACH(auto signalPtr, signalMap)
|
||||
{
|
||||
(*signalPtr)(TSignalParam(pos));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void TGUIManager::OnMove(vec2 shift)
|
||||
@ -309,6 +322,8 @@ void TGUIManager::OnMove(vec2 shift)
|
||||
|
||||
TotalShift += shift;
|
||||
|
||||
std::vector<std::shared_ptr<boost::signal<void (TSignalParam)>>> signalMap;
|
||||
|
||||
for (i = WidgetArr.rbegin(); i != WidgetArr.rend(); ++i)
|
||||
{
|
||||
if (!moveIsProcessed && i->Widget->CheckClick(LastTapPos-TotalShift))
|
||||
@ -316,7 +331,8 @@ void TGUIManager::OnMove(vec2 shift)
|
||||
bool isTransparentForInput = i->Widget->IsTransparentForInput();
|
||||
|
||||
i->Widget->OnMove(shift);
|
||||
(*(i->SignalMap[CONST_DRAG_SIGNAL_NAME]))(TSignalParam(shift));
|
||||
|
||||
signalMap.push_back((i->SignalMap[CONST_DRAG_SIGNAL_NAME]));
|
||||
|
||||
if (! isTransparentForInput)
|
||||
{
|
||||
@ -325,6 +341,13 @@ void TGUIManager::OnMove(vec2 shift)
|
||||
}
|
||||
}
|
||||
|
||||
//Keep this outside since signal may affect WidgetArr
|
||||
BOOST_FOREACH(auto signalPtr, signalMap)
|
||||
{
|
||||
(*signalPtr)(TSignalParam(shift));
|
||||
}
|
||||
|
||||
|
||||
for (i = WidgetArr.rbegin(); i != WidgetArr.rend(); ++i)
|
||||
{
|
||||
if (!moveOutIsProcessed && i->Widget->CheckClick(LastTapPos) && !i->Widget->CheckClick(LastTapPos-TotalShift))
|
||||
|
Loading…
Reference in New Issue
Block a user