Refactor for documentation

This commit is contained in:
Eduardo Bart
2012-06-25 19:13:30 -03:00
parent 2c7ae6e521
commit 98a1b611bf
106 changed files with 654 additions and 780 deletions

View File

@@ -47,7 +47,7 @@ void exitSignalHandler(int sig)
case SIGINT:
if(!signaled) {
signaled = true;
g_eventDispatcher.addEvent(std::bind(&Application::close, &g_app));
g_dispatcher.addEvent(std::bind(&Application::close, &g_app));
}
break;
}
@@ -155,7 +155,7 @@ void Application::terminate()
g_lua.terminate();
// flush remaining dispatcher events
g_eventDispatcher.flush();
g_dispatcher.flush();
// terminate graphics
m_foreground = nullptr;
@@ -182,7 +182,7 @@ void Application::run()
g_clock.update();
// show the application only after we draw some frames
g_eventDispatcher.scheduleEvent([] { g_window.show(); }, 10);
g_dispatcher.scheduleEvent([] { g_window.show(); }, 10);
while(!m_stopping) {
@@ -281,7 +281,7 @@ void Application::poll()
//g_particleManager.update();
Connection::poll();
g_eventDispatcher.poll();
g_dispatcher.poll();
}
void Application::close()

View File

@@ -25,7 +25,7 @@
#include <framework/core/clock.h>
#include "timer.h"
EventDispatcher g_eventDispatcher;
EventDispatcher g_dispatcher;
void EventDispatcher::flush()

View File

@@ -26,7 +26,7 @@
#include "clock.h"
#include "scheduledevent.h"
// @bindsingleton g_eventDispatcher
// @bindsingleton g_dispatcher
class EventDispatcher
{
public:
@@ -44,6 +44,6 @@ private:
std::priority_queue<ScheduledEventPtr, std::vector<ScheduledEventPtr>, lessScheduledEvent> m_scheduledEventList;
};
extern EventDispatcher g_eventDispatcher;
extern EventDispatcher g_dispatcher;
#endif

View File

