コード例 #1
0
//==============================================================================
void ScrollBar::paint (Graphics& g)
{
    if (thumbAreaSize > 0)
    {
        LookAndFeel& lf = getLookAndFeel();

        const int thumb = (thumbAreaSize > lf.getMinimumScrollbarThumbSize (*this))
                                ? thumbSize : 0;

        if (vertical)
        {
            lf.drawScrollbar (g, *this,
                              0, thumbAreaStart,
                              getWidth(), thumbAreaSize,
                              vertical,
                              thumbStart, thumb,
                              isMouseOver(), isMouseButtonDown());
        }
        else
        {
            lf.drawScrollbar (g, *this,
                              thumbAreaStart, 0,
                              thumbAreaSize, getHeight(),
                              vertical,
                              thumbStart, thumb,
                              isMouseOver(), isMouseButtonDown());
        }
    }
}
コード例 #2
0
//==============================================================================
void ResizableCornerComponent::paint (Graphics& g)
{
    getLookAndFeel()
        .drawCornerResizer (g, getWidth(), getHeight(),
                            isMouseOverOrDragging(),
                            isMouseButtonDown());
}
コード例 #3
0
void CustomSlider::updateSliderPos()
{
    float newValue = param.getValue();
    
    if (newValue != (float) Slider::getValue() && ! isMouseButtonDown())
        Slider::setValue (newValue);
}
コード例 #4
0
ファイル: InputSystem.cpp プロジェクト: 0xTHR34T/EagleEngine
	void InputSystem::waitForKeyPress()
	{
		while(1)
		{
			for(int i = 0; i < 256; ++i)
			{
				if(isKeyDown((KeyboardKey)i))
				{
					return;
				}
			}

			for(int i = 0; i < 4; ++i)
			{
				if(isMouseButtonDown((MouseButton)i))
				{
					return;
				}
			}

			eagle.sleep(10);

			eagle.updateEngine();
		}
	}
コード例 #5
0
ファイル: AudioPlaybackDemo.cpp プロジェクト: AydinSakar/JUCE
    void updateCursorPosition()
    {
        currentPositionMarker.setVisible (transportSource.isPlaying() || isMouseButtonDown());

        currentPositionMarker.setRectangle (Rectangle<float> (timeToX (transportSource.getCurrentPosition()) - 0.75f, 0,
                                                              1.5f, (float) (getHeight() - scrollbar.getHeight())));
    }
コード例 #6
0
ファイル: juce_ConcertinaPanel.cpp プロジェクト: AGenews/GUI
    void paint (Graphics& g)
    {
        const Rectangle<int> area (getWidth(), getHeaderSize());
        g.reduceClipRegion (area);

        getLookAndFeel().drawConcertinaPanelHeader (g, area, isMouseOver(), isMouseButtonDown(),
                                                    getPanel(), *component);
    }
コード例 #7
0
//==============================================================================
void StretchableLayoutResizerBar::paint (Graphics& g)
{
    getLookAndFeel().drawStretchableLayoutResizerBar (g,
                                                      getWidth(), getHeight(),
                                                      isVertical,
                                                      isMouseOver(),
                                                      isMouseButtonDown());
}
コード例 #8
0
ファイル: AudioDemoPlaybackPage.cpp プロジェクト: Frongo/JUCE
    void timerCallback()
    {
        currentPositionMarker.setVisible (transportSource.isPlaying() || isMouseButtonDown());

        double currentPlayPosition = transportSource.getCurrentPosition();

        currentPositionMarker.setRectangle (Rectangle<float> (timeToX (currentPlayPosition) - 0.75f, 0,
                                                              1.5f, (float) getHeight()));
    }
