Example #1
0
void KoHelpWidget::scrollDown()
{
	if ( m_helpViewport->height() - m_helpView->height() - m_ypos > 0 )
		stopScrolling();
	else
	{
		m_ypos -= 2;
		m_helpViewport->scroll( 0, -2 );
		m_helpViewport->update();
		updateButtons();
	}
} // KoHelpWidget::scrollUp()
Example #2
0
void KoHelpWidget::scrollUp()
{
	if ( m_ypos > 0 )
		stopScrolling();
	else
	{
		m_ypos += 2;
		m_helpViewport->scroll( 0, 2 );
		m_helpViewport->update();
		updateButtons();
	}
} // KoHelpWidget::scrollUp()
Example #3
0
KoHelpWidget::KoHelpWidget( const QString & help, QWidget* parent )
		: QWidget( parent )
{
	QGridLayout* layout = new QGridLayout( this );
	layout->setMargin( 2 );
	layout->addWidget( m_upButton = new KoHelpNavButton( KoHelpNavButton::Up, this ), 0, 1, Qt::AlignHCenter );
	layout->addWidget( m_helpViewport = new QWidget( this ), 1, 1 );
	layout->addWidget( m_downButton = new KoHelpNavButton( KoHelpNavButton::Down, this ), 2, 1, Qt::AlignHCenter );
	layout->setSpacing( 5 );
	layout->setColumnStretch( 1, 1 );

	m_helpView = new KoHelpView( m_helpViewport );
	m_helpViewport->setBackgroundRole( QPalette::Light );
	setText( help );

	setBackgroundRole( QPalette::Light );

	connect( m_upButton, SIGNAL( pressed() ), this, SLOT( startScrollingUp() ) );
	connect( m_downButton, SIGNAL( pressed() ), this, SLOT( startScrollingDown() ) );
	connect( m_upButton, SIGNAL( released() ), this, SLOT( stopScrolling() ) );
	connect( m_downButton, SIGNAL( released() ), this, SLOT( stopScrolling() ) );
	connect( m_helpView, SIGNAL( linkClicked( const QString& ) ), this, SIGNAL( linkClicked( const QString& ) ) );
} // KoHelpWidget::KoHelpWidget
bool SystemView::input(InputConfig* config, Input input)
{
	if(input.value != 0)
	{
		if(config->getDeviceId() == DEVICE_KEYBOARD && input.value && input.id == SDLK_r && SDL_GetModState() & KMOD_LCTRL && Settings::getInstance()->getBool("Debug"))
		{
			LOG(LogInfo) << " Reloading SystemList view";

			// reload themes
			for(auto it = mEntries.begin(); it != mEntries.end(); it++)
				it->object->loadTheme();

			populate();
			updateHelpPrompts();
			return true;
		}
		if(config->isMappedTo("left", input))
		{
			listInput(-1);
			return true;
		}
		if(config->isMappedTo("right", input))
		{
			listInput(1);
			return true;
		}
		if(config->isMappedTo("a", input))
		{
			stopScrolling();
			
			SystemData *systemData = getSelected();
			
			// decide whether to show game list or launch the command directly
			if ( !systemData->getDirectLaunch() )
			{
				ViewController::get()->goToGameList(getSelected());
			}else{
				systemData->launchGame( mWindow, nullptr );
			}
			return true;
		}
	}else{
		if(config->isMappedTo("left", input) || config->isMappedTo("right", input))
			listInput(0);
	}

	return GuiComponent::input(config, input);
}
Example #5
0
void GuiList<listType>::input(InputConfig* config, Input input)
{
	if(mRowVector.size() > 0)
	{
		if(input.value != 0)
		{
			if(config->isMappedTo("down", input))
			{
				mScrollDir = 1;
				scroll();
			}

			if(config->isMappedTo("up", input))
			{
				mScrollDir = -1;
				scroll();
			}
			if(config->isMappedTo("pagedown", input))
			{
				mScrollDir = 10;
				scroll();
			}

			if(config->isMappedTo("pageup", input))
			{
				mScrollDir = -10;
				scroll();
			}
		}else{
			//if((button == InputManager::DOWN && mScrollDir > 0) || (button == InputManager::PAGEDOWN && mScrollDir > 0) || (button == InputManager::UP && mScrollDir < 0) || (button == InputManager::PAGEUP && mScrollDir < 0))
			if(config->isMappedTo("down", input) || config->isMappedTo("up", input) || config->isMappedTo("pagedown", input) || config->isMappedTo("pageup", input))
			{
				stopScrolling();
			}
		}
	}
}
Example #6
0
/**
 * Handles moving over the minimap.
 * Will change the camera center when the mouse is moved in mouse-moving mode.
 * @param action Pointer to an action.
 * @param state State that the action handlers belong to.
 */
