Пример #1
0
 void timerCallback() override
 {
     if (canMoveTransport())
         updateCursorPosition();
     else
         setRange (visibleRange.movedToStartAt (transportSource.getCurrentPosition() - (visibleRange.getLength() / 2.0)));
 }
Пример #2
0
 void setRange (Range<double> newRange)
 {
     visibleRange = newRange;
     scrollbar.setCurrentRange (visibleRange);
     updateCursorPosition();
     repaint();
 }
Пример #3
0
void TextBoxWidget::updateDimensions() {
	TextWidget::updateDimensions();
	w += _borderWidth * 2;
	h += _borderWidth * 2;
	updateCursorPosition();
	notifyGeometryChange();
}
Пример #4
0
/*
	processInput - This method updates first gets all input from Windows
	for the mouse and the keyboard. It then asks the event handlers
	to respond to the input.
*/
void WindowsInput::processInput(Game *game)
{
	WindowsOS *os = (WindowsOS*)game->getOS();
	WINDOWINFO wi = os->getWindowInfo();
	updateCursorPosition(game, wi, game->getGUI()->getCursor());
	updateInputState();
	respondToKeyboardInput(game);
	respondToMouseInput(game);
}
Пример #5
0
void MouseV3::parsePointerData(QByteArray &data)
{
    if (data.length() >= 7)
    {
        unsigned char firstByte = data.at(3);
        unsigned char secondByte = data.at(4);
        int newDownEventIndex = firstByte << 8 | secondByte;
        firstByte = data.at(5);
        secondByte = data.at(6);
        int newMoveEventIndex = firstByte << 8 | secondByte;

        int pointerDataOffset = 7;
        int pointerLength = 4;
        int pointerCount = (data.length() - pointerDataOffset) / pointerLength;

        pointers = new QList<TouchPoint*>();

        for (int i = 0; i < pointerCount; ++i)
        {
            TouchPoint *currentPointer = new TouchPoint();
            firstByte = data.at(pointerDataOffset + (i * pointerLength));
            secondByte = data.at(pointerDataOffset + (i * pointerLength) + 1);
            int x = firstByte << 8 | secondByte;

            firstByte = data.at(pointerDataOffset + (i * pointerLength) + 2);
            secondByte = data.at(pointerDataOffset + (i * pointerLength) + 3);
            int y = firstByte << 8 | secondByte;

            currentPointer->x = x;
            currentPointer->y = y;

            pointers->append(currentPointer);
        }

        if (newDownEventIndex > downEventIndex)
        {
            moveEventIndex = -1;
            pointersUp();
        }

        downEventIndex = newDownEventIndex;
        moveEventIndex = newMoveEventIndex;

        if (pointers->length() == 1)
        {
            updateCursorPosition();
        }
        else if (pointers->length() > 1)
        {
            parseMultitouch();
        }
    }
    else
    {
        qDebug() << "Not enough data for parsePointerData";
    }
}
Пример #6
0
AeEditor* AeWindow::createEditor() {
	AeEditor* e = new AeEditor(this);
	e->setCxxModel();
	e->setColourScheme(mColourScheme);
	connect(e, SIGNAL(dirtied(QWidget*,bool)), this, SLOT(handleDirtied(QWidget*,bool)));
	connect(e->model(), SIGNAL(positionInfo(QString)), ui->statusbar, SLOT(showMessage(QString)));
	connect(e, SIGNAL(updateCursorPosition(QString)), cursor_position, SLOT(setText(QString)));

	return e;
}
Пример #7
0
    void CScene3PCamera::setActive(bool status)
    {
    // reset the cursor only if we are switching back to active from inactive
    if(!Active && status)
    {
    updateCursorPosition();
    }

    Active = status;
    }
