示例#1
0
    //-----------------------------------------------------------------------
    //                          o n M o u s e D o w n
    //-----------------------------------------------------------------------
    void TGScrollBox::onMouseDown(int x, int y, int b)
    {
        int   x1, y1, x2, y2;
        if (b != LeftButton)
            return;
        focus();
        getBounds(x1, y1, x2, y2);

        // vertical scrolling ?
        if (clientHeight > 0.0f && x >= x2 - 12 && y <= y2 - 12)
        {
            scrolling = 1;
            setMouseTrackingControl(this);
            onMouseMoved(x, y);
            return;
        }

        // horizontal scrolling ?
        if (clientWidth > 0.0f && y >= y2 - 12 && x <= x2 - 12)
        {
            scrolling = 2;
            setMouseTrackingControl(this);
            onMouseMoved(x, y);
            return;
        }
    }
示例#2
0
void InputListener::onEvent(const sf::Event& event)
{
	switch (event.type)
	{
		/* Window */
		case sf::Event::LostFocus:               onFocusLost();                                   break;
		case sf::Event::GainedFocus:             onFocusGained();                                 break;
		case sf::Event::Closed:                  onWindowClosed();                                break;
		case sf::Event::Resized:                 onWindowResized(event.size);                     break;
			
		/* Keyboard */
		case sf::Event::TextEntered:             onTextEntered(event.text);                       break;
		case sf::Event::KeyPressed:              onKeyPressed(event.key);                         break;
		case sf::Event::KeyReleased:             onKeyReleased(event.key);                        break;
			
		/* Mouse */
		case sf::Event::MouseEntered:            onMouseEntered();                                break;
		case sf::Event::MouseLeft:               onMouseLeft();                                   break;
		case sf::Event::MouseMoved:              onMouseMoved(event.mouseMove);                   break;
		case sf::Event::MouseWheelMoved:         onMouseWheelMoved(event.mouseWheel);             break;
		case sf::Event::MouseButtonPressed:      onMouseButtonPressed(event.mouseButton);         break;
		case sf::Event::MouseButtonReleased:     onMouseButtonReleased(event.mouseButton);        break;
			
		/* Joystick */
		case sf::Event::JoystickConnected:       onJoystickConnected(event.joystickConnect);      break;
		case sf::Event::JoystickDisconnected:    onJoystickDisconnected(event.joystickConnect);   break;
		case sf::Event::JoystickButtonPressed:   onJoystickButtonPressed(event.joystickButton);   break;
		case sf::Event::JoystickButtonReleased:  onJoystickButtonReleased(event.joystickButton);  break;
		case sf::Event::JoystickMoved:           onJoystickMoved(event.joystickMove);             break;
			
		default:
			Logger::log("Warning", "Unknow event type: %d", event.type);
			break;
	}
}
示例#3
0
void SFMLInputSource::dispatchOne(sf::Event const& event) {
    switch (event.type) {
    case sf::Event::KeyPressed:
        onKeyPressed(event.key);
        break;

    case sf::Event::KeyReleased:
        onKeyReleased(event.key);
        break;

    case sf::Event::MouseButtonPressed:
        onMouseButtonPressed(event.mouseButton);
        break;

    case sf::Event::MouseButtonReleased:
        onMouseButtonReleased(event.mouseButton);
        break;

    case sf::Event::MouseMoved:
        onMouseMoved(event.mouseMove);
        break;

    case sf::Event::MouseWheelMoved:
        onMouseWheelMoved(event.mouseWheel);
        break;

    default:
        break;
    }
}
示例#4
0
//------------------------------------------------------------------------
CMouseEventResult CSlider::onMouseDown (CPoint& where, const CButtonState& buttons)
{
	if (!(buttons & kLButton))
		return kMouseEventNotHandled;

	CRect handleRect;
	delta = calculateDelta (where, getMode () != kFreeClickMode ? &handleRect : 0);
	if (getMode () == kTouchMode && !handleRect.pointInside (where))
		return kMouseEventNotHandled;

	oldVal    = getMin () - 1;
	oldButton = buttons;

	if ((getMode () == kRelativeTouchMode && handleRect.pointInside (where)) || getMode () != kRelativeTouchMode)
	{
		if (checkDefaultValue (buttons))
		{
			return kMouseDownEventHandledButDontNeedMovedOrUpEvents;
		}
	}
	startVal = getValue ();
	beginEdit ();
	mouseStartPoint = where;
	if (buttons & kZoomModifier)
		return kMouseEventHandled;
	return onMouseMoved (where, buttons);
}
示例#5
0
//------------------------------------------------------------------------
CMouseEventResult CTextKickButton::onMouseDown (CPoint& where, const long& buttons)
{
	if (!(buttons & kLButton))
		return kMouseEventNotHandled;
	fEntryState = value;
	beginEdit ();
	return onMouseMoved (where, buttons);
}
示例#6
0
文件: cbuttons.cpp 项目: DaniM/lyngo
//------------------------------------------------------------------------
CMouseEventResult CCheckBox::onMouseDown (CPoint& where, const CButtonState& buttons)
{
	if (buttons.isLeftButton ())
	{
		beginEdit ();
		previousValue = value;
		return onMouseMoved (where, buttons);
	}
	return kMouseDownEventHandledButDontNeedMovedOrUpEvents;
}
示例#7
0
	void EditorBase::mouseMoved(const CL_Pointf &p_mousePos, const CL_Pointf &p_inconditionalMousePos)
	{
		m_lastMousePos = m_mousePos;
		m_mousePos = p_mousePos;
		m_deltaMousePos = m_mousePos - m_lastMousePos;

		m_inconditionalLastMousePos = m_inconditionalMousePos;
		m_inconditionalMousePos = p_inconditionalMousePos;
		m_inconditionalDeltaMousePos = m_inconditionalMousePos - m_inconditionalLastMousePos;

		onMouseMoved();
	}