void MiniMapView::mouseOver(Action *action, State *state)
{
	InteractiveSurface::mouseOver(action, state);

	if (_isMouseScrolling && action->getDetails()->type == SDL_MOUSEMOTION)
	{
		// The following is the workaround for a rare problem where sometimes
		// the mouse-release event is missed for any reason.
		// However if the SDL is also missed the release event, then it is to no avail :(
		// (checking: is the dragScroll-mouse-button still pressed?)
		if (0==(SDL_GetMouseState(0,0)&SDL_BUTTON(Options::battleDragScrollButton))) { // so we missed again the mouse-release :(
			// Check if we have to revoke the scrolling, because it was too short in time, so it was a click
			if ((!_mouseMovedOverThreshold) && ((int)(SDL_GetTicks() - _mouseScrollingStartTime) <= (Options::dragScrollTimeTolerance)))
			{
					_camera->centerOnPosition(_posBeforeMouseScrolling);
					_redraw = true;
			}
			_isMouseScrolled = _isMouseScrolling = false;
			stopScrolling(action);
			return;
		}

		_isMouseScrolled = true;

		// Set the mouse cursor back
		SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE);
		SDL_WarpMouse(_xBeforeMouseScrolling, _yBeforeMouseScrolling);
		SDL_EventState(SDL_MOUSEMOTION, SDL_ENABLE);

		// Check the threshold
		_totalMouseMoveX += action->getDetails()->motion.xrel;
		_totalMouseMoveY += action->getDetails()->motion.yrel;
		if (!_mouseMovedOverThreshold)
			_mouseMovedOverThreshold = ((std::abs(_totalMouseMoveX) > Options::dragScrollPixelTolerance) || (std::abs(_totalMouseMoveY) > Options::dragScrollPixelTolerance));

		// Calculate the move
		int newX, newY;
		int scrollX, scrollY;

		if (Options::battleDragScrollInvert)
		{
			scrollX = action->getDetails()->motion.xrel;
			scrollY = action->getDetails()->motion.yrel;
		}
		else
		{
			scrollX = -action->getDetails()->motion.xrel;
			scrollY = -action->getDetails()->motion.yrel;
		}
		_mouseScrollX += scrollX;
		_mouseScrollY += scrollY;
		newX = _posBeforeMouseScrolling.x + _mouseScrollX / action->getXScale() / 4;
		newY = _posBeforeMouseScrolling.y + _mouseScrollY / action->getYScale() / 4;

		// Keep the limits...
		if (newX < -1 || _camera->getMapSizeX() < newX)
		{
			_mouseScrollX -= scrollX;
			newX = _posBeforeMouseScrolling.x + _mouseScrollX / 4;
		}
		if (newY < -1 || _camera->getMapSizeY() < newY)
		{
			_mouseScrollY -= scrollY;
			newY = _posBeforeMouseScrolling.y + _mouseScrollY / 4;
		}

		// Scrolling
		_camera->centerOnPosition(Position(newX,newY,_camera->getViewLevel()));
		_redraw = true;

		// We don't want to look the mouse-cursor jumping :)
		if (Options::battleDragScrollInvert)
		{
			action->getDetails()->motion.x = _xBeforeMouseScrolling;
			action->getDetails()->motion.y = _yBeforeMouseScrolling;
		}
		else
		{
			Position delta(-scrollX, -scrollY, 0);
			int barWidth = _game->getScreen()->getCursorLeftBlackBand();
			int barHeight = _game->getScreen()->getCursorTopBlackBand();
			int cursorX = _cursorPosition.x + delta.x;
			int cursorY =_cursorPosition.y + delta.y;
			_cursorPosition.x = std::min((int)Round((getX() + getWidth()) * action->getXScale()) + barWidth, std::max((int)Round(getX() * action->getXScale()) + barWidth, cursorX));
			_cursorPosition.y = std::min((int)Round((getY() + getHeight()) * action->getYScale()) + barHeight, std::max((int)Round(getY() * action->getYScale()) + barHeight, cursorY));
			action->getDetails()->motion.x = _cursorPosition.x;
			action->getDetails()->motion.y = _cursorPosition.y;
		}
		_game->getCursor()->handle(action);
	}
}
Example #7
0
/**
 * Handles mouse clicks on the minimap. Will change the camera center to the clicked point.
 * @param action Pointer to an action.
 * @param state State that the action handlers belong to.
 */