Пример #8
0
GLboolean TextBoxWidget::onKeyDown(int key, int special) {
	std::string text = getText();
	int currentPosition = cursorPosition;

	if (key == 0) {
		switch (special) {
			case GLUT_KEY_LEFT:
				currentPosition--;

				if (currentPosition < 0) {
					currentPosition = 0;
				}

				cursorPosition = currentPosition;
				showCursor = true;
				break;

			case GLUT_KEY_RIGHT:
				currentPosition++;

				if (currentPosition > text.length()) {
					currentPosition = text.length();
				}

				cursorPosition = currentPosition;
				showCursor = true;
				break;
		}
		
		updateCursorPosition();
	} else {
		if (key == 8) {
			if (currentPosition > 0) {
				text.erase(currentPosition - 1, 1);
				currentPosition--;
			}

			cursorPosition = currentPosition;
		} else if (key == 127) {
			if (currentPosition < text.length()) {
				text.erase(currentPosition, 1);
			}

			cursorPosition = currentPosition;
		} else {
			text.insert(cursorPosition, 1, (char)key);
			cursorPosition++;
		}

		setText(text);
	}

	return true;
}
Пример #9
0
void UrlBar::handleEvent(const XEvent& event)
{
    switch (event.type) {
    case Expose:
        drawUrlBar();
        break;
    case ButtonRelease:
        addFocus();
        updateCursorPosition(event.xbutton.x);
        break;
    case SelectionRequest:
        respondClipboardRequest(event.xselectionrequest);
        break;
    case SelectionNotify:
        pasteClipboardText(event);
        break;
    }
}
Пример #10
0
	void DemoKeeper::createScene()
	{
		base::BaseDemoManager::createScene();
		createEntities();

		const MyGUI::VectorWidgetPtr& root = MyGUI::LayoutManager::getInstance().loadLayout("HelpPanel.layout");
		if (root.size() == 1)
			root.at(0)->findWidget("Text")->castType<MyGUI::TextBox>()->setCaption("Implementation of custom complex cursor behaviour, interaction of system and in-game cursors.");

		std::string resourceCategory = MyGUI::ResourceManager::getInstance().getCategoryName();
		MyGUI::FactoryManager::getInstance().registerFactory<ResourcePointerContext>(resourceCategory);

		MyGUI::ResourceManager::getInstance().load("Contexts.xml");

#ifdef MYGUI_SAMPLES_INPUT_OIS
		MyGUI::ResourceManager::getInstance().load("DemoPointers.xml");
#elif MYGUI_SAMPLES_INPUT_WIN32
		MyGUI::ResourceManager::getInstance().load("DemoPointersW32.xml");
#elif MYGUI_SAMPLES_INPUT_WIN32_OIS
		MyGUI::ResourceManager::getInstance().load("DemoPointersW32.xml");
#endif

		mPointerContextManager = new PointerContextManager(this);
		mPointerContextManager->addContext("ptrx_Normal");
		mPointerContextManager->setPointer("default");

		mEnemyPanel = new EnemyPanel();
		mFriendPanel = new FriendPanel();
		mControlPanel = new ControlPanel(mPointerContextManager);

		MyGUI::IntSize size = MyGUI::RenderManager::getInstance().getViewSize();
		setMousePosition(size.width / 2, size.height / 2);
		updateCursorPosition();

#ifdef MYGUI_OGRE_PLATFORM
		mEnemyPanel->setVisible(false);
		mFriendPanel->setVisible(false);
#endif

		updateCamera(0, 0);
	}
Пример #11
0
void TextEditor::setupEditor(QFont *font) {
   setFont(*font);
   setTabStopWidth(Options::tabWidth() * QFontMetrics(*font).width(' '));
   
   // strip formatting when pasting rich-text
   setAcceptRichText(false);
   setLineWrapMode(QTextEdit::NoWrap);
  
   m_syntaxTip = new SyntaxTip(this);
   m_registerTip = new RegisterTip(this);

   QShortcut *jumpToPC = new QShortcut(QKeySequence(tr("CTRL+J")), this, SLOT(focusPC()), SLOT(focusPC()), Qt::WidgetShortcut);
   
   
   //setContextMenuPolicy(Qt::CustomContextMenu);
   setContextMenuPolicy(Qt::NoContextMenu);
   connect(this, SIGNAL(textChanged()), this, SLOT(codeChanged()));
   connect(this, SIGNAL(textChanged()), m_parent, SLOT(contentChangedProxy()));

   // TODO:  temp?  optimize!
   connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(updateCursorPosition()));
   
   // signals for enabling/disabling editing functionality
   connect(this, SIGNAL(undoAvailable(bool)), this, SLOT(undoAvailabilityModified(bool)));
   connect(this, SIGNAL(undoAvailable(bool)), this, SLOT(undoAvailabilityModified(bool)));

   connect(this, SIGNAL(undoAvailable(bool)), m_parent, SLOT(undoAvailabilityModified(bool)));
   connect(this, SIGNAL(redoAvailable(bool)), m_parent, SLOT(redoAvailabilityModified(bool)));
   connect(this, SIGNAL(copyAvailable(bool)), m_parent, SLOT(copyAvailabilityModified(bool)));
   connect(verticalScrollBar(), SIGNAL(valueChanged(int)), m_parent, SLOT(updateLineNumbers(int)));
   connect(verticalScrollBar(), SIGNAL(valueChanged(int)), m_syntaxTip, SLOT(editorScrolled(int)));
