示例#1
0
//virtual
BOOL LLMouseHandler::handleAnyMouseClick(S32 x, S32 y, MASK mask, EClickType clicktype, BOOL down)
{
	BOOL handled = FALSE;
	if (down)
	{
		switch (clicktype)
		{
		case CLICK_LEFT: handled = handleMouseDown(x, y, mask); break;
		case CLICK_RIGHT: handled = handleRightMouseDown(x, y, mask); break;
		case CLICK_MIDDLE: handled = handleMiddleMouseDown(x, y, mask); break;
		case CLICK_DOUBLELEFT: handled = handleDoubleClick(x, y, mask); break;
		default:
			llwarns << "Unhandled enum." << llendl;
		}
	}
	else
	{
		switch (clicktype)
		{
		case CLICK_LEFT: handled = handleMouseUp(x, y, mask); break;
		case CLICK_RIGHT: handled = handleRightMouseUp(x, y, mask); break;
		case CLICK_MIDDLE: handled = handleMiddleMouseUp(x, y, mask); break;
		case CLICK_DOUBLELEFT: handled = handleDoubleClick(x, y, mask); break;
		default:
			llwarns << "Unhandled enum." << llendl;
		}
	}
	return handled;
}
示例#2
0
void TetrisState::handleInput(Tetris & tetris, SDL_Event e)
{
	switch (e.type) {
	case SDL_MOUSEBUTTONDOWN:
		handleMouseDown(tetris, e);
		break;
	case SDL_MOUSEBUTTONUP:
		handleMouseUp(tetris, e);
		break;
	case SDL_KEYDOWN:
		handleKeyDown(tetris, e);
		break;
	case SDL_KEYUP:
		handleKeyUp(tetris, e);
		break;
	default:
		break;
	}
}
示例#3
0
extern "C" int SDL_main(int, char **)  // 2-arg form is required by SDL
{
    if (!sdlInit(250, 140, "../img/icon.png", "Music Test")) {
        return EXIT_FAILURE;
    }

    SdlSurface play = sdlLoadImage("../img/button-play.png");
    SdlSurface pause = sdlLoadImage("../img/button-pause.png");
    SdlSurface next = sdlLoadImage("../img/button-next.png");
    SdlSurface prev = sdlLoadImage("../img/button-prev.png");

    // Define the control buttons.
    GuiButton playButton{105, 90, play};
    GuiButton nextTrack{155, 90, next};
    GuiButton prevTrack{55, 90, prev};
    std::vector<GuiButton *> buttons = {&playButton, &nextTrack, &prevTrack};

    auto font = sdlLoadFont("../DejaVuSans.ttf", 14);
    auto white = SDL_Color{255, 255, 255, 0};
    sdlDrawText(font, "Now playing:", SDL_Rect{10, 10, 230, 20}, white);

    auto trackTitle = SDL_Rect{10, 30, 230, 50};
    sdlDrawText(font, "Nothing", trackTitle, white);

    SDL_UpdateRect(screen, 0, 0, 0, 0);

    auto musicFiles = getMusicFiles("../music");
    assert(!musicFiles.empty());

    int trackNum = 0;

    playButton.onClick([&] {
        if (!Mix_PlayingMusic()) {  // have we started playing music at all
            auto &track = musicFiles[trackNum];
            sdlPlayMusic(track.music);
            playButton.setImage(pause);
            sdlDrawText(font, track.path, trackTitle, white);
        }
        else {
            if (Mix_PausedMusic()) {
                playButton.setImage(pause);
                Mix_ResumeMusic();
            }
            else {
                playButton.setImage(play);
                Mix_PauseMusic();
            }
        }
    });

    nextTrack.onClick([&] {
        if (!Mix_PlayingMusic()) return;

        trackNum = (trackNum + 1) % musicFiles.size();
        auto &track = musicFiles[trackNum];
        sdlDrawText(font, track.path, trackTitle, white);
        if (Mix_PausedMusic()) {
            sdlPlayMusic(track.music);
            Mix_PauseMusic();
        }
        else {
            sdlPlayMusic(track.music);
        }
    });

    prevTrack.onClick([&] {
        if (!Mix_PlayingMusic()) return;

        trackNum = (trackNum - 1) % musicFiles.size();
        auto &track = musicFiles[trackNum];
        sdlDrawText(font, track.path, trackTitle, white);
        if (Mix_PausedMusic()) {
            sdlPlayMusic(track.music);
            Mix_PauseMusic();
        }
        else {
            sdlPlayMusic(track.music);
        }
    });

    bool isDone = false;
    SDL_Event event;
    while (!isDone) {
        while (SDL_PollEvent(&event)) {
            if (event.type == SDL_MOUSEBUTTONUP) {
                handleMouseUp(event.button, buttons);
            }
            else if (event.type == SDL_QUIT) {
                Mix_HaltMusic();
                isDone = true;
            }
        }

        SDL_UpdateRect(screen, 0, 0, 0, 0);
        SDL_Delay(1);
    }

    return EXIT_SUCCESS;
}
bool WebPopupMenuImpl::handleInputEvent(const WebInputEvent& inputEvent)
{
    if (!m_widget)
        return false;

    // FIXME: WebKit seems to always return false on mouse events methods. For
    // now we'll assume it has processed them (as we are only interested in
    // whether keyboard events are processed).
    switch (inputEvent.type) {
    case WebInputEvent::MouseMove:
        handleMouseMove(static_cast<const WebMouseEvent&>(inputEvent));
        return true;

    case WebInputEvent::MouseLeave:
        handleMouseLeave(static_cast<const WebMouseEvent&>(inputEvent));
        return true;

    case WebInputEvent::MouseWheel:
        handleMouseWheel(static_cast<const WebMouseWheelEvent&>(inputEvent));
        return true;

    case WebInputEvent::MouseDown:
        handleMouseDown(static_cast<const WebMouseEvent&>(inputEvent));
        return true;

    case WebInputEvent::MouseUp:
        handleMouseUp(static_cast<const WebMouseEvent&>(inputEvent));
        return true;

    // In Windows, RawKeyDown only has information about the physical key, but
    // for "selection", we need the information about the character the key
    // translated into. For English, the physical key value and the character
    // value are the same, hence, "selection" works for English. But for other
    // languages, such as Hebrew, the character value is different from the
    // physical key value. Thus, without accepting Char event type which
    // contains the key's character value, the "selection" won't work for
    // non-English languages, such as Hebrew.
    case WebInputEvent::RawKeyDown:
    case WebInputEvent::KeyDown:
    case WebInputEvent::KeyUp:
    case WebInputEvent::Char:
        return handleKeyEvent(static_cast<const WebKeyboardEvent&>(inputEvent));

    case WebInputEvent::TouchStart:
    case WebInputEvent::TouchMove:
    case WebInputEvent::TouchEnd:
    case WebInputEvent::TouchCancel:
        return handleTouchEvent(static_cast<const WebTouchEvent&>(inputEvent));

    case WebInputEvent::GestureScrollBegin:
    case WebInputEvent::GestureScrollEnd:
    case WebInputEvent::GestureScrollUpdate:
    case WebInputEvent::GestureFlingStart:
    case WebInputEvent::GestureFlingCancel:
    case WebInputEvent::GestureTap:
    case WebInputEvent::GestureTapUnconfirmed:
    case WebInputEvent::GestureTapDown:
    case WebInputEvent::GestureShowPress:
    case WebInputEvent::GestureTapCancel:
    case WebInputEvent::GestureDoubleTap:
    case WebInputEvent::GestureTwoFingerTap:
    case WebInputEvent::GestureLongPress:
    case WebInputEvent::GestureLongTap:
    case WebInputEvent::GesturePinchBegin:
    case WebInputEvent::GesturePinchEnd:
    case WebInputEvent::GesturePinchUpdate:
        return handleGestureEvent(static_cast<const WebGestureEvent&>(inputEvent));

    case WebInputEvent::Undefined:
    case WebInputEvent::MouseEnter:
    case WebInputEvent::ContextMenu:
        return false;
    }
    return false;
}
示例#5
0
BOOL LLToolCompScale::handleMiddleMouseUp(S32 x, S32 y, MASK mask)
{
	LLToolCompScale::getInstance()->mManip->handleMiddleMouseUp(x,y,mask);
	return handleMouseUp(x,y,mask);
}
示例#6
0
/*!
 * Handles the mouse up event.
 * \param x X screen coordinate
 * \param y Y screen coordinate
 * \param button What button was released
 * \param modKeys State of all modifier keys
 */
void Menu::mouseUpEvent(int x, int y, int button, const int modKeys)
{
    handleMouseUp(x, y, button, modKeys);
}
示例#7
0
void Menu::mouseUpEvent(int x, int y, int button)
{
    handleMouseUp(x, y, button);
}