@@ -54,7 +54,7 @@ void Logger::log(Fw::LogLevel level, const std::string& message)
if(m_onLog) {
// schedule log callback, because this callback can run lua code that may affect the current state
g_eventDispatcher.addEvent([=] {
g_dispatcher.addEvent([=] {
if(m_onLog)
m_onLog(level, outmsg, now);
});

View File

@@ -42,7 +42,7 @@ AnimatedTexture::AnimatedTexture(int width, int height, int channels, int numFra
m_framesDelay[i] = framesDelay[i];
}
m_currentFrame = -1;
g_eventDispatcher.scheduleEvent(std::bind(&AnimatedTexture::processAnimation, this), 0);
g_dispatcher.scheduleEvent(std::bind(&AnimatedTexture::processAnimation, this), 0);
}
AnimatedTexture::~AnimatedTexture()
@@ -71,6 +71,6 @@ void AnimatedTexture::processAnimation()
// continue to animate only if something still referencing this texture
if(self.use_count() > 1)
g_eventDispatcher.scheduleEvent(std::bind(&AnimatedTexture::processAnimation, self), m_framesDelay[m_currentFrame]);
g_dispatcher.scheduleEvent(std::bind(&AnimatedTexture::processAnimation, self), m_framesDelay[m_currentFrame]);
}
*/

View File

@@ -594,7 +594,8 @@ void Application::registerLuaFunctions()
g_lua.bindSingletonFunction("g_ui", "getStyle", &UIManager::getStyle, &g_ui);
g_lua.bindSingletonFunction("g_ui", "getStyleClass", &UIManager::getStyleClass, &g_ui);
g_lua.bindSingletonFunction("g_ui", "loadUI", &UIManager::loadUI, &g_ui);
g_lua.bindSingletonFunction("g_ui", "createWidgetFromStyle", &UIManager::createWidgetFromStyle, &g_ui);
g_lua.bindSingletonFunction("g_ui", "displayUI", &UIManager::displayUI, &g_ui);
g_lua.bindSingletonFunction("g_ui", "createWidget", &UIManager::createWidget, &g_ui);
g_lua.bindSingletonFunction("g_ui", "createWidgetFromOTML", &UIManager::createWidgetFromOTML, &g_ui);
g_lua.bindSingletonFunction("g_ui", "getRootWidget", &UIManager::getRootWidget, &g_ui);
g_lua.bindSingletonFunction("g_ui", "getDraggingWidget", &UIManager::getDraggingWidget, &g_ui);
@@ -634,10 +635,10 @@ void Application::registerLuaFunctions()
g_lua.bindSingletonFunction("g_sounds", "getCurrentMusic", &SoundManager::getCurrentMusic, &g_sounds);
// EventDispatcher
g_lua.registerSingletonClass("g_eventDispatcher");
g_lua.bindSingletonFunction("g_eventDispatcher", "addEvent", &EventDispatcher::addEvent, &g_eventDispatcher);
g_lua.bindSingletonFunction("g_eventDispatcher", "scheduleEvent", &EventDispatcher::scheduleEvent, &g_eventDispatcher);
g_lua.bindSingletonFunction("g_eventDispatcher", "cycleEvent", &EventDispatcher::cycleEvent, &g_eventDispatcher);
g_lua.registerSingletonClass("g_dispatcher");
g_lua.bindSingletonFunction("g_dispatcher", "addEvent", &EventDispatcher::addEvent, &g_dispatcher);
g_lua.bindSingletonFunction("g_dispatcher", "scheduleEvent", &EventDispatcher::scheduleEvent, &g_dispatcher);
g_lua.bindSingletonFunction("g_dispatcher", "cycleEvent", &EventDispatcher::cycleEvent, &g_dispatcher);
// ResourceManager
g_lua.registerSingletonClass("g_resources");

View File

@@ -96,8 +96,12 @@ namespace luabinder
LuaCppFunction bind_fun_specializer(const F& f) {
enum { N = std::tuple_size<Tuple>::value };
return [=](LuaInterface* lua) -> int {
if(lua->stackSize() != N)
throw LuaBadNumberOfArgumentsException(N, lua->stackSize());
while(lua->stackSize() != N) {
if(lua->stackSize() < N)
g_lua.pushNil();
else
g_lua.pop();
}
Tuple tuple;
pack_values_into_tuple<N>::call(tuple, lua);
return expand_fun_arguments<N,Ret>::call(tuple, f, lua);

View File

@@ -127,7 +127,7 @@ void Connection::write(uint8* buffer, uint16 size)
auto weakSelf = ConnectionWeakPtr(shared_from_this());
// wait 1 ms to do the real send
m_sendEvent = g_eventDispatcher.scheduleEvent([=] {
m_sendEvent = g_dispatcher.scheduleEvent([=] {
if(!weakSelf.lock())
return;
//m_writeTimer.cancel();

View File

@@ -119,7 +119,7 @@ bool UIGridLayout::internalUpdate()
if(m_fitChildren && preferredHeight != parentWidget->getHeight()) {
// must set the preferred height later
g_eventDispatcher.addEvent([=] {
g_dispatcher.addEvent([=] {
parentWidget->setHeight(preferredHeight);
});
}

View File

@@ -85,7 +85,7 @@ bool UIHorizontalLayout::internalUpdate()
if(m_fitChildren && preferredWidth != parentWidget->getWidth()) {
// must set the preferred width later
g_eventDispatcher.addEvent([=] {
g_dispatcher.addEvent([=] {
parentWidget->setWidth(preferredWidth);
});
}

View File

@@ -65,7 +65,7 @@ void UILayout::updateLater()
return;
auto self = asUILayout();
g_eventDispatcher.addEvent([self] {
g_dispatcher.addEvent([self] {
self->m_updateScheduled = false;
self->update();
});

View File

@@ -214,7 +214,7 @@ void UIManager::updateHoveredWidget()
if(m_hoverUpdateScheduled)
return;
g_eventDispatcher.addEvent([this] {
g_dispatcher.addEvent([this] {
if(!m_rootWidget)
return;
@@ -278,11 +278,11 @@ void UIManager::onWidgetDestroy(const UIWidgetPtr& widget)
if(m_checkEvent && !m_checkEvent->isExecuted())
return;
m_checkEvent = g_eventDispatcher.scheduleEvent([this] {
m_checkEvent = g_dispatcher.scheduleEvent([this] {
g_lua.collectGarbage();
UIWidgetList backupList = m_destroyedWidgets;
m_destroyedWidgets.clear();
g_eventDispatcher.scheduleEvent([backupList] {
g_dispatcher.scheduleEvent([backupList] {
g_lua.collectGarbage();
for(const UIWidgetPtr& widget : backupList) {
if(widget->getUseCount() != 1)
@@ -404,7 +404,7 @@ UIWidgetPtr UIManager::loadUI(const std::string& file, const UIWidgetPtr& parent
}
}
UIWidgetPtr UIManager::createWidgetFromStyle(const std::string& styleName, const UIWidgetPtr& parent)
UIWidgetPtr UIManager::createWidget(const std::string& styleName, const UIWidgetPtr& parent)
{
OTMLNodePtr node = OTMLNode::create(styleName);
try {

View File

@@ -49,7 +49,8 @@ public:
std::string getStyleClass(const std::string& styleName);
UIWidgetPtr loadUI(const std::string& file, const UIWidgetPtr& parent);
UIWidgetPtr createWidgetFromStyle(const std::string& styleName, const UIWidgetPtr& parent);
UIWidgetPtr displayUI(const std::string& file) { return loadUI(file, m_rootWidget); }
UIWidgetPtr createWidget(const std::string& styleName, const UIWidgetPtr& parent);
UIWidgetPtr createWidgetFromOTML(const OTMLNodePtr& widgetNode, const UIWidgetPtr& parent);
void setMouseReceiver(const UIWidgetPtr& widget) { m_mouseReceiver = widget; }

View File

@@ -86,7 +86,7 @@ bool UIVerticalLayout::internalUpdate()
if(m_fitChildren && preferredHeight != parentWidget->getHeight()) {
// must set the preferred width later
g_eventDispatcher.addEvent([=] {
g_dispatcher.addEvent([=] {
parentWidget->setHeight(preferredHeight);
});
}

View File

@@ -505,7 +505,7 @@ void UIWidget::applyStyle(const OTMLNodePtr& styleNode)
if(m_firstOnStyle) {
auto self = asUIWidget();
g_eventDispatcher.addEvent([self] {
g_dispatcher.addEvent([self] {
self->callLuaField("onSetup");
});
// always focus new child
@@ -832,7 +832,7 @@ bool UIWidget::setRect(const Rect& rect)
// avoid massive update events
if(!m_updateEventScheduled) {
UIWidgetPtr self = asUIWidget();
g_eventDispatcher.addEvent([self, oldRect]() {
g_dispatcher.addEvent([self, oldRect]() {
self->m_updateEventScheduled = false;
if(oldRect != self->getRect())
self->onGeometryChange(oldRect, self->getRect());
@@ -1318,7 +1318,7 @@ void UIWidget::updateStyle()
if(m_loadingStyle && !m_updateStyleScheduled) {
UIWidgetPtr self = asUIWidget();
g_eventDispatcher.addEvent([self] {
g_dispatcher.addEvent([self] {
self->m_updateStyleScheduled = false;
self->updateStyle();
});