//   connect(m_parent, SIGNAL(isModifiable(bool)), this, SLOT(modifiabilityChanged(bool)));
   connect(this, SIGNAL(updateModifiability(bool)), m_parent, SLOT(modifiabilityChanged(bool)));
   connect(m_parent, SIGNAL(fontChanged(const QFont&)), this, SLOT(fontChanged(const QFont&)));
   connect(Options::m_options, SIGNAL(errorHighlightingEnabledChanged(bool)), this, SLOT(errorHighlightingEnabledChanged(bool)));
   
   //modifiabilityChanged(m_parent->isModifiable());
   m_syntaxHighligher = new SyntaxHighlighter(this);
   setMouseTracking(true);
}
Пример #12
0
void QAndroidInputContext::showInputPanel()
{
    if (QGuiApplication::applicationState() != Qt::ApplicationActive) {
        connect(qGuiApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(showInputPanelLater(Qt::ApplicationState)));
        return;
    }
    QSharedPointer<QInputMethodQueryEvent> query = focusObjectInputMethodQueryThreadSafe();
    if (query.isNull())
        return;

    disconnect(m_updateCursorPosConnection);
    if (qGuiApp->focusObject()->metaObject()->indexOfSignal("cursorPositionChanged(int,int)") >= 0) // QLineEdit breaks the pattern
        m_updateCursorPosConnection = connect(qGuiApp->focusObject(), SIGNAL(cursorPositionChanged(int,int)), this, SLOT(updateCursorPosition()));
    else
        m_updateCursorPosConnection = connect(qGuiApp->focusObject(), SIGNAL(cursorPositionChanged()), this, SLOT(updateCursorPosition()));
    QRectF itemRect = qGuiApp->inputMethod()->inputItemRectangle();
    QRect rect = qGuiApp->inputMethod()->inputItemTransform().mapRect(itemRect).toRect();
    QWindow *window = qGuiApp->focusWindow();
    if (window)
        rect = QRect(window->mapToGlobal(rect.topLeft()), rect.size());

    QtAndroidInput::showSoftwareKeyboard(rect.left(),
                                         rect.top(),
                                         rect.width(),
                                         rect.height(),
                                         query->value(Qt::ImHints).toUInt());
}

