예제 #1
0
bool InternalWindow::notifyMouseButtonPressed(const Events::MouseButtonPressedEventArgs& e) {
    auto newe = Events::MouseButtonPressedEventArgs(e.getPosition() - Point2f::toVector(getPosition()), e.getButton());
    if (_mouseOver && e.getButton() == SDL_BUTTON_LEFT) {
        if (!_isDragging && _closeButton->contains(newe.getPosition())) {
            AudioSystem::get().playSoundFull(AudioSystem::get().getGlobalSound(GSND_BUTTON_CLICK));
            destroy();
            return true;
        }

        // Bring the window in front of all other windows
        bringToFront();

        // Only the top title bar triggers dragging
        if (_titleBar->contains(newe.getPosition())) {
            _isDragging = true;
            _mouseDragOffset[0] = getX() - e.getPosition().x();
            _mouseDragOffset[1] = getY() - e.getPosition().y();

            // Move the window immediatly
            return notifyMouseMoved(Events::MouseMovedEventArgs(e.getPosition()));
        } else {
            _isDragging = false;
        }
    } else if (e.getButton() == SDL_BUTTON_RIGHT) {
        _isDragging = false;
    }

    return Container::notifyMouseButtonPressed(e);
}
예제 #2
0
bool InternalWindow::notifyMouseClicked(const int button, const int x, const int y)
{
    if(_mouseOver && button == SDL_BUTTON_LEFT)
    {
        //Check if close button is pressed first
        if(_mouseOverCloseButton) {
            AudioSystem::get().playSoundFull(AudioSystem::get().getGlobalSound(GSND_BUTTON_CLICK));
            destroy();
            return true;
        }

        //Bring the window in front of all other windows
        bringToFront();

        //Only the top title bar triggers dragging
        if(_titleBar->contains(x, y)) {
            _isDragging = true;
            _mouseDragOffset[0] = getX() - x;
            _mouseDragOffset[1] = getY() - y;

            //Move the window immediatly
            return notifyMouseMoved(x, y);
        }
        else {
            _isDragging = false;
        }
    }
    else if(button == SDL_BUTTON_RIGHT) {
        _isDragging = false;
    }

    return ComponentContainer::notifyMouseClicked(button, x, y);
}
예제 #3
0
bool Slider::notifyMouseClicked(const int button, const int x, const int y)
{
    if(button == SDL_BUTTON_LEFT && contains(x, y)) {
        _isDragging = true;
        notifyMouseMoved(x, y);
    }
    else {
        _isDragging = false;
    }

    return _isDragging;
}
예제 #4
0
//------------------------------------------
bool  ofCoreEvents::notifyMouseEvent(const ofMouseEventArgs & mouseEvent){
	switch(mouseEvent.type){
		case ofMouseEventArgs::Moved:
			return notifyMouseMoved(mouseEvent.x,mouseEvent.y);
		case ofMouseEventArgs::Dragged:
			return notifyMouseDragged(mouseEvent.x,mouseEvent.y,mouseEvent.button);
		case ofMouseEventArgs::Pressed:
			return notifyMousePressed(mouseEvent.x,mouseEvent.y,mouseEvent.button);
		case ofMouseEventArgs::Released:
			return notifyMouseReleased(mouseEvent.x,mouseEvent.y,mouseEvent.button);
		case ofMouseEventArgs::Scrolled:
			return notifyMouseScrolled(mouseEvent.x,mouseEvent.y,mouseEvent.scrollX,mouseEvent.scrollY);
		case ofMouseEventArgs::Entered:
			return notifyMouseEntered(mouseEvent.x,mouseEvent.y);
		case ofMouseEventArgs::Exited:
			return notifyMouseExited(mouseEvent.x,mouseEvent.y);
	}
	return false;
}
예제 #5
0
파일: window.cpp 프로젝트: maoueh/PHS4700
LRESULT Window::messageHandler(UINT messageId, WPARAM wParameter, LPARAM lParameter)
{
    // TODO Break Down in smaller pieces like keyboardMessageHandler, mouseMessageHandler
    //      and then map key to functions
	switch(messageId)
	{
	  case WM_DESTROY:
      {
          notifyWindowClosed();
          return FALSE;
      }
      case WM_SYSKEYDOWN: // Fall through
      case WM_KEYDOWN:
      {
          notifyKeyPressed(wParameter, LOWORD(lParameter));
          return FALSE;
      }
      case WM_SYSKEYUP: // Fall through
      case WM_KEYUP:
      {
          notifyKeyReleased(wParameter);
          return FALSE;
      }
      case WM_LBUTTONDOWN:
      {
          notifyMousePressed(MOUSE_BUTTON_LEFT, LOWORD(lParameter), HIWORD(lParameter));
          return FALSE;
      }
      case WM_LBUTTONUP:
      {
          notifyMouseReleased(MOUSE_BUTTON_LEFT, LOWORD(lParameter), HIWORD(lParameter));
          return FALSE;
      }
      case WM_LBUTTONDBLCLK:
      {
          notifyMouseDoubleClicked(MOUSE_BUTTON_LEFT, LOWORD(lParameter), HIWORD(lParameter));
          return FALSE;
      }
      case WM_MBUTTONDOWN:
      {
          notifyMousePressed(MOUSE_BUTTON_MIDDLE, LOWORD(lParameter), HIWORD(lParameter));
          return FALSE;
      }
      case WM_MBUTTONUP:
      {
          notifyMouseReleased(MOUSE_BUTTON_MIDDLE, LOWORD(lParameter), HIWORD(lParameter));
          return FALSE;
      }
      case WM_MBUTTONDBLCLK:
      {
          notifyMouseDoubleClicked(MOUSE_BUTTON_MIDDLE, LOWORD(lParameter), HIWORD(lParameter));
          return FALSE;
      }
      case WM_RBUTTONDOWN:
      {
          notifyMousePressed(MOUSE_BUTTON_RIGHT, LOWORD(lParameter), HIWORD(lParameter));
          return FALSE;
      }
      case WM_RBUTTONUP:
      {
          notifyMouseReleased(MOUSE_BUTTON_RIGHT, LOWORD(lParameter), HIWORD(lParameter));
          return FALSE;
      }
      case WM_RBUTTONDBLCLK:
      {
          notifyMouseDoubleClicked(MOUSE_BUTTON_RIGHT, LOWORD(lParameter), HIWORD(lParameter));
          return FALSE;
      }
      case WM_MOUSEWHEEL:
      {
          notifyMouseWheel(LOWORD(lParameter), HIWORD(lParameter), GET_WHEEL_DELTA_WPARAM(wParameter));
          return FALSE;
      }
      case WM_MOUSEMOVE:
      {
          notifyMouseMoved(LOWORD(lParameter), HIWORD(lParameter));
          return FALSE;
      }
      case WM_SIZE:
      {
          mWidth = LOWORD(lParameter);
          mHeight = HIWORD(lParameter);
          notifyWindowResized();
          return FALSE;
      }
	}

    return DefWindowProc( mHandle, messageId, wParameter, lParameter );
}