void MiniMapView::mouseClick(Action *action, State *state)
{
	InteractiveSurface::mouseClick(action, state);

	// The following is the workaround for a rare problem where sometimes
	// the mouse-release event is missed for any reason.
	// However if the SDL is also missed the release event, then it is to no avail :(
	// (this part handles the release if it is missed and now an other button is used)
	if (_isMouseScrolling) {
		if (action->getDetails()->button.button != Options::battleDragScrollButton
		&& 0==(SDL_GetMouseState(0,0)&SDL_BUTTON(Options::battleDragScrollButton))) { // so we missed again the mouse-release :(
			// Check if we have to revoke the scrolling, because it was too short in time, so it was a click
			if ((!_mouseMovedOverThreshold) && ((int)(SDL_GetTicks() - _mouseScrollingStartTime) <= (Options::dragScrollTimeTolerance)))
				{ _camera->centerOnPosition(_posBeforeMouseScrolling); _redraw = true; }
			_isMouseScrolled = _isMouseScrolling = false;
			stopScrolling(action);
		}
	}

	// Drag-Scroll release: release mouse-scroll-mode
	if (_isMouseScrolling)
	{
		// While scrolling, other buttons are ineffective
		if (action->getDetails()->button.button == Options::battleDragScrollButton)
		{
			_isMouseScrolling = false;
			stopScrolling(action);
		}
		else
		{
			return;
		}
		// Check if we have to revoke the scrolling, because it was too short in time, so it was a click
		if ((!_mouseMovedOverThreshold) && ((int)(SDL_GetTicks() - _mouseScrollingStartTime) <= (Options::dragScrollTimeTolerance)))
		{
			_isMouseScrolled = false;
			stopScrolling(action);
			_camera->centerOnPosition(_posBeforeMouseScrolling);
			_redraw = true;
		}
		if (_isMouseScrolled) return;
	}

	if (action->getDetails()->button.button == SDL_BUTTON_RIGHT)
	{
		((MiniMapState*)(state))->btnOkClick(action);
	}

	if (action->getDetails()->button.button == SDL_BUTTON_LEFT)
	{
		int origX = action->getRelativeXMouse() / action->getXScale();
		int origY = action->getRelativeYMouse() / action->getYScale();
		// get offset (in cells) of the click relative to center of screen
		int xOff = (origX / CELL_WIDTH) - ((getWidth() / 2) / CELL_WIDTH);
		int yOff = (origY / CELL_HEIGHT) - ((getHeight() / 2) / CELL_HEIGHT);
		// center the camera on this new position
		int newX = _camera->getCenterPosition().x + xOff;
		int newY = _camera->getCenterPosition().y + yOff;
		_camera->centerOnPosition(Position(newX,newY,_camera->getViewLevel()));
		_redraw = true;
	}
}
Example #8
0
void System::stopScrolling()
{
    jnipp::Method<void> stopScrolling(m_NidroidClass, "stopScrolling", "()V");

    stopScrolling(m_Nidroid);
}
bool SystemView::input(InputConfig* config, Input input)
{
	if(input.value != 0)
	{
		if(config->getDeviceId() == DEVICE_KEYBOARD && input.value && input.id == SDLK_r && SDL_GetModState() & KMOD_LCTRL && Settings::getInstance()->getBool("Debug"))
		{
			LOG(LogInfo) << " Reloading all";
			ViewController::get()->reloadAll();
			return true;
		}

		switch (mCarousel.type)
		{
		case VERTICAL:
		case VERTICAL_WHEEL:
			if (config->isMappedTo("up", input))
			{
				listInput(-1);
				return true;
			}
			if (config->isMappedTo("down", input))
			{
				listInput(1);
				return true;
			}
			break;
		case HORIZONTAL:
		case HORIZONTAL_WHEEL:
		default:
			if (config->isMappedTo("left", input))
			{
				listInput(-1);
				return true;
			}
			if (config->isMappedTo("right", input))
			{
				listInput(1);
				return true;
			}
			break;
		}

		if(config->isMappedTo("a", input))
		{
			stopScrolling();
			ViewController::get()->goToGameList(getSelected());
			return true;
		}
		if (config->isMappedTo("x", input))
		{
			// get random system
			// go to system
			setCursor(SystemData::getRandomSystem());
			return true;
		}
	}else{
		if(config->isMappedTo("left", input) ||
			config->isMappedTo("right", input) ||
			config->isMappedTo("up", input) ||
			config->isMappedTo("down", input))
			listInput(0);
		if(!UIModeController::getInstance()->isUIModeKid() && config->isMappedTo("select", input) && Settings::getInstance()->getBool("ScreenSaverControls"))
		{
			mWindow->startScreenSaver();
			mWindow->renderScreenSaver();
			return true;
		}
	}

	return GuiComponent::input(config, input);
}
Example #10
0
bool ScrollerPrivate::eventFilter(QObject *obj, QEvent *event)
{
    if (obj != m_scrollArea
        || (event->type() != QEvent::GraphicsSceneMouseMove
            && event->type() != QEvent::GraphicsSceneMousePress
            && event->type() != QEvent::GraphicsSceneMouseRelease
            /*&& event->type() != QEvent::GraphicsSceneKeyPressed
            && event->type() != QEvent::GraphicsSceneKeyReleased*/))
        return false;

    QGraphicsSceneMouseEvent* mouseEvent = 
        static_cast<QGraphicsSceneMouseEvent*>(event);

    m_eventViewport = mouseEvent->widget();

    bool eventConsumed = false;

    switch (m_state) {
    case ScrollerPrivate::Stopped:
        if (mouseEvent->type() == QEvent::GraphicsSceneMousePress &&
            mouseEvent->buttons() == Qt::LeftButton) {
            m_cursorPos = QCursor::pos();
            m_speed = QPointF(0.0, 0.0);
            m_state = Started;
        }

        eventConsumed = true;
        break;

    case ScrollerPrivate::Started:
        if (mouseEvent->type() == QEvent::GraphicsSceneMouseMove) {
            m_cursorPos = QCursor::pos();
            m_state = ManualScrolling;

            if (!m_scrollTimer.isActive()) 
                m_scrollTimer.start(UpdateScrollingInterval);
            else {
                m_scrollTimer.stop();
                m_scrollTimer.start(UpdateScrollingInterval);
            }

        } else if (mouseEvent->type() == QEvent::MouseButtonRelease) {
            m_speed = QPoint(0, 0);
            m_state = Stopped;

            if (m_scrollTimer.isActive())
                m_scrollTimer.stop();
        }
        eventConsumed = true;
        break;

    case ScrollerPrivate::ManualScrolling:
        if (mouseEvent->type() == QEvent::GraphicsSceneMouseMove &&
            m_scrollArea->viewport()->boundingRect().contains(mouseEvent->pos()) ) {

            ScrollBar *hscroll = m_scrollArea->horizontalScrollBar();
            ScrollBar *vscroll = m_scrollArea->verticalScrollBar();

            QPointF d = m_scrollFactor * (mapToScrollArea(QCursor::pos()) - mapToScrollArea(m_cursorPos)); 

            hscroll->setSliderPosition(hscroll->sliderPosition() - d.x());
            vscroll->setSliderPosition(vscroll->sliderPosition() - d.y());

            if (m_lastCursorTime.elapsed() > UpdateScrollingInterval) {
                m_speed = mapToScrollArea(QCursor::pos()) - mapToScrollArea(m_cursorPos);
                m_lastCursorTime.restart();
            }

            m_lastFrameTime.restart();

            m_cursorPos = QCursor::pos();
        } else if (mouseEvent->type() == QEvent::GraphicsSceneMouseRelease) {
            m_state = AutoScrolling;
            m_scrollSlowAccum = 0;
            if (m_scrollTimer.isActive()) {
                m_scrollTimer.stop();
                m_scrollTimer.start(UpdateScrollingSmoothInterval);
            }
        }
        eventConsumed = true;
        break;

    case ScrollerPrivate::AutoScrolling:
        if (mouseEvent->type() == QEvent::GraphicsSceneMousePress) {
            stopScrolling();
        } else if (mouseEvent->type() == QEvent::MouseButtonRelease) {
            m_state = Stopped;
        }
        eventConsumed  = true;
        break;

    default:
        break;
    }

    return eventConsumed;
}