コード例 #9
0
ファイル: Input.cpp プロジェクト: JonathanPalmerGD/PVGame
bool Input::isActivateKeyDown() const
{
	//if(isKeyDown(VK_RETURN))
	//	return true;
	if(isMouseButtonDown(MouseLeft))
		return true;
	if(isGamepadButtonDown(ButtonB))
		return true;
	return false;
}
コード例 #10
0
void ImageKnob::paint(Graphics &g) {
    if(isMouseOver() && !isMouseButtonDown()) {
        onMouseOver();
    }

    const int y = (int)(filmstripImageCount * getValue()) * knobWidth;
    knobArea.setY(y);
    const Image knobFrame = imageStates->normal.getClippedImage(knobArea);
    const Image resizedKnobFrame = knobFrame.rescaled(knobWidth, knobWidth, Graphics::highResamplingQuality);
    g.drawImageAt(resizedKnobFrame, 0, 0);
}
コード例 #11
0
ファイル: InputSystem.cpp プロジェクト: 0xTHR34T/EagleEngine
	bool InputSystem::isMouseButtonPressed(MouseButton button)
	{
		bool a = 0;

		if(!m_oldButtons[button] && isMouseButtonDown(button))
		{
			a = 1;
		}
		else
		{
			a = 0;
		}

		return a;
	}
コード例 #12
0
ファイル: InputSystem.cpp プロジェクト: 0xTHR34T/EagleEngine
	bool InputSystem::isMouseButtonReleased(MouseButton button)
	{
		bool a = 0;

		if(m_oldButtons[button] && !isMouseButtonDown(button))
		{
			a = 1;
		}
		else
		{
			a = 0;
		}

		return a;
	}
コード例 #13
0
void ScrollBar::timerCallback()
{
    if (isMouseButtonDown())
    {
        startTimer (40);

        if (lastMousePos < thumbStart)
            setCurrentRange (visibleRange - visibleRange.getLength());
        else if (lastMousePos > thumbStart + thumbSize)
            setCurrentRangeStart (visibleRange.getEnd());
    }
    else
    {
        stopTimer();
    }
}
コード例 #14
0
ファイル: Engine.cpp プロジェクト: ennioquaglia/GameEngine
    void SceneManager::act(float deltaTimeMs)
    {
        fps=1.0f/(deltaTimeMs/1000.0f);
        //if(isKeyPressed(GLFW_KEY_F9))reload();
        //if(isKeyPressed(GLFW_KEY_F10))script.compileAndReload(this);
        if(isKeyPressed(GLFW_KEY_F1))useDebugCamera(!isUsingDebugCamera);
        if(isUsingDebugCamera) {
                if(isMouseButtonDown(MouseState::LEFT_BUTTON)) {
                        vec2 delta=getMousePositionDelta();
                        if(delta.x)debugCamera.setRotX(debugCamera.getRotX()-delta.x);
                        if(delta.y)debugCamera.setRotY(debugCamera.getRotY()+delta.y);
                    }
                float speed=1;
                if(isKeyDown(GLFW_KEY_LEFT_SHIFT))speed*=1.5;
                debugCamera.Pos+=(getPositionMovementRotated(debugCamera.getRotX())*(deltaTimeMs/100.0f))*speed;
            }

        actorManager->update(deltaTimeMs);
		systemManager->update(deltaTimeMs);
    }
コード例 #15
0
	void SDLInput::update() {
		impl->recentlyPressedKeys.clear();
		impl->recentlyReleasedKeys.clear();

		impl->recentlyPressedMouseButtons = 0;
		impl->recentlyReleasedMouseButtons = 0;

		SDL_Event e;
		while (SDL_PollEvent(&e) != 0) {

			if (e.type == SDL_QUIT) {
				impl->windowClosed = true;
			}

			if (isKeyDown(e)) {
				Key key = getKey(e);
				impl->recentlyPressedKeys.insert(key);
				impl->pressedKeys.insert(key);
			}

			if (isKeyUp(e)) {
				Key key = getKey(e);
				impl->recentlyReleasedKeys.insert(key);
				impl->pressedKeys.erase(key);
			}

			if (isMouseMove(e)) {
				impl->mousePosition = Vec2{(double) e.motion.x, (double) e.motion.y};
			}

			if (isMouseButtonDown(e)) {
				impl->pressedMouseButtons |= mouseButtonToInt(getMouseButton(e));
				impl->recentlyPressedMouseButtons |= mouseButtonToInt(getMouseButton(e));
			}

			if (isMouseButtonUp(e)) {
				impl->pressedMouseButtons &= ~(mouseButtonToInt(getMouseButton(e)));
				impl->recentlyReleasedMouseButtons |= mouseButtonToInt(getMouseButton(e));
			}
		}
	}
