Пример #1
0
bool slider::touch(int x, int y, touch_action action)
{
    system * sys = get_system();

    math::vec2 pos = global_position();

    if((pos.x < x && x < pos.x + get_size().x &&
       (pos.y < y && y < pos.y + get_size().y)))
    {
        if(action == touch_action::DOWN)
        {
            sys->capture(this);
            return true;
        }
    }

    if(sys->capture_test(this))
    {
        if(action == touch_action::UP)
        {
            sys->capture_release();
        }
        else if(action == touch_action::MOVE)
        {
            const float value = (math::clamp(x, pos.x, pos.x + get_size().x) - pos.x) / get_size().x;
            model_->set_value(value);
        }
        return true;
    }
    return false;
}
Пример #2
0
void slider::draw()
{
    EPS_STATE_BLEND(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    math::vec2 pos = global_position();
    const float value = model_->get_value();

    draw_slider_end(pos, value);
    draw_slider_begin(pos, value);
    draw_tracker(pos, value);
}
Пример #3
0
bool Button::mouse_down(ci::app::MouseEvent evt) {
    ci::Rectf global = rect_;
    global.offset(global_position());

    if (global.contains(evt.getPos())) {
        pressed_ = true;
        send_press_events();
    }

    return false;
}
Пример #4
0
void QNitpickerPlatformWindow::_process_mouse_event(Input::Event *ev)
{
	QPoint global_position(ev->ax(), ev->ay());
	QPoint local_position(global_position.x() - geometry().x(),
			              global_position.y() - geometry().y());

	//qDebug() << "local_position =" << local_position;
	//qDebug() << "global_position =" << global_position;

	switch (ev->type()) {

		case Input::Event::PRESS:

			if (qnpw_verbose)
				PDBG("PRESS");

			/* make this window the focused window */
			requestActivateWindow();

			switch (ev->code()) {
				case Input::BTN_LEFT:
					_mouse_button_state |= Qt::LeftButton;
					break;
				case Input::BTN_RIGHT:
					_mouse_button_state |= Qt::RightButton;
					break;
				case Input::BTN_MIDDLE:
					_mouse_button_state |= Qt::MidButton;
					break;
				case Input::BTN_SIDE:
					_mouse_button_state |= Qt::XButton1;
					break;
				case Input::BTN_EXTRA:
					_mouse_button_state |= Qt::XButton2;
					break;
			}
			break;

		case Input::Event::RELEASE:

			if (qnpw_verbose)
				PDBG("RELEASE");

			switch (ev->code()) {
				case Input::BTN_LEFT:
					_mouse_button_state &= ~Qt::LeftButton;
					break;
				case Input::BTN_RIGHT:
					_mouse_button_state &= ~Qt::RightButton;
					break;
				case Input::BTN_MIDDLE:
					_mouse_button_state &= ~Qt::MidButton;
					break;
				case Input::BTN_SIDE:
					_mouse_button_state &= ~Qt::XButton1;
					break;
				case Input::BTN_EXTRA:
					_mouse_button_state &= ~Qt::XButton2;
					break;
			}
			break;

		case Input::Event::WHEEL:

			if (qnpw_verbose)
				PDBG("WHEEL");

			QWindowSystemInterface::handleWheelEvent(window(),
					                                 local_position,
					                                 local_position,
					                                 ev->ry() * 120,
					                                 Qt::Vertical);
			return;

		default:
			break;
	}

	QWindowSystemInterface::handleMouseEvent(window(),
			                                 local_position,
			                                 global_position,
			                                 _mouse_button_state);
}
Пример #5
0
void QNitpickerPlatformWindow::_process_mouse_event(Input::Event const &ev)
{
	QPoint global_position(ev.ax(), ev.ay());
	QPoint local_position(global_position.x() - geometry().x(),
			              global_position.y() - geometry().y());

	switch (ev.type()) {

		case Input::Event::PRESS:

			/* make this window the focused window */
			requestActivateWindow();

			switch (ev.code()) {
				case Input::BTN_LEFT:
					_mouse_button_state |= Qt::LeftButton;
					break;
				case Input::BTN_RIGHT:
					_mouse_button_state |= Qt::RightButton;
					break;
				case Input::BTN_MIDDLE:
					_mouse_button_state |= Qt::MidButton;
					break;
				case Input::BTN_SIDE:
					_mouse_button_state |= Qt::XButton1;
					break;
				case Input::BTN_EXTRA:
					_mouse_button_state |= Qt::XButton2;
					break;
			}
			break;

		case Input::Event::RELEASE:

			switch (ev.code()) {
				case Input::BTN_LEFT:
					_mouse_button_state &= ~Qt::LeftButton;
					break;
				case Input::BTN_RIGHT:
					_mouse_button_state &= ~Qt::RightButton;
					break;
				case Input::BTN_MIDDLE:
					_mouse_button_state &= ~Qt::MidButton;
					break;
				case Input::BTN_SIDE:
					_mouse_button_state &= ~Qt::XButton1;
					break;
				case Input::BTN_EXTRA:
					_mouse_button_state &= ~Qt::XButton2;
					break;
			}
			break;

		case Input::Event::WHEEL:

			QWindowSystemInterface::handleWheelEvent(window(),
					                                 local_position,
					                                 local_position,
					                                 ev.ry() * 120,
					                                 Qt::Vertical);
			return;

		default:
			break;
	}

	QWindowSystemInterface::handleMouseEvent(window(),
			                                 local_position,
			                                 global_position,
			                                 _mouse_button_state);
}