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