コード例 #16
0
ファイル: InputSystem.cpp プロジェクト: 0xTHR34T/EagleEngine
	bool InputSystem::isMouseButtonReleased(int touchID)
	{
		if(touchID < 0 || touchID > INPUT_SUPPORTED_TOUCH_COUNT - 1)
		{
			for(int i = 0; i < INPUT_SUPPORTED_TOUCH_COUNT; ++i)
			{
				if(isMouseButtonReleased(i))
				{
					return 1;
				}
			}

			return 0;
		}

		if(m_oldTouchList[touchID] && !isMouseButtonDown(touchID))
		{
			return 1;
		}
		else
		{
			return 0;
		}
	}
コード例 #17
0
ファイル: juce_Button.cpp プロジェクト: 2DaT/Obxd
Button::ButtonState Button::updateState()
{
    return updateState (isMouseOver (true), isMouseButtonDown());
}
コード例 #18
0
ファイル: InputSystem.cpp プロジェクト: 0xTHR34T/EagleEngine
	void InputSystem::update()
	{
#ifndef PLATFORM_WP8
		m_keyboard->Poll();

		if(!SUCCEEDED(m_keyboard->GetDeviceState(256, (LPVOID)&m_keyState)))
		{
			m_keyboard->Acquire();
		}

		m_mouse->Poll();

		if(!SUCCEEDED(m_mouse->GetDeviceState(sizeof(DIMOUSESTATE), &m_mouseState)))
		{
			m_mouse->Acquire();
		}

		m_mouseMove.x = m_mouseState.lX;
		m_mouseMove.y = m_mouseState.lY;

		m_wheelMove = m_mouseState.lZ;

		POINT mousePoint;
		GetCursorPos(&mousePoint);
		ScreenToClient(m_windowHandle, &mousePoint);
		m_mousePosition.x = mousePoint.x;
		m_mousePosition.y = mousePoint.y;

		if(m_joystickValidity)
		{
			if(!SUCCEEDED(m_joystick->GetDeviceState(sizeof(DIJOYSTATE2), &m_joystickState)))
			{
				m_joystick->Acquire();
			}

			m_joystickAxis.x = (m_joystickState.lX - 32767) / 32767;
			m_joystickAxis.y = (m_joystickState.lY - 32767) / 32767;
		}

		float currentTime = eagle.getTimer()->getPassedTimeSeconds();

		for(int i = 0; i < 256; ++i)
		{
			if(isKeyPressed((KeyboardKey)i))
			{
				m_keyHoldDuration[i] = 0;
				m_keyHoldStart[i] = currentTime;

				m_keyTapCount[i]++;

				m_keyTotalPressCount[i]++;

				addToKeySequence(i);
			}
			else if(isKeyDown((KeyboardKey)i))
			{
				m_keyHoldDuration[i] = currentTime - m_keyHoldStart[i];
			}
			else
			{
				m_keyHoldDuration[i] = 0;
			}
		}

		for(int i = 0; i < 4; ++i)
		{
			if(isMouseButtonPressed((MouseButton)i))
			{
				m_buttonHoldDuration[i] = 0;
				m_buttonHoldStart[i] = currentTime;

				m_buttonTapCount[i]++;

				m_buttonTotalPressCount[i]++;
			}
			else if(isMouseButtonDown((MouseButton)i))
			{
				m_buttonHoldDuration[i] = currentTime - m_buttonHoldStart[i];
			}
			else
			{
				m_buttonHoldDuration[i] = 0;
			}
		}

		if(m_tapTimer.stopWatch(1))
		{
			for(int i = 0; i < 256; ++i)
			{
				m_keyTapFrequency[i] = m_keyTapCount[i];

				m_keyTapCount[i] = 0;
			}

			for(int i = 0; i < 4; ++i)
			{
				m_buttonTapFrequency[i] = m_buttonTapCount[i];

				m_buttonTapCount[i] = 0;
			}

			m_tapTimer.reset();
		}

#else
	
		int currentTime = eagle.getTimer()->getPassedTimeSeconds();

		for(int i = 0; i < INPUT_SUPPORTED_TOUCH_COUNT; ++i)
		{
			if(isMouseButtonPressed(i))
			{
				m_touchHoldDuration[i] = 0;
				m_touchHoldStart[i] = currentTime;

				m_touchTapCount[i]++;

				m_touchTotalPressCount[i]++;
			}
			else if(isMouseButtonDown(i))
			{
				m_touchHoldDuration[i] = currentTime - m_touchHoldStart[i];
			}
			else
			{
				m_touchHoldDuration[i] = 0;

				m_touchMoveList[i].set(0, 0);
			}
		}

		if(m_tapTimer.stopWatch(1))
		{
			for(int i = 0; i < 4; ++i)
			{
				m_touchTapFrequency[i] = m_touchTapCount[i];

				m_touchTapCount[i] = 0;
			}

			m_tapTimer.reset();
		}
#endif
	}
