diff --git a/doomsday/client/src/ui/clientwindow.cpp b/doomsday/client/src/ui/clientwindow.cpp index 5c859a4000..3ce760b67e 100644 --- a/doomsday/client/src/ui/clientwindow.cpp +++ b/doomsday/client/src/ui/clientwindow.cpp @@ -130,7 +130,7 @@ DENG2_PIMPL(ClientWindow) App::app().audienceForStartupComplete() += this; // Listen to input. - self.canvas().audienceForMouseStateChange += this; + self.canvas().audienceForMouseStateChange() += this; } ~Instance() @@ -138,8 +138,8 @@ DENG2_PIMPL(ClientWindow) App::app().audienceForGameChange() -= this; App::app().audienceForStartupComplete() -= this; - self.canvas().audienceForFocusChange -= this; - self.canvas().audienceForMouseStateChange -= this; + self.canvas().audienceForFocusChange() -= this; + self.canvas().audienceForMouseStateChange() -= this; releaseRef(cursorX); releaseRef(cursorY); @@ -341,7 +341,7 @@ DENG2_PIMPL(ClientWindow) } */ - self.canvas().audienceForFocusChange += this; + self.canvas().audienceForFocusChange() += this; #ifdef WIN32 if(self.isFullScreen()) @@ -651,8 +651,8 @@ ClientWindow::ClientWindow(String const &id) : BaseWindow(id) , d(new Instance(this)) { - canvas().audienceForGLResize += this; - canvas().audienceForGLInit += this; + canvas().audienceForGLResize() += this; + canvas().audienceForGLInit() += this; #ifdef WIN32 // Set an icon for the window. diff --git a/doomsday/client/src/ui/dialogs/videosettingsdialog.cpp b/doomsday/client/src/ui/dialogs/videosettingsdialog.cpp index da370bef0c..d3ece3ddfe 100644 --- a/doomsday/client/src/ui/dialogs/videosettingsdialog.cpp +++ b/doomsday/client/src/ui/dialogs/videosettingsdialog.cpp @@ -70,12 +70,12 @@ DENG2_OBSERVES(PersistentCanvasWindow, AttributeChange) #ifdef USE_COLOR_DEPTH_CHOICE area.add(depths = new ChoiceWidget); #endif - win.audienceForAttributeChange += this; + win.audienceForAttributeChange() += this; } ~Instance() { - win.audienceForAttributeChange -= this; + win.audienceForAttributeChange() -= this; } /** diff --git a/doomsday/libappfw/include/de/framework/guiwidgetprivate.h b/doomsday/libappfw/include/de/framework/guiwidgetprivate.h index 8ed31c717a..00ca9de28a 100644 --- a/doomsday/libappfw/include/de/framework/guiwidgetprivate.h +++ b/doomsday/libappfw/include/de/framework/guiwidgetprivate.h @@ -60,7 +60,7 @@ class GuiWidgetPrivate : public Private, { if(_observingAtlas) { - _observingAtlas->audienceForReposition -= this; + _observingAtlas->audienceForReposition() -= this; } /** @@ -80,7 +80,7 @@ class GuiWidgetPrivate : public Private, { // Automatically start observing the root atlas. _observingAtlas = &root().atlas(); - _observingAtlas->audienceForReposition += this; + _observingAtlas->audienceForReposition() += this; } } diff --git a/doomsday/libappfw/src/basewindow.cpp b/doomsday/libappfw/src/basewindow.cpp index 8831eae76f..d85f7554bb 100644 --- a/doomsday/libappfw/src/basewindow.cpp +++ b/doomsday/libappfw/src/basewindow.cpp @@ -37,14 +37,14 @@ DENG2_PIMPL(BaseWindow) , xf(&defaultXf) { // Listen to input. - self.canvas().audienceForKeyEvent += this; - self.canvas().audienceForMouseEvent += this; + self.canvas().audienceForKeyEvent() += this; + self.canvas().audienceForMouseEvent() += this; } ~Instance() { - self.canvas().audienceForKeyEvent -= this; - self.canvas().audienceForMouseEvent -= this; + self.canvas().audienceForKeyEvent() -= this; + self.canvas().audienceForMouseEvent() -= this; } void keyEvent(KeyEvent const &ev) diff --git a/doomsday/libappfw/src/widgets/documentwidget.cpp b/doomsday/libappfw/src/widgets/documentwidget.cpp index 1fb98813b3..df33af3204 100644 --- a/doomsday/libappfw/src/widgets/documentwidget.cpp +++ b/doomsday/libappfw/src/widgets/documentwidget.cpp @@ -125,7 +125,7 @@ public Font::RichFormat::IStyle void glInit() { - atlas().audienceForReposition += this; + atlas().audienceForReposition() += this; glText.init(atlas(), self.font(), this); @@ -145,7 +145,7 @@ public Font::RichFormat::IStyle void glDeinit() { - atlas().audienceForReposition -= this; + atlas().audienceForReposition() -= this; glText.deinit(); drawable.clear(); } diff --git a/doomsday/libappfw/src/widgets/logwidget.cpp b/doomsday/libappfw/src/widgets/logwidget.cpp index 11425e6998..49ea394bdc 100644 --- a/doomsday/libappfw/src/widgets/logwidget.cpp +++ b/doomsday/libappfw/src/widgets/logwidget.cpp @@ -463,8 +463,8 @@ public Font::RichFormat::IStyle Atlas::BackingStore | Atlas::AllowDefragment, GLTexture::maximumSize().min(Atlas::Size(4096, 2048))); - entryAtlas->audienceForReposition += this; - entryAtlas->audienceForOutOfSpace += this; + entryAtlas->audienceForReposition() += this; + entryAtlas->audienceForOutOfSpace() += this; // Simple texture for the scroll indicator. Image solidWhitePixel = Image::solidColor(Image::Color(255, 255, 255, 255), diff --git a/doomsday/libdeng2/include/de/data/observers.h b/doomsday/libdeng2/include/de/data/observers.h index 9c06c404da..a0a6bd294c 100644 --- a/doomsday/libdeng2/include/de/data/observers.h +++ b/doomsday/libdeng2/include/de/data/observers.h @@ -141,7 +141,7 @@ DENG2_FOR_EACH_OBSERVER(Name##Audience, Var, self.audienceFor##Name) #define DENG2_FOR_PUBLIC_AUDIENCE2(Name, Var) \ - DENG2_FOR_EACH_OBSERVER(Name##Audience, Var, audienceFor##Name) + DENG2_FOR_EACH_OBSERVER(Name##Audience, Var, self.audienceFor##Name()) namespace de { diff --git a/doomsday/libgui/include/de/gui/atlas.h b/doomsday/libgui/include/de/gui/atlas.h index 42705e9715..473a09138c 100644 --- a/doomsday/libgui/include/de/gui/atlas.h +++ b/doomsday/libgui/include/de/gui/atlas.h @@ -109,13 +109,13 @@ class LIBGUI_PUBLIC Atlas : public Lockable * repositioned for some reasons (e.g., defragmentation). Normally once * allocated, content will remain at its initial place. */ - DENG2_DEFINE_AUDIENCE(Reposition, void atlasContentRepositioned(Atlas &)) + DENG2_DEFINE_AUDIENCE2(Reposition, void atlasContentRepositioned(Atlas &)) /** * Audience that will be notified when an allocation fails due to the atlas * being so full that there is no room for the new image. */ - DENG2_DEFINE_AUDIENCE(OutOfSpace, void atlasOutOfSpace(Atlas &)) + DENG2_DEFINE_AUDIENCE2(OutOfSpace, void atlasOutOfSpace(Atlas &)) public: /** diff --git a/doomsday/libgui/include/de/gui/canvas.h b/doomsday/libgui/include/de/gui/canvas.h index df88bf08fc..480b8da46c 100644 --- a/doomsday/libgui/include/de/gui/canvas.h +++ b/doomsday/libgui/include/de/gui/canvas.h @@ -57,29 +57,29 @@ class LIBGUI_PUBLIC Canvas : public QGLWidget, public KeyEventSource, public Mou * screen. Note that the notification comes straight from the event loop * (timer signal) instead of during a paint event. */ - DENG2_DEFINE_AUDIENCE(GLReady, void canvasGLReady(Canvas &)) + DENG2_DEFINE_AUDIENCE2(GLReady, void canvasGLReady(Canvas &)) /** * Notified when the canvas's GL state needs to be initialized. This is * called immediately before drawing the contents of the canvas for the * first time (during a paint event). */ - DENG2_DEFINE_AUDIENCE(GLInit, void canvasGLInit(Canvas &)) + DENG2_DEFINE_AUDIENCE2(GLInit, void canvasGLInit(Canvas &)) /** * Notified when a canvas's size has changed. */ - DENG2_DEFINE_AUDIENCE(GLResize, void canvasGLResized(Canvas &)) + DENG2_DEFINE_AUDIENCE2(GLResize, void canvasGLResized(Canvas &)) /** * Notified when drawing of the canvas contents has been requested. */ - DENG2_DEFINE_AUDIENCE(GLDraw, void canvasGLDraw(Canvas &)) + DENG2_DEFINE_AUDIENCE2(GLDraw, void canvasGLDraw(Canvas &)) /** * Notified when the canvas gains or loses input focus. */ - DENG2_DEFINE_AUDIENCE(FocusChange, void canvasFocusChanged(Canvas &, bool hasFocus)) + DENG2_DEFINE_AUDIENCE2(FocusChange, void canvasFocusChanged(Canvas &, bool hasFocus)) public: explicit Canvas(CanvasWindow *parent, QGLWidget* shared = 0); diff --git a/doomsday/libgui/include/de/gui/gluniform.h b/doomsday/libgui/include/de/gui/gluniform.h index 066db6c79d..d126ec3a4c 100644 --- a/doomsday/libgui/include/de/gui/gluniform.h +++ b/doomsday/libgui/include/de/gui/gluniform.h @@ -67,12 +67,12 @@ class LIBGUI_PUBLIC GLUniform /** * Notified when the value of the uniform changes. */ - DENG2_DEFINE_AUDIENCE(ValueChange, void uniformValueChanged(GLUniform &)) + DENG2_DEFINE_AUDIENCE2(ValueChange, void uniformValueChanged(GLUniform &)) /** * Notified when the uniform instance is deleted. */ - DENG2_DEFINE_AUDIENCE(Deletion, void uniformDeleted(GLUniform &)) + DENG2_DEFINE_AUDIENCE2(Deletion, void uniformDeleted(GLUniform &)) public: GLUniform(char const *nameInShader, Type uniformType); diff --git a/doomsday/libgui/include/de/gui/guiapp.h b/doomsday/libgui/include/de/gui/guiapp.h index 8e7813010f..8e6ea2a15e 100644 --- a/doomsday/libgui/include/de/gui/guiapp.h +++ b/doomsday/libgui/include/de/gui/guiapp.h @@ -48,7 +48,7 @@ class LIBGUI_PUBLIC GuiApp : public QApplication, public App, /** * Notified when a Canvas is recreated. */ - DENG2_DEFINE_AUDIENCE(GLContextChange, void appGLContextChanged()) + DENG2_DEFINE_AUDIENCE2(GLContextChange, void appGLContextChanged()) public: GuiApp(int &argc, char **argv); diff --git a/doomsday/libgui/include/de/gui/keyeventsource.h b/doomsday/libgui/include/de/gui/keyeventsource.h index 49d5fc9671..eb0fa89bf3 100644 --- a/doomsday/libgui/include/de/gui/keyeventsource.h +++ b/doomsday/libgui/include/de/gui/keyeventsource.h @@ -32,10 +32,14 @@ namespace de { class LIBGUI_PUBLIC KeyEventSource { public: - DENG2_DEFINE_AUDIENCE(KeyEvent, void keyEvent(KeyEvent const &)) + DENG2_DEFINE_AUDIENCE2(KeyEvent, void keyEvent(KeyEvent const &)) public: + KeyEventSource(); virtual ~KeyEventSource() {} + +private: + DENG2_PRIVATE(d) }; } // namespace de diff --git a/doomsday/libgui/include/de/gui/mouseeventsource.h b/doomsday/libgui/include/de/gui/mouseeventsource.h index b6ea7e773a..f23d93a2ad 100644 --- a/doomsday/libgui/include/de/gui/mouseeventsource.h +++ b/doomsday/libgui/include/de/gui/mouseeventsource.h @@ -38,12 +38,15 @@ class LIBGUI_PUBLIC MouseEventSource Trapped }; - DENG2_DEFINE_AUDIENCE(MouseStateChange, void mouseStateChanged(State)) - - DENG2_DEFINE_AUDIENCE(MouseEvent, void mouseEvent(MouseEvent const &)) + DENG2_DEFINE_AUDIENCE2(MouseStateChange, void mouseStateChanged(State)) + DENG2_DEFINE_AUDIENCE2(MouseEvent, void mouseEvent(MouseEvent const &)) public: + MouseEventSource(); virtual ~MouseEventSource() {} + +private: + DENG2_PRIVATE(d) }; } // namespace de diff --git a/doomsday/libgui/include/de/gui/persistentcanvaswindow.h b/doomsday/libgui/include/de/gui/persistentcanvaswindow.h index a7c2e91dbd..717095b90d 100644 --- a/doomsday/libgui/include/de/gui/persistentcanvaswindow.h +++ b/doomsday/libgui/include/de/gui/persistentcanvaswindow.h @@ -78,7 +78,7 @@ class LIBGUI_PUBLIC PersistentCanvasWindow : public CanvasWindow * changes are queued, the notification is made only after all the changes * have been applied. */ - DENG2_DEFINE_AUDIENCE(AttributeChange, void windowAttributesChanged(PersistentCanvasWindow &)) + DENG2_DEFINE_AUDIENCE2(AttributeChange, void windowAttributesChanged(PersistentCanvasWindow &)) public: /** diff --git a/doomsday/libgui/libgui.pro b/doomsday/libgui/libgui.pro index 0b37defaf3..bc9bd3c494 100644 --- a/doomsday/libgui/libgui.pro +++ b/doomsday/libgui/libgui.pro @@ -150,7 +150,9 @@ SOURCES += \ src/imagebank.cpp \ src/kdtreeatlasallocator.cpp \ src/keyevent.cpp \ + src/keyeventsource.cpp \ src/mouseevent.cpp \ + src/mouseeventsource.cpp \ src/nativefont.cpp \ src/qtnativefont.h \ src/persistentcanvaswindow.cpp \ diff --git a/doomsday/libgui/src/atlas.cpp b/doomsday/libgui/src/atlas.cpp index fc53624cea..66ee4af311 100644 --- a/doomsday/libgui/src/atlas.cpp +++ b/doomsday/libgui/src/atlas.cpp @@ -139,13 +139,19 @@ DENG2_PIMPL(Atlas) markFullyChanged(); mayDefrag = false; - DENG2_FOR_PUBLIC_AUDIENCE(Reposition, i) + DENG2_FOR_PUBLIC_AUDIENCE2(Reposition, i) { i->atlasContentRepositioned(self); } } + + DENG2_PIMPL_AUDIENCE(Reposition) + DENG2_PIMPL_AUDIENCE(OutOfSpace) }; +DENG2_AUDIENCE_METHOD(Atlas, Reposition) +DENG2_AUDIENCE_METHOD(Atlas, OutOfSpace) + Atlas::Atlas(Flags const &flags, Size const &totalSize) : d(new Instance(this, flags, totalSize)) {} @@ -252,7 +258,7 @@ Id Atlas::alloc(Image const &image) { LOG_GL_XVERBOSE("Atlas is full with %.1f%% usage") << d->usedPercentage()*100; - DENG2_FOR_AUDIENCE(OutOfSpace, i) + DENG2_FOR_AUDIENCE2(OutOfSpace, i) { i->atlasOutOfSpace(*this); } diff --git a/doomsday/libgui/src/canvas.cpp b/doomsday/libgui/src/canvas.cpp index 662cf79795..16d3f4840c 100644 --- a/doomsday/libgui/src/canvas.cpp +++ b/doomsday/libgui/src/canvas.cpp @@ -101,7 +101,7 @@ DENG2_PIMPL(Canvas) mouseGrabbed = true; - DENG2_FOR_PUBLIC_AUDIENCE(MouseStateChange, i) + DENG2_FOR_PUBLIC_AUDIENCE2(MouseStateChange, i) { i->mouseStateChanged(Trapped); } @@ -119,7 +119,7 @@ DENG2_PIMPL(Canvas) // Tell the mouse driver that the mouse is untrapped. mouseGrabbed = false; - DENG2_FOR_PUBLIC_AUDIENCE(MouseStateChange, i) + DENG2_FOR_PUBLIC_AUDIENCE2(MouseStateChange, i) { i->mouseStateChanged(Untrapped); } @@ -171,7 +171,7 @@ DENG2_PIMPL(Canvas) } #endif - DENG2_FOR_PUBLIC_AUDIENCE(KeyEvent, i) + DENG2_FOR_PUBLIC_AUDIENCE2(KeyEvent, i) { i->keyEvent(KeyEvent(ev->isAutoRepeat()? KeyEvent::Repeat : ev->type() == QEvent::KeyPress? KeyEvent::Pressed : @@ -215,8 +215,20 @@ DENG2_PIMPL(Canvas) /// @todo Double buffering is not really needed in manual FB mode. framebuf.swapBuffers(self, mode); } + + DENG2_PIMPL_AUDIENCE(GLReady) + DENG2_PIMPL_AUDIENCE(GLInit) + DENG2_PIMPL_AUDIENCE(GLResize) + DENG2_PIMPL_AUDIENCE(GLDraw) + DENG2_PIMPL_AUDIENCE(FocusChange) }; +DENG2_AUDIENCE_METHOD(Canvas, GLReady) +DENG2_AUDIENCE_METHOD(Canvas, GLInit) +DENG2_AUDIENCE_METHOD(Canvas, GLResize) +DENG2_AUDIENCE_METHOD(Canvas, GLDraw) +DENG2_AUDIENCE_METHOD(Canvas, FocusChange) + Canvas::Canvas(CanvasWindow* parent, QGLWidget* shared) : QGLWidget(parent, shared), d(new Instance(this, parent)) { @@ -299,16 +311,16 @@ bool Canvas::isGLReady() const void Canvas::copyAudiencesFrom(Canvas const &other) { - audienceForGLReady = other.audienceForGLReady; - audienceForGLInit = other.audienceForGLInit; - audienceForGLResize = other.audienceForGLResize; - audienceForGLDraw = other.audienceForGLDraw; - audienceForFocusChange = other.audienceForFocusChange; + d->audienceForGLReady = other.d->audienceForGLReady; + d->audienceForGLInit = other.d->audienceForGLInit; + d->audienceForGLResize = other.d->audienceForGLResize; + d->audienceForGLDraw = other.d->audienceForGLDraw; + d->audienceForFocusChange = other.d->audienceForFocusChange; - audienceForKeyEvent = other.audienceForKeyEvent; + audienceForKeyEvent() = other.audienceForKeyEvent(); - audienceForMouseStateChange = other.audienceForMouseStateChange; - audienceForMouseEvent = other.audienceForMouseEvent; + audienceForMouseStateChange() = other.audienceForMouseStateChange(); + audienceForMouseEvent() = other.audienceForMouseEvent(); } GLTarget &Canvas::renderTarget() const @@ -336,7 +348,7 @@ void Canvas::initializeGL() #endif GLInfo::glInit(); - DENG2_FOR_AUDIENCE(GLInit, i) i->canvasGLInit(*this); + DENG2_FOR_AUDIENCE2(GLInit, i) i->canvasGLInit(*this); } void Canvas::resizeGL(int w, int h) @@ -372,7 +384,7 @@ void Canvas::updateSize() d->currentSize = d->pendingSize; d->reconfigureFramebuffer(); - DENG2_FOR_AUDIENCE(GLResize, i) i->canvasGLResized(*this); + DENG2_FOR_AUDIENCE2(GLResize, i) i->canvasGLResized(*this); } void Canvas::showEvent(QShowEvent* ev) @@ -424,7 +436,7 @@ void Canvas::notifyReady() LOG_GL_WARNING("OpenGL 2.0 is not supported!"); LOGDEV_GL_XVERBOSE("Notifying GL ready"); - DENG2_FOR_AUDIENCE(GLReady, i) i->canvasGLReady(*this); + DENG2_FOR_AUDIENCE2(GLReady, i) i->canvasGLReady(*this); // This Canvas instance might have been destroyed now. } @@ -446,7 +458,7 @@ void Canvas::paintGL() // Make sure any changes to the state stack become effective. GLState::current().apply(); - DENG2_FOR_AUDIENCE(GLDraw, i) i->canvasGLDraw(*this); + DENG2_FOR_AUDIENCE2(GLDraw, i) i->canvasGLDraw(*this); LIBGUI_ASSERT_GL_OK(); } @@ -456,7 +468,7 @@ void Canvas::focusInEvent(QFocusEvent*) LOG_AS("Canvas"); LOG_INPUT_VERBOSE("Gained focus"); - DENG2_FOR_AUDIENCE(FocusChange, i) i->canvasFocusChanged(*this, true); + DENG2_FOR_AUDIENCE2(FocusChange, i) i->canvasFocusChanged(*this, true); } void Canvas::focusOutEvent(QFocusEvent*) @@ -467,7 +479,7 @@ void Canvas::focusOutEvent(QFocusEvent*) // Automatically ungrab the mouse if focus is lost. d->ungrabMouse(); - DENG2_FOR_AUDIENCE(FocusChange, i) i->canvasFocusChanged(*this, false); + DENG2_FOR_AUDIENCE2(FocusChange, i) i->canvasFocusChanged(*this, false); } void Canvas::keyPressEvent(QKeyEvent *ev) @@ -507,7 +519,7 @@ void Canvas::mousePressEvent(QMouseEvent *ev) ev->accept(); - DENG2_FOR_AUDIENCE(MouseEvent, i) + DENG2_FOR_AUDIENCE2(MouseEvent, i) { i->mouseEvent(MouseEvent(translateButton(ev->button()), MouseEvent::Pressed, Vector2i(ev->pos().x(), ev->pos().y()))); @@ -524,7 +536,7 @@ void Canvas::mouseReleaseEvent(QMouseEvent* ev) ev->accept(); - DENG2_FOR_AUDIENCE(MouseEvent, i) + DENG2_FOR_AUDIENCE2(MouseEvent, i) { i->mouseEvent(MouseEvent(translateButton(ev->button()), MouseEvent::Released, Vector2i(ev->pos().x(), ev->pos().y()))); @@ -538,7 +550,7 @@ void Canvas::mouseMoveEvent(QMouseEvent *ev) // Absolute events are only emitted when the mouse is untrapped. if(!d->mouseGrabbed) { - DENG2_FOR_AUDIENCE(MouseEvent, i) + DENG2_FOR_AUDIENCE2(MouseEvent, i) { i->mouseEvent(MouseEvent(MouseEvent::Absolute, Vector2i(ev->pos().x(), ev->pos().y()))); @@ -559,7 +571,7 @@ void Canvas::wheelEvent(QWheelEvent *ev) int axis = (ev->orientation() == Qt::Horizontal? 0 : 1); int dir = (ev->delta() < 0? -1 : 1); - DENG2_FOR_AUDIENCE(MouseEvent, i) + DENG2_FOR_AUDIENCE2(MouseEvent, i) { i->mouseEvent(MouseEvent(MouseEvent::FineAngle, axis == 0? Vector2i(ev->delta(), 0) : @@ -571,7 +583,7 @@ void Canvas::wheelEvent(QWheelEvent *ev) { d->wheelDir[axis] = dir; - DENG2_FOR_AUDIENCE(MouseEvent, i) + DENG2_FOR_AUDIENCE2(MouseEvent, i) { i->mouseEvent(MouseEvent(MouseEvent::Step, axis == 0? Vector2i(dir, 0) : diff --git a/doomsday/libgui/src/canvaswindow.cpp b/doomsday/libgui/src/canvaswindow.cpp index c4a08f9a2e..1a8a498c03 100644 --- a/doomsday/libgui/src/canvaswindow.cpp +++ b/doomsday/libgui/src/canvaswindow.cpp @@ -105,7 +105,7 @@ DENG2_PIMPL(CanvasWindow) canvas->makeCurrent(); LIBGUI_ASSERT_GL_OK(); - DENG2_FOR_EACH_OBSERVER(Canvas::GLInitAudience, i, canvas->audienceForGLInit) + DENG2_FOR_EACH_OBSERVER(Canvas::GLInitAudience, i, canvas->audienceForGLInit()) { i->canvasGLInit(*canvas); } @@ -127,7 +127,7 @@ DENG2_PIMPL(CanvasWindow) } // Restore the old focus change audience. - canvas->audienceForFocusChange = canvasFocusAudience; + canvas->audienceForFocusChange() = canvasFocusAudience; LOGDEV_GL_MSG("Canvas replaced with %p") << de::dintptr(canvas); } @@ -139,8 +139,8 @@ CanvasWindow::CanvasWindow() // Create the drawing canvas for this window. setCentralWidget(d->canvas = new Canvas(this)); // takes ownership - d->canvas->audienceForGLReady += this; - d->canvas->audienceForGLDraw += this; + d->canvas->audienceForGLReady() += this; + d->canvas->audienceForGLDraw() += this; // All input goes to the canvas. d->canvas->setFocus(); @@ -166,8 +166,8 @@ void CanvasWindow::recreateCanvas() // Steal the focus change audience temporarily so no spurious focus // notifications are sent. - d->canvasFocusAudience = canvas().audienceForFocusChange; - canvas().audienceForFocusChange.clear(); + d->canvasFocusAudience = canvas().audienceForFocusChange(); + canvas().audienceForFocusChange().clear(); // We'll re-trap the mouse after the new canvas is ready. d->mouseWasTrapped = canvas().isMouseTrapped(); @@ -178,7 +178,7 @@ void CanvasWindow::recreateCanvas() // Create the replacement Canvas. Once it's created and visible, we'll // finish the switch-over. d->recreated = new Canvas(this, d->canvas); - d->recreated->audienceForGLReady += this; + d->recreated->audienceForGLReady() += this; //d->recreated->setGeometry(d->canvas->geometry()); d->recreated->show(); diff --git a/doomsday/libgui/src/glprogram.cpp b/doomsday/libgui/src/glprogram.cpp index b4d736a903..69b64f067e 100644 --- a/doomsday/libgui/src/glprogram.cpp +++ b/doomsday/libgui/src/glprogram.cpp @@ -140,8 +140,8 @@ DENG2_PIMPL(GLProgram) { foreach(GLUniform const *u, bound) { - u->audienceForValueChange -= this; - u->audienceForDeletion -= this; + u->audienceForValueChange() -= this; + u->audienceForDeletion() -= this; } texturesChanged = false; bound.clear(); @@ -351,8 +351,8 @@ GLProgram &GLProgram::bind(GLUniform const &uniform) d->bound.insert(&uniform); d->changed.insert(&uniform); - uniform.audienceForValueChange += d; - uniform.audienceForDeletion += d; + uniform.audienceForValueChange() += d; + uniform.audienceForDeletion() += d; if(uniform.type() == GLUniform::Sampler2D) { @@ -370,8 +370,8 @@ GLProgram &GLProgram::unbind(GLUniform const &uniform) d->bound.remove(&uniform); d->changed.remove(&uniform); - uniform.audienceForValueChange -= d.get(); - uniform.audienceForDeletion -= d.get(); + uniform.audienceForValueChange() -= d.get(); + uniform.audienceForDeletion() -= d.get(); if(uniform.type() == GLUniform::Sampler2D) { diff --git a/doomsday/libgui/src/gluniform.cpp b/doomsday/libgui/src/gluniform.cpp index d14f62a297..a0b90e437a 100644 --- a/doomsday/libgui/src/gluniform.cpp +++ b/doomsday/libgui/src/gluniform.cpp @@ -71,7 +71,7 @@ DENG2_PIMPL(GLUniform) ~Instance() { - DENG2_FOR_PUBLIC_AUDIENCE(Deletion, i) i->uniformDeleted(self); + DENG2_FOR_PUBLIC_AUDIENCE2(Deletion, i) i->uniformDeleted(self); switch(type) { @@ -141,7 +141,7 @@ DENG2_PIMPL(GLUniform) void markAsChanged() { - DENG2_FOR_PUBLIC_AUDIENCE(ValueChange, i) + DENG2_FOR_PUBLIC_AUDIENCE2(ValueChange, i) { i->uniformValueChanged(self); } @@ -158,8 +158,14 @@ DENG2_PIMPL(GLUniform) } } } + + DENG2_PIMPL_AUDIENCE(Deletion) + DENG2_PIMPL_AUDIENCE(ValueChange) }; +DENG2_AUDIENCE_METHOD(GLUniform, Deletion) +DENG2_AUDIENCE_METHOD(GLUniform, ValueChange) + GLUniform::GLUniform(char const *nameInShader, Type uniformType) : d(new Instance(this, QLatin1String(nameInShader), uniformType)) {} diff --git a/doomsday/libgui/src/guiapp.cpp b/doomsday/libgui/src/guiapp.cpp index 160628a373..6353c38b33 100644 --- a/doomsday/libgui/src/guiapp.cpp +++ b/doomsday/libgui/src/guiapp.cpp @@ -36,8 +36,12 @@ DENG2_PIMPL(GuiApp) { loop.audienceForIteration() += self; } + + DENG2_PIMPL_AUDIENCE(GLContextChange) }; +DENG2_AUDIENCE_METHOD(GuiApp, GLContextChange) + GuiApp::GuiApp(int &argc, char **argv) : QApplication(argc, argv), App(applicationFilePath(), arguments()), @@ -80,8 +84,8 @@ void GuiApp::notifyDisplayModeChanged() void GuiApp::notifyGLContextChanged() { - qDebug() << "notifying GL context change" << audienceForGLContextChange.size(); - DENG2_FOR_AUDIENCE(GLContextChange, i) i->appGLContextChanged(); + qDebug() << "notifying GL context change" << audienceForGLContextChange().size(); + DENG2_FOR_AUDIENCE2(GLContextChange, i) i->appGLContextChanged(); } int GuiApp::execLoop() diff --git a/doomsday/libgui/src/keyeventsource.cpp b/doomsday/libgui/src/keyeventsource.cpp new file mode 100644 index 0000000000..ab8dd6935e --- /dev/null +++ b/doomsday/libgui/src/keyeventsource.cpp @@ -0,0 +1,34 @@ +/** @file keyeventsource.cpp + * + * @authors Copyright (c) 2014 Jaakko Keränen + * + * @par License + * LGPL: http://www.gnu.org/licenses/lgpl.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 3 of the License, or (at your + * option) any later version. This program is distributed in the hope that it + * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. You should have received a copy of + * the GNU Lesser General Public License along with this program; if not, see: + * http://www.gnu.org/licenses + */ + +#include "de/KeyEventSource" + +namespace de { + +DENG2_PIMPL_NOREF(KeyEventSource) +{ + DENG2_PIMPL_AUDIENCE(KeyEvent) +}; + +DENG2_AUDIENCE_METHOD(KeyEventSource, KeyEvent) + +KeyEventSource::KeyEventSource() : d(new Instance) +{} + +} // namespace de + diff --git a/doomsday/libgui/src/mouseeventsource.cpp b/doomsday/libgui/src/mouseeventsource.cpp new file mode 100644 index 0000000000..6484672746 --- /dev/null +++ b/doomsday/libgui/src/mouseeventsource.cpp @@ -0,0 +1,35 @@ +/** @file mouseeventsource.cpp + * + * @authors Copyright (c) 2014 Jaakko Keränen + * + * @par License + * LGPL: http://www.gnu.org/licenses/lgpl.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 3 of the License, or (at your + * option) any later version. This program is distributed in the hope that it + * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. You should have received a copy of + * the GNU Lesser General Public License along with this program; if not, see: + * http://www.gnu.org/licenses + */ + +#include "de/MouseEventSource" + +namespace de { + +DENG2_PIMPL_NOREF(MouseEventSource) +{ + DENG2_PIMPL_AUDIENCE(MouseStateChange) + DENG2_PIMPL_AUDIENCE(MouseEvent) +}; + +DENG2_AUDIENCE_METHOD(MouseEventSource, MouseStateChange) +DENG2_AUDIENCE_METHOD(MouseEventSource, MouseEvent) + +MouseEventSource::MouseEventSource() : d(new Instance) +{} + +} // namespace de diff --git a/doomsday/libgui/src/persistentcanvaswindow.cpp b/doomsday/libgui/src/persistentcanvaswindow.cpp index 241a7c3772..e820005a2e 100644 --- a/doomsday/libgui/src/persistentcanvaswindow.cpp +++ b/doomsday/libgui/src/persistentcanvaswindow.cpp @@ -737,7 +737,7 @@ DENG2_PIMPL(PersistentCanvasWindow) } // The queue is now empty; all modifications to state have been applied. - DENG2_FOR_PUBLIC_AUDIENCE(AttributeChange, i) + DENG2_FOR_PUBLIC_AUDIENCE2(AttributeChange, i) { i->windowAttributesChanged(self); } @@ -761,8 +761,12 @@ DENG2_PIMPL(PersistentCanvasWindow) return st; } + + DENG2_PIMPL_AUDIENCE(AttributeChange) }; +DENG2_AUDIENCE_METHOD(PersistentCanvasWindow, AttributeChange) + PersistentCanvasWindow::PersistentCanvasWindow(String const &id) : d(new Instance(this, id)) { @@ -896,7 +900,7 @@ void PersistentCanvasWindow::moveEvent(QMoveEvent *) d->state.setFlag(Instance::State::Centered, false); // Notify. - DENG2_FOR_AUDIENCE(AttributeChange, i) + DENG2_FOR_AUDIENCE2(AttributeChange, i) { i->windowAttributesChanged(*this); } diff --git a/doomsday/tests/test_glsandbox/testwindow.cpp b/doomsday/tests/test_glsandbox/testwindow.cpp index aa4c13b1fe..5a96be082e 100644 --- a/doomsday/tests/test_glsandbox/testwindow.cpp +++ b/doomsday/tests/test_glsandbox/testwindow.cpp @@ -81,8 +81,8 @@ DENG2_OBSERVES(Bank, Load) // Use this as the main window. setMain(i); - self.canvas().audienceForGLInit += this; - self.canvas().audienceForGLResize += this; + self.canvas().audienceForGLInit() += this; + self.canvas().audienceForGLResize() += this; Clock::appClock().audienceForTimeChange() += this; uColor = Vector4f(.5f, .75f, .5f, 1);