void QAndroidInputContext::showInputPanelLater(Qt::ApplicationState state)
{
Пример #13
0
int main(int argc, char * argv[])
{
	int ch, opt;
	int errflag;
	char *optargTrainingSet=NULL, optargSep=',';
	std::vector<char> trainingSet;
	
	while ((opt = getopt(argc, argv, ":hc:s:")) != -1)
	{
		switch (opt)
		{
			case 'h':
				errflag++;
				break;
			case 'c':
				optargTrainingSet = optarg;
				break;
			case 's':
				sscanf(optarg, "%c", &optargSep);
				break;
			case ':':
				std::cerr << "option -" << optopt << "requires an operand" << std::endl;
				errflag++;
				break;
			case '?':
				std::cerr << "unrecognized option:-" << optopt << std::endl;
				errflag++;
				break;
		}
	}
	
	if (errflag || (optargTrainingSet == NULL))
	{
		printCLHelp(argv[0]);
		return EXIT_FAILURE;
	}
	
	if (splitStringToChar(optargTrainingSet, trainingSet, optargSep) != 0)
	{
		return EXIT_FAILURE;
	}
	
	// Initialize app
	initTT();
	
	//char a[] = {'a', 's', 'd', 'f', ' '};
	charsRefer = generateString(trainingSet.data(), (int)trainingSet.size(), buffersize);
	charsTyped.resize(buffersize);
	charsTyped.clear();
	
	setupScreen();
	updateReferLine(charsRefer);
	updateActionLine(charsTyped, charsRefer);
	updateInfoLine();
	updateCursorPosition(charsTyped);
	
	ch = getch();
	while (ch != ASCII_CTRL_C)
	{
		if (!isPrintableKey(ch) && !isSpecialKey(ch))
		{
			ch = getch();
			continue;
		}
		switch (ch)
		{
			case ASCII_BACKSPACE:
			case ASCII_DELETE:
				std::cout << (char) ASCII_CTRL_G; // sound the bell
				refresh();
				break;
			case ASCII_CTRL_R:
				resetStatistics();
			case ASCII_NEWLINE:
			case ASCII_CRETURN:
				if (isEOL(charsTyped) || (ch == ASCII_CTRL_R))
				{
					charsRefer = generateString(trainingSet.data(), (int)trainingSet.size(), buffersize);
					updateReferLine(charsRefer);
					clearActionLine();
					clearBuffer(charsTyped);
				}
				break;
			default:
				if (addChar(charsTyped, ch))
				{
					updateActionLine(charsTyped, charsRefer);
				}
				updateInfoLine();
				updateCursorPosition(charsTyped);
		}
		ch = getch();
	}
	
	refresh();
	endwin();
	
	/*
	std::cout << "buffersize= " << buffersize << std::endl;
	std::cout << "reference = " << charsRefer.size() << std::endl;
	std::cout << "capacity  = " << charsTyped.capacity() << std::endl;
	std::cout << "typed_in  = " << charsTyped.size() << std::endl;
	 */
	printf("Goodbye!\n");
	return 0;
}
Пример #14
0
 void CScene3PCamera::setBoxSize(irr::f32 newSize)
 {
 BoxSize = newSize;
 updateCursorPosition();
 }
Пример #15
0
    //! animates the scene node
    void CScene3PCamera::animateNode(irr::scene::ISceneNode *node, irr::u32 timeMs)
    {
    // make sure you don't go attaching this animator to anything other than a camera
    irr::scene::ICameraSceneNode *camera = (irr::scene::ICameraSceneNode*)node;

    if(Manager->getActiveCamera() != camera)
    {
    return;
    }

    if(Active)
    {
    // Camera is active, rotate as necessary
    irr::core::position2d<irr::f32> pos = Cursor->getRelativePosition();

    if(pos.X < 0.5f-BoxSize-EPSILON)
    {
    AngleY -= (pos.X-(0.5f-BoxSize))*RotationSpeed;//Decrement of this statement gives the correct movement to the mouse.... by smartwhiz
    }

    if(pos.X > 0.5f+BoxSize+EPSILON)
    {
    AngleY -= (pos.X-(0.5f+BoxSize))*RotationSpeed;//Decrement of this statement gives the correct movement to the mouse.... by smartwhiz
    }

    // So we don't get huge rotation numbers
    if(AngleY > 360.0f)
    {
    AngleY += 360.0f;
    }

    if(AngleY < 0.0f)
    {
    AngleY -= 360.0f;
    }

    if(pos.Y < 0.5f-BoxSize-EPSILON)
    {
    AngleZ -= (pos.Y-(0.5f-BoxSize))*RotationSpeed;
    }

    if(pos.Y > 0.5f+BoxSize+EPSILON)
    {
    AngleZ -= (pos.Y-(0.5f+BoxSize))*RotationSpeed;
    }

    // Ensure Vertical Rotation Angle is bounded correctly
    if(AngleZ < MinAngle) AngleZ = MinAngle;
    else if(AngleZ > MaxAngle) AngleZ = MaxAngle;

    //keep the player in the view angle that of the camera, this is the change made......... by smartwhiz
	if (XRotatePlayer == true){
	Player->setRotation(irr::core::vector3df(0,-(AngleY+180),0));
	}


    updateCursorPosition();
    }

    // Create translation vector
    irr::core::vector3df translation(Distancia,0,0);
    translation.rotateXYBy(-AngleZ,irr::core::vector3df(0,0,0));
    translation.rotateXZBy(AngleY,irr::core::vector3df(0,0,0));

    // Assumes the camera is *not* a child of the player node
    camera->setTarget(Player->getPosition()+TargetOffset);
    camera->setPosition(Player->getPosition()+translation+TargetOffset);
    }