Ejemplo n.º 1
0
void Window::processEvents()
{
    if (m_eventQueue.empty() || !m_context)
        return;

    glfwMakeContextCurrent(m_window);

    while (!m_eventQueue.empty())
    {
        WindowEvent* event = m_eventQueue.front();
        m_eventQueue.pop();
        event->setWindow(this);

        processEvent(*event);

        delete event;

        if (!m_context)
        {
            clearEventQueue();
            return;
        }
    }

    glfwMakeContextCurrent(nullptr);
}
Ejemplo n.º 2
0
WindowEventTransitPtr WindowEvent::create(  FieldContainerUnrecPtr Source,
                                        Time TimeStamp)
{
    WindowEvent* TheEvent = WindowEvent::createEmpty();

    TheEvent->setSource(Source);
    TheEvent->setTimeStamp(TimeStamp);

    return WindowEventTransitPtr(TheEvent);
}
Ejemplo n.º 3
0
void GameImpl::handle_window_event(const WindowEvent& event) {
    switch (event.get_type()) {
        case WindowEvent::Type::CLOSE: {
            request_state_change(StateId::EXIT);
            break;
        }
    }
}
Ejemplo n.º 4
0
void Window::postprocessEvent(WindowEvent & event)
{
    switch (event.type())
    {
    case WindowEvent::Type::Paint:
        swap();
        break;

    case WindowEvent::Type::Close:
        if (!event.isAccepted())
            destroy();
        break;

    default:
        break;
    }
}
Ejemplo n.º 5
0
// slot/callback to update the control point of the curve,
// and refresh the polyline which used to view the curve.
void onKeyboardEvent(const WindowEvent &e)
{
	if (e.type() != WET_KEY)
		return;

	switch (e.int_data)
	{					  
	case phoenix::Key_0: g_iSelectedCP = 0; break;
	case phoenix::Key_1: g_iSelectedCP = 1; break;
	case phoenix::Key_2: g_iSelectedCP = 2; break;
	case phoenix::Key_3: g_iSelectedCP = 3; break;
	case phoenix::Key_UP: 
		{
			if (g_iSelectedCP < aCPs.size() && -1 < g_iSelectedCP) {
				aCPs[g_iSelectedCP].setY( aCPs[g_iSelectedCP].getY() + 1 ); 
				calculatePolylineFromCP(aCPs);
			}
		} break; 
	case phoenix::Key_DOWN: 
		{
			if (g_iSelectedCP < aCPs.size() && -1 < g_iSelectedCP) {
				aCPs[g_iSelectedCP].setY( aCPs[g_iSelectedCP].getY() - 1 );
				calculatePolylineFromCP(aCPs);
			}
		} break; 
	case phoenix::Key_LEFT: 
		{
			if (g_iSelectedCP < aCPs.size() && -1 < g_iSelectedCP) {
				aCPs[g_iSelectedCP].setX( aCPs[g_iSelectedCP].getX() - 1 );
				calculatePolylineFromCP(aCPs);
			}
		} break; 
	case phoenix::Key_RIGHT: 
		{
			if (g_iSelectedCP < aCPs.size() && -1 < g_iSelectedCP) {
				aCPs[g_iSelectedCP].setX( aCPs[g_iSelectedCP].getX() + 1 );
				calculatePolylineFromCP(aCPs);
			}
		} break; 
	default:
		{
			int a = 0;
			int b = a;
			++b;
		}
		break;
	} 
} 
Ejemplo n.º 6
0
void RendererBase::onWindowEvent(EventBase *event)
{
    WindowEvent *eventWindow = static_cast<WindowEvent *>(event);
    switch(event->Type())
    {
    case Window::EVENT_GUI_WINDOW_MOVED:
        calcTransform(eventWindow->SourceWindow());
        break;
    case Window::EVENT_GUI_WINDOW_SIZED:
        setVertices(eventWindow->SourceWindow());
        break;
    case Window::EVENT_GUI_WINDOW_ROTATED:
        calcTransform(eventWindow->SourceWindow());
        break;
    case Window::EVENT_GUI_WINDOW_SCALED:
        calcTransform(eventWindow->SourceWindow());
        break;
    case Window::EVENT_GUI_WINDOW_ANCHOR_CHANGED:
        setVertices(eventWindow->SourceWindow());
        break;
    }
}
void WindowEventHandler::handleEvent(WindowEvent & event)
{
    if (!event.window())
        return;

    switch (event.type())
    {
        case WindowEvent::Resize:
            resizeEvent(static_cast<ResizeEvent&>(event));
            break;

        case WindowEvent::FrameBufferResize:
            framebufferResizeEvent(static_cast<ResizeEvent&>(event));
            break;

        case WindowEvent::Move:
            moveEvent(static_cast<MoveEvent&>(event));
            break;

        case WindowEvent::Paint:
            paintEvent(static_cast<PaintEvent&>(event));
            break;

        case WindowEvent::KeyPress:
            keyPressEvent(static_cast<KeyEvent&>(event));
            break;

        case WindowEvent::KeyRelease:
            keyReleaseEvent(static_cast<KeyEvent&>(event));
            break;

        case WindowEvent::MousePress:
            mousePressEvent(static_cast<MouseEvent&>(event));
            break;

        case WindowEvent::MouseRelease:
            mouseReleaseEvent(static_cast<MouseEvent&>(event));
            break;

        case WindowEvent::MouseMove:
            mouseMoveEvent(static_cast<MouseEvent&>(event));
            break;

        case WindowEvent::MouseEnter:

            break;

        case WindowEvent::MouseLeave:

            break;

        case WindowEvent::Scroll:
            scrollEvent(static_cast<ScrollEvent&>(event));
            break;

        case WindowEvent::Focus:
            focusEvent(static_cast<FocusEvent&>(event));
            break;

        case WindowEvent::Iconify:
            iconifyEvent(static_cast<IconifyEvent&>(event));
            break;

        case WindowEvent::Timer:
            timerEvent(static_cast<TimerEvent&>(event));
            break;

        default:
            break;
    }
}