📄 menumanager.cpp
字号:
// create in-animation: DemoItemAnimation *anim = new DemoItemAnimation(item, DemoItemAnimation::ANIM_IN); anim->setDuration(float(1000 + (i * 20)) * Colors::animSpeedButtons); anim->setStartPos(QPointF(xOffset, -ih)); anim->setPosAt(0.20, QPointF(xOffset, -ih)); anim->setPosAt(0.50, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY + (10 * float(i / 4.0f)))); anim->setPosAt(0.60, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY)); anim->setPosAt(0.70, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY + (5 * float(i / 4.0f)))); anim->setPosAt(0.80, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY)); anim->setPosAt(0.90, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY + (2 * float(i / 4.0f)))); anim->setPosAt(1.00, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY)); movie_in->append(anim); // create out-animation: anim = new DemoItemAnimation(item, DemoItemAnimation::ANIM_OUT); anim->hideOnFinished = true; anim->setDuration((700 + (30 * i)) * Colors::animSpeedButtons); anim->setStartPos(QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY)); anim->setPosAt(0.60, QPointF(xOffset, 600 - ih - ih)); anim->setPosAt(0.65, QPointF(xOffset + 20, 600 - ih)); anim->setPosAt(1.00, QPointF(sw + iw, 600 - ih)); movie_out->append(anim); i++; n = n.nextSibling(); } // create quit button: TextButton *backButton = new TextButton("Quit", TextButton::RIGHT, QUIT, this->window->scene, 0, TextButton::PANEL); backButton->setRecursiveVisible(false); backButton->setZValue(10); qreal iw = backButton->sceneBoundingRect().width(); // create in-animation: DemoItemAnimation *BackButtonIn = new DemoItemAnimation(backButton, DemoItemAnimation::ANIM_IN); BackButtonIn->setDuration(1800 * Colors::animSpeedButtons); BackButtonIn->setStartPos(QPointF(-iw, Colors::contentStartY + Colors::contentHeight - 35)); BackButtonIn->setPosAt(0.5, QPointF(-iw, Colors::contentStartY + Colors::contentHeight - 35)); BackButtonIn->setPosAt(0.7, QPointF(xOffset, Colors::contentStartY + Colors::contentHeight - 35)); BackButtonIn->setPosAt(1.0, QPointF(xOffset, Colors::contentStartY + Colors::contentHeight - 26)); movie_in->append(BackButtonIn); // create out-animation: DemoItemAnimation *BackButtonOut = new DemoItemAnimation(backButton, DemoItemAnimation::ANIM_OUT); BackButtonOut->hideOnFinished = true; BackButtonOut->setDuration(400 * Colors::animSpeedButtons); BackButtonOut->setStartPos(QPointF(xOffset, Colors::contentStartY + Colors::contentHeight - 26)); BackButtonOut->setPosAt(1.0, QPointF(-iw, Colors::contentStartY + Colors::contentHeight - 26)); movie_out->append(BackButtonOut); // Create fullscreen button: xOffset = 70; TextButton *item = new TextButton("Toggle fullscreen", TextButton::RIGHT, FULLSCREEN, this->window->scene, 0, TextButton::PANEL); item->setRecursiveVisible(false); item->setZValue(10); // create in-animation: DemoItemAnimation *anim = new DemoItemAnimation(item, DemoItemAnimation::ANIM_IN); anim->setDuration(1800 * Colors::animSpeedButtons); anim->setStartPos(QPointF(sw, Colors::contentStartY + Colors::contentHeight - 35)); anim->setPosAt(0.5, QPointF(sw, Colors::contentStartY + Colors::contentHeight - 35)); anim->setPosAt(0.7, QPointF(xOffset + 535, Colors::contentStartY + Colors::contentHeight - 35)); anim->setPosAt(1.0, QPointF(xOffset + 535, Colors::contentStartY + Colors::contentHeight - 26)); movie_in->append(anim); // create out-animation: anim = new DemoItemAnimation(item, DemoItemAnimation::ANIM_OUT); anim->hideOnFinished = true; anim->setDuration(400 * Colors::animSpeedButtons); anim->setStartPos(QPointF(xOffset + 535, Colors::contentStartY + Colors::contentHeight - 26)); anim->setPosAt(1.0, QPointF(sw, Colors::contentStartY + Colors::contentHeight - 26)); movie_out->append(anim); // Create menu content: this->createInfo(new MenuContentItem(el, this->window->scene, 0), el.attribute("name") + " -info");}void MenuManager::createRightMenu1(const QDomElement &el){ Movie *movie_in = new Movie(); Movie *movie_out = new Movie(); Movie *movie_shake = new Movie(); this->score->insertMovie(el.attribute("name"), movie_in); this->score->insertMovie(el.attribute("name")+ " -out", movie_out); this->score->insertMovie(el.attribute("name")+ " -shake", movie_shake); qreal sw = this->window->scene->sceneRect().width(); int xOffset = 15; int yOffset = 10; QDomNode n = el.firstChild(); int i=0; while (!n.isNull()){ QDomElement e = n.toElement(); TextButton *item = new TextButton(e.attribute("name"), TextButton::LEFT, MENU2, this->window->scene, 0); item->setRecursiveVisible(false); item->setZValue(10); qreal ih = item->sceneBoundingRect().height(); qreal iw = item->sceneBoundingRect().width(); qreal ihp = ih + 3; // create in-animation: DemoItemAnimation *anim = new DemoItemAnimation(item, DemoItemAnimation::ANIM_IN); anim->setDuration(float(1000 + (i * 20)) * Colors::animSpeedButtons); anim->setStartPos(QPointF(xOffset, -ih)); anim->setPosAt(0.20, QPointF(xOffset, -ih)); anim->setPosAt(0.50, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY + (10 * float(i / 4.0f)))); anim->setPosAt(0.60, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY)); anim->setPosAt(0.70, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY + (5 * float(i / 4.0f)))); anim->setPosAt(0.80, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY)); anim->setPosAt(0.90, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY + (1 * float(i / 4.0f)))); anim->setPosAt(1.00, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY)); movie_in->append(anim); // create out-animation: anim = new DemoItemAnimation(item, DemoItemAnimation::ANIM_OUT); anim->hideOnFinished = true; anim->setDuration((700 + (30 * i)) * Colors::animSpeedButtons); anim->setStartPos(QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY)); anim->setPosAt(0.60, QPointF(xOffset, 600 - ih - ih)); anim->setPosAt(0.65, QPointF(xOffset + 20, 600 - ih)); anim->setPosAt(1.00, QPointF(sw + iw, 600 - ih)); movie_out->append(anim); // create shake-animation: anim = new DemoItemAnimation(item); anim->setDuration(700 * Colors::animSpeedButtons); anim->setStartPos(QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY)); anim->setPosAt(0.55, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY - i*2.0)); anim->setPosAt(0.70, QPointF(xOffset - 10, (i * ihp) + yOffset + Colors::contentStartY - i*1.5)); anim->setPosAt(0.80, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY - i*1.0)); anim->setPosAt(0.90, QPointF(xOffset - 2, (i * ihp) + yOffset + Colors::contentStartY - i*0.5)); anim->setPosAt(1.00, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY)); movie_shake->append(anim); i++; n = n.nextSibling(); } // create backbutton: TextButton *backButton = new TextButton("Main menu", TextButton::RIGHT, ROOT, this->window->scene, 0, TextButton::PANEL); backButton->setRecursiveVisible(false); backButton->setZValue(10); qreal iw = backButton->sceneBoundingRect().width(); DemoItemAnimation *BackButtonIn = new DemoItemAnimation(backButton, DemoItemAnimation::ANIM_IN); BackButtonIn->setDuration(1800 * Colors::animSpeedButtons); BackButtonIn->setStartPos(QPointF(-iw, Colors::contentStartY + Colors::contentHeight - 35)); BackButtonIn->setPosAt(0.5, QPointF(-iw, Colors::contentStartY + Colors::contentHeight - 35)); BackButtonIn->setPosAt(0.7, QPointF(xOffset, Colors::contentStartY + Colors::contentHeight - 35)); BackButtonIn->setPosAt(1.0, QPointF(xOffset, Colors::contentStartY + Colors::contentHeight - 26)); movie_in->append(BackButtonIn); DemoItemAnimation *BackButtonOut = new DemoItemAnimation(backButton, DemoItemAnimation::ANIM_OUT); BackButtonOut->hideOnFinished = true; BackButtonOut->setDuration(400 * Colors::animSpeedButtons); BackButtonOut->setStartPos(QPointF(xOffset, Colors::contentStartY + Colors::contentHeight - 26)); BackButtonOut->setPosAt(1.0, QPointF(-iw, Colors::contentStartY + Colors::contentHeight - 26)); movie_out->append(BackButtonOut); // create menu content text this->createInfo(new MenuContentItem(el, this->window->scene, 0), el.attribute("name") + " -info");}void MenuManager::createLeafMenu(const QDomElement &el){ QString name = el.attribute("name"); Movie *movie_in = new Movie(); Movie *movie_out = new Movie(); this->score->insertMovie(name + " -buttons", movie_in); this->score->insertMovie(name + " -buttons -out", movie_out); qreal sw = this->window->scene->sceneRect().width(); qreal sh = this->window->scene->sceneRect().height(); int xOffset = 75; // Create launch button if (el.attribute("executable") != "false"){ TextButton *item = new TextButton("Launch", TextButton::RIGHT, LAUNCH, this->window->scene, 0, TextButton::PANEL); item->setRecursiveVisible(false); item->setZValue(10); // create in-animation: DemoItemAnimation *anim = new DemoItemAnimation(item, DemoItemAnimation::ANIM_IN); anim->setDuration(1050 * Colors::animSpeedButtons); anim->setStartPos(QPointF(sw, Colors::contentStartY + Colors::contentHeight - 35)); anim->setPosAt(0.10, QPointF(sw, Colors::contentStartY + Colors::contentHeight - 35)); anim->setPosAt(0.30, QPointF(xOffset + 330, Colors::contentStartY + Colors::contentHeight - 35)); anim->setPosAt(0.35, QPointF(xOffset + 350, Colors::contentStartY + Colors::contentHeight - 35)); anim->setPosAt(0.40, QPointF(xOffset + 330, Colors::contentStartY + Colors::contentHeight - 35)); anim->setPosAt(0.45, QPointF(xOffset + 335, Colors::contentStartY + Colors::contentHeight - 35)); anim->setPosAt(0.50, QPointF(xOffset + 330, Colors::contentStartY + Colors::contentHeight - 35)); anim->setPosAt(1.00, QPointF(xOffset + 330, Colors::contentStartY + Colors::contentHeight - 26)); movie_in->append(anim); // create out-animation: anim = new DemoItemAnimation(item, DemoItemAnimation::ANIM_OUT); anim->hideOnFinished = true; anim->setDuration(300 * Colors::animSpeedButtons); anim->setStartPos(QPointF(xOffset + 330, Colors::contentStartY + Colors::contentHeight - 26)); anim->setPosAt(1.0, QPointF(xOffset + 330, sh)); movie_out->append(anim); } // Create documentation button: TextButton *item = new TextButton("Documentation", TextButton::RIGHT, DOCUMENTATION, this->window->scene, 0, TextButton::PANEL); item->setRecursiveVisible(false); item->setZValue(10); // create in-animation: DemoItemAnimation *anim = new DemoItemAnimation(item, DemoItemAnimation::ANIM_IN); anim->setDuration(1050 * Colors::animSpeedButtons); anim->setStartPos(QPointF(sw, Colors::contentStartY + Colors::contentHeight - 35)); anim->setPosAt(0.10, QPointF(sw, Colors::contentStartY + Colors::contentHeight - 35)); anim->setPosAt(0.30, QPointF(xOffset + 530, Colors::contentStartY + Colors::contentHeight - 35)); anim->setPosAt(0.35, QPointF(xOffset + 560, Colors::contentStartY + Colors::contentHeight - 35)); anim->setPosAt(0.40, QPointF(xOffset + 530, Colors::contentStartY + Colors::contentHeight - 35)); anim->setPosAt(0.45, QPointF(xOffset + 535, Colors::contentStartY + Colors::contentHeight - 35)); anim->setPosAt(0.50, QPointF(xOffset + 530, Colors::contentStartY + Colors::contentHeight - 35)); anim->setPosAt(1.00, QPointF(xOffset + 530, Colors::contentStartY + Colors::contentHeight - 26)); movie_in->append(anim); // create out-animation: anim = new DemoItemAnimation(item, DemoItemAnimation::ANIM_OUT); anim->hideOnFinished = true; anim->setDuration(300 * Colors::animSpeedButtons); anim->setStartPos(QPointF(xOffset + 530, Colors::contentStartY + Colors::contentHeight - 26)); anim->setPosAt(1.0, QPointF(xOffset + 530, sh)); movie_out->append(anim); // Create info item: this->createInfo(new ExampleContent(name, this->window->scene, 0), el.attribute("name"));}void MenuManager::createInfo(DemoItem *item, const QString &name){ Movie *movie_in = new Movie(); Movie *movie_out = new Movie(); this->score->insertMovie(name, movie_in); this->score->insertMovie(name + " -out", movie_out); item->setZValue(8); item->setRecursiveVisible(false); float xOffset = 230.0f; DemoItemAnimation *infoIn = new DemoItemAnimation(item, DemoItemAnimation::ANIM_IN); infoIn->timeline->setCurveShape(QTimeLine::LinearCurve); infoIn->setDuration(650); infoIn->setStartPos(QPointF(this->window->scene->sceneRect().width(), Colors::contentStartY)); infoIn->setPosAt(0.60, QPointF(xOffset, Colors::contentStartY)); infoIn->setPosAt(0.70, QPointF(xOffset + 20, Colors::contentStartY)); infoIn->setPosAt(0.80, QPointF(xOffset, Colors::contentStartY)); infoIn->setPosAt(0.90, QPointF(xOffset + 7, Colors::contentStartY)); infoIn->setPosAt(1.00, QPointF(xOffset, Colors::contentStartY)); movie_in->append(infoIn); DemoItemAnimation *infoOut = new DemoItemAnimation(item, DemoItemAnimation::ANIM_OUT); infoOut->timeline->setCurveShape(QTimeLine::EaseInCurve); infoOut->setDuration(300); infoOut->hideOnFinished = true; infoOut->setStartPos(QPointF(xOffset, Colors::contentStartY)); infoOut->setPosAt(1.0, QPointF(-600, Colors::contentStartY)); movie_out->append(infoOut);}void MenuManager::createTicker(){ if (!Colors::noTicker){ Movie *movie_in = new Movie(); Movie *movie_out = new Movie(); this->score->insertMovie("ticker", movie_in); this->score->insertMovie("ticker -out", movie_out); this->ticker = new ItemCircleAnimation(this->window->scene, 0); this->ticker->setZValue(50); this->ticker->hide(); // Move ticker in: int qtendpos = 485; int qtPosY = 120; DemoItemAnimation *qtIn = new DemoItemAnimation(this->ticker, DemoItemAnimation::ANIM_IN); qtIn->setDuration(500); qtIn->startDelay = 2000; qtIn->setStartPos(QPointF(this->window->scene->sceneRect().width(), Colors::contentStartY + qtPosY)); qtIn->setPosAt(0.60, QPointF(qtendpos, Colors::contentStartY + qtPosY)); qtIn->setPosAt(0.70, QPointF(qtendpos + 30, Colors::contentStartY + qtPosY)); qtIn->setPosAt(0.80, QPointF(qtendpos, Colors::contentStartY + qtPosY)); qtIn->setPosAt(0.90, QPointF(qtendpos + 5, Colors::contentStartY + qtPosY)); qtIn->setPosAt(1.00, QPointF(qtendpos, Colors::contentStartY + qtPosY)); movie_in->append(qtIn); // Move ticker out: DemoItemAnimation *qtOut = new DemoItemAnimation(this->ticker, DemoItemAnimation::ANIM_OUT); qtOut->hideOnFinished = true; qtOut->setDuration(500); qtOut->setStartPos(QPointF(qtendpos, Colors::contentStartY + qtPosY)); qtOut->setPosAt(1.00, QPointF(this->window->scene->sceneRect().width() + 700, Colors::contentStartY + qtPosY)); movie_out->append(qtOut); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -