Пример #1
0
//! Connects to mouseDown, mouseDrag, mouseWheel and resize signals of \a window, with optional priority \a signalPriority
void CameraUi::connect( const app::WindowRef &window, int signalPriority )
{
	mWindow = window;
	mSignalPriority = signalPriority;
	if( window ) {
		mMouseDownConnection = window->getSignalMouseDown().connect( signalPriority,
			[this]( app::MouseEvent &event ) { mouseDown( event ); } );
		mMouseUpConnection = window->getSignalMouseUp().connect( signalPriority,
			[this]( app::MouseEvent &event ) { mouseUp( event ); } );
		mMouseDragConnection = window->getSignalMouseDrag().connect( signalPriority,
			[this]( app::MouseEvent &event ) { mouseDrag( event ); } );
		mMouseWheelConnection = window->getSignalMouseWheel().connect( signalPriority,
			[this]( app::MouseEvent &event ) { mouseWheel( event ); } );
		mWindowResizeConnection = window->getSignalResize().connect( signalPriority,
			[this]() {
				setWindowSize( mWindow->getSize() );
				if( mCamera )
					mCamera->setAspectRatio( mWindow->getAspectRatio() );
			}
		);
	}
	else
		disconnect();
		
	mLastAction = ACTION_NONE;
}
Пример #2
0
void mouseWheel_Aux(GLFWwindow* pWindow, double x, double y)
{
#ifdef USE_ANTTWEAKBAR
    int ant = TwEventMouseWheelGLFW(static_cast<int>(x));
    if (ant != 0)
        return;
#endif
    mouseWheel(pWindow, x, y);
}
Пример #3
0
//-----------------------------------------------------------------------
bool Window::Update()
{
	SDL_Event event;
	while ( SDL_PollEvent(&event) )
	{
		switch ( event.type )
		{
			// ќбщие событи¤
		case SDL_QUIT:
			SDL_Quit();
			return false;
			// —обыти¤ мыши
		case SDL_MOUSEBUTTONUP:
			eventMouse(GetMouseButton(event.button.button), false, event.button.x, event.button.y);
			break;
		case SDL_MOUSEBUTTONDOWN:
			eventMouse(GetMouseButton(event.button.button), true, event.button.x, event.button.y);
			break;
		case SDL_MOUSEMOTION:
			eventCursor(event.motion.x, event.motion.y, event.motion.xrel, event.motion.yrel);
			break;
		case SDL_MOUSEWHEEL:
			mouseWheel(event.wheel.x, event.button.x, event.button.y); // TODO: ? может не x?
			break;
			// —обыти¤ клавиатуры
		case SDL_KEYDOWN:
			eventKey((KEYS)(event.key.keysym.sym), L'', true);
			break;
		case SDL_KEYUP:
			eventKey((KEYS)(event.key.keysym.sym), L'', false);
			break;
		}

		// —обыти¤ окна
		if ( event.type == SDL_WINDOWEVENT )
		{
			switch ( event.window.event )
			{
				// событие изменени¤ размера окна
			case SDL_WINDOWEVENT_SIZE_CHANGED:
				if ( m_newWidth != event.window.data1 || m_newHeight != event.window.data2 )
				{
					m_isResize = true;
					m_newWidth = event.window.data1;
					m_newHeight = event.window.data2;
					m_desc.Size.X = m_newWidth;
					m_desc.Size.Y = m_newHeight;
				}
				break;
			}
		}
	}

	return true;
}
void mouseWheel_Aux(GLFWwindow* pWindow, double x, double y)
{
#ifdef USE_ANTTWEAKBAR
    static int scrollpos = 0;
    scrollpos += static_cast<int>(y);
    int ant = TwEventMouseWheelGLFW(scrollpos);
    if (ant != 0)
        return;
#endif
    mouseWheel(pWindow, x, y);
}
Пример #5
0
ServerProxy::EResult
ServerProxy::parseMessage(const UInt8* code)
{
	if (memcmp(code, kMsgDMouseMove, 4) == 0) {
		mouseMove();
	}

	else if (memcmp(code, kMsgDMouseRelMove, 4) == 0) {
		mouseRelativeMove();
	}

	else if (memcmp(code, kMsgDMouseWheel, 4) == 0) {
		mouseWheel();
	}

	else if (memcmp(code, kMsgDKeyDown, 4) == 0) {
		keyDown();
	}

	else if (memcmp(code, kMsgDKeyUp, 4) == 0) {
		keyUp();
	}

	else if (memcmp(code, kMsgDMouseDown, 4) == 0) {
		mouseDown();
	}

	else if (memcmp(code, kMsgDMouseUp, 4) == 0) {
		mouseUp();
	}

	else if (memcmp(code, kMsgDKeyRepeat, 4) == 0) {
		keyRepeat();
	}

	else if (memcmp(code, kMsgCKeepAlive, 4) == 0) {
		// echo keep alives and reset alarm
		ProtocolUtil::writef(m_stream, kMsgCKeepAlive);
		resetKeepAliveAlarm();
	}

	else if (memcmp(code, kMsgCNoop, 4) == 0) {
		// accept and discard no-op
	}

	else if (memcmp(code, kMsgCEnter, 4) == 0) {
		enter();
	}

	else if (memcmp(code, kMsgCLeave, 4) == 0) {
		leave();
	}

	else if (memcmp(code, kMsgCClipboard, 4) == 0) {
		grabClipboard();
	}

	else if (memcmp(code, kMsgCScreenSaver, 4) == 0) {
		screensaver();
	}

	else if (memcmp(code, kMsgQInfo, 4) == 0) {
		queryInfo();
	}

	else if (memcmp(code, kMsgCInfoAck, 4) == 0) {
		infoAcknowledgment();
	}

	else if (memcmp(code, kMsgDClipboard, 4) == 0) {
		setClipboard();
	}

	else if (memcmp(code, kMsgCResetOptions, 4) == 0) {
		resetOptions();
	}

	else if (memcmp(code, kMsgDSetOptions, 4) == 0) {
		setOptions();
	}

	else if (memcmp(code, kMsgDFileTransfer, 4) == 0) {
		fileChunkReceived();
	}
	else if (memcmp(code, kMsgDDragInfo, 4) == 0) {
		dragInfoReceived();
	}

	else if (memcmp(code, kMsgCClose, 4) == 0) {
		// server wants us to hangup
		LOG((CLOG_DEBUG1 "recv close"));
		m_client->disconnect(NULL);
		return kDisconnect;
	}
	else if (memcmp(code, kMsgEBad, 4) == 0) {
		LOG((CLOG_ERR "server disconnected due to a protocol error"));
		m_client->disconnect("server reported a protocol error");
		return kDisconnect;
	}
	else {
		return kUnknown;
	}

	// send a reply.  this is intended to work around a delay when
	// running a linux server and an OS X (any BSD?) client.  the
	// client waits to send an ACK (if the system control flag
	// net.inet.tcp.delayed_ack is 1) in hopes of piggybacking it
	// on a data packet.  we provide that packet here.  i don't
	// know why a delayed ACK should cause the server to wait since
	// TCP_NODELAY is enabled.
	ProtocolUtil::writef(m_stream, kMsgCNoop);

	return kOkay;
}
Пример #6
0
  const SUCCESS Events::handleEvent(const SDL_Event * const Event)
  {
    switch(Event->type)
    {  //newline brackets implemented since this is a lot of nesting
    case SDL_WINDOWEVENT: ///Some sort of input or output gained or lost
      {
        const Uint8 &winID = Event->window.windowID;
        switch(Event->window.event) 
        {
        case SDL_WINDOWEVENT_ENTER:   ///Mouse message handling gained or lost
          return mouseEnter(winID);
          
        case SDL_WINDOWEVENT_LEAVE:   ///General input message handling gained or lost
          return mouseLeave(winID);

        case SDL_WINDOWEVENT_MINIMIZED:   ///Output to the screen at all gained or lost
          return minimized(winID);
          
        case SDL_WINDOWEVENT_RESTORED:
          return restored(winID);
          
        case SDL_WINDOWEVENT_MAXIMIZED:
          return maximized(winID);
          
        case SDL_WINDOWEVENT_SHOWN:
          return shown(winID);
          
        case SDL_WINDOWEVENT_HIDDEN:
          return hidden(winID);
          
        case SDL_WINDOWEVENT_EXPOSED:
          return exposed(winID);
          
        case SDL_WINDOWEVENT_FOCUS_GAINED:
          return keyboardFocusGain(winID);
          
        case SDL_WINDOWEVENT_FOCUS_LOST:
          return keyboardFocusLost(winID);
          
        case SDL_WINDOWEVENT_SIZE_CHANGED:
            return changeSize(winID);
            
        case SDL_WINDOWEVENT_RESIZED:
          return resized(winID, Dimensions<int>(Event->window.data1, Event->window.data2));
          
        case SDL_WINDOWEVENT_MOVED:
          return moved(winID, Point<int>(Event->window.data1, Event->window.data2));
          
        case SDL_WINDOWEVENT_CLOSE:
          return windowExited(winID);
          
        default:   ///For some reason there is an unknown window event
          return FAILED;
        }
        break;
      }
    case SDL_KEYDOWN:
      {
        if(Event->key.repeat)
        {
          return keyHeld(Event->key.windowID, Event->key.keysym);
        }
        else
        {
          return keyPressed(Event->key.windowID, Event->key.keysym);
        }
        break;
      }
    case SDL_KEYUP:
        return keyReleased(Event->key.windowID, Event->key.keysym);
        
    case SDL_TEXTINPUT:
        return textInput(Event->text.windowID, Event->text.text);
        
    case SDL_TEXTEDITING:
        return textEdit(Event->edit.windowID, Event->edit.text, Event->edit.start, Event->edit.length);
        
    case SDL_MOUSEMOTION:
      return mouseMove(Event->motion.windowID, Event->motion.which,
                       Delta<Point<int> >(Point<int>(Event->motion.xrel, Event->motion.yrel), 
                                          Point<int>(Event->motion.x, Event->motion.y)),
                       bitset<N_MOUSE_BUTTONS>(Event->motion.state));
                       
    case SDL_MOUSEBUTTONDOWN:
      return mouseButtonPressed(Event->button.windowID, Event->button.which, Event->button.button, Event->button.clicks,
                                Point<int>(Event->button.x, Event->button.y));
      
    case SDL_MOUSEBUTTONUP:
        return mouseButtonReleased(Event->button.windowID, Event->button.which, Event->button.button, Event->button.clicks,
                                  Point<int>(Event->button.x, Event->button.y));
     
    case SDL_MOUSEWHEEL:
        return mouseWheel(Event->wheel.windowID, Event->wheel.which, Point<int>(Event->wheel.x, Event->wheel.y));
        
    case SDL_JOYAXISMOTION:
      return joyAxis(Event->jaxis.which, Event->jaxis.axis, Event->jaxis.value);
    
    case SDL_JOYBUTTONDOWN:
      return joyButtonPressed(Event->jbutton.which, Event->jbutton.button);
      
    case SDL_JOYBUTTONUP:
      return joyButtonReleased(Event->jbutton.which, Event->jbutton.button);
      
    case SDL_JOYHATMOTION:
      return joyHatChange(Event->jhat.which, Event->jhat.hat, Event->jhat.value);
        
    case SDL_JOYBALLMOTION:
      return joyBallMove(Event->jball.which, Event->jball.ball, Point<int>(Event->jball.xrel, Event->jball.yrel));
      
    case SDL_DROPFILE:
    {
      const SUCCESS ret = droppedFile(Event->drop.file);
      SDL_free(Event->drop.file);
      return ret;
    }
      
    case SDL_SYSWMEVENT:
      return unhandledSystemEvent(Event->syswm.msg);
     
    case SDL_QUIT:
      return appExited();
        
    case SDL_USEREVENT:
    default:
      {
        return userEvent(Event->user.windowID, Event->user.code, Event->user.data1, Event->user.data2);
      }
    }

    return FAILED;
  }
Пример #7
0
bool EventHandler::handleEvent(SDL_Event &event) {
	switch (event.type) {
	case SDL_TEXTINPUT:
		textInput(std::string(event.text.text));
		break;
	case SDL_KEYUP:
		keyRelease((int32_t) event.key.keysym.sym);
		break;
	case SDL_KEYDOWN:
		// we are handling this on our own
		if (!event.key.repeat)
			keyPress((int32_t) event.key.keysym.sym, (int16_t) event.key.keysym.mod);
		break;
	case SDL_MOUSEMOTION: {
		if (event.motion.which == SDL_TOUCH_MOUSEID)
			break;
		SDL_Window *window = SDL_GetWindowFromID(event.motion.windowID);
		if (!(SDL_GetWindowFlags(window) & SDL_WINDOW_INPUT_FOCUS))
			break;
		mouseMotion(event.motion.x, event.motion.y, event.motion.xrel, event.motion.yrel);
		break;
	}
	case SDL_MOUSEBUTTONDOWN:
		if (event.button.which == SDL_TOUCH_MOUSEID)
			break;
		mouseButtonPress(event.button.x, event.button.y, event.button.button);
		break;
	case SDL_MOUSEBUTTONUP:
		if (event.button.which == SDL_TOUCH_MOUSEID)
			break;
		mouseButtonRelease(event.button.x, event.button.y, event.button.button);
		break;
	case SDL_MOUSEWHEEL:
		if (event.wheel.which == SDL_TOUCH_MOUSEID)
			break;
		mouseWheel(event.wheel.x, event.wheel.y);
		break;
	case SDL_CONTROLLERAXISMOTION: {
		const uint8_t axis = event.caxis.axis;
		if (axis != SDL_CONTROLLER_AXIS_LEFTX && axis != SDL_CONTROLLER_AXIS_LEFTY && axis != SDL_CONTROLLER_AXIS_RIGHTX && axis != SDL_CONTROLLER_AXIS_RIGHTY)
			break;
		const bool horizontal = (axis == SDL_CONTROLLER_AXIS_LEFTX || axis == SDL_CONTROLLER_AXIS_RIGHTX);
		joystickMotion(horizontal, event.caxis.value);
		break;
	}
	case SDL_CONTROLLERBUTTONDOWN:
		controllerButtonPress(getControllerButtonName(event.cbutton.button));
		break;
	case SDL_CONTROLLERBUTTONUP:
		controllerButtonRelease(getControllerButtonName(event.cbutton.button));
		break;
	case SDL_CONTROLLERDEVICEADDED:
		joystickDeviceAdded(event.cdevice.which);
		break;
	case SDL_CONTROLLERDEVICEREMOVED:
		joystickDeviceRemoved(event.cdevice.which);
		break;
	case SDL_JOYDEVICEADDED:
		joystickDeviceAdded(event.jdevice.which);
		break;
	case SDL_JOYDEVICEREMOVED:
		joystickDeviceRemoved(event.jdevice.which);
		break;
	case SDL_DOLLARRECORD:
		gestureRecord(event.dgesture.gestureId);
		break;
	case SDL_DOLLARGESTURE:
		gesture(event.dgesture.gestureId, event.dgesture.error, event.dgesture.numFingers);
		break;
	case SDL_MULTIGESTURE:
		multiGesture(event.mgesture.dTheta, event.mgesture.dDist, event.mgesture.numFingers);
		break;
	case SDL_JOYHATMOTION:
		break;
	case SDL_JOYBUTTONDOWN:
		joystickButtonPress(event.jbutton.button);
		break;
	case SDL_JOYBUTTONUP:
		joystickButtonRelease(event.jbutton.button);
		break;
	case SDL_JOYAXISMOTION:
		joystickMotion(event.jaxis.axis == 0, event.jaxis.value);
		break;
	case SDL_FINGERDOWN:
		fingerPress(event.tfinger.fingerId, event.tfinger.x, event.tfinger.y);
		break;
	case SDL_FINGERUP:
		fingerRelease(event.tfinger.fingerId, event.tfinger.x, event.tfinger.y);
		break;
	case SDL_FINGERMOTION:
		fingerMotion(event.tfinger.fingerId, event.tfinger.x, event.tfinger.y, event.tfinger.dx, event.tfinger.dy);
		break;
	case SDL_WINDOWEVENT:
		switch (event.window.event) {
		case SDL_WINDOWEVENT_RESIZED:
		case SDL_WINDOWEVENT_SIZE_CHANGED:
			for (EventObservers::iterator i = _observers.begin(); i != _observers.end(); ++i) {
				(*i)->onWindowResize();
			}
			break;
		case SDL_WINDOWEVENT_CLOSE:
			return false;
		}
		break;
	}
	return true;
}
Пример #8
0
int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: SendTotalSamples((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 1: on_butAppBck_clicked(); break;
        case 2: on_butRefresh_clicked(); break;
        case 3: on_butStop_clicked(); break;
        case 4: on_butStart_clicked(); break;
        case 5: on_butZoomIn_clicked(); break;
        case 6: on_butZoomOut_clicked(); break;
        case 7: on_butExit_clicked(); break;
        case 8: on_butRemoveAll_clicked(); break;
        case 9: on_butRemoveSelected_clicked(); break;
        case 10: on_butSine_clicked(); break;
        case 11: on_butSquare_clicked(); break;
        case 12: on_butTriangle_clicked(); break;
        case 13: on_butSawtooth_clicked(); break;
        case 14: on_butPulse_clicked(); break;
        case 15: on_butRandom_clicked(); break;
        case 16: on_butMergeAll_clicked(); break;
        case 17: on_actionZoom_Out_triggered(); break;
        case 18: on_actionZoomin_triggered(); break;
        case 19: on_actionRemove_Selected_triggered(); break;
        case 20: on_actionRemove_All_triggered(); break;
        case 21: on_actionRandom_triggered(); break;
        case 22: on_actionMerge_All_triggered(); break;
        case 23: on_actionPulse_triggered(); break;
        case 24: on_actionSAwtooth_triggered(); break;
        case 25: on_actionTriangle_triggered(); break;
        case 26: on_actionSquare_triggered(); break;
        case 27: on_actionSine_triggered(); break;
        case 28: titleDoubleClick((*reinterpret_cast< QMouseEvent*(*)>(_a[1])),(*reinterpret_cast< QCPPlotTitle*(*)>(_a[2]))); break;
        case 29: axisLabelDoubleClick((*reinterpret_cast< QCPAxis*(*)>(_a[1])),(*reinterpret_cast< QCPAxis::SelectablePart(*)>(_a[2]))); break;
        case 30: legendDoubleClick((*reinterpret_cast< QCPLegend*(*)>(_a[1])),(*reinterpret_cast< QCPAbstractLegendItem*(*)>(_a[2]))); break;
        case 31: selectionChanged(); break;
        case 32: mousePress(); break;
        case 33: mouseWheel(); break;
        case 34: addRandomGraph(); break;
        case 35: addSineGraph(); break;
        case 36: addSquareGraph(); break;
        case 37: addTriangleGraph(); break;
        case 38: addSawtoothGraph(); break;
        case 39: addPulseGraph(); break;
        case 40: removeSelectedGraph(); break;
        case 41: removeAllGraphs(); break;
        case 42: contextMenuRequest((*reinterpret_cast< QPoint(*)>(_a[1]))); break;
        case 43: moveLegend(); break;
        case 44: graphClicked((*reinterpret_cast< QCPAbstractPlottable*(*)>(_a[1]))); break;
        case 45: receiveValue((*reinterpret_cast< double(*)>(_a[1]))); break;
        case 46: receiveValue((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 47: receiveValue((*reinterpret_cast< uint(*)>(_a[1]))); break;
        case 48: callLineEditInput((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 49: openWaveDataWindow(); break;
        case 50: RxSamples((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 51: RxStartTick((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 52: RxStopTick((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 53: RxDutyCycle((*reinterpret_cast< int(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 54;
    }
    return _id;
}
Пример #9
0
int SDLApp::run() {

#ifdef USE_X11
    SDLApp::initX11ClipboardEventFilter();
#endif

    Uint32 msec=0, last_msec=0, buffer_msec=0, total_msec = 0;

    frame_count = 0;
    fps_updater = 0;

    if(!appFinished) init();

    msec = SDL_GetTicks();
    last_msec = msec;

    while(!appFinished) {
        last_msec = msec;
        msec      = SDL_GetTicks();

        Uint32 delta_msec = msec - last_msec;

        // cant have delta ticks be less than 8ms
        buffer_msec += delta_msec;
        if(buffer_msec < min_delta_msec) {
            SDL_Delay(1);
            continue;
        }

        delta_msec = buffer_msec;
        buffer_msec =0;

        //determine time elapsed since last time we were here
        total_msec += delta_msec;

        float t  = total_msec / 1000.0f;
        float dt = delta_msec / 1000.0f;

        fps_updater += delta_msec;

        //update framerate if a second has passed
        if (fps_updater >= 1000) {
            updateFramerate();
        }

        //process new events
        SDL_Event event;
        while ( SDL_PollEvent(&event) ) {

            switch(event.type) {
                case SDL_QUIT:
                    quit();
                    break;

                case SDL_MOUSEMOTION:
                    mouseMove(&event.motion);
                    break;

#if SDL_VERSION_ATLEAST(1,3,0)
                case SDL_MOUSEWHEEL:
                    mouseWheel(&event.wheel);
                    break;

		case SDL_WINDOWEVENT:
		    if(event.window.event == SDL_WINDOWEVENT_RESIZED) {
			resize(event.window.data1, event.window.data2);
		    }
                    break;
#else
                case SDL_VIDEORESIZE:
                    resize(event.resize.w, event.resize.h);
                    break;
#endif

                case SDL_MOUSEBUTTONDOWN:
                    mouseClick(&event.button);
                    break;

                case SDL_MOUSEBUTTONUP:
                    mouseClick(&event.button);
                    break;

                case SDL_KEYDOWN:
                    keyPress(&event.key);
                    break;

                case SDL_KEYUP:
                    keyPress(&event.key);
                    break;

                default:
                    break;
            }
        }

        update(t, dt);

        //update display
        display.update();
        frame_count++;
    }

    return return_code;
}
Пример #10
0
bool COscScaler::eventFilter( QObject * obj, QEvent * e )
{
    QMouseEvent  * me;
    QKeyEvent    * ke;
    //QResizeEvent * re;
    if ( obj == m_pd->xBottom )
    {
        switch ( e->type() )
        {
        case QEvent::MouseMove:
            me = reinterpret_cast< QMouseEvent * >( e );
            // Подсвечивать или нет.
            m_pd->m_paintX = true;
            // Если включена прокрутка, вызываем прокрутку.
            if ( m_pd->m_dragX ) 
            {
                // А если включено масштабирование, вызываем масштабирование.
                if ( m_pd->m_scale )
                    scaleX( me->pos() );
                else
                    dragXY( me->pos() );
            }
            break;

        case QEvent::MouseButtonPress:
            m_pd->m_dragX = true;
            me = reinterpret_cast< QMouseEvent * >( e );
            m_pd->m_at = me->pos();
            m_pd->xMinBase = m_pd->m_plot->axisScaleDiv( QwtPlot::xBottom )->lowerBound();
            m_pd->xMaxBase = m_pd->m_plot->axisScaleDiv( QwtPlot::xBottom )->upperBound();
            m_pd->yMinBase = m_pd->m_plot->axisScaleDiv( QwtPlot::yLeft )->lowerBound();
            m_pd->yMaxBase = m_pd->m_plot->axisScaleDiv( QwtPlot::yLeft )->upperBound();
            break;

        case QEvent::MouseButtonRelease:
            m_pd->m_dragX = false;
            break;

        case QEvent::MouseButtonDblClick:
            m_pd->m_plot->setAxisAutoScale( QwtPlot::xBottom );
            m_pd->m_plot->replot();
            break;

        case QEvent::Leave:
            m_pd->m_paintX = false;
            m_pd->xBottom->releaseKeyboard();
            m_pd->xBottom->update();
            m_pd->m_scale = false;
            m_keyEqualScales = false;
            break;

        case QEvent::Enter:
            m_pd->m_paintX = true;
            m_pd->xBottom->grabKeyboard();
            m_pd->xBottom->update();
            break;

        case QEvent::Paint:
            // Рисуем то, что нужно было,
            obj->event( e );
            // А потом своё.
            if ( m_pd->m_paintX )
                paintX();
            return true;
        break;
        }
    }
    else if ( obj == m_pd->yLeft )
    {
        switch ( e->type() )
        {
        case QEvent::MouseMove:
            me = reinterpret_cast< QMouseEvent * >( e );
            // Подсвечивать или нет.
            m_pd->m_paintY = true;
            // Если включена прокрутка, вызываем прокрутку.
            if ( m_pd->m_dragY )
            {
                // А если включено масштабирование, вызываем масштабирование.
                if ( m_pd->m_scale )
                    scaleY( me->pos() );
                else
                    dragXY( me->pos() );
            }                
            break;

        case QEvent::MouseButtonPress:
            m_pd->m_dragY = true;
            me = reinterpret_cast< QMouseEvent * >( e );
            m_pd->m_at = me->pos();
            m_pd->xMinBase = m_pd->m_plot->axisScaleDiv( QwtPlot::xBottom )->lowerBound();
            m_pd->xMaxBase = m_pd->m_plot->axisScaleDiv( QwtPlot::xBottom )->upperBound();
            m_pd->yMinBase = m_pd->m_plot->axisScaleDiv( QwtPlot::yLeft )->lowerBound();
            m_pd->yMaxBase = m_pd->m_plot->axisScaleDiv( QwtPlot::yLeft )->upperBound();
            break;

        case QEvent::MouseButtonRelease:
            m_pd->m_dragY = false;
            break;

        case QEvent::MouseButtonDblClick:
            m_pd->m_plot->setAxisAutoScale( QwtPlot::yLeft );
            m_pd->m_plot->replot();
            break;

        case QEvent::Leave:
            m_pd->m_paintY = false;
            m_pd->yLeft->releaseKeyboard();
            m_pd->yLeft->update();
            m_pd->m_scale = false;
            m_keyEqualScales = false;
            break;

        case QEvent::Enter:
            m_pd->m_paintY = true;
            m_pd->yLeft->grabKeyboard();
            m_pd->yLeft->update();
            break;

        case QEvent::Paint:
            // Рисуем то, что нужно было,
            obj->event( e );
            // А потом своё.
            if ( m_pd->m_paintY )
                paintY();
            return true;
        }
    }
    else if ( obj == m_pd->canvas )
    {
        switch ( e->type() )
        {
        case QEvent::Wheel:
            mouseWheel( e );
            return false;
        }
    }
    
    if ( e->type() == QEvent::KeyPress )
    {
        ke = reinterpret_cast< QKeyEvent * >( e );
        switch( ke->key() )
        {
        case Qt::Key_Shift:
            m_pd->m_scale = true;
            break;
        case Qt::Key_Alt:
            m_pd->m_scale = true;
            m_keyEqualScales = true;
            break;
        }
    }
    else if ( e->type() == QEvent::KeyRelease )
    {
        ke = reinterpret_cast< QKeyEvent * >( e );
        switch( ke->key() )
        {
        case Qt::Key_Shift:
            m_pd->m_scale = false;
            break;
        case Qt::Key_Alt:
            m_pd->m_scale = false;
            m_keyEqualScales = false;
            break;
        }
    }    
    return false;
}
Пример #11
0
void Settings::writeSettings()
{
    setValue(KEY_LANGUAGE, language());

    setValue(KEY_SESSION_AUTOPLAY, sessionAutoplay());
    setValue(KEY_SESSION_CHANNEL, sessionChannel());
    setValue(KEY_SESSION_REMEMBER_VOLUME, sessionRememberVolume());
    setValue(KEY_SESSION_VOLUME, sessionVolume());

    if (globalConfig && globalConfig->disableSettings("channels")) {
        remove("channels");
    } else {
        setValue(KEY_PLAYLIST, playlist());
        setValue(KEY_PLAYLIST_UPDATE, playlistUpdate());
        setValue(KEY_PLAYLIST_UPDATE_URL, playlistUpdateUrl());
        setValue(KEY_RADIO_CATEGORY, radioCategory());
        setValue(KEY_HD_CATEGORY, hdCategory());
        setValue(KEY_UDPXY, udpxy());
        setValue(KEY_UDPXY_URL, udpxyUrl());
        setValue(KEY_UDPXY_PORT, udpxyPort());
    }

    if (globalConfig && globalConfig->disableSettings("gui")) {
        remove("gui");
    } else {
        setValue(KEY_WIDTH, width());
        setValue(KEY_HEIGHT, height());
        setValue(KEY_POS_X, posX());
        setValue(KEY_POS_Y, posY());

        setValue(KEY_OSD, osd());
        setValue(KEY_TRAY_ENABLED, trayEnabled());
        setValue(KEY_HIDE_TO_TRAY, hideToTray());
        setValue(KEY_MOUSE_WHEEL, mouseWheel());
        setValue(KEY_REMEMBER_GUI_SESSION, rememberGuiSession());
        setValue(KEY_ICONS, icons());
    }

    if (globalConfig && globalConfig->disableSettings("backend")) {
        remove("backend");
    } else {
        setValue(KEY_VOUT, vout());
        setValue(KEY_AOUT, aout());
        setValue(KEY_YUV_TO_RGB, yuvToRgb());
        setValue(KEY_SPDIF, spdif());

        setValue(KEY_REMEMBER_VIDEO_SETTINGS, rememberVideoSettings());
        setValue(KEY_REMEMBER_VIDEO_PER_CHANNEL, rememberVideoPerChannel());
        setValue(KEY_ASPECT_RATIO, aspectRatio());
        setValue(KEY_CROP_RATIO, cropRatio());
        setValue(KEY_DEINTERLACING, deinterlacing());
        setValue(KEY_AUDIO_LANGUAGE, audioLanguage());
        setValue(KEY_SUBTITLE_LANGUAGE, subtitleLanguage());

        setValue(KEY_MUTE_ON_MINIMIZE, muteOnMinimize());
        setValue(KEY_TELETEXT, teletext());
    }

    if (globalConfig && globalConfig->disableSettings("recorder")) {
        remove("recorder");
    } else {
        setValue(KEY_RECORDER_DIRECTORY, recorderDirectory());
        setValue(KEY_SNAPSHOTS_DIRECTORY, snapshotsDirectory());
    }

    if (globalConfig && globalConfig->disableSettings("xmltv")) {
        remove("xmltv");
    } else {
        setValue(KEY_XMLTV_UPDATE, xmltvUpdate());
        setValue(KEY_XMLTV_UPDATE_LOCATION, xmltvUpdateLocation());
        setValue(KEY_XMLTV_UPDATE_REMOTE, xmltvUpdateRemote());
    }

    sync();
}
Пример #12
0
void CameraUi::mouseWheel( app::MouseEvent &event )
{
	mouseWheel( event.getWheelIncrement() );
	event.setHandled();
}
Пример #13
0
void EventRecorder::redisplay(double t, double dt)
{
     if (isRecording) {
        recordedEvents.push_back(Event(t, dt, TerrainNode::nextGroundHeightAtCamera));
    } else if (isPlaying) {
        ostringstream s;
        bool replay = true;
        isPlaying = false;
        while (replay && lastPlayed < recordedEvents.size()) {
            Event e = recordedEvents[lastPlayed++];
            switch (e.kind) {
            case Event::DISPLAY:
                t = e.display.t;
                dt = e.display.dt;
                TerrainNode::nextGroundHeightAtCamera = e.display.groundHeight;
                replay = false;
                break;
            case Event::MOUSE:
                mouseClick((button) e.e.arg1, (state) e.e.arg2, (modifier) e.e.m, e.e.arg3, e.e.arg4);
                savedX = e.e.arg3;
                savedY = e.e.arg4;
                break;
            case Event::MOTION:
                mouseMotion(e.e.arg1, e.e.arg2);
                savedX = e.e.arg1;
                savedY = e.e.arg2;
                break;
            case Event::PASSIVEMOTION:
                mousePassiveMotion(e.e.arg1, e.e.arg2);
                savedX = e.e.arg1;
                savedY = e.e.arg2;
                break;
            case Event::WHEEL:
                mouseWheel((wheel) e.e.arg1, (modifier) e.e.m, e.e.arg2, e.e.arg3);
                savedX = e.e.arg2;
                savedY = e.e.arg3;
                break;
            case Event::KEYBOARD:
                if (e.e.arg4 == 0) {
                    keyTyped(e.e.arg1, (modifier) e.e.m, e.e.arg2, e.e.arg3);
                    if (e.e.arg1 == 27) {
                        ::exit(0);
                    }
                } else {
                    keyReleased(e.e.arg1, (modifier) e.e.m, e.e.arg2, e.e.arg3);
                }
                break;
            case Event::SPECIAL:
                if (e.e.arg4 == 0) {
                    specialKey((key) e.e.arg1, (modifier) e.e.m, e.e.arg2, e.e.arg3);
                } else {
                    specialKeyReleased((key) e.e.arg1, (modifier) e.e.m, e.e.arg2, e.e.arg3);
                }
                break;
            }
        }
        isPlaying = lastPlayed < recordedEvents.size();
    }

    if (next != NULL) {
        next->redisplay(t, dt);
    }

    if (isPlaying) {
        ptr<FrameBuffer> fb = FrameBuffer::getDefault();
        vec4<GLint> vp = fb->getViewport();

        fb->setBlend(true, ADD, SRC_ALPHA, ONE_MINUS_SRC_ALPHA, ADD, ZERO, ONE);
        fb->setColorMask(true, true, true, false);
        fb->setDepthMask(false);
        fb->setStencilMask(0, 0);

        correctU->set(vec3f(0.f, 0.f, 1.f));
        rescaleU->set(vec4f(2.0f * (float)(savedX + 0.5f * cursW) / vp.z - 1.0f, 2.0f * (float)(vp.w - savedY - 0.5f * cursH) / vp.w - 1.0f, cursW / (float)vp.z, cursH / (float)vp.w));

        cursorSamplerU->set(cursor);
        fb->drawQuad(cursorProg);

        fb->setBlend(false);
        fb->setColorMask(true, true, true, true);
        fb->setDepthMask(true);
        fb->setStencilMask(0xFFFFFFFF,0xFFFFFFFF);
    }

    if (isPlaying && saveVideo) {
        int frameCount = 0;
        if (lastSavedEvent >= 0) {
            double prevTime = recordedEvents[lastSavedEvent].display.t;
            double curTime = recordedEvents[lastPlayed - 1].display.t;
            assert(recordedEvents[lastSavedEvent].kind == Event::DISPLAY && prevTime > 0.0);
            assert(recordedEvents[lastPlayed - 1].kind == Event::DISPLAY && curTime > 0.0);
            frameCount = int(floor(curTime / 40000.0) - floor(prevTime / 40000.0));
        }
        // if the delay between two recorded frames is more than 1/25 of a second
        // the first one must be saved several times in the video to keep a video
        // framerate of 25 frames per second.
        for (int i = 0; i < frameCount; ++i) {
            char name[256];
            sprintf(name, frames, lastSavedFrame++);
            saveFrame(name);
        }
        lastSavedEvent = lastPlayed - 1;
    }
}
Пример #14
0
int SDL_Event_Handler::processEvents() {
  SDL_Event e;

  while (SDL_PollEvent(&e)) {
    switch (e.type) {
      case SDL_WINDOWEVENT:
        windowEvent(&e);
        break;
      case SDL_KEYDOWN:
        keyboardDown(&e);
        break;
      case SDL_KEYUP:
        keyboardUp(&e);
        break;
      case SDL_TEXTEDITING:
        //textEdit(&e);
        break;
      case SDL_TEXTINPUT:
        textInput(&e);
        break;
      case SDL_MOUSEMOTION:
        //mouseMotion(&e);
        break;
      case SDL_MOUSEBUTTONDOWN:
        mouseButtonDown(&e);
        break;
      case SDL_MOUSEBUTTONUP:
        mouseButtonUp(&e);
        break;
      case SDL_MOUSEWHEEL:
        mouseWheel(&e);
        break;
      case SDL_JOYAXISMOTION:
        //joystickAxisMotion(&e);
        break;
      case SDL_JOYBALLMOTION:
        //joyBallAxisMotion(&e);
        break;
      case SDL_JOYHATMOTION:
        //joyHatMotion(&e);
        break;
      case SDL_JOYBUTTONDOWN:
        //joyButtonDown(&e);
        break;
      case SDL_JOYBUTTONUP:
        //joyButtonUp(&e);
        break;
      case SDL_JOYDEVICEADDED:
        joyDeviceAdded(&e);
        break;
      case SDL_JOYDEVICEREMOVED:
        joyDeviceRemoved(&e);
        break;
      case SDL_CONTROLLERAXISMOTION:
        //controllerAxisMotion(&e);
        break;
      case SDL_CONTROLLERBUTTONDOWN:
        controllerButtonDown(&e);
        break;
      case SDL_CONTROLLERBUTTONUP:
        controllerButtonUp(&e);
        break;
      case SDL_CONTROLLERDEVICEADDED:
        //controllerDeviceAdded(&e);
        break;
      case SDL_CONTROLLERDEVICEREMOVED:
        //controllerDeviceRemoved(&e);
        break;
      case SDL_CONTROLLERDEVICEREMAPPED:
        //controllerDeviceRemmaped(&e);
        break;
#if SDL_VERSION_ATLEAST(2, 0, 4)
      case SDL_AUDIODEVICEADDED:
        //audioDeviceAdded(&e);
        break;
      case SDL_AUDIODEVICEREMOVED:
        //audioDeviceRemoved(&e);
        break;
#endif
      case SDL_QUIT:
        quit(&e);
        return 1;
      case SDL_FINGERMOTION:
        //fingerMotion(&e);
        break;
      case SDL_FINGERDOWN:
        //fingerDown(&e);
        break;
      case SDL_FINGERUP:
        //fingerUp(&e);
        break;
      case SDL_MULTIGESTURE:
        //multigesture(&e);
        break;
      case SDL_DOLLARGESTURE:
        //dollarGesture(&e);
        break;
      case SDL_DOLLARRECORD:
        //dollarRecord(&e);
        break;
      case SDL_DROPFILE:
        //dropFile(&e);
        break;
#if SDL_VERSION_ATLEAST(2, 0, 5)
      case SDL_DROPTEXT:
        //dropText(&e);
        break;
      case SDL_DROPBEGIN:
        //dropBegin(&e);
        break;
      case SDL_DROPCOMPLETE:
        //dropEnd(&e);
        break;
#endif
    }
  }

  return 0;
}
Пример #15
0
void LfoScreen::wheelEvent(QWheelEvent *event)
{
    mouseW = event->delta();
    emit mouseWheel(mouseW / 120);
    event->accept();
}