Beispiel #1
0
void MGuiWindow::moveScroll(const MVector2 & direction)
{
	m_scroll.x += direction.x;
	m_scroll.y += direction.y;

	limitScroll();
}
Beispiel #2
0
void TouchUI::draw( QPainter & painter )
{
	_screen_width = painter.window().width();
	_screen_height = painter.window().height();
	limitScroll();

	// draw background
	QRect rect(0,0,painter.window().width(),_height);
	painter.drawTiledPixmap( rect, _background );
	
	// draw icons
	for ( int i = 0; i < _items.count(); i++ )
	{
        UIItem * t = _items[i];
		int posx = t->x1;
		int posy = t->y1;
		if ( posx < 0 ) posx = _screen_width+posx;
		QSvgRenderer * image = t->image;
		if ( t->highlighted )
			painter.setCompositionMode( QPainter::CompositionMode_HardLight );
		else
			painter.setCompositionMode( QPainter::CompositionMode_SourceOver );
		if ( image == NULL ) continue;
		int h = image->defaultSize().height();
		int w = image->defaultSize().width();
		int img_width = g_config.ui_size;
		int img_height = g_config.ui_size;
		ImageLoadThread::fitImage( w,h, img_width, img_height, false );
		QRectF r( posx+_xoffset, posy+_yoffset, w, h );
		image->render( &painter, r );
	}
}
Beispiel #3
0
void MGuiWindow::resizeScroll(void)
{
	unsigned int i;

	MVector2 min = getScale();
	MVector2 max = getScale();

	unsigned int oSize = m_objects.size();
	for(i=0; i<oSize; i++)
	{
		MVector2 p1 = m_objects[i]->getPosition();
		MVector2 p2 = p1 + m_objects[i]->getScale();

		min.x = MIN(min.x, p1.x);
		min.y = MIN(min.y, p1.y);

		max.x = MAX(max.x, p2.x);
		max.y = MAX(max.y, p2.y);
	}

	m_minScroll = min;
	m_maxScroll = max;

	if(isHorizontalScroll())
	{
		if(m_minScroll.x < 0)
			m_minScroll.x -= m_margin.x;
		else
			m_minScroll.x = 0;
		m_maxScroll.x += m_margin.x;
	}

	if(isVerticalScroll())
	{
		if(m_minScroll.y < 0)
			m_minScroll.y -= m_margin.y;
		else
			m_minScroll.y = 0;
		m_maxScroll.y += m_margin.y;
	}

	rescaleScrollingBar();

	m_hScrollSlide.onChange();
	m_vScrollSlide.onChange();

	limitScroll();
}