示例#8
0
void ContextView::processMouseMoved(sf::Event& event) {
  if (m_hasCapture && m_isMouseDown) {
    processMouseDragged(event);
  } else {
    sf::Vector2i mousePos{event.mouseMove.x, event.mouseMove.y};
    if (m_lastMouseEventWasMove && (m_lastMouseMovePos == mousePos)) {
      return;
    }
    m_lastMouseMovePos = mousePos;
    m_lastMouseEventWasMove = true;
    onMouseMoved(event);
  }
}
void ItemListSelectUserInterface::onActivate()
{
   Parent::onActivate();

   mNameSoFar = "";
   mStillTypingNameTimer.clear();

   clearMenuItems();    // We'll repopulate below...

   if(mItemSelectedWithMouse)
      onMouseMoved();
   //else
   //   mSelectedIndex = 0;
}
示例#10
0
//------------------------------------------------------------------------
CMouseEventResult CMyParamDisplay::onMouseDown (CPoint& where, const long& buttons)
{
	if (!(buttons & kLButton))
		return kMouseEventNotHandled;
		
	mInitialPos = where;
	mInitialValue = value;
	
	beginEdit ();
	if (checkDefaultValue (buttons))
	{
		endEdit ();
		return kMouseDownEventHandledButDontNeedMovedOrUpEvents;
	}
	if (buttons & kShift)
		return kMouseEventHandled;
	return onMouseMoved (where, buttons);
}
示例#11
0
void Scene::processEvents()
{
    SDL_Event event; //  Events of SDL
    while ( SDL_PollEvent(&event) )
    {
        if(PGE_Window::processEvents(event)!=0) continue;
        switch(event.type)
        {
            case SDL_QUIT:
                {
                    doExit          = true;
                    running         = false;
                    _doShutDown = true;
                    break;
                }// End work of program
            break;
            case SDL_KEYDOWN: // If pressed key
                onKeyboardPressedSDL(event.key.keysym.sym, event.key.keysym.mod);
                onKeyboardPressed(event.key.keysym.scancode);
            break;
            case SDL_KEYUP: // If released key
                onKeyboardReleasedSDL(event.key.keysym.sym, event.key.keysym.mod);
                onKeyboardReleased(event.key.keysym.scancode);
            break;
            case SDL_MOUSEBUTTONDOWN:
                onMousePressed(event.button);
            break;
            case SDL_MOUSEBUTTONUP:
                onMouseReleased(event.button);
            break;
            case SDL_MOUSEWHEEL:
                onMouseWheel(event.wheel);
            break;
            case SDL_MOUSEMOTION:
                onMouseMoved(event.motion);
            break;
        }
    }
}
示例#12
0
//-----------------------------------------------------------------------------------------
TestTransformation::TestTransformation()
    : m_bPressed(false)
    , m_bTouch(false)
    , m_StartPan(-1, -1)
    , m_LastPan(-1, -1)
{
    // On cr�e une camera
    CCamera* pCamera = m_pSceneManager->createCamera();

    m_vNewEyePosition = QVector3D(8., 8., 4.);
    pCamera->setEyePosition(m_vNewEyePosition);
    pCamera->setCenter(QVector3D(0., 0., 0.));

    qDebug() << "Create View";
    m_pView = createWidget3D(pCamera);
    m_pView->setAttribute(Qt::WA_AcceptTouchEvents);
    qDebug() << "End create View";

    // On cr�e un noeud afin d'y placer une lumi�re
    CSceneNode* pRootNode = getSceneManager()->getRootNode();

    // On cr�e une lumi�re diffuse bleue
    CLight* pLight = getSceneManager()->createLight();
    pLight->setDiffuseColor(1.0, 1.0, 1.0);
    pLight->setAmbientColor(1.0, 1.0, 1.0);
    pLight->setDirection(QVector3D(-1, 0, 0));
    pLight->setSpecularColor(1.0f, 1.0f, 1.0f);

    // On l'associe au noeud
    pRootNode->addItem(pLight);

    // SkyBox
    CSkyBox* pSkyBoxMesh = CMeshManager::getInstance().createCustomMesh<CSkyBox>("CSkyBox", "SkyBoxMesh");

    CMeshInstance* pSkyBox = getSceneManager()->createMeshInstance(pSkyBoxMesh, "SkyBox");
    pSkyBox->setSelectable(false);
    CSceneNode* pSkyBoxNode = pRootNode->createChild("SkyBoxNode");
    pSkyBoxNode->scale(400.);
    pSkyBoxNode->addItem(pSkyBox);


    CMaterial* pSkyBoxMat = CMaterialManager::getInstance().createMaterial("SkyBoxMaterial");
    pSkyBox->setMaterialName(pSkyBoxMat->getName());

    QStringList fileNames;
    fileNames << "://Resources/xpos.png" << "://Resources/xneg.png" << "://Resources/ypos.png"
              << "://Resources/yneg.png" << "://Resources/zpos.png" << "://Resources/zneg.png";

    ATexture* pSkyBoxTexture = CTextureManager::getInstance().createTextureCube("SkyBoxTexCube", fileNames);
    pSkyBoxMat->addTexture(pSkyBoxTexture, eDiffuse);

#ifdef EMBEDDED_TARGET
    CShader* pShader = CShaderManager::getInstance().createShader(
                "SkyBoxShader",
                "://Resources/skyboxES.vertex.glsl",
                "",
                "://Resources/skyboxES.fragment.glsl");
#else
    CShader* pShader = CShaderManager::getInstance().createShader(
                "SkyBoxShader",
                "://Resources/skybox.vertex.glsl",
                "",
                "://Resources/skybox.fragment.glsl");
#endif

    pSkyBoxMat->getRenderPass(0)->setShaderName(pShader->getName());
    pSkyBoxMat->getRenderPass(0)->renderStates().setFaceCulling(CFaceCulling(false));

    // Particules
    CBillboard* pBillboard = getSceneManager()->createBillboard();
    QVector<QVector3D> pos;
    for (int i = 0; i < 1000; ++i)
        pos << QVector3D(
                   Math::randDouble(-200., +200.),
                   Math::randDouble(-200., +200.),
                   Math::randDouble(-200., +200.));
    pBillboard->addPositions(pos);

    CMaterial* pBillboardMat = CMaterialManager::getInstance().createMaterial("BillboardMaterial");
    pBillboardMat->getRenderPass(0)->renderStates().setFaceCulling(CFaceCulling(false));
    CBlending blending;
    blending.setEnabled(true);
    blending.setBlendEquation(eAdd, eAdd);

    blending.setBlendSeparateFunction(Source::eSourceAlpha, Destination::eOneMinusSourceAlpha, Source::eOne, Destination::eZero);
    pBillboardMat->getRenderPass(0)->renderStates().setBlending(blending);

    ATexture* pBillboardTexture = CTextureManager::getInstance().createTexture2D("BillBoardTex", "://Resources/particle.png");
    pBillboardMat->addTexture(pBillboardTexture, eDiffuse);

    CShader* pBillboardShader = CShaderManager::getInstance().createShader("BillboardShader",
        "://Resources/billboard.vertex.glsl",
        "://Resources/billboard.geometry.glsl",
        "://Resources/billboard.fragment.glsl");

    pBillboardMat->getRenderPass(0)->setShaderName(pBillboardShader->getName());
    pBillboard->setMaterialName(pBillboardMat->getName());
    pBillboardShader->setUniformValue("halfSize", 1.);

    CSceneNode* pBillboardNode = pRootNode->createChild("BillboardNode");
    pBillboardNode->addItem(pBillboard);

    // Orbites
    CPolyLine* pPolyLine = CMeshManager::getInstance().createCustomMesh<CPolyLine>("CPolyLine", "CPolyLine");

    QList<QVector3D> pts;

    for (int i = 0; i <= 360; ++i)
    {
        pts << QVector3D(cos(Math::degToRad((real)i)), 0., sin(Math::degToRad((real)i)));
    }

    pPolyLine->addPoints(pts);

    CSphereMesh* pSphereMesh = CMeshManager::getInstance().createCustomMesh<CSphereMesh>("CSphereMesh", "SphereMesh");

    CMeshInstance* pSun = getSceneManager()->createMeshInstance(pSphereMesh, "Sun");
    CMaterial* pSunMat = CMaterialManager::getInstance().createMaterial("SunMat");
    pSunMat->setAmbientColor(1., 1., 1.);

    CTexture2D* pSunTexture = CTextureManager::getInstance().createTexture2D("SunTex", ":/Resources/sun.png");
    pSunMat->addTexture(pSunTexture, eDiffuse);
    pSun->setMaterialName(pSunMat->getName());

    CMeshInstance* pEarth = getSceneManager()->createMeshInstance(pSphereMesh, "Earth");
    CMaterial* pEarthMat = CMaterialManager::getInstance().createMaterial("EarthMat");

    CTexture2D* pEarthTexture = CTextureManager::getInstance().createTexture2D("EarthTex", ":/Resources/earth.png");
    pEarthMat->addTexture(pEarthTexture, eDiffuse);

    pEarthMat->setAmbientColor(0.1, 0.1, 0.1);
    pEarthMat->setDiffuseColor(1.0, 1.0, 1.0);
    pEarthMat->setShininessFactor(10);
    pEarth->setMaterialName(pEarthMat->getName());

    CMeshInstance* pJupiter = getSceneManager()->createMeshInstance(pSphereMesh, "Jupiter");
    CMaterial* pJupiterMat = CMaterialManager::getInstance().createMaterial("JupiterMat");
    pJupiterMat->setAmbientColor(0.4, 0.4, 0.4);

    CTexture2D* pJupiterTexture = CTextureManager::getInstance().createTexture2D("JupiterTex", ":/Resources/jupiter.png");
    pJupiterMat->addTexture(pJupiterTexture, eDiffuse);
    pJupiter->setMaterialName(pJupiterMat->getName());

    CMeshInstance* pMoon = getSceneManager()->createMeshInstance(pSphereMesh, "Moon");
    CMaterial* pMoonMat = CMaterialManager::getInstance().createMaterial("MoonMat");
    CTexture2D* pMoonTexture = CTextureManager::getInstance().createTexture2D("MoonTex", ":/Resources/moon.png");
    pMoonMat->addTexture(pMoonTexture, eDiffuse);
    pMoon->setMaterialName(pMoonMat->getName());

    CCoordinateSystem* pCoordinateSystemMesh = CMeshManager::getInstance().createCustomMesh<CCoordinateSystem>("CCoordinateSystem", "CCoordinateSystem");
    CMeshInstance* pCoordinateSystem = getSceneManager()->createMeshInstance(pCoordinateSystemMesh, "CoordinateSystem");
    pRootNode->addItem(pCoordinateSystem);
    pRootNode->addItem(pSkyBox);

    m_pSolarSystemNode = pRootNode->createChild(QVector3D(0., 0., 0.));

    m_pSunNode = m_pSolarSystemNode->createChild(QVector3D(0., 0., 0.));
    m_pSunNode->scale(4.0);
    m_pSunNode->addItem(pSun);

    m_pSunToEarthNode = m_pSolarSystemNode->createChild();
    m_pSunToJupiterNode = m_pSolarSystemNode->createChild();

    CMeshInstance* pSunToEarthPLine = getSceneManager()->createMeshInstance(pPolyLine, "SunToEarth");
    pSunToEarthPLine->setMaterialName(CMaterialManager::getInstance().getMaterialNameByColor(Color::eWhite));
    m_pSunToEarthNode->addItem(pSunToEarthPLine);
    m_pSunToEarthNode->scale(10.0);
    m_pEarthNode = m_pSolarSystemNode->createChild(QVector3D(10.0, 0., 0.));
    m_pEarthNode->scale(1.0);
    m_pEarthNode->addItem(pEarth);

    CMeshInstance* pSunToJupiterPLine = getSceneManager()->createMeshInstance(pPolyLine, "SunToJupiter");
    pSunToJupiterPLine->setMaterialName(CMaterialManager::getInstance().getMaterialNameByColor(Color::eWhite));
    m_pSunToJupiterNode->addItem(pSunToJupiterPLine);
    m_pSunToJupiterNode->scale(20);
    m_pJupiterNode = m_pSolarSystemNode->createChild(QVector3D(20.0, 0., 0.));
    m_pJupiterNode->scale(4.0);
    m_pJupiterNode->addItem(pJupiter);

    m_pEarthToMoonNode = m_pEarthNode->createChild();
    CMeshInstance* pEarthToMoonPLine = getSceneManager()->createMeshInstance(pPolyLine, "EarthToMoon");
    pEarthToMoonPLine->setMaterialName(CMaterialManager::getInstance().getMaterialNameByColor(Color::eWhite));
    m_pEarthToMoonNode->addItem(pEarthToMoonPLine);
    m_pEarthToMoonNode->scale(2.0);
    m_pEarthToMoonNode->rotate(QVector3D(1.0, 0.0, 0.0), 30);
    m_pMoonNode = m_pEarthToMoonNode->createChild(QVector3D(1.0, 0.0, 0.));
    m_pMoonNode->scale(0.2);
    m_pMoonNode->addItem(pMoon);

    QTimer* pTimer = new QTimer(this);
    connect(pTimer, SIGNAL(timeout()), this, SLOT(onTimeout()));
    pTimer->start(5);


    connect(m_pView, SIGNAL(mouseMoved()),				this, SLOT(onMouseMoved()));
    connect(m_pView, SIGNAL(mouseReleased()),			this, SLOT(onMouseReleased()));
    connect(m_pView, SIGNAL(mousePressed()),			this, SLOT(onMousePressed()));
    connect(m_pView, SIGNAL(touchScaleStarted()),       this, SLOT(onTouchScaleStarted()));
    connect(m_pView, SIGNAL(touchScaleChanged(real)),	this, SLOT(onTouchScaleChanged(real)));
    connect(m_pView, SIGNAL(touchScaleEnded()),         this, SLOT(onTouchScaleEnded()));

    //m_pView->setGeometry(QRect(1920, 100, 400, 300));

    m_GlobalTime.start();
}
示例#13
0
文件: cframe.cpp 项目: EQ4/vstgui
//-----------------------------------------------------------------------------
CMouseEventResult CFrame::platformOnMouseMoved (CPoint& where, const CButtonState& buttons)
{
	CollectInvalidRects cir (this);
	return onMouseMoved (where, buttons);
}
示例#14
0
void Clickable::mouseMoved(MouseEvent* mouse_event) {
  emit onMouseMoved(mouse_event);
}