示例#1
0
bool PGE_Fader::tickFader(float ticks)
{
    if(fadeSpeed<1) return true; //Idling animation
    if(cur_ratio==target_ratio)
        return true;

    manual_ticks-=fabs(ticks);
        while(manual_ticks<=0.0f)
        {
            fadeStep();
            manual_ticks+=fadeSpeed;
        }
        return (cur_ratio==target_ratio);
}
示例#2
0
// Handle widget when animation is finished
void MyWidget::aniFinished() {

	// Move widget out of screen
	if(!isShown) {
		this->setGeometry(rectHidden);
		emit widgetClosed();
		scrollbar->setValue(0);
	} else
		scrollbar->setScrollbarShown();

	fadeStep(true);
	emit notifyOfAniFinished();

}
示例#3
0
void PalAnim::fade(Video::PalDesc *palDesc, int16 fadeV, int16 allColors) {
	bool stop;
	int16 i;

	if (_vm->shouldQuit())
		return;

	_fadeValue = (fadeV < 0) ? -fadeV : 2;

	if (_vm->_global->_colorCount < 256) {
		if (palDesc)
			_vm->_video->setFullPalette(palDesc);
		return;
	}

	if (!_vm->_global->_setAllPalette) {
		if (!palDesc) {
			for (i = 0; i < 16; i++) {
				_toFadeRed[i] = 0;
				_toFadeGreen[i] = 0;
				_toFadeBlue[i] = 0;
			}
		} else {
			for (i = 0; i < 16; i++) {
				_toFadeRed[i] = palDesc->vgaPal[i].red;
				_toFadeGreen[i] = palDesc->vgaPal[i].green;
				_toFadeBlue[i] = palDesc->vgaPal[i].blue;
			}
		}
	} else {
		if (_vm->_global->_inVM != 0)
			error("PalAnim::fade(): _vm->_global->_inVM != 0 is not supported");

		if (!palDesc) {
			for (i = 0; i < 256; i++) {
				_toFadeRed[i] = 0;
				_toFadeGreen[i] = 0;
				_toFadeBlue[i] = 0;
			}
		} else {
			for (i = 0; i < 256; i++) {
				_toFadeRed[i] = palDesc->vgaPal[i].red;
				_toFadeGreen[i] = palDesc->vgaPal[i].green;
				_toFadeBlue[i] = palDesc->vgaPal[i].blue;
			}
		}
	}

	if (allColors == 0) {
		do {
			stop = fadeStep(0);
			_vm->_video->waitRetrace();

			if (fadeV > 0)
				_vm->_util->delay(fadeV);
		} while (!stop);

		if (palDesc)
			_vm->_video->setFullPalette(palDesc);
		else
			_vm->_util->clearPalette();
	}

	if (allColors == 1) {
		do {
			_vm->_video->waitRetrace();
			stop = fadeStep(1);
		} while (!stop);

		do {
			_vm->_video->waitRetrace();
			stop = fadeStep(2);
		} while (!stop);

		do {
			_vm->_video->waitRetrace();
			stop = fadeStep(3);
		} while (!stop);

		if (palDesc)
			_vm->_video->setFullPalette(palDesc);
		else
			_vm->_util->clearPalette();
	}
}
示例#4
0
// Setup widget
void MyWidget::setup(int layoutMargin, QString borderColor, QString backgroundColor) {

	// Some styling
	visibleArea = QSize(600,400);
	this->borderColor = borderColor;
	this->backgroundColor = (backgroundColor == "" ? "rgba(0,0,0,200)" : backgroundColor);
	borderLeftRight = -1;
	borderTopDown = -1;
	fullscreen = false;

	// The different QRects
	rectShown = QRect();
	rectHidden = QRect(0,-10,10,10);
	rectAni = QRect();

	// The current geometry and position
	isShown = false;
	this->setGeometry(rectHidden);

	// Fading
	backOpacityShow = 0.5;
	backOpacityCur = 0;
	centerOpacityCur = 0;
	fade = new QTimeLine;
	fadeIN = true;
	fadeEffectCenter = new QGraphicsOpacityEffect;
	connect(fade, SIGNAL(valueChanged(qreal)), this, SLOT(fadeStep()));
	connect(fade, SIGNAL(finished()), this, SLOT(aniFinished()));

	// The current widget look
	this->setStyleSheet(QString("background: rgba(0,0,0,%1);").arg(255*backOpacityShow));

	// the central widget containing all the information
	center = new QWidget(this);
	center->setGraphicsEffect(fadeEffectCenter);
	center->setObjectName("center");
	// For some reason, if the border is not defined right here at the beginning, it wont be visible...
	if(borderColor == "")
		center->setStyleSheet(QString("#center { background: %1; border-radius: 10px; font-size: 12pt; }").arg(this->backgroundColor));
	else
		center->setStyleSheet(QString("#center {background: %1; border-radius: 15px; font-size: 12pt; border: 2px solid %2; }").arg(this->backgroundColor).arg(borderColor));

	// Create and set the scrollarea with main layout
	QVBoxLayout *central = new QVBoxLayout;
	central->setMargin(layoutMargin);
	QScrollArea *scroll = new QScrollArea(this);
	scroll->setObjectName("scrollWidget");
	scroll->setStyleSheet("QWidget#scrollWidget { background: transparent; padding-bottom: 3px; border-radius: 0px; }");
	QWidget *scrollWidget = new QWidget(scroll->widget());
	scrollWidget->setStyleSheet("background: transparent;");
	scroll->setWidgetResizable(true);
	scroll->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
	scrollWidget->setLayout(central);
	scroll->setWidget(scrollWidget);
	mainlayout = new QVBoxLayout;
	if(layoutMargin == 0) mainlayout->setMargin(0);
	center->setLayout(mainlayout);
	mainlayout->addWidget(scroll);

	// This widget gets the main layout set to
	centralWidget = new QWidget;
	central->addWidget(centralWidget);

	// And set the custom scrollbar
	scrollbar = new CustomScrollbar;
	scroll->setVerticalScrollBar(scrollbar);

	// And in case the monitor resolution is so small, that the horizontal scrollbar is visible:
	CustomScrollbar *scrollbarHor = new CustomScrollbar;
	scroll->setHorizontalScrollBar(scrollbarHor);

}
示例#5
0
// The animation function
void MyWidget::animate() {

	bool noAni = false;
	if(QFile(QDir::homePath() + "/.photoqt/mywidget_noani").exists())
		noAni = true;

	QRect shown;
	if(fullscreen)
		shown = rectShown;
	else if(borderLeftRight == -1 || borderTopDown == -1)
		shown = QRect((rectShown.width()-visibleArea.width())/2.0,(rectShown.height()-visibleArea.height())/2.0,visibleArea.width(),visibleArea.height());
	else
		shown = QRect(borderLeftRight, borderTopDown, rectShown.width()-borderLeftRight*2, rectShown.height()-borderTopDown*2);

	// Open widget
	if(!isShown) {

		if(fade->state() == QTimeLine::Running) {
			fade->stop();
			fadeStep(true);
		}

		// The background is initially transparent but the geometry is full
		this->setStyleSheet(QString("background: rgba(0,0,0,0);"));
		this->setGeometry(rectShown);

		// Widget is shown
		isShown = true;

		if(noAni) {

			fadeIN = true;
			center->setGeometry(shown);
			fadeStep(true);
			aniFinished();

		} else {

			// Prepare widget
			fadeEffectCenter->setOpacity(0);
			center->setGeometry(shown);

			// Start fade
			fade->setDuration(100);
			fade->setLoopCount(5);
			fadeIN = true;
			fade->start();

		}

		// Block all base functions
		emit blockFunc(true);

		// Make sure this widget is on top
		this->raise();

	// Close widget
	} else if(isShown) {

		if(fade->state() == QTimeLine::Running) {
			fade->stop();
			fadeStep(true);
		}

		// Widget is hidden again
		isShown = false;

		if(noAni) {

			fadeIN = false;
			fadeStep(true);
			aniFinished();

		} else {

			fade->setDuration(100);
			fade->setLoopCount(5);
			fadeIN = false;
			fade->start();

		}

		// Unblock all base functions
		emit blockFunc(false);

	}

}