コード例 #19
0
 void moved() override
 {
     if (isMouseButtonDown())
         relativePos = getBounds().getCentre().toFloat() / Point<int> (getParentWidth(), getParentHeight()).toFloat();
 }
コード例 #20
0
ファイル: Engine.cpp プロジェクト: dbralir/ludum-dare-32
bool Engine::isMouseButtonUp(sf::Mouse::Button button) const {
    return !isMouseButtonDown(button);
}
コード例 #21
0
ファイル: RTSCamera.cpp プロジェクト: bpetar/leonline
void RTSCamera::animate(u32 elapsed)
{
	bool movebymouse = false;
   f32 nRotX = rotX;
   f32 nRotY = rotY;
   f32 nZoom = currentZoom;

   vector3df translate(oldTarget);
   vector3df tvectX = Pos - Target;
   tvectX = tvectX.crossProduct(UpVector);
   tvectX.normalize();

//   if(oldTarget.X != 0)
//   {
//   }

   //Zoom
   if (isMouseButtonDown(MOUSE_BUTTON_RIGHT) && isMouseButtonDown(MOUSE_BUTTON_LEFT))
   {
      if (!zooming)
      {
         zoomStartX = MousePos.X;
         zoomStartY = MousePos.Y;
         zooming = true;
         nZoom = currentZoom;
      }
      else
      {
         f32 old = nZoom;
         nZoom += (zoomStartX - MousePos.X) * zoomSpeed * 100;

//         f32 targetMinDistance = 0.1f;
//         if (nZoom < targetMinDistance)
//            nZoom = targetMinDistance;

         if (nZoom < targetMinDistance)
            nZoom = targetMinDistance;
         else if (nZoom > targetMaxDistance)
            nZoom = targetMaxDistance;


         if (nZoom < 0)
            nZoom = old;
      }
   }
   else
   {
      if (zooming)
      {
         f32 old = currentZoom;
         currentZoom = currentZoom + (zoomStartX - MousePos.X ) * zoomSpeed;
         nZoom = currentZoom;

         if (nZoom < 0)
            nZoom = currentZoom = old;
      }
      zooming = false;
   }

   //We rotate in Editor with right mouse button
   if(isMouseButtonDown(MOUSE_BUTTON_RIGHT) && !isKeyDown(KEY_SHIFT) && !isKeyDown(KEY_LSHIFT) && !isKeyDown(KEY_RSHIFT))
   {
	   movebymouse = true;
      if (!rotating)
      {
         rotateStartX = MousePos.X;
         rotateStartY = MousePos.Y;
         rotating = true;
         //nRotX = rotX;
         //nRotY = rotY;
      }
      else
      {
         nRotX -= (rotateStartX - MousePos.X) * rotateSpeed * (f32)elapsed/500;
         nRotY -= (rotateStartY - MousePos.Y) * rotateSpeed * (f32)elapsed/500;
		 rotX = nRotX;//rotX - (rotateStartX - MousePos.X) * rotateSpeed * (f32)elapsed/500;
         rotY = nRotY;//rotY - (rotateStartY - MousePos.Y) * rotateSpeed * (f32)elapsed/500;
		 if(rotY < -350)
		 {
			 rotY = -350;
			 nRotY = -350;
		 }
		 if(rotY > -280)
		 {
			 rotY = -280;
			 nRotY = -280;
		 }
		 printf("PERA CAMERA:%f\n", rotY);
      }
   }
   else
   {
      if (rotating)
      {
         rotX = rotX - (rotateStartX - MousePos.X) * rotateSpeed * (f32)elapsed/500;
         rotY = rotY - (rotateStartY - MousePos.Y) * rotateSpeed * (f32)elapsed/500;
         nRotX = rotX;
         nRotY = rotY;
      }

      rotating = false;
   }

   //Translate
   if(isMouseButtonDown(MOUSE_BUTTON_RIGHT) && (isKeyDown(KEY_SHIFT) || isKeyDown(KEY_LSHIFT) || isKeyDown(KEY_RSHIFT)))
   {
	    movebymouse = true;
      if (!translating)
      {
         translateStartX = MousePos.X;
         translateStartY = MousePos.Y;
         translating = true;
      }
      else
      {
         translate += tvectX * (translateStartX - MousePos.X) * translateSpeed * (f32)elapsed/100;
         translate.X += tvectX.Z * (translateStartY - MousePos.Y) * translateSpeed * (f32)elapsed/100;
         translate.Z -= tvectX.X * (translateStartY - MousePos.Y) * translateSpeed * (f32)elapsed/100;

         oldTarget = translate;
      }
   }
   else if (isKeyDown(KEY_KEY_W) || isKeyDown(KEY_UP) && !zooming && !isKeyDown(KEY_SHIFT) && !isKeyDown(KEY_LSHIFT) && !isKeyDown(KEY_RSHIFT))
   {
      if (!translating)
         translating = true;
      else
      {
         vector3df movevector = getPosition() - getTarget();
         movevector.Y = 0;
         movevector.normalize();

          translate =getTarget() - movevector * translateSpeed * (f32)elapsed/100;
         oldTarget = translate;
         //setPosition(getPosition() - movevector * translateSpeed * (f32)elapsed/100);
         //setTarget(getTarget() - movevector * translateSpeed * (f32)elapsed/100);
         //updateAbsolutePosition();
      }
   }
   else if (isKeyDown(KEY_KEY_S) || isKeyDown(KEY_DOWN) && !zooming && !isKeyDown(KEY_SHIFT) && !isKeyDown(KEY_LSHIFT) && !isKeyDown(KEY_RSHIFT))
   {
      if (!translating)
         translating = true;
      else
      {
         vector3df movevector = getPosition() - getTarget();
         movevector.Y = 0;
         movevector.normalize();

          translate =getTarget() + movevector * translateSpeed * (f32)elapsed/100;
         oldTarget = translate;
//        setPosition(getPosition() + movevector * translateSpeed * (f32)elapsed/100);
  //       setTarget(getTarget() + movevector * translateSpeed * (f32)elapsed/100);
    //     updateAbsolutePosition();
      }
   }
   else if (isKeyDown(KEY_KEY_A) || isKeyDown(KEY_LEFT) && !zooming && !isKeyDown(KEY_SHIFT) && !isKeyDown(KEY_LSHIFT) && !isKeyDown(KEY_RSHIFT))
   {
      if (!translating)
         translating = true;
      else
      {
         /*translate += tvectX * (translateStartX - MousePos.X) * translateSpeed * (f32)elapsed/100;
         translate.X += tvectX.Z * (translateStartY - MousePos.Y) * translateSpeed * (f32)elapsed/100;
         translate.Z -= tvectX.X * (translateStartY - MousePos.Y) * translateSpeed * (f32)elapsed/100;
*/
          //= translate;


		 vector3df totargetvector = getPosition() - getTarget();
         totargetvector.normalize();
         vector3df crossvector = totargetvector.crossProduct(getUpVector());
         vector3df strafevector = crossvector.normalize();

         translate =getTarget() - strafevector * translateSpeed * (f32)elapsed/100;
         oldTarget = translate;
         //setPosition(getPosition() - strafevector * translateSpeed * (f32)elapsed/100);
         //setTarget(getTarget() - strafevector * translateSpeed * (f32)elapsed/100);
		 //oldTarget = getTarget();
         //updateAbsolutePosition();
      }
   }
   else if (isKeyDown(KEY_KEY_D) || isKeyDown(KEY_RIGHT) && !zooming && !isKeyDown(KEY_SHIFT) && !isKeyDown(KEY_LSHIFT) && !isKeyDown(KEY_RSHIFT))
   {
      if (!translating)
         translating = true;
      else
      {
         vector3df totargetvector = getPosition() - getTarget();
         totargetvector.normalize();
         vector3df crossvector = totargetvector.crossProduct(getUpVector());
         vector3df strafevector = crossvector.normalize();

         translate =getTarget() + strafevector * translateSpeed * (f32)elapsed/100;
         oldTarget = translate;
        //setPosition(getPosition() + strafevector * translateSpeed * (f32)elapsed/100);
         //setTarget(getTarget() + strafevector * translateSpeed * (f32)elapsed/100);
         //updateAbsolutePosition();
      }
   }
   else
   {
      translating = false;

	  /*moving camera when mouse on screen edges*/
      /*if (!translating && !zooming && !rotating)
      {
         //Mouse Coordinates go from 0 to 1 on both axes
         if (MousePos.X < 0.05)   //Up
         {
            vector3df totargetvector = getPosition() - getTarget();
            totargetvector.normalize();
            vector3df crossvector = totargetvector.crossProduct(getUpVector());
            vector3df strafevector = crossvector.normalize();

            setPosition(getPosition() - strafevector * translateSpeed);
            setTarget(getTarget() - strafevector * translateSpeed);
            updateAbsolutePosition();
         }
         else if (MousePos.X > 0.95) //Down
         {
            vector3df totargetvector = getPosition() - getTarget();
            totargetvector.normalize();
            vector3df crossvector = totargetvector.crossProduct(getUpVector());
            vector3df strafevector = crossvector.normalize();

            setPosition(getPosition() + strafevector * translateSpeed);
            setTarget(getTarget() + strafevector * translateSpeed);
            updateAbsolutePosition();
         }
         else if (MousePos.Y < 0.05)   //Up
         {
            vector3df movevector = getPosition() - getTarget();
            movevector.Y = 0;
            movevector.normalize();

            setPosition(getPosition() - movevector * translateSpeed);
            setTarget(getTarget() - movevector * translateSpeed);
            updateAbsolutePosition();
         }
         else if (MousePos.Y > 0.95) //Down
         {
            vector3df movevector = getPosition() - getTarget();
            movevector.Y = 0;
            movevector.normalize();

            setPosition(getPosition() + movevector * translateSpeed);
            setTarget(getTarget() + movevector * translateSpeed);
            updateAbsolutePosition();
         }
      }*/
   }

   //Set Position
   //if(movebymouse)
   //{
		Target = translate;

		Pos.X = nZoom + Target.X;
		Pos.Y = Target.Y;
		Pos.Z = Target.Z;

		Pos.rotateXYBy(nRotY, Target);
		Pos.rotateXZBy(-nRotX, Target);

		//Correct Rotation Error
		UpVector.set(0,1,0);
		UpVector.rotateXYBy(-nRotY, core::vector3df(0,0,0));
		UpVector.rotateXZBy(-nRotX+180.f, core::vector3df(0,0,0));
   //}
}
コード例 #22
0
ファイル: Input.cpp プロジェクト: MarkSkyzoid/ciri
	bool Input::isMouseButtonUp( MouseButton button ) const {
		return !isMouseButtonDown(button);
	}