Beispiel #1
0
// draw
void draw(void)
{
	MMouse * mouse = MMouse::getInstance();
	MRenderingContext * render = MEngine::getInstance()->getRenderingContext();
	Maratis::getInstance()->graphicLoop();

	if(logo)
	{
		set2dMode(render);
		render->setBlendingMode(M_BLENDING_ALPHA);
		render->enableTexture();
		render->setColor4(MVector4(1.0f));
		drawLogo();
	}

	if(mouse->isLeftButtonPushed() || mouse->isMiddleButtonPushed() || (mouse->getWheelDirection() != 0))
		logo = false;

	MWindow::getInstance()->swapBuffer();
}
void MGuiSlide::onEvent(MWinEvent * windowEvent)
{
	MGuiWindow * parent = getParentWindow();

	MMouse * mouse = MMouse::getInstance();

	switch(windowEvent->type)
	{
	case MWIN_EVENT_MOUSE_WHEEL_MOVE:
	case MWIN_EVENT_MOUSE_MOVE:
		if(parent->isHighLight() && m_button.isPointInside(getMouseLocalPosition()) && (! mouse->isLeftButtonPushed()) && (! mouse->isMiddleButtonPushed()) && (! mouse->isRightButtonPushed()))
		{
			setHighLight(true);

			if(m_pointerEvent) // send gui event
			{
				MGuiEvent guiEvent;

				guiEvent.type = MGUI_EVENT_MOUSE_MOVE;
				guiEvent.data[0] = windowEvent->data[0];
				guiEvent.data[1] = windowEvent->data[1];

				m_pointerEvent(this, &guiEvent);
			}

			// break events
			if(parent->breakEvents())
				return;
		}
		else{
			setHighLight(false);
		}

		if(isPressed())
		{
			float value = getValueFromPoint(getMouseLocalPosition());
			setValue(value);
		}
		break;
	case MWIN_EVENT_MOUSE_BUTTON_DOWN:
		if(isHighLight())
		{
			if(windowEvent->data[0] == MMOUSE_BUTTON_LEFT){
				setPressed(true);
				m_offset = getMouseLocalPosition() - m_button.getPosition();
			}

			if(m_pointerEvent) // send gui event
			{
				MGuiEvent guiEvent;

				guiEvent.type = MGUI_EVENT_MOUSE_BUTTON_DOWN;
				guiEvent.data[0] = windowEvent->data[0];

				m_pointerEvent(this, &guiEvent);
			}
		}
		break;
	case MWIN_EVENT_MOUSE_BUTTON_UP:
		if(windowEvent->data[0] == MMOUSE_BUTTON_LEFT)
		{
			setPressed(false);
		}
		break;
	}
}