/*****************************************************************************
 * $LastChangedDate: 2011-04-09 21:58:06 -0400 (Sat, 09 Apr 2011) $
 * @file
 * @author  Jim E. Brooks  http://www.palomino3d.org
 * @brief   Window/View events.
 *//*
 * LEGAL:   COPYRIGHT (C) 2008 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
 *****************************************************************************/

#ifndef VIEW_EVENTS_HH
#define VIEW_EVENTS_HH 1

#include "base/singleton.hh"
#include "base/event.hh"
#include "view/view.hh"

namespace view {

////////////////////////////////////////////////////////////////////////////////
/// @brief Window/View events.
///
/// This event struct is a global.
/// It cannot be a member of Window class since listeners could be registered
/// before Window is created.
///
class Events
{
public:
    DEFINE_GetInstance( Events )  // Singleton

#define EVENT_VIEW_PRE_DRAW_ALL_VIEWS view::Events::GetInstance().GetPreDrawAllViews()
    Event<>&  GetPreDrawAllViews( void ) { return mPreDrawAllViews; }

#define EVENT_VIEW_POST_DRAW_ALL_VIEWS view::Events::GetInstance().GetPostDrawAllViews()
    Event<>&  GetPostDrawAllViews( void ) { return mPostDrawAllViews; }

#define EVENT_VIEW_PRE_DRAW_ONE_VIEW view::Events::GetInstance().GetPreDrawOneView()
    Event<shptr<View> >&  GetPreDrawOneView( void ) { return mPreDrawOneView; }

#define EVENT_VIEW_POST_DRAW_ONE_VIEW view::Events::GetInstance().GetPostDrawOneView()
    Event<shptr<View> >&  GetPostDrawOneView( void ) { return mPostDrawOneView; }

private:
    CLASS_VAR Events*   msInstance;
    Event<>             mPreDrawAllViews;   ///< called before drawing the first view
    Event<>             mPostDrawAllViews;  ///< called after drawing the last view
    Event<shptr<View> > mPreDrawOneView;    ///< called before drawing one view
    Event<shptr<View> > mPostDrawOneView;   ///< called after drawing one view
};

#if VIEW_MODULE_CC
Events* Events::msInstance;
#endif

} // namespace view

#endif // VIEW_EVENTS_HH
