コード例 #1
0
ファイル: InternalWindow.cpp プロジェクト: dreamsxin/egoboo
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
ファイル: InternalWindow.cpp プロジェクト: italoalesil/egoboo
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
ファイル: Slider.cpp プロジェクト: italoalesil/egoboo
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 );
}