From 7575235abdb732d1d234cdaa9887d41be39c2940 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Wed, 29 Jul 2009 13:02:18 +1000 Subject: Recording options via menu. --- tools/qmlviewer/main.cpp | 15 +- tools/qmlviewer/qmlviewer.cpp | 217 ++++++++++++++++++++++++--- tools/qmlviewer/qmlviewer.h | 17 ++- tools/qmlviewer/qmlviewer.pro | 5 +- tools/qmlviewer/recopts.ui | 338 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 562 insertions(+), 30 deletions(-) create mode 100644 tools/qmlviewer/recopts.ui diff --git a/tools/qmlviewer/main.cpp b/tools/qmlviewer/main.cpp index 8784ae0..e5f5e05 100644 --- a/tools/qmlviewer/main.cpp +++ b/tools/qmlviewer/main.cpp @@ -32,7 +32,7 @@ void usage() qWarning(" - png file for raw frames"); qWarning(" - 'ffmpeg' for other formats"); qWarning(" -recorddither ordered|threshold|floyd .... set GIF dither recording mode"); - qWarning(" -recordperiod ............. set time between recording frames"); + qWarning(" -recordrate ........................ set recording frame rate"); qWarning(" -record arg .............................. add a recording process argument"); qWarning(" -autorecord [from-] ...... set recording to start and stop"); qWarning(" -devicekeys .............................. use numeric keys (see F1)"); @@ -63,7 +63,7 @@ int main(int argc, char ** argv) bool frameless = false; QString fileName; - int period = 0; + double fps = 0; int autorecord_from = 0; int autorecord_to = 0; QString dither = "none"; @@ -83,8 +83,8 @@ int main(int argc, char ** argv) skin = QString(argv[++i]); } else if (arg == "-netcache") { cache = QString(argv[++i]).toInt(); - } else if (arg == "-recordperiod") { - period = QString(argv[++i]).toInt(); + } else if (arg == "-recordrate") { + fps = QString(argv[++i]).toDouble(); } else if (arg == "-recordfile") { recordfile = QString(argv[++i]); } else if (arg == "-record") { @@ -127,8 +127,8 @@ int main(int argc, char ** argv) viewer.addLibraryPath(lib); viewer.setNetworkCacheSize(cache); viewer.setRecordFile(recordfile); - if (period>0) - viewer.setRecordPeriod(period); + if (fps>0) + viewer.setRecordRate(fps); if (autorecord_to) viewer.setAutoRecord(autorecord_from,autorecord_to); if (!skin.isEmpty() && QDir(skin).exists()) @@ -136,7 +136,8 @@ int main(int argc, char ** argv) if (devkeys) viewer.setDeviceKeys(true); viewer.setRecordDither(dither); - viewer.setRecordArgs(recordargs); + if (recordargs.count()) + viewer.setRecordArgs(recordargs); if (!fileName.isEmpty()) { viewer.openQml(fileName); viewer.show(); diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index 95cd24b..643760b 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -12,6 +12,7 @@ ****************************************************************************/ #include +#include "ui_recopts.h" #include "qmlviewer.h" #include @@ -30,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -127,6 +129,79 @@ void PreviewDeviceSkin::slotPopupMenu() menu->exec(QCursor::pos()); } +static struct { const char *name, *args; } ffmpegprofiles[] = { + {"Maximum Quality", "-sameq"}, + {"High Quality", "-qcomp 0.75"}, + {"Medium Quality", "-qcomp 0.5"}, + {"Low Quality", "-qcomp 0.2"}, + {"Custom ffmpeg arguments", ""}, + {0,0} +}; + +class RecordingDialog : public QDialog, public Ui::RecordingOptions { + Q_OBJECT + +public: + RecordingDialog(QWidget *parent) : QDialog(parent) + { + setupUi(this); + hz->setValidator(new QDoubleValidator(hz)); + for (int i=0; ffmpegprofiles[i].name; ++i) { + profile->addItem(ffmpegprofiles[i].name); + } + } + + void setArguments(QString a) + { + int i; + for (i=0; ffmpegprofiles[i].args[0]; ++i) { + if (ffmpegprofiles[i].args == a) { + profile->setCurrentIndex(i); + args->setText(QLatin1String(ffmpegprofiles[i].args)); + return; + } + } + customargs = a; + args->setText(a); + profile->setCurrentIndex(i); + } + + QString arguments() const + { + int i = profile->currentIndex(); + return ffmpegprofiles[i].args[0] ? QLatin1String(ffmpegprofiles[i].args) : customargs; + } + +private slots: + void pickProfile(int i) + { + if (ffmpegprofiles[i].args[0]) { + args->setText(QLatin1String(ffmpegprofiles[i].args)); + } else { + args->setText(customargs); + } + } + + void storeCustomArgs(QString s) + { + setArguments(s); + } + +private: + QString customargs; +}; + +QString QmlViewer::getVideoFileName() +{ + QString title = convertAvailable || ffmpegAvailable ? tr("Save Video File") : tr("Save PNG Frames"); + QStringList types; + if (ffmpegAvailable) types += tr("Common Video files")+QLatin1String(" (*.avi *.mpeg *.mov)"); + if (convertAvailable) types += tr("GIF Animation")+QLatin1String(" (*.gif)"); + types += tr("Individual PNG frames")+QLatin1String(" (*.png)"); + if (ffmpegAvailable) types += tr("All ffmpeg formats (*.*)"); + return QFileDialog::getSaveFileName(this, title, "", types.join(";; ")); +} + QmlViewer::QmlViewer(QWidget *parent, Qt::WindowFlags flags) : QWidget(parent, flags), frame_stream(0), scaleSkin(true), mb(0) @@ -137,7 +212,28 @@ QmlViewer::QmlViewer(QWidget *parent, Qt::WindowFlags flags) palette = 0; disabledPalette = 0; record_autotime = 0; - record_period = 20; + record_rate = 50; + record_args += QLatin1String("-sameq"); + + recdlg = new RecordingDialog(this); + connect(recdlg->pickfile, SIGNAL(clicked()), this, SLOT(pickRecordingFile())); + senseFfmpeg(); + senseImageMagick(); + if (!ffmpegAvailable) + recdlg->ffmpegOptions->hide(); + if (!ffmpegAvailable && !convertAvailable) + recdlg->rateOptions->hide(); + QString warn; + if (!ffmpegAvailable) { + if (!convertAvailable) + warn = tr("ffmpeg and ImageMagick not available - no video output"); + else + warn = tr("ffmpeg not available - GIF and PNG outputs only"); + recdlg->warning->setText(warn); + } else { + recdlg->warning->hide(); + } + if (!(flags & Qt::FramelessWindowHint)) createMenu(menuBar(),0); @@ -205,6 +301,10 @@ void QmlViewer::createMenu(QMenuBar *menu, QMenu *flatmenu) connect(recordAction, SIGNAL(triggered()), this, SLOT(toggleRecordingWithSelection())); recordMenu->addAction(recordAction); + QAction *recordOptions = new QAction(tr("Recording &Options..."), parent); + connect(recordOptions, SIGNAL(triggered()), this, SLOT(chooseRecordingOptions())); + recordMenu->addAction(recordOptions); + if (flatmenu) flatmenu->addSeparator(); QMenu *skinMenu = flatmenu ? flatmenu->addMenu(tr("&Skin")) : menu->addMenu(tr("&Skin")); @@ -310,15 +410,57 @@ void QmlViewer::takeSnapShot() ++snapshotcount; } +void QmlViewer::pickRecordingFile() +{ + QString fileName = getVideoFileName(); + if (!fileName.isEmpty()) + recdlg->file->setText(fileName); +} + +void QmlViewer::chooseRecordingOptions() +{ + recdlg->file->setText(record_file); + if (record_rate == 24) + recdlg->hz24->setChecked(true); + else if (record_rate == 25) + recdlg->hz25->setChecked(true); + else if (record_rate == 50) + recdlg->hz50->setChecked(true); + else if (record_rate == 60) + recdlg->hz60->setChecked(true); + else { + recdlg->hzCustom->setChecked(true); + recdlg->hz->setText(QString::number(record_rate)); + } + recdlg->setArguments(record_args.join(" ")); + if (recdlg->exec()) { + record_file = recdlg->file->text(); + if (recdlg->hz24->isChecked()) + record_rate = 24; + else if (recdlg->hz25->isChecked()) + record_rate = 25; + else if (recdlg->hz50->isChecked()) + record_rate = 50; + else if (recdlg->hz60->isChecked()) + record_rate = 60; + else { + record_rate = recdlg->hz->text().toDouble(); + } + record_args = recdlg->arguments().split(" ",QString::SkipEmptyParts); + } +} + void QmlViewer::toggleRecordingWithSelection() { if (!recordTimer.isRunning()) { - QString fileName = QFileDialog::getSaveFileName(this, tr("Save Video File"), "", tr("Common Video files (*.avi *.mpeg *.mov);; GIF Animation (*.gif);; Individual PNG frames (*.png);; All ffmpeg formats (*.*)")); - if (fileName.isEmpty()) - return; - if (!fileName.contains(QRegExp(".[^\\/]*$"))) - fileName += ".avi"; - setRecordFile(fileName); + if (record_file.isEmpty()) { + QString fileName = getVideoFileName(); + if (fileName.isEmpty()) + return; + if (!fileName.contains(QRegExp(".[^\\/]*$"))) + fileName += ".avi"; + setRecordFile(fileName); + } } toggleRecording(); } @@ -503,9 +645,9 @@ void QmlViewer::setRecordFile(const QString& f) record_file = f; } -void QmlViewer::setRecordPeriod(int ms) +void QmlViewer::setRecordRate(int fps) { - record_period = ms; + record_rate = fps; } void QmlViewer::sceneResized(QSize size) @@ -545,32 +687,63 @@ void QmlViewer::keyPressEvent(QKeyEvent *event) QWidget::keyPressEvent(event); } +void QmlViewer::senseImageMagick() +{ + QProcess proc; + proc.start("convert", QStringList() << "-h"); + proc.waitForFinished(2000); + QString help = proc.readAllStandardOutput(); + convertAvailable = help.contains("ImageMagick"); +} + +void QmlViewer::senseFfmpeg() +{ + QProcess proc; + proc.start("ffmpeg", QStringList() << "-h"); + proc.waitForFinished(2000); + QString ffmpegHelp = proc.readAllStandardOutput(); + ffmpegAvailable = ffmpegHelp.contains("-s "); + ffmpegHelp = tr("Video recording use ffmpeg:")+"\n\n"+ffmpegHelp; + + QDialog *d = new QDialog(recdlg); + QVBoxLayout *l = new QVBoxLayout(d); + QTextBrowser *b = new QTextBrowser(d); + QFont f = b->font(); + f.setFamily("courier"); + b->setFont(f); + b->setText(ffmpegHelp); + l->addWidget(b); + d->setLayout(l); + ffmpegHelpWindow = d; + connect(recdlg->ffmpegHelp,SIGNAL(clicked()), ffmpegHelpWindow, SLOT(show())); +} + void QmlViewer::setRecording(bool on) { if (on == recordTimer.isRunning()) return; - QUnifiedTimer::instance()->setTimingInterval(on ? record_period:16); + int period = int(1000/record_rate+0.5); + QUnifiedTimer::instance()->setTimingInterval(on ? period:16); QUnifiedTimer::instance()->setConsistentTiming(on); if (on) { canvas->setViewportUpdateMode(QGraphicsView::FullViewportUpdate); - recordTimer.setInterval(record_period); + recordTimer.setInterval(period); recordTimer.setRunning(true); - QString fmt = record_file.right(4).toLower(); - if (fmt != ".png" && fmt != ".gif") { + frame_fmt = record_file.right(4).toLower(); + frame = QImage(canvas->width(),canvas->height(),QImage::Format_RGB32); + if (frame_fmt != ".png" && (!convertAvailable || frame_fmt != ".gif")) { // Stream video to ffmpeg QProcess *proc = new QProcess(this); connect(proc, SIGNAL(finished(int)), this, SLOT(ffmpegFinished(int))); frame_stream = proc; - frame = QImage(canvas->width(),canvas->height(),QImage::Format_RGB32); QStringList args; - args << "-sameq"; // ie. high args << "-y"; - args << "-r" << QString::number(1000/record_period); + args << "-r" << QString::number(record_rate); args << "-f" << "rawvideo"; - args << "-pix_fmt" << "rgb32"; + args << "-pix_fmt" << (frame_fmt == ".gif" ? "rgb24" : "rgb32"); args << "-s" << QString("%1x%2").arg(canvas->width()).arg(canvas->height()); args << "-i" << "-"; args += record_args; @@ -635,7 +808,7 @@ void QmlViewer::setRecording(bool on) // ImageMagick and gifsicle for GIF encoding progress.setLabelText(tr("Converting frames to GIF file...")); QStringList args; - args << "-delay" << QString::number(record_period/10); + args << "-delay" << QString::number(period/10); args << inputs; args << record_file; qDebug() << "Converting..." << record_file << "(this may take a while)"; @@ -685,7 +858,13 @@ void QmlViewer::recordFrame() { canvas->QWidget::render(&frame); if (frame_stream) { - frame_stream->write((char*)frame.bits(),frame.numBytes()); + if (frame_fmt == ".gif") { + // ffmpeg can't do 32bpp with gif + QImage rgb24 = frame.convertToFormat(QImage::Format_RGB888); + frame_stream->write((char*)rgb24.bits(),rgb24.numBytes()); + } else { + frame_stream->write((char*)frame.bits(),frame.numBytes()); + } } else { frames.append(new QImage(frame)); } diff --git a/tools/qmlviewer/qmlviewer.h b/tools/qmlviewer/qmlviewer.h index e7177eb..15acf72 100644 --- a/tools/qmlviewer/qmlviewer.h +++ b/tools/qmlviewer/qmlviewer.h @@ -26,6 +26,7 @@ class PreviewDeviceSkin; class QFxTestEngine; class QmlPalette; class QProcess; +class RecordingDialog; class QmlViewer : public QWidget { @@ -34,10 +35,9 @@ public: QmlViewer(QWidget *parent=0, Qt::WindowFlags flags=0); void setRecordDither(const QString& s) { record_dither = s; } - void setRecordPeriod(int ms); + void setRecordRate(int fps); void setRecordFile(const QString&); void setRecordArgs(const QStringList&); - int recordPeriod() const { return record_period; } void setRecording(bool on); bool isRecording() const { return recordTimer.isRunning(); } void setAutoRecord(int from, int to); @@ -69,10 +69,13 @@ private slots: void autoStartRecording(); void autoStopRecording(); void recordFrame(); + void chooseRecordingOptions(); + void pickRecordingFile(); private: void setupProxy(); void setupPalettes(); + QString getVideoFileName(); QString currentFileName; PreviewDeviceSkin *skin; @@ -81,6 +84,7 @@ private: QmlPalette *palette; QmlPalette *disabledPalette; QmlTimer recordTimer; + QString frame_fmt; QImage frame; QList frames; QProcess* frame_stream; @@ -89,13 +93,20 @@ private: QString record_dither; QString record_file; QStringList record_args; - int record_period; + int record_rate; int record_autotime; bool devicemode; QAction *recordAction; QString currentSkin; bool scaleSkin; mutable QMenuBar *mb; + RecordingDialog *recdlg; + + void senseImageMagick(); + void senseFfmpeg(); + QWidget *ffmpegHelpWindow; + bool ffmpegAvailable; + bool convertAvailable; }; QT_END_NAMESPACE diff --git a/tools/qmlviewer/qmlviewer.pro b/tools/qmlviewer/qmlviewer.pro index 08d2d2b..a8ccd91 100644 --- a/tools/qmlviewer/qmlviewer.pro +++ b/tools/qmlviewer/qmlviewer.pro @@ -1,12 +1,15 @@ +TEMPLATE = app +CONFIG += qt uic DESTDIR = ../../bin QT += declarative script network sql # Input HEADERS += qmlviewer.h SOURCES += main.cpp qmlviewer.cpp +FORMS = recopts.ui + include($$QT_SOURCE_TREE/tools/shared/deviceskin/deviceskin.pri) target.path=$$[QT_INSTALL_BINS] INSTALLS += target -CONFIG += console diff --git a/tools/qmlviewer/recopts.ui b/tools/qmlviewer/recopts.ui new file mode 100644 index 0000000..041a4c4 --- /dev/null +++ b/tools/qmlviewer/recopts.ui @@ -0,0 +1,338 @@ + + + RecordingOptions + + + + 0 + 0 + 290 + 297 + + + + Recording options + + + + + + + 0 + 0 + + + + File: + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + ... + + + + + + + + 0 + + + + + Profile: + + + + + + + + + + + + + Help + + + + + + + + + + + 0 + + + + + + 0 + 0 + + + + Rate: + + + + + + + 24Hz + + + + + + + 50Hz + + + + + + + 25Hz + + + + + + + + 0 + 0 + + + + 60Hz + + + true + + + + + + + 0 + + + + + + + + + + + + + 0 + 0 + + + + + 60 + 0 + + + + + 100 + 16777215 + + + + + + + + Hz + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + + + hzCustom + clicked() + hz + setFocus() + + + 54 + 104 + + + 85 + 107 + + + + + hz + textChanged(QString) + hzCustom + toggle() + + + 138 + 102 + + + 49 + 104 + + + + + hz + selectionChanged() + hzCustom + toggle() + + + 110 + 105 + + + 51 + 103 + + + + + buttonBox + accepted() + RecordingOptions + accept() + + + 280 + 287 + + + 60 + 219 + + + + + buttonBox + rejected() + RecordingOptions + reject() + + + 280 + 287 + + + 92 + 219 + + + + + profile + activated(int) + RecordingOptions + pickProfile(int) + + + 72 + 132 + + + 48 + 194 + + + + + args + textEdited(QString) + RecordingOptions + storeCustomArgs(QString) + + + 108 + 161 + + + 102 + 189 + + + + + + filePicked(QString) + argumentsPicked(QString) + pickFile() + pickProfile(int) + storeCustomArgs(QString) + + -- cgit v0.12 From 28a72e09be58628e6f30c6bd345ff1fe63a117a4 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 22 Jul 2009 13:38:48 +0200 Subject: fix calculator example --- demos/declarative/calculator/calculator.qml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/demos/declarative/calculator/calculator.qml b/demos/declarative/calculator/calculator.qml index 001730d..1cc8fa8 100644 --- a/demos/declarative/calculator/calculator.qml +++ b/demos/declarative/calculator/calculator.qml @@ -58,21 +58,21 @@ Rect { GridLayout { id: NumKeypad; y: 32; spacing: 2; columns: 3 - CalcButton { operation: 7 } - CalcButton { operation: 8 } - CalcButton { operation: 9 } - CalcButton { operation: 4 } - CalcButton { operation: 5 } - CalcButton { operation: 6 } - CalcButton { operation: 1 } - CalcButton { operation: 2 } - CalcButton { operation: 3 } + CalcButton { operation: "7" } + CalcButton { operation: "8" } + CalcButton { operation: "9" } + CalcButton { operation: "4" } + CalcButton { operation: "5" } + CalcButton { operation: "6" } + CalcButton { operation: "1" } + CalcButton { operation: "2" } + CalcButton { operation: "3" } } HorizontalLayout { y: 128; spacing: 2 - CalcButton { operation: 0; width: 50 } + CalcButton { operation: "0"; width: 50 } CalcButton { operation: "."; x: 77; width: 50 } CalcButton { operation: "="; id: Equals; x: 77; width: 102 } } -- cgit v0.12 From c2cfe5c403f379b3196416960880ade859b7e509 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 22 Jul 2009 20:27:29 +0200 Subject: remove itemParent() and related. Consistently use parentItem() as it is consistent with the naming in QGraphicsItem. --- src/declarative/fx/qfxanchors.cpp | 58 ++++++++++++++--------------- src/declarative/fx/qfxcomponentinstance.cpp | 2 +- src/declarative/fx/qfxgridview.cpp | 4 +- src/declarative/fx/qfxitem.cpp | 45 ++++++++-------------- src/declarative/fx/qfxitem.h | 7 +--- src/declarative/fx/qfxitem_p.h | 2 +- src/declarative/fx/qfxlayouts.cpp | 8 ++-- src/declarative/fx/qfxlineedit.cpp | 2 +- src/declarative/fx/qfxlistview.cpp | 2 +- src/declarative/fx/qfxpathview.cpp | 2 +- src/declarative/fx/qfxpathview_p.h | 2 +- src/declarative/fx/qfxrepeater.cpp | 4 +- src/declarative/fx/qfxtextedit.cpp | 2 +- src/declarative/util/qfxview.cpp | 2 +- src/declarative/util/qmlstateoperations.cpp | 10 ++--- 15 files changed, 67 insertions(+), 85 deletions(-) diff --git a/src/declarative/fx/qfxanchors.cpp b/src/declarative/fx/qfxanchors.cpp index 9704fef..9093c8e 100644 --- a/src/declarative/fx/qfxanchors.cpp +++ b/src/declarative/fx/qfxanchors.cpp @@ -152,9 +152,9 @@ void QFxAnchorsPrivate::fillChanged() if (!fill || !isItemComplete()) return; - if (fill == item->itemParent()) { //child-parent + if (fill == item->parentItem()) { //child-parent setItemPos(QPointF(leftMargin, topMargin)); - } else if (fill->itemParent() == item->itemParent()) { //siblings + } else if (fill->parentItem() == item->parentItem()) { //siblings setItemPos(QPointF(fill->x()+leftMargin, fill->y()+topMargin)); } setItemWidth(fill->width()-leftMargin-rightMargin); @@ -166,12 +166,12 @@ void QFxAnchorsPrivate::centeredInChanged() if (!centeredIn || fill || !isItemComplete()) return; - if (centeredIn == item->itemParent()) { - QPointF p((item->itemParent()->width() - item->width()) / 2., - (item->itemParent()->height() - item->height()) / 2.); + if (centeredIn == item->parentItem()) { + QPointF p((item->parentItem()->width() - item->width()) / 2., + (item->parentItem()->height() - item->height()) / 2.); setItemPos(p); - } else if (centeredIn->itemParent() == item->itemParent()) { + } else if (centeredIn->parentItem() == item->parentItem()) { QPointF p(centeredIn->x() + (centeredIn->width() - item->width()) / 2., centeredIn->y() + (centeredIn->height() - item->height()) / 2.); @@ -328,7 +328,7 @@ void QFxAnchors::setFill(QFxItem *f) d->fill = f; return; } - if (f != d->item->itemParent() && f->itemParent() != d->item->itemParent()){ + if (f != d->item->parentItem() && f->parentItem() != d->item->parentItem()){ qmlInfo(d->item) << "Can't anchor to an item that isn't a parent or sibling."; return; } @@ -360,7 +360,7 @@ void QFxAnchors::setCenteredIn(QFxItem* c) d->centeredIn = c; return; } - if (c != d->item->itemParent() && c->itemParent() != d->item->itemParent()){ + if (c != d->item->parentItem() && c->parentItem() != d->item->parentItem()){ qmlInfo(d->item) << "Can't anchor to an item that isn't a parent or sibling."; return; } @@ -379,10 +379,10 @@ bool QFxAnchorsPrivate::calcStretch(const QFxAnchorLine &edge1, QFxAnchorLine::AnchorLine line, int &stretch) { - bool edge1IsParent = (edge1.item == item->itemParent()); - bool edge2IsParent = (edge2.item == item->itemParent()); - bool edge1IsSibling = (edge1.item->itemParent() == item->itemParent()); - bool edge2IsSibling = (edge2.item->itemParent() == item->itemParent()); + bool edge1IsParent = (edge1.item == item->parentItem()); + bool edge2IsParent = (edge2.item == item->parentItem()); + bool edge1IsSibling = (edge1.item->parentItem() == item->parentItem()); + bool edge2IsSibling = (edge2.item->parentItem() == item->parentItem()); bool invalid = false; if ((edge2IsParent && edge1IsParent) || (edge2IsSibling && edge1IsSibling)) { @@ -390,10 +390,10 @@ bool QFxAnchorsPrivate::calcStretch(const QFxAnchorLine &edge1, - ((int)position(edge1.item, edge1.anchorLine) + offset1); } else if (edge2IsParent && edge1IsSibling) { stretch = ((int)position(edge2.item, edge2.anchorLine) + offset2) - - ((int)position(item->itemParent(), line) + - ((int)position(item->parentItem(), line) + (int)position(edge1.item, edge1.anchorLine) + offset1); } else if (edge2IsSibling && edge1IsParent) { - stretch = ((int)position(item->itemParent(), line) + (int)position(edge2.item, edge2.anchorLine) + offset2) + stretch = ((int)position(item->parentItem(), line) + (int)position(edge2.item, edge2.anchorLine) + offset2) - ((int)position(edge1.item, edge1.anchorLine) + offset1); } else invalid = true; @@ -422,9 +422,9 @@ void QFxAnchorsPrivate::updateVerticalAnchors() setItemHeight(height); //Handle top - if (top.item == item->itemParent()) { + if (top.item == item->parentItem()) { setItemY(adjustedPosition(top.item, top.anchorLine) + topMargin); - } else if (top.item->itemParent() == item->itemParent()) { + } else if (top.item->parentItem() == item->parentItem()) { setItemY(position(top.item, top.anchorLine) + topMargin); } } else if (usedAnchors & QFxAnchors::HasBottomAnchor) { @@ -438,24 +438,24 @@ void QFxAnchorsPrivate::updateVerticalAnchors() } //Handle bottom - if (bottom.item == item->itemParent()) { + if (bottom.item == item->parentItem()) { setItemY(adjustedPosition(bottom.item, bottom.anchorLine) - item->height() - bottomMargin); - } else if (bottom.item->itemParent() == item->itemParent()) { + } else if (bottom.item->parentItem() == item->parentItem()) { setItemY(position(bottom.item, bottom.anchorLine) - item->height() - bottomMargin); } } else if (usedAnchors & QFxAnchors::HasVCenterAnchor) { //(stetching handled above) //Handle vCenter - if (vCenter.item == item->itemParent()) { + if (vCenter.item == item->parentItem()) { setItemY(adjustedPosition(vCenter.item, vCenter.anchorLine) - item->height()/2 + vCenterOffset); - } else if (vCenter.item->itemParent() == item->itemParent()) { + } else if (vCenter.item->parentItem() == item->parentItem()) { setItemY(position(vCenter.item, vCenter.anchorLine) - item->height()/2 + vCenterOffset); } } else if (usedAnchors & QFxAnchors::HasBaselineAnchor) { //Handle baseline - if (baseline.item->itemParent() == item->itemParent()) { + if (baseline.item->parentItem() == item->parentItem()) { setItemY(position(baseline.item, baseline.anchorLine) - item->baselineOffset()); } } @@ -488,9 +488,9 @@ void QFxAnchorsPrivate::updateHorizontalAnchors() setItemWidth(width); //Handle left - if (left.item == item->itemParent()) { + if (left.item == item->parentItem()) { setItemX(adjustedPosition(left.item, left.anchorLine) + leftMargin); - } else if (left.item->itemParent() == item->itemParent()) { + } else if (left.item->parentItem() == item->parentItem()) { setItemX(position(left.item, left.anchorLine) + leftMargin); } } else if (usedAnchors & QFxAnchors::HasRightAnchor) { @@ -504,16 +504,16 @@ void QFxAnchorsPrivate::updateHorizontalAnchors() } //Handle right - if (right.item == item->itemParent()) { + if (right.item == item->parentItem()) { setItemX(adjustedPosition(right.item, right.anchorLine) - item->width() - rightMargin); - } else if (right.item->itemParent() == item->itemParent()) { + } else if (right.item->parentItem() == item->parentItem()) { setItemX(position(right.item, right.anchorLine) - item->width() - rightMargin); } } else if (usedAnchors & QFxAnchors::HasHCenterAnchor) { //Handle hCenter - if (hCenter.item == item->itemParent()) { + if (hCenter.item == item->parentItem()) { setItemX(adjustedPosition(hCenter.item, hCenter.anchorLine) - item->width()/2 + hCenterOffset); - } else if (hCenter.item->itemParent() == item->itemParent()) { + } else if (hCenter.item->parentItem() == item->parentItem()) { setItemX(position(hCenter.item, hCenter.anchorLine) - item->width()/2 + hCenterOffset); } } @@ -892,7 +892,7 @@ bool QFxAnchorsPrivate::checkHAnchorValid(QFxAnchorLine anchor) const } else if (anchor.anchorLine & QFxAnchorLine::Vertical_Mask) { qmlInfo(item) << "Can't anchor a horizontal edge to a vertical edge."; return false; - } else if (anchor.item != item->itemParent() && anchor.item->itemParent() != item->itemParent()){ + } else if (anchor.item != item->parentItem() && anchor.item->parentItem() != item->parentItem()){ qmlInfo(item) << "Can't anchor to an item that isn't a parent or sibling."; return false; } else if (anchor.item == item) { @@ -929,7 +929,7 @@ bool QFxAnchorsPrivate::checkVAnchorValid(QFxAnchorLine anchor) const } else if (anchor.anchorLine & QFxAnchorLine::Horizontal_Mask) { qmlInfo(item) << "Can't anchor a vertical edge to a horizontal edge."; return false; - } else if (anchor.item != item->itemParent() && anchor.item->itemParent() != item->itemParent()){ + } else if (anchor.item != item->parentItem() && anchor.item->parentItem() != item->parentItem()){ qmlInfo(item) << "Can't anchor to an item that isn't a parent or sibling."; return false; } else if (anchor.item == item){ diff --git a/src/declarative/fx/qfxcomponentinstance.cpp b/src/declarative/fx/qfxcomponentinstance.cpp index 3ea45bd..a85b25d 100644 --- a/src/declarative/fx/qfxcomponentinstance.cpp +++ b/src/declarative/fx/qfxcomponentinstance.cpp @@ -113,7 +113,7 @@ void QFxComponentInstance::create() QFxItem *objitem = qobject_cast(obj); if (objitem) { d->instance = objitem; - objitem->setItemParent(this); + objitem->setParentItem(this); objitem->setFocus(true); connect(objitem, SIGNAL(widthChanged()), this, SLOT(updateSize())); connect(objitem, SIGNAL(heightChanged()), this, SLOT(updateSize())); diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp index 27ac92d..8df6f2a 100644 --- a/src/declarative/fx/qfxgridview.cpp +++ b/src/declarative/fx/qfxgridview.cpp @@ -1380,9 +1380,9 @@ void QFxGridView::destroyRemoved() void QFxGridView::createdItem(int index, QFxItem *item) { Q_D(QFxGridView); - item->setItemParent(this); + item->setParentItem(this); if (d->requestedIndex != index) { - item->setItemParent(this); + item->setParentItem(this); d->unrequestedItems.insert(item, index); if (d->flow == QFxGridView::LeftToRight) { item->setPos(QPointF(d->colPosAt(index), d->rowPosAt(index))); diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index b8f4696..edf61e4 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -354,7 +354,7 @@ void QFxContents::setItem(QFxItem *item) This signal is emitted when the parent of the item changes. - \sa setItemParent() + \sa setParentItem() */ /*! @@ -440,22 +440,23 @@ QFxItem::~QFxItem() \property QFxItem::parent This property holds the parent of the item. */ -void QFxItem::setItemParent(QFxItem *parent) +void QFxItem::setParentItem(QFxItem *parent) { - setParent(parent); + QFxItem *oldParent = parentItem(); + if (parent == oldParent || !parent) return; + + QObject::setParent(parent); + QGraphicsObject::setParentItem(parent); + + parentChanged(parent, oldParent); } /*! Returns the QFxItem parent of this item. */ -QFxItem *QFxItem::itemParent() const -{ - return qobject_cast(QGraphicsItem::parentItem()); -} - QFxItem *QFxItem::parentItem() const { - return itemParent(); + return qobject_cast(QGraphicsObject::parentItem()); } /*! @@ -849,7 +850,7 @@ void QFxItem::qmlLoaded() qWarning() << d->_qmlcomp->errors(); QFxItem *qmlChild = qobject_cast(obj); if (qmlChild) { - qmlChild->setItemParent(this); + qmlChild->setParentItem(this); d->_qmlChildren.insert(d->_qml.toString(), qmlChild); d->qmlItem = qmlChild; } else { @@ -1037,8 +1038,8 @@ void QFxItem::keyPressEvent(QKeyEvent *event) QFxKeyEvent ke(*event); emit keyPress(&ke); event->setAccepted(ke.isAccepted()); - if (itemParent() && !ke.isAccepted()) - itemParent()->keyPressEvent(event); + if (parentItem() && !ke.isAccepted()) + parentItem()->keyPressEvent(event); } /*! @@ -1049,8 +1050,8 @@ void QFxItem::keyReleaseEvent(QKeyEvent *event) QFxKeyEvent ke(*event); emit keyRelease(&ke); event->setAccepted(ke.isAccepted()); - if (itemParent() && !ke.isAccepted()) - itemParent()->keyReleaseEvent(event); + if (parentItem() && !ke.isAccepted()) + parentItem()->keyReleaseEvent(event); } /*! @@ -2271,22 +2272,6 @@ void QFxItem::setOptions(Options options, bool set) } } -/*! - \fn void QFxItem::setParent(QFxItem *parent) - - Sets the parent of the item to \a parent. - */ -void QFxItem::setParent(QFxItem *p) -{ - if (p == parent() || !p) return; - - QObject::setParent(p); - - QFxItem *oldParent = itemParent(); - setParentItem(p); - parentChanged(p, oldParent); -} - void QFxItem::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) { paintContents(*p); diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index a75bdcd..c444507 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -121,7 +121,7 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta Q_OBJECT Q_INTERFACES(QmlParserStatus) - Q_PROPERTY(QFxItem * parent READ itemParent WRITE setItemParent NOTIFY parentChanged DESIGNABLE false FINAL) + Q_PROPERTY(QFxItem * parent READ parentItem WRITE setParentItem NOTIFY parentChanged DESIGNABLE false FINAL) Q_PROPERTY(QmlList* children READ children DESIGNABLE false) Q_PROPERTY(QmlList* resources READ resources DESIGNABLE false) Q_PROPERTY(QFxAnchors * anchors READ anchors DESIGNABLE false CONSTANT FINAL) @@ -176,9 +176,8 @@ public: QFxItem(QFxItem *parent = 0); virtual ~QFxItem(); - QFxItem *itemParent() const; // ### remove me QFxItem *parentItem() const; - void setItemParent(QFxItem *parent); // ## setParentItem + void setParentItem(QFxItem *parent); // ## setParentItem QmlList *data(); QmlList *children(); @@ -240,8 +239,6 @@ public: void setTransformOrigin(TransformOrigin); QPointF transformOriginPoint() const; - void setParent(QFxItem *); - QRect itemBoundingRect(); // ### remove me void setPaintMargin(qreal margin); diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h index 5ab31b8..08d2e4a 100644 --- a/src/declarative/fx/qfxitem_p.h +++ b/src/declarative/fx/qfxitem_p.h @@ -92,7 +92,7 @@ public: Q_Q(QFxItem); if (parent) - q->setItemParent(parent); + q->setParentItem(parent); _baselineOffset.invalidate(); q->setAcceptedMouseButtons(Qt::NoButton); q->setFlags(QGraphicsItem::ItemHasNoContents | diff --git a/src/declarative/fx/qfxlayouts.cpp b/src/declarative/fx/qfxlayouts.cpp index 6b94321..0546845 100644 --- a/src/declarative/fx/qfxlayouts.cpp +++ b/src/declarative/fx/qfxlayouts.cpp @@ -378,12 +378,12 @@ void QFxBaseLayout::preLayout() if (d->aut & Horizontal) setWidth(int(width)); - else if (itemParent()) - setImplicitWidth(itemParent()->width()); + else if (parentItem()) + setImplicitWidth(parentItem()->width()); if (d->aut & Vertical) setHeight(int(height)); - else if (itemParent()) - setImplicitHeight(itemParent()->height()); + else if (parentItem()) + setImplicitHeight(parentItem()->height()); setLayoutItem(0); } diff --git a/src/declarative/fx/qfxlineedit.cpp b/src/declarative/fx/qfxlineedit.cpp index 4ff3504..a185383 100644 --- a/src/declarative/fx/qfxlineedit.cpp +++ b/src/declarative/fx/qfxlineedit.cpp @@ -367,7 +367,7 @@ void QFxLineEdit::createCursor() return; } - d->cursorItem->setItemParent(this); + d->cursorItem->setParentItem(this); d->cursorItem->setX(d->control->cursorToX()); d->cursorItem->setHeight(d->control->height()); } diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp index 36ecddd..5f1defd 100644 --- a/src/declarative/fx/qfxlistview.cpp +++ b/src/declarative/fx/qfxlistview.cpp @@ -1615,7 +1615,7 @@ void QFxListView::createdItem(int index, QFxItem *item) { Q_D(QFxListView); if (d->requestedIndex != index) { - item->setItemParent(viewport()); + item->setParentItem(viewport()); d->unrequestedItems.insert(item, index); if (d->orient == Qt::Vertical) item->setY(d->positionAt(index)); diff --git a/src/declarative/fx/qfxpathview.cpp b/src/declarative/fx/qfxpathview.cpp index 2a36c25..98121e6 100644 --- a/src/declarative/fx/qfxpathview.cpp +++ b/src/declarative/fx/qfxpathview.cpp @@ -737,7 +737,7 @@ void QFxPathView::createdItem(int index, QFxItem *item) { Q_D(QFxPathView); if (d->requestedIndex != index) { - item->setItemParent(this); + item->setParentItem(this); d->updateItem(item, index < d->firstIndex ? 0.0 : 1.0); } } diff --git a/src/declarative/fx/qfxpathview_p.h b/src/declarative/fx/qfxpathview_p.h index 63c8224..be9509f 100644 --- a/src/declarative/fx/qfxpathview_p.h +++ b/src/declarative/fx/qfxpathview_p.h @@ -96,7 +96,7 @@ public: requestedIndex = modelIndex; QFxItem *item = model->item(modelIndex); if (item) - item->setItemParent(q); + item->setParentItem(q); requestedIndex = -1; return item; } diff --git a/src/declarative/fx/qfxrepeater.cpp b/src/declarative/fx/qfxrepeater.cpp index 084921b..a231f20 100644 --- a/src/declarative/fx/qfxrepeater.cpp +++ b/src/declarative/fx/qfxrepeater.cpp @@ -62,7 +62,7 @@ QFxItem *QFxRepeaterPrivate::addItem(QmlContext *ctxt, QFxItem *lastItem) QObject *nobj = component->create(ctxt); QFxItem *item = qobject_cast(nobj); if (item) { - item->setParent(q->itemParent()); + item->setParent(q->parentItem()); // item->stackUnder(lastItem); deletables << nobj; } else { @@ -259,7 +259,7 @@ void QFxRepeater::regenerate() qDeleteAll(d->deletables); d->deletables.clear(); - if (!d->component || !itemParent() || !isComponentComplete()) + if (!d->component || !parentItem() || !isComponentComplete()) return; QFxItem *lastItem = this; diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp index fbb2d53..abad7fc 100644 --- a/src/declarative/fx/qfxtextedit.cpp +++ b/src/declarative/fx/qfxtextedit.cpp @@ -531,7 +531,7 @@ void QFxTextEdit::loadCursorDelegate() this, SLOT(moveCursorDelegate())); d->control->setCursorWidth(0); dirtyCache(cursorRect()); - d->cursor->setItemParent(this); + d->cursor->setParentItem(this); d->cursor->setHeight(QFontMetrics(d->font.font()).height()); moveCursorDelegate(); }else{ diff --git a/src/declarative/util/qfxview.cpp b/src/declarative/util/qfxview.cpp index 96d9e8e..2f5cdd3 100644 --- a/src/declarative/util/qfxview.cpp +++ b/src/declarative/util/qfxview.cpp @@ -443,7 +443,7 @@ QFxItem* QFxView::addItem(const QString &qml, QFxItem* parent) if (!parent) parent = d->root; - item->setItemParent(parent); + item->setParentItem(parent); return item; } return 0; diff --git a/src/declarative/util/qmlstateoperations.cpp b/src/declarative/util/qmlstateoperations.cpp index 3d03c34..7caf3ed 100644 --- a/src/declarative/util/qmlstateoperations.cpp +++ b/src/declarative/util/qmlstateoperations.cpp @@ -63,8 +63,8 @@ public: void QmlParentChangePrivate::doChange(QFxItem *targetParent) { - if (targetParent && target && target->itemParent()) { - QPointF me = target->itemParent()->mapToScene(QPointF(0,0)); + if (targetParent && target && target->parentItem()) { + QPointF me = target->parentItem()->mapToScene(QPointF(0,0)); QPointF them = targetParent->mapToScene(QPointF(0,0)); QPointF themx = targetParent->mapToScene(QPointF(1,0)); @@ -73,7 +73,7 @@ void QmlParentChangePrivate::doChange(QFxItem *targetParent) themx -= them; themy -= them; - target->setItemParent(targetParent); + target->setParentItem(targetParent); // XXX - this is silly and will only work in a few cases @@ -112,7 +112,7 @@ void QmlParentChangePrivate::doChange(QFxItem *targetParent) target->setX(target->x() - rx); target->setY(target->y() - ry); } else if (target) { - target->setItemParent(targetParent); + target->setParentItem(targetParent); } } @@ -182,7 +182,7 @@ void QmlParentChange::execute() { Q_D(QmlParentChange); if (d->target) - d->origParent = d->target->itemParent(); + d->origParent = d->target->parentItem(); d->doChange(d->parent); } -- cgit v0.12 From 348d74a53bfe0b1db6081748d25303637180ad9d Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 22 Jul 2009 21:09:42 +0200 Subject: Remove the rotation/scale properties from QFxItem This is directly supported in QGraphicsItem and we should use the methods from there. The transformation handling code in QGraphicsItem needs further cleanups to get to the agreed model (using a QGraphicsTransform and only implementing rotate/scale as trivial transformations) --- src/declarative/fx/qfxitem.cpp | 102 ++--------------------------------------- src/declarative/fx/qfxitem.h | 11 ----- src/declarative/fx/qfxitem_p.h | 9 ++-- 3 files changed, 7 insertions(+), 115 deletions(-) diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index edf61e4..35f3b71 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -308,12 +308,6 @@ void QFxContents::setItem(QFxItem *item) */ /*! - \fn void QFxItem::scaleChanged() - - This signal is emitted when the scale of the item changes. -*/ - -/*! \fn void QFxItem::stateChanged(const QString &state) This signal is emitted when the \a state of the item changes. @@ -1334,29 +1328,6 @@ void QFxItem::setBaselineOffset(qreal offset) */ /*! - \property QFxItem::rotation - This property holds the rotation of the item in degrees. - - This specifies how many degrees to rotate the item around its transformOrigin. - The default rotation is 0 degrees (i.e. not rotated at all). -*/ -qreal QFxItem::rotation() const -{ - Q_D(const QFxItem); - return d->_rotation; -} - -void QFxItem::setRotation(qreal rotation) -{ - Q_D(QFxItem); - if (d->_rotation == rotation) - return; - d->_rotation = rotation; - setTransform(d->transform); - emit rotationChanged(); -} - -/*! \qmlproperty real Item::scale This property holds the scale of the item. @@ -1393,21 +1364,6 @@ void QFxItem::setRotation(qreal rotation) */ /*! - \property QFxItem::scale - This property holds the scale of the item. - - A scale of less than 1 means the item will be displayed smaller than - normal, and a scale of greater than 1 means the item will be - displayed larger than normal. A negative scale means the item will - be mirrored. - - By default, items are displayed at a scale of 1 (i.e. at their - normal size). - - Scaling is from the item's transformOrigin. -*/ - -/*! \qmlproperty real Item::opacity The opacity of the item. Opacity is specified as a number between 0 @@ -1837,7 +1793,7 @@ QFxItemPrivate::AnchorLines::AnchorLines(QFxItem *q) baseline.anchorLine = QFxAnchorLine::Baseline; } -QPointF QFxItemPrivate::transformOrigin() const +QPointF QFxItemPrivate::computeTransformOrigin() const { Q_Q(const QFxItem); @@ -1980,14 +1936,14 @@ void QFxItem::setTransformOrigin(TransformOrigin origin) Q_D(QFxItem); if (origin != d->origin) { d->origin = origin; - update(); + QPointF to = d->computeTransformOrigin(); + QGraphicsItem::setTransformOrigin(to.x(), to.y()); } } QPointF QFxItem::transformOriginPoint() const { - Q_D(const QFxItem); - return d->transformOrigin(); + return QGraphicsItem::transformOrigin(); } qreal QFxItem::width() const @@ -2080,61 +2036,11 @@ bool QFxItem::heightValid() const return d->heightValid; } -qreal QFxItem::scale() const -{ - Q_D(const QFxItem); - return d->scale; -} - -void QFxItem::setScale(qreal s) -{ - Q_D(QFxItem); - if (d->scale == s) - return; - - d->scale = s; - setTransform(d->transform); - - emit scaleChanged(); -} - QRect QFxItem::itemBoundingRect() { return boundingRect().toAlignedRect(); } -QTransform QFxItem::transform() const -{ - Q_D(const QFxItem); - return d->transform; -} - -//### optimize (perhaps cache scale and rot transforms, and have dirty flags) -//### we rely on there not being an "if (d->transform == m) return;" check -void QFxItem::setTransform(const QTransform &m) -{ - Q_D(QFxItem); - d->transform = m; - QTransform scaleTransform, rotTransform; - if (d->scale != 1) { - QPointF to = transformOriginPoint(); - if (to.x() != 0. || to.y() != 0.) - scaleTransform.translate(to.x(), to.y()); - scaleTransform.scale(d->scale, d->scale); - if (to.x() != 0. || to.y() != 0.) - scaleTransform.translate(-to.x(), -to.y()); - } - if (d->_rotation != 0) { - QPointF to = d->transformOrigin(); - if (to.x() != 0. || to.y() != 0.) - rotTransform.translate(to.x(), to.y()); - rotTransform.rotate(d->_rotation); - if (to.x() != 0. || to.y() != 0.) - rotTransform.translate(-to.x(), -to.y()); - } - QGraphicsItem::setTransform(scaleTransform * rotTransform * d->transform); -} - QFxItem *QFxItem::mouseGrabberItem() const { QGraphicsScene *s = scene(); diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index c444507..3047713 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -142,8 +142,6 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta Q_PROPERTY(QFxAnchorLine verticalCenter READ verticalCenter CONSTANT FINAL) Q_PROPERTY(QFxAnchorLine baseline READ baseline CONSTANT FINAL) Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged) - Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged) // ## remove me - Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged) // ### remove me Q_PROPERTY(bool clip READ clip WRITE setClip) // ### move to QGI/QGO, NOTIFY Q_PROPERTY(bool focus READ hasFocus WRITE setFocus NOTIFY focusChanged FINAL) Q_PROPERTY(bool activeFocus READ hasActiveFocus NOTIFY activeFocusChanged FINAL) @@ -205,12 +203,6 @@ public: qreal baselineOffset() const; void setBaselineOffset(qreal); - qreal rotation() const; - void setRotation(qreal); - - qreal scale() const; - void setScale(qreal); - QList *transform(); bool isClassComplete() const; @@ -245,9 +237,6 @@ public: QRectF boundingRect() const; virtual void paintContents(QPainter &); - QTransform transform() const; // ### remove me - void setTransform(const QTransform &); // ### remove me - QFxItem *mouseGrabberItem() const; virtual bool hasFocus() const; diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h index 08d2e4a..7bdd382 100644 --- a/src/declarative/fx/qfxitem_p.h +++ b/src/declarative/fx/qfxitem_p.h @@ -76,13 +76,13 @@ class QFxItemPrivate : public QGraphicsItemPrivate public: QFxItemPrivate() : _anchors(0), _contents(0), qmlItem(0), _qmlcomp(0), - _baselineOffset(0), _rotation(0.), + _baselineOffset(0), _classComplete(true), _componentComplete(true), _keepMouse(false), _anchorLines(0), _stateGroup(0), canvas(0), origin(QFxItem::TopLeft), options(QFxItem::NoOption), widthValid(false), heightValid(false), width(0), height(0), - paintmargin(0), scale(1) + paintmargin(0) {} ~QFxItemPrivate() { delete _anchors; } @@ -149,7 +149,6 @@ public: QList _qmlnewcomp; QmlNullableValue _baselineOffset; - float _rotation; bool _classComplete:1; bool _componentComplete:1; @@ -189,10 +188,8 @@ public: qreal width; qreal height; qreal paintmargin; - qreal scale; - QPointF transformOrigin() const; - QTransform transform; + QPointF computeTransformOrigin() const; void gvRemoveMouseFilter(); void gvAddMouseFilter(); -- cgit v0.12 From ab795618fed2ef88536e14d1ef91b692bd765400 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 22 Jul 2009 20:27:29 +0200 Subject: fix after the itemParent/parentItem cleanup. The fx items often call setParent() instead of setParentItem() so we can't simply remove that method. --- src/declarative/fx/qfxitem.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index 3047713..822af74 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -175,7 +175,8 @@ public: virtual ~QFxItem(); QFxItem *parentItem() const; - void setParentItem(QFxItem *parent); // ## setParentItem + void setParentItem(QFxItem *parent); + void setParent(QFxItem *parent) { setParentItem(parent); } QmlList *data(); QmlList *children(); -- cgit v0.12 From a6afeb2f0a12d781f5599da34d16f4dabfc9ccdb Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 22 Jul 2009 22:14:10 +0200 Subject: remove scenePos() as it exists in QGraphicsItem. --- src/declarative/fx/qfxitem.cpp | 8 -------- src/declarative/fx/qfxitem.h | 2 -- 2 files changed, 10 deletions(-) diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 35f3b71..318ad3b 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -1896,14 +1896,6 @@ void QFxItem::parentChanged(QFxItem *, QFxItem *) } /*! - Returns the item's (0, 0) point mapped to scene coordinates. - */ -QPointF QFxItem::scenePos() const -{ - return mapToScene(QPointF(0, 0)); -} - -/*! \enum QFxItem::TransformOrigin Controls the point about which simple transforms like scale apply. diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index 822af74..1c0db84 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -226,8 +226,6 @@ public: void setImplicitHeight(qreal); bool heightValid() const; // ### better name? - QPointF scenePos() const; // ### remove me - TransformOrigin transformOrigin() const; void setTransformOrigin(TransformOrigin); QPointF transformOriginPoint() const; -- cgit v0.12 From 978f4b014980e1e307676dbdc8ad1d9c50d4a8fb Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 22 Jul 2009 22:18:23 +0200 Subject: Remove itemBoundingRect() We can simply use boundingRect() instead. --- src/declarative/fx/qfxitem.cpp | 5 ----- src/declarative/fx/qfxitem.h | 2 -- src/declarative/fx/qfxmouseregion.cpp | 3 +-- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 318ad3b..a23fc3b 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -2028,11 +2028,6 @@ bool QFxItem::heightValid() const return d->heightValid; } -QRect QFxItem::itemBoundingRect() -{ - return boundingRect().toAlignedRect(); -} - QFxItem *QFxItem::mouseGrabberItem() const { QGraphicsScene *s = scene(); diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index 1c0db84..3620513 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -230,8 +230,6 @@ public: void setTransformOrigin(TransformOrigin); QPointF transformOriginPoint() const; - QRect itemBoundingRect(); // ### remove me - void setPaintMargin(qreal margin); QRectF boundingRect() const; virtual void paintContents(QPainter &); diff --git a/src/declarative/fx/qfxmouseregion.cpp b/src/declarative/fx/qfxmouseregion.cpp index bc19c23..e4e7442 100644 --- a/src/declarative/fx/qfxmouseregion.cpp +++ b/src/declarative/fx/qfxmouseregion.cpp @@ -333,8 +333,7 @@ void QFxMouseRegion::mouseMoveEvent(QGraphicsSceneMouseEvent *event) // ### we should skip this if these signals aren't used // ### can GV handle this for us? - const QRect &bounds = itemBoundingRect(); - bool contains = bounds.contains(d->lastPos.toPoint()); + bool contains = boundingRect().contains(d->lastPos); if (d->hovered && !contains) setHovered(false); else if (!d->hovered && contains) -- cgit v0.12 From b44728b41ccc24b272f49e878cd28b29430aad57 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 23 Jul 2009 06:57:53 +0200 Subject: rename transformOrigin to transformOriginPoint Like this we do not clash with the transformOrigin property in QFxItem. --- src/declarative/fx/qfxitem.cpp | 8 +------- src/declarative/fx/qfxitem.h | 1 - 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index a23fc3b..009e192 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -1928,16 +1928,10 @@ void QFxItem::setTransformOrigin(TransformOrigin origin) Q_D(QFxItem); if (origin != d->origin) { d->origin = origin; - QPointF to = d->computeTransformOrigin(); - QGraphicsItem::setTransformOrigin(to.x(), to.y()); + QGraphicsItem::setTransformOriginPoint(d->computeTransformOrigin()); } } -QPointF QFxItem::transformOriginPoint() const -{ - return QGraphicsItem::transformOrigin(); -} - qreal QFxItem::width() const { Q_D(const QFxItem); diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index 3620513..791d215 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -228,7 +228,6 @@ public: TransformOrigin transformOrigin() const; void setTransformOrigin(TransformOrigin); - QPointF transformOriginPoint() const; void setPaintMargin(qreal margin); QRectF boundingRect() const; -- cgit v0.12 From d53f55357ed9581b02088dff95fbe955412f476d Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 27 Jul 2009 06:45:50 +0200 Subject: make QFxItem use QGraphicsTransform removed all the QFxTransform code and converted QFxItem::transform to use a QmlList instead of a QList. --- src/declarative/fx/fx.pri | 2 - src/declarative/fx/qfxflipable.cpp | 10 +- src/declarative/fx/qfxflipable.h | 8 +- src/declarative/fx/qfxitem.cpp | 81 +++- src/declarative/fx/qfxitem.h | 15 +- src/declarative/fx/qfxitem_p.h | 10 +- src/declarative/fx/qfxtransform.cpp | 919 ------------------------------------ src/declarative/fx/qfxtransform.h | 356 -------------- src/declarative/fx/qfxwebview.cpp | 1 - 9 files changed, 83 insertions(+), 1319 deletions(-) delete mode 100644 src/declarative/fx/qfxtransform.cpp delete mode 100644 src/declarative/fx/qfxtransform.h diff --git a/src/declarative/fx/fx.pri b/src/declarative/fx/fx.pri index 24c5536..9b4b5ab 100644 --- a/src/declarative/fx/fx.pri +++ b/src/declarative/fx/fx.pri @@ -36,7 +36,6 @@ HEADERS += \ fx/qfxtextedit_p.h \ fx/qfxtext.h \ fx/qfxtext_p.h \ - fx/qfxtransform.h \ fx/qfxpixmap.cpp \ fx/qfxvisualitemmodel.h \ fx/qfxlistview.h \ @@ -65,7 +64,6 @@ SOURCES += \ fx/qfxlineedit.cpp \ fx/qfxtext.cpp \ fx/qfxtextedit.cpp \ - fx/qfxtransform.cpp \ fx/qfxpixmap.cpp \ fx/qfxvisualitemmodel.cpp \ fx/qfxlistview.cpp \ diff --git a/src/declarative/fx/qfxflipable.cpp b/src/declarative/fx/qfxflipable.cpp index fafd04a..bd01d48 100644 --- a/src/declarative/fx/qfxflipable.cpp +++ b/src/declarative/fx/qfxflipable.cpp @@ -41,7 +41,7 @@ #include "qfxflipable.h" #include "private/qfxitem_p.h" -#include "qfxtransform.h" +#include "QtGui/qgraphicstransform.h" #include QT_BEGIN_NAMESPACE @@ -59,8 +59,8 @@ public: QFxFlipable::Side current; QFxItem *front; QFxItem *back; - QFxAxis *axis; - QFxRotation3D axisRotation; + QGraphicsAxis *axis; + QGraphicsRotation3D axisRotation; qreal rotation; }; @@ -180,13 +180,13 @@ void QFxFlipable::setBack(QFxItem *back) information on specifying an axis. */ -QFxAxis *QFxFlipable::axis() +QGraphicsAxis *QFxFlipable::axis() { Q_D(QFxFlipable); return d->axis; } -void QFxFlipable::setAxis(QFxAxis *axis) +void QFxFlipable::setAxis(QGraphicsAxis *axis) { Q_D(QFxFlipable); //### disconnect if we are already connected? diff --git a/src/declarative/fx/qfxflipable.h b/src/declarative/fx/qfxflipable.h index 5aa038d..4306e9f 100644 --- a/src/declarative/fx/qfxflipable.h +++ b/src/declarative/fx/qfxflipable.h @@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QFxAxis; +class QGraphicsAxis; class QFxFlipablePrivate; class Q_DECLARATIVE_EXPORT QFxFlipable : public QFxItem { @@ -61,7 +61,7 @@ class Q_DECLARATIVE_EXPORT QFxFlipable : public QFxItem Q_ENUMS(Side) Q_PROPERTY(QFxItem *front READ front WRITE setFront) Q_PROPERTY(QFxItem *back READ back WRITE setBack) - Q_PROPERTY(QFxAxis *axis READ axis WRITE setAxis) + Q_PROPERTY(QGraphicsAxis *axis READ axis WRITE setAxis) Q_PROPERTY(qreal rotation READ rotation WRITE setRotation) Q_PROPERTY(Side side READ side NOTIFY sideChanged) public: @@ -74,8 +74,8 @@ public: QFxItem *back(); void setBack(QFxItem *); - QFxAxis *axis(); - void setAxis(QFxAxis *axis); + QGraphicsAxis *axis(); + void setAxis(QGraphicsAxis *axis); qreal rotation() const; void setRotation(qreal angle); diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 009e192..efdd4fc 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #include #include @@ -55,7 +56,6 @@ #include "qlistmodelinterface.h" #include "qfxanchors_p.h" -#include "qfxtransform.h" #include "qfxscalegrid.h" #include "qfxview.h" #include "qmlstategroup.h" @@ -74,6 +74,12 @@ QT_BEGIN_NAMESPACE QML_DEFINE_NOCREATE_TYPE(QFxContents) QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Item,QFxItem) +QML_DEFINE_NOCREATE_TYPE(QGraphicsTransform); +QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Scale,QGraphicsScale) +QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Axis,QGraphicsAxis) +QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rotation,QGraphicsRotation) +QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rotation3D,QGraphicsRotation3D) + /*! \group group_animation \title Animation @@ -633,6 +639,50 @@ void QFxItemPrivate::children_clear() // ### } + +void QFxItemPrivate::transform_removeAt(int i) +{ + if (!transformData) + return; + transformData->graphicsTransforms.removeAt(i); + dirtySceneTransform = 1; +} + +int QFxItemPrivate::transform_count() const +{ + return transformData ? transformData->graphicsTransforms.size() : 0; +} + +void QFxItemPrivate::transform_append(QGraphicsTransform *item) +{ + if (!transformData) + transformData = new QGraphicsItemPrivate::TransformData; + if (!transformData->graphicsTransforms.contains(item)) + transformData->graphicsTransforms.append(item); + transformData->onlyTransform = false; + dirtySceneTransform = 1; +} + +void QFxItemPrivate::transform_insert(int, QGraphicsTransform *) +{ + // ### +} + +QGraphicsTransform *QFxItemPrivate::transform_at(int idx) const +{ + if (!transformData) + return 0; + return transformData->graphicsTransforms.at(idx); +} + +void QFxItemPrivate::transform_clear() +{ + if (!transformData) + return; + transformData->graphicsTransforms.clear(); + dirtySceneTransform = 1; +} + /*! \qmlproperty list Item::data \default @@ -1652,17 +1702,14 @@ void QFxItem::setState(const QString &state) /*! \property QFxItem::transform - This property holds the list of transformations to apply. - - For more information see \l Transform. + This property holds a list of transformations set on the item. */ -QList *QFxItem::transform() +QmlList* QFxItem::transform() { Q_D(QFxItem); - return &(d->_transform); + return &(d->transform); } - /*! Creates a new child of the given component \a type. The newChildCreated() signal will be emitted when and if the child is @@ -1733,25 +1780,6 @@ void QFxItem::componentComplete() d->_stateGroup->componentComplete(); if (d->_anchors) d->anchors()->d_func()->updateOnComplete(); - if (!d->_transform.isEmpty()) - updateTransform(); -} - -/*! - \internal -*/ -void QFxItem::updateTransform() -{ - Q_D(QFxItem); - QTransform trans; - for (int ii = d->_transform.count() - 1; ii >= 0; --ii) { - QFxTransform *a = d->_transform.at(ii); - if (!a->isIdentity()) - trans = a->transform() * trans; - } - - setTransform(trans); - transformChanged(trans); } /*! @@ -1759,6 +1787,7 @@ void QFxItem::updateTransform() */ void QFxItem::transformChanged(const QTransform &) { + // ### FIXME } QmlStateGroup *QFxItemPrivate::states() diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index 791d215..f4051e5 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -49,6 +49,7 @@ #include #include #include +#include #include QT_BEGIN_HEADER @@ -57,6 +58,8 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) +class QGraphicsTransform; + class QFxItem; class Q_DECLARATIVE_EXPORT QFxContents : public QObject { @@ -112,7 +115,6 @@ public: class QmlState; class QmlTransition; -class QFxTransform; class QFxKeyEvent; class QFxAnchors; class QFxItemPrivate; @@ -145,7 +147,7 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta Q_PROPERTY(bool clip READ clip WRITE setClip) // ### move to QGI/QGO, NOTIFY Q_PROPERTY(bool focus READ hasFocus WRITE setFocus NOTIFY focusChanged FINAL) Q_PROPERTY(bool activeFocus READ hasActiveFocus NOTIFY activeFocusChanged FINAL) - Q_PROPERTY(QList* transform READ transform) // ## QGI/QGO + Q_PROPERTY(QmlList* transform READ transform DESIGNABLE false FINAL) // ## QGI/QGO Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin) // ### move to QGI Q_ENUMS(TransformOrigin) Q_CLASSINFO("DefaultProperty", "data") @@ -204,13 +206,11 @@ public: qreal baselineOffset() const; void setBaselineOffset(qreal); - QList *transform(); + QmlList *transform(); bool isClassComplete() const; bool isComponentComplete() const; - void updateTransform(); // ### private! - bool keepMouseGrab() const; void setKeepMouseGrab(bool); @@ -327,6 +327,11 @@ QT_END_NAMESPACE QML_DECLARE_TYPE(QFxContents) QML_DECLARE_TYPE(QFxItem) +QML_DECLARE_TYPE(QGraphicsTransform) +QML_DECLARE_TYPE(QGraphicsScale) +QML_DECLARE_TYPE(QGraphicsAxis) +QML_DECLARE_TYPE(QGraphicsRotation) +QML_DECLARE_TYPE(QGraphicsRotation3D) QT_END_HEADER diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h index 7bdd382..ebd77f8 100644 --- a/src/declarative/fx/qfxitem_p.h +++ b/src/declarative/fx/qfxitem_p.h @@ -130,7 +130,15 @@ public: void children_clear(); QML_DECLARE_LIST_PROXY(QFxItemPrivate, QFxItem *, children) - QList _transform; + // transform property + void transform_removeAt(int); + int transform_count() const; + void transform_append(QGraphicsTransform *); + void transform_insert(int, QGraphicsTransform *); + QGraphicsTransform *transform_at(int) const; + void transform_clear(); + QML_DECLARE_LIST_PROXY(QFxItemPrivate, QGraphicsTransform *, transform) + QFxAnchors *anchors() { if (!_anchors) { Q_Q(QFxItem); diff --git a/src/declarative/fx/qfxtransform.cpp b/src/declarative/fx/qfxtransform.cpp deleted file mode 100644 index 9fc66ef..0000000 --- a/src/declarative/fx/qfxtransform.cpp +++ /dev/null @@ -1,919 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "private/qfxitem_p.h" -#include "qfxtransform.h" -#include - -#include -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -QT_BEGIN_NAMESPACE - -QML_DEFINE_NOCREATE_TYPE(QFxTransform); - -/*! - \qmlclass Transform - \brief A transformation. -*/ -QFxTransform::QFxTransform(QObject *parent) : - QObject(parent) -{ -} - -QFxTransform::~QFxTransform() -{ -} - -bool QFxTransform::isIdentity() const -{ - return true; -} - -QTransform QFxTransform::transform() const -{ - return QTransform(); -} - -void QFxTransform::update() -{ - QFxItem *item = qobject_cast(parent()); - if (item) - item->updateTransform(); -} - -/*! - \qmlclass Scale - \brief A Scale object provides a way to scale an Item. - - The scale object gives more control over scaling than using Item's scale property. Specifically, - it allows a different scale for the x and y axes, and allows the scale to be relative to an - arbitrary point. - - The following example scales the X axis of the Rect, relative to its interior point 25, 25: - \qml - Rect { - width: 100; height: 100 - color: "blue" - transform: Scale { originX: 25; originY: 25; xScale: 3} - } - \endqml -*/ - -QFxScale::QFxScale(QObject *parent) -: QFxTransform(parent), _originX(0), _originY(0), _xScale(1), _yScale(1), _dirty(true) -{ -} - -QFxScale::~QFxScale() -{ -} - -/*! - \qmlproperty real Scale::originX - \qmlproperty real Scale::originY - - The origin point for the scale. The scale will be relative to this point. -*/ -qreal QFxScale::originX() const -{ - return _originX; -} - -void QFxScale::setOriginX(qreal ox) -{ - _originX = ox; - update(); -} - -qreal QFxScale::originY() const -{ - return _originY; -} - -void QFxScale::setOriginY(qreal oy) -{ - _originY = oy; - update(); -} - -/*! - \qmlproperty real Scale::xScale - - The scaling factor for the X axis. -*/ -qreal QFxScale::xScale() const -{ - return _xScale; -} - -void QFxScale::setXScale(qreal scale) -{ - if (_xScale == scale) - return; - _xScale = scale; - update(); - emit scaleChanged(); -} - -/*! - \qmlproperty real Scale::yScale - - The scaling factor for the Y axis. -*/ -qreal QFxScale::yScale() const -{ - return _yScale; -} - -void QFxScale::setYScale(qreal scale) -{ - if (_yScale == scale) - return; - _yScale = scale; - update(); - emit scaleChanged(); -} - -bool QFxScale::isIdentity() const -{ - return (_xScale == 1. && _yScale == 1.); -} - -QTransform QFxScale::transform() const -{ - if (_dirty) { - _transform = QTransform(); - _dirty = false; - _transform.translate(_originX, _originY); - _transform.scale(_xScale, _yScale); - _transform.translate(-_originX, -_originY); - } - return _transform; -} - -void QFxScale::update() -{ - _dirty = true; - QFxTransform::update(); -} - -QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Scale,QFxScale) - - -/*! - \qmlclass Axis - \brief A Axis object defines an axis that can be used for rotation or translation. - - An axis is specified by 2 points in 3D space: a start point and - an end point. While technically the axis is the line running through these two points - (and thus many different sets of two points could define the same axis), the distance - between the points does matter for translation along an axis. - - \image 3d-axis.png - - \qml - Axis { startX: 20; startY: 0; endX: 40; endY: 60; endZ: 20 } - \endqml -*/ - -QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Axis,QFxAxis) - -QFxAxis::QFxAxis(QObject *parent) -: QObject(parent), _startX(0), _startY(0), _endX(0), _endY(0), _endZ(0) -{ -} - -QFxAxis::~QFxAxis() -{ -} - -/*! - \qmlproperty real Axis::startX - \qmlproperty real Axis::startY - - The start point of the axis. The z-position of the start point is assumed to be 0, and cannot - be changed. -*/ -qreal QFxAxis::startX() const -{ - return _startX; -} - -void QFxAxis::setStartX(qreal x) -{ - _startX = x; - emit updated(); -} - -qreal QFxAxis::startY() const -{ - return _startY; -} - -void QFxAxis::setStartY(qreal y) -{ - _startY = y; - emit updated(); -} - -/*! - \qmlproperty real Axis::endX - \qmlproperty real Axis::endY - \qmlproperty real Axis::endZ - - The end point of the axis. -*/ -qreal QFxAxis::endX() const -{ - return _endX; -} - -void QFxAxis::setEndX(qreal x) -{ - _endX = x; - emit updated(); -} - -qreal QFxAxis::endY() const -{ - return _endY; -} - -void QFxAxis::setEndY(qreal y) -{ - _endY = y; - emit updated(); -} - -qreal QFxAxis::endZ() const -{ - return _endZ; -} - -void QFxAxis::setEndZ(qreal z) -{ - _endZ = z; - emit updated(); -} - -/*! - \qmlclass Rotation - \brief A Rotation object provides a way to rotate an Item around a point. - - The following example rotates a Rect around its interior point 25, 25: - \qml - Rect { - width: 100; height: 100 - color: "blue" - transform: Rotation { originX: 25; originY: 25; angle: 45} - } - \endqml -*/ - -QFxRotation::QFxRotation(QObject *parent) -: QFxTransform(parent), _originX(0), _originY(0), _angle(0), _dirty(true) -{ -} - -QFxRotation::~QFxRotation() -{ -} - -/*! - \qmlproperty real Rotation::originX - \qmlproperty real Rotation::originY - - The point to rotate around. -*/ -qreal QFxRotation::originX() const -{ - return _originX; -} - -void QFxRotation::setOriginX(qreal ox) -{ - _originX = ox; - update(); -} - -qreal QFxRotation::originY() const -{ - return _originY; -} - -void QFxRotation::setOriginY(qreal oy) -{ - _originY = oy; - update(); -} - -/*! - \qmlproperty real Rotation::angle - - The angle, in degrees, to rotate. -*/ -qreal QFxRotation::angle() const -{ - return _angle; -} - -void QFxRotation::setAngle(qreal angle) -{ - if (_angle == angle) - return; - _angle = angle; - update(); - emit angleChanged(); -} - -bool QFxRotation::isIdentity() const -{ - return (_angle == 0.); -} - -QTransform QFxRotation::transform() const -{ - if (_dirty) { - _transform = QTransform(); - _dirty = false; - _transform.translate(_originX, _originY); - _transform.rotate(_angle); - _transform.translate(-_originX, -_originY); - } - return _transform; -} - -void QFxRotation::update() -{ - _dirty = true; - QFxTransform::update(); -} - -QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rotation,QFxRotation) - -/*! - \qmlclass Rotation3D - \brief A Rotation3D object provides a way to rotate an Item around an axis. - - Here is an example of various rotations applied to an \l Image. - \snippet doc/src/snippets/declarative/rotation.qml 0 - - \image axisrotation.png -*/ - -QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rotation3D,QFxRotation3D) - -QFxRotation3D::QFxRotation3D(QObject *parent) -: QFxTransform(parent), _angle(0), _dirty(true) -{ - connect(&_axis, SIGNAL(updated()), this, SLOT(update())); -} - -QFxRotation3D::~QFxRotation3D() -{ -} - -/*! - \qmlproperty real Rotation3D::axis.startX - \qmlproperty real Rotation3D::axis.startY - \qmlproperty real Rotation3D::axis.endX - \qmlproperty real Rotation3D::axis.endY - \qmlproperty real Rotation3D::axis.endZ - - A rotation axis is specified by 2 points in 3D space: a start point and - an end point. The z-position of the start point is assumed to be 0, and cannot - be changed. - - \image 3d-rotation-axis.png - - \sa Axis -*/ -QFxAxis *QFxRotation3D::axis() -{ - return &_axis; -} - -/*! - \qmlproperty real Rotation3D::angle - - The angle, in degrees, to rotate around the specified axis. -*/ -qreal QFxRotation3D::angle() const -{ - return _angle; -} - -void QFxRotation3D::setAngle(qreal angle) -{ - _angle = angle; - update(); -} - -bool QFxRotation3D::isIdentity() const -{ - return (_angle == 0.) || (_axis.endZ() == 0. && _axis.endY() == _axis.startY() && _axis.endX() == _axis.startX()); -} - -const qreal inv_dist_to_plane = 1. / 1024.; -QTransform QFxRotation3D::transform() const -{ - if (_dirty) { - _transform = QTransform(); - - if (!isIdentity()) { - if (angle() != 0.) { - QTransform rotTrans; - rotTrans.translate(-_axis.startX(), -_axis.startY()); - QTransform rotTrans2; - rotTrans2.translate(_axis.startX(), _axis.startY()); - - qreal rad = angle() * 2. * M_PI / 360.; - qreal c = ::cos(rad); - qreal s = ::sin(rad); - - qreal x = _axis.endX() - _axis.startX(); - qreal y = _axis.endY() - _axis.startY(); - qreal z = _axis.endZ(); - - qreal len = x * x + y * y + z * z; - if (len != 1.) { - len = ::sqrt(len); - x /= len; - y /= len; - z /= len; - } - - QTransform rot(x*x*(1-c)+c, x*y*(1-c)-z*s, x*z*(1-c)+y*s*inv_dist_to_plane, - y*x*(1-c)+z*s, y*y*(1-c)+c, y*z*(1-c)-x*s*inv_dist_to_plane, - 0, 0, 1); - - _transform *= rotTrans; - _transform *= rot; - _transform *= rotTrans2; - } - } - - _dirty = false; - } - - return _transform; -} - -void QFxRotation3D::update() -{ - _dirty = true; - QFxTransform::update(); -} - -/*! - \internal - \qmlclass Translation3D - \brief A Translation3D object provides a way to move an Item along an axis. - - The following example translates the image to 10, 3. - \qml -Image { - source: "logo.png" - transform: [ - Translation3D { - axis.startX: 0 - axis.startY: 0 - axis.endX: 1 - axis.endY: .3 - distance: 10 - } - ] -} - \endqml -*/ - -QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Translation3D,QFxTranslation3D) - -QFxTranslation3D::QFxTranslation3D(QObject *parent) -: QFxTransform(parent), _distance(0), _dirty(true) -{ - connect(&_axis, SIGNAL(updated()), this, SLOT(update())); -} - -QFxTranslation3D::~QFxTranslation3D() -{ -} - -/*! - \qmlproperty real Translation3D::axis.startX - \qmlproperty real Translation3D::axis.startY - \qmlproperty real Translation3D::axis.endX - \qmlproperty real Translation3D::axis.endY - \qmlproperty real Translation3D::axis.endZ - - A translation axis is specified by 2 points in 3D space: a start - point and an end point. The z-position of the start point is assumed - to be 0, and cannot be changed. Changing the z-position of the end - point is only valid when running under OpenGL. - - \sa Axis -*/ -QFxAxis *QFxTranslation3D::axis() -{ - return &_axis; -} - -/*! - \qmlproperty real Translation3D::distance - - The distance to translate along the specified axis. distance is a - multiplier; in the example below, a distance of 1 would translate to - 100, 50, while a distance of 0.5 would translate to 50, 25. - - \qml - Translation3D { axis.startX: 0; axis.startY: 0; axis.endX: 100; axis.endY: 50 } - \endqml -*/ -qreal QFxTranslation3D::distance() const -{ - return _distance; -} - -void QFxTranslation3D::setDistance(qreal distance) -{ - _distance = distance; - update(); -} - -bool QFxTranslation3D::isIdentity() const -{ - return (_distance == 0.) || (_axis.endZ() == 0. && _axis.endY() == _axis.startY() && _axis.endX() == _axis.startX()); -} - -QTransform QFxTranslation3D::transform() const -{ - if (_dirty) { - _transform = QTransform(); - - if (!isIdentity()) { - if (distance() != 0.) { - QTransform trans; - trans.translate((_axis.endX() - _axis.startX()) * distance(), - (_axis.endY() - _axis.startY()) * distance()); - _transform *= trans; - } - } - - _dirty = false; - } - - return _transform; -} - -void QFxTranslation3D::update() -{ - _dirty = true; - - if (_axis.endZ() != 0. && distance() != 0.) { - qmlInfo(this) << "QTransform cannot translate along Z-axis."; - } - - QFxTransform::update(); -} - -/*! - \internal - \qmlclass Perspective - \brief A Perspective object specifies a perspective transformation. - - A Perspective transform only affects an item when running under - OpenGL. When running under software rasterization it has no effect. -*/ - -QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Perspective,QFxPerspective) - -QFxPerspective::QFxPerspective(QObject *parent) - : QFxTransform(parent) -{ -} - -QFxPerspective::~QFxPerspective() -{ -} - -/*! - \qmlproperty real Perspective::angle -*/ - -/*! - \qmlproperty real Perspective::aspect -*/ - -/*! - \qmlproperty real Perspective::x -*/ - -/*! - \qmlproperty real Perspective::y -*/ - -/*! - \qmlproperty real Perspective::scale -*/ - -/*! - \qmlclass Squish - \brief A Squish object allows you to distort an item's appearance by 'squishing' it. - - Conceptually, a Squish works by allowing you to move the four corners of an item, - and distorting the item to fit into the newly created polygon. - - \image squish-transform.png - - Here is an example of various \l Image squishes. - \qml - Rect { - id: Screen - width: 360; height: 80 - color: "white" - - HorizontalLayout { - margin: 10 - spacing: 10 - Image { source: "qt.png" } - Image { - source: "qt.png" - transform: Squish { - x:0; y:0; width:60; height:60 - topLeftX:0; topLeftY:0 - topRightX:50; topRightY:10 - bottomLeftX:0; bottomLeftY:60 - bottomRightX: 60; bottomRightY:60 - } - } - Image { - source: "qt.png" - transform: Squish { - x:0; y:0; width:60; height:60 - topLeftX:0; topLeftY:0 - topRightX:50; topRightY:0 - bottomLeftX:10; bottomLeftY:50 - bottomRightX: 60; bottomRightY:60 - } - } - Image { - source: "qt.png" - transform: Squish { - x:0; y:0; width:60; height:60 - topLeftX:0; topLeftY:10 - topRightX:60; topRightY:10 - bottomLeftX:0; bottomLeftY:50 - bottomRightX: 60; bottomRightY:50 - } - } - Image { - source: "qt.png" - transform: Squish { - x:0; y:0; width:60; height:60 - topLeftX:10; topLeftY:0 - topRightX:50; topRightY:0 - bottomLeftX:10; bottomLeftY:60 - bottomRightX: 50; bottomRightY:60 - } - } - } - } - \endqml - - \image squish.png -*/ -QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Squish,QFxSquish) - -QFxSquish::QFxSquish(QObject *parent) - : QFxTransform(parent) -{ -} - -QFxSquish::~QFxSquish() -{ -} - -/*! - \qmlproperty real Squish::x - \qmlproperty real Squish::y - \qmlproperty real Squish::width - \qmlproperty real Squish::height - - This is usually set to the original geometry of the item being squished. -*/ -qreal QFxSquish::x() const -{ - return p.x(); -} - -void QFxSquish::setX(qreal v) -{ - p.setX(v); - update(); -} - -qreal QFxSquish::y() const -{ - return p.y(); -} - -void QFxSquish::setY(qreal v) -{ - p.setY(v); - update(); -} - -qreal QFxSquish::width() const -{ - return s.width(); -} - -void QFxSquish::setWidth(qreal v) -{ - s.setWidth(v); - update(); -} - -qreal QFxSquish::height() const -{ - return s.height(); -} - -void QFxSquish::setHeight(qreal v) -{ - s.setHeight(v); - update(); -} - -/*! - \qmlproperty real Squish::topLeftX - \qmlproperty real Squish::topLeftY - - The top left point for the squish. -*/ -qreal QFxSquish::topLeft_x() const -{ - return p1.x(); -} - -void QFxSquish::settopLeft_x(qreal v) -{ - p1.setX(v); - update(); -} - -qreal QFxSquish::topLeft_y() const -{ - return p1.y(); -} - -void QFxSquish::settopLeft_y(qreal v) -{ - p1.setY(v); - update(); -} - -/*! - \qmlproperty real Squish::topRightX - \qmlproperty real Squish::topRightY - - The top right point for the squish. -*/ -qreal QFxSquish::topRight_x() const -{ - return p2.x(); -} - -void QFxSquish::settopRight_x(qreal v) -{ - p2.setX(v); - update(); -} - -qreal QFxSquish::topRight_y() const -{ - return p2.y(); -} - -void QFxSquish::settopRight_y(qreal v) -{ - p2.setY(v); - update(); -} - -/*! - \qmlproperty real Squish::bottomLeftX - \qmlproperty real Squish::bottomLeftY - - The bottom left point for the squish. -*/ -qreal QFxSquish::bottomLeft_x() const -{ - return p3.x(); -} - -void QFxSquish::setbottomLeft_x(qreal v) -{ - p3.setX(v); - update(); -} - -qreal QFxSquish::bottomLeft_y() const -{ - return p3.y(); -} - -void QFxSquish::setbottomLeft_y(qreal v) -{ - p3.setY(v); - update(); -} - -/*! - \qmlproperty real Squish::bottomRightX - \qmlproperty real Squish::bottomRightY - - The bottom right point for the squish. -*/ -qreal QFxSquish::bottomRight_x() const -{ - return p4.x(); -} - -void QFxSquish::setbottomRight_x(qreal v) -{ - p4.setX(v); - update(); -} - -qreal QFxSquish::bottomRight_y() const -{ - return p4.y(); -} - -void QFxSquish::setbottomRight_y(qreal v) -{ - p4.setY(v); - update(); -} - -bool QFxSquish::isIdentity() const -{ - return false; -} - -QTransform QFxSquish::transform() const -{ - QPolygonF poly; - poly << p << QPointF(p.x() + s.width(), p.y()) << QPointF(p.x() + s.width(), p.y() + s.height()) << QPointF(p.x(), p.y() + s.height()); - QPolygonF poly2; - poly2 << p1 << p2 << p4 << p3; - - QTransform t; - QTransform::quadToQuad(poly, poly2, t); - return t; -} - -QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxtransform.h b/src/declarative/fx/qfxtransform.h deleted file mode 100644 index fb49294..0000000 --- a/src/declarative/fx/qfxtransform.h +++ /dev/null @@ -1,356 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QFXTRANSFORM_H -#define QFXTRANSFORM_H - -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class Q_DECLARATIVE_EXPORT QFxTransform : public QObject -{ - Q_OBJECT -public: - QFxTransform(QObject *parent=0); - ~QFxTransform(); - - void update(); - - virtual bool isIdentity() const; - virtual QTransform transform() const; -}; - -class Q_DECLARATIVE_EXPORT QFxScale : public QFxTransform -{ - Q_OBJECT - - Q_PROPERTY(qreal originX READ originX WRITE setOriginX) - Q_PROPERTY(qreal originY READ originY WRITE setOriginY) - Q_PROPERTY(qreal xScale READ xScale WRITE setXScale NOTIFY scaleChanged()) - Q_PROPERTY(qreal yScale READ yScale WRITE setYScale NOTIFY scaleChanged()) -public: - QFxScale(QObject *parent=0); - ~QFxScale(); - - qreal originX() const; - void setOriginX(qreal); - - qreal originY() const; - void setOriginY(qreal); - - qreal xScale() const; - void setXScale(qreal); - - qreal yScale() const; - void setYScale(qreal); - - virtual bool isIdentity() const; - virtual QTransform transform() const; - -Q_SIGNALS: - void scaleChanged(); - -private Q_SLOTS: - void update(); -private: - qreal _originX; - qreal _originY; - qreal _xScale; - qreal _yScale; - - mutable bool _dirty; - mutable QTransform _transform; -}; - -class Q_DECLARATIVE_EXPORT QFxAxis : public QObject -{ - Q_OBJECT - - Q_PROPERTY(qreal startX READ startX WRITE setStartX) - Q_PROPERTY(qreal startY READ startY WRITE setStartY) - Q_PROPERTY(qreal endX READ endX WRITE setEndX) - Q_PROPERTY(qreal endY READ endY WRITE setEndY) - Q_PROPERTY(qreal endZ READ endZ WRITE setEndZ) -public: - QFxAxis(QObject *parent=0); - ~QFxAxis(); - - qreal startX() const; - void setStartX(qreal); - - qreal startY() const; - void setStartY(qreal); - - qreal endX() const; - void setEndX(qreal); - - qreal endY() const; - void setEndY(qreal); - - qreal endZ() const; - void setEndZ(qreal); - -Q_SIGNALS: - void updated(); - -private: - qreal _startX; - qreal _startY; - qreal _endX; - qreal _endY; - qreal _endZ; -}; - -class Q_DECLARATIVE_EXPORT QFxRotation : public QFxTransform -{ - Q_OBJECT - - Q_PROPERTY(qreal originX READ originX WRITE setOriginX) - Q_PROPERTY(qreal originY READ originY WRITE setOriginY) - Q_PROPERTY(qreal angle READ angle WRITE setAngle NOTIFY angleChanged()) -public: - QFxRotation(QObject *parent=0); - ~QFxRotation(); - - qreal originX() const; - void setOriginX(qreal); - - qreal originY() const; - void setOriginY(qreal); - - qreal angle() const; - void setAngle(qreal); - - virtual bool isIdentity() const; - virtual QTransform transform() const; - -Q_SIGNALS: - void angleChanged(); - -private Q_SLOTS: - void update(); -private: - qreal _originX; - qreal _originY; - qreal _angle; - - mutable bool _dirty; - mutable QTransform _transform; -}; - -class Q_DECLARATIVE_EXPORT QFxRotation3D : public QFxTransform -{ - Q_OBJECT - - Q_PROPERTY(QFxAxis *axis READ axis) - Q_PROPERTY(qreal angle READ angle WRITE setAngle) -public: - QFxRotation3D(QObject *parent=0); - ~QFxRotation3D(); - - QFxAxis *axis(); - - qreal angle() const; - void setAngle(qreal); - - virtual bool isIdentity() const; - virtual QTransform transform() const; - -private Q_SLOTS: - void update(); -private: - QFxAxis _axis; - qreal _angle; - - mutable bool _dirty; - mutable QTransform _transform; -}; - -class Q_DECLARATIVE_EXPORT QFxTranslation3D : public QFxTransform -{ - Q_OBJECT - - Q_PROPERTY(QFxAxis *axis READ axis) - Q_PROPERTY(qreal distance READ distance WRITE setDistance) -public: - QFxTranslation3D(QObject *parent=0); - ~QFxTranslation3D(); - - QFxAxis *axis(); - - qreal distance() const; - void setDistance(qreal); - - virtual bool isIdentity() const; - virtual QTransform transform() const; - -private Q_SLOTS: - void update(); -private: - QFxAxis _axis; - qreal _distance; - - mutable bool _dirty; - mutable QTransform _transform; -}; - -class Q_DECLARATIVE_EXPORT QFxPerspective : public QFxTransform -{ - Q_OBJECT - - Q_PROPERTY(qreal angle READ angle WRITE setAngle) - Q_PROPERTY(qreal aspect READ aspect WRITE setAspect) - Q_PROPERTY(qreal x READ x WRITE setX) - Q_PROPERTY(qreal y READ y WRITE setY) - Q_PROPERTY(qreal scale READ scale WRITE setScale) -public: - QFxPerspective(QObject *parent=0); - ~QFxPerspective(); - - qreal angle() const { return _angle; } - void setAngle(qreal v) { _angle = v; update(); } - - qreal aspect() const { return _aspect; } - void setAspect(qreal v) { _aspect = v; update(); } - - qreal x() const { return _x; } - void setX(qreal v) { _x = v; update(); } - - qreal y() const { return _y; } - void setY(qreal v) { _y = v; update(); } - - qreal scale() const { return _scale; } - void setScale(qreal v) { _scale = v; update(); } - -private: - qreal _scale; - qreal _x; - qreal _y; - qreal _angle; - qreal _aspect; -}; - -class Q_DECLARATIVE_EXPORT QFxSquish : public QFxTransform -{ - Q_OBJECT - - Q_PROPERTY(qreal x READ x WRITE setX) - Q_PROPERTY(qreal y READ y WRITE setY) - Q_PROPERTY(qreal width READ width WRITE setWidth) - Q_PROPERTY(qreal height READ height WRITE setHeight) - Q_PROPERTY(qreal topLeftX READ topLeft_x WRITE settopLeft_x) - Q_PROPERTY(qreal topLeftY READ topLeft_y WRITE settopLeft_y) - Q_PROPERTY(qreal topRightX READ topRight_x WRITE settopRight_x) - Q_PROPERTY(qreal topRightY READ topRight_y WRITE settopRight_y) - Q_PROPERTY(qreal bottomLeftX READ bottomLeft_x WRITE setbottomLeft_x) - Q_PROPERTY(qreal bottomLeftY READ bottomLeft_y WRITE setbottomLeft_y) - Q_PROPERTY(qreal bottomRightX READ bottomRight_x WRITE setbottomRight_x) - Q_PROPERTY(qreal bottomRightY READ bottomRight_y WRITE setbottomRight_y) -public: - QFxSquish(QObject *parent=0); - ~QFxSquish(); - - qreal x() const; - void setX(qreal); - - qreal y() const; - void setY(qreal); - - qreal width() const; - void setWidth(qreal); - - qreal height() const; - void setHeight(qreal); - - qreal topLeft_x() const; - void settopLeft_x(qreal); - - qreal topLeft_y() const; - void settopLeft_y(qreal); - - qreal topRight_x() const; - void settopRight_x(qreal); - - qreal topRight_y() const; - void settopRight_y(qreal); - - qreal bottomLeft_x() const; - void setbottomLeft_x(qreal); - - qreal bottomLeft_y() const; - void setbottomLeft_y(qreal); - - qreal bottomRight_y() const; - void setbottomRight_y(qreal); - - qreal bottomRight_x() const; - void setbottomRight_x(qreal); - - virtual bool isIdentity() const; - virtual QTransform transform() const; - -private: - QPointF p; - QSizeF s; - QPointF p1, p2, p3, p4; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QFxTransform) -QML_DECLARE_TYPE(QFxScale) -QML_DECLARE_TYPE(QFxAxis) -QML_DECLARE_TYPE(QFxRotation) -QML_DECLARE_TYPE(QFxRotation3D) -QML_DECLARE_TYPE(QFxTranslation3D) -QML_DECLARE_TYPE(QFxPerspective) -QML_DECLARE_TYPE(QFxSquish) - -QT_END_HEADER - -#endif // QFXTRANSFORM_H diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp index 4c6af69..83f9249 100644 --- a/src/declarative/fx/qfxwebview.cpp +++ b/src/declarative/fx/qfxwebview.cpp @@ -55,7 +55,6 @@ #include "qml.h" #include "qmlengine.h" #include "qmlstate.h" -#include "qfxtransform.h" #include "qfxscalegrid.h" #include "qlistmodelinterface.h" -- cgit v0.12 From 1a781d12fb06541fe921e1506b28007b34494a9e Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 27 Jul 2009 07:00:49 +0200 Subject: always set the correct point for the transform origin. --- src/declarative/fx/qfxitem.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index efdd4fc..0cc1fbc 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -1044,12 +1044,8 @@ void QFxItem::geometryChanged(const QRectF &newGeometry, if (d->_anchors) d->_anchors->d_func()->updateMe(); - if (newGeometry.size() != oldGeometry.size()) { - if (rotation() && transformOrigin() != QFxItem::TopLeft) - setRotation(rotation()); - if (scale() && transformOrigin() != QFxItem::TopLeft) - setScale(scale()); - } + if (transformOrigin() != QFxItem::TopLeft) + setTransformOriginPoint(d->computeTransformOrigin()); if (newGeometry.x() != oldGeometry.x()) emit xChanged(); -- cgit v0.12 From 1fa49662fa7f05d3d7933a3c636ad996fab68118 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 27 Jul 2009 12:24:21 +0200 Subject: QGraphicsAxis is gone Also clean up a now unused method. --- src/declarative/fx/qfxitem.cpp | 9 --------- src/declarative/fx/qfxitem.h | 2 -- 2 files changed, 11 deletions(-) diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 0cc1fbc..5978e73 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -76,7 +76,6 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Item,QFxItem) QML_DEFINE_NOCREATE_TYPE(QGraphicsTransform); QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Scale,QGraphicsScale) -QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Axis,QGraphicsAxis) QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rotation,QGraphicsRotation) QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rotation3D,QGraphicsRotation3D) @@ -1778,14 +1777,6 @@ void QFxItem::componentComplete() d->anchors()->d_func()->updateOnComplete(); } -/*! - \internal -*/ -void QFxItem::transformChanged(const QTransform &) -{ - // ### FIXME -} - QmlStateGroup *QFxItemPrivate::states() { Q_Q(QFxItem); diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index f4051e5..4837881 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -275,7 +275,6 @@ protected: virtual bool mouseFilter(QGraphicsSceneMouseEvent *); virtual void mouseUngrabEvent(); - virtual void transformChanged(const QTransform &); virtual void classBegin(); virtual void classComplete(); virtual void componentComplete(); @@ -329,7 +328,6 @@ QML_DECLARE_TYPE(QFxContents) QML_DECLARE_TYPE(QFxItem) QML_DECLARE_TYPE(QGraphicsTransform) QML_DECLARE_TYPE(QGraphicsScale) -QML_DECLARE_TYPE(QGraphicsAxis) QML_DECLARE_TYPE(QGraphicsRotation) QML_DECLARE_TYPE(QGraphicsRotation3D) -- cgit v0.12 From c12f369d16e8993594680485758f44c813b78f45 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 27 Jul 2009 12:25:23 +0200 Subject: rewrite QFxFlipable to work with graphics transforms. Remove it's builtin axis and rotation properties. At least rotation also clashes with QGraphicsObject::rotation making it a bad idea. Now Flipable is a pure two sided item, and the developer/designer will have to set up the flipping tranformation himself. --- src/declarative/fx/qfxflipable.cpp | 160 ++++++++----------------------------- src/declarative/fx/qfxflipable.h | 14 +--- 2 files changed, 33 insertions(+), 141 deletions(-) diff --git a/src/declarative/fx/qfxflipable.cpp b/src/declarative/fx/qfxflipable.cpp index bd01d48..228d938 100644 --- a/src/declarative/fx/qfxflipable.cpp +++ b/src/declarative/fx/qfxflipable.cpp @@ -50,18 +50,15 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Flipable,QFxFlipable) class QFxFlipablePrivate : public QFxItemPrivate { + Q_DECLARE_PUBLIC(QFxFlipable) public: - QFxFlipablePrivate() : current(QFxFlipable::Front), front(0), back(0), axis(0), rotation(0) {} + QFxFlipablePrivate() : current(QFxFlipable::Front), front(0), back(0) {} - void setBackTransform(); - void _q_updateAxis(); + void updateSceneTransformFromParent(); QFxFlipable::Side current; QFxItem *front; QFxItem *back; - QGraphicsAxis *axis; - QGraphicsRotation3D axisRotation; - qreal rotation; }; /*! @@ -174,104 +171,6 @@ void QFxFlipable::setBack(QFxItem *back) } /*! - \qmlproperty Axis Flipable::axis - - The axis to flip around. See the \l Axis documentation for more - information on specifying an axis. -*/ - -QGraphicsAxis *QFxFlipable::axis() -{ - Q_D(QFxFlipable); - return d->axis; -} - -void QFxFlipable::setAxis(QGraphicsAxis *axis) -{ - Q_D(QFxFlipable); - //### disconnect if we are already connected? - if (d->axis) - disconnect(d->axis, SIGNAL(updated()), this, SLOT(_q_updateAxis())); - d->axis = axis; - connect(d->axis, SIGNAL(updated()), this, SLOT(_q_updateAxis())); - d->_q_updateAxis(); -} - -void QFxFlipablePrivate::_q_updateAxis() -{ - axisRotation.axis()->setStartX(axis->startX()); - axisRotation.axis()->setStartY(axis->startY()); - axisRotation.axis()->setEndX(axis->endX()); - axisRotation.axis()->setEndY(axis->endY()); - axisRotation.axis()->setEndZ(axis->endZ()); -} - -void QFxFlipablePrivate::setBackTransform() -{ - if (!back) - return; - - QPointF p1(0, 0); - QPointF p2(1, 0); - QPointF p3(1, 1); - - axisRotation.setAngle(180); - p1 = axisRotation.transform().map(p1); - p2 = axisRotation.transform().map(p2); - p3 = axisRotation.transform().map(p3); - axisRotation.setAngle(rotation); - - QTransform mat; - mat.translate(back->width()/2,back->height()/2); - if (back->width() && p1.x() >= p2.x()) - mat.rotate(180, Qt::YAxis); - if (back->height() && p2.y() >= p3.y()) - mat.rotate(180, Qt::XAxis); - mat.translate(-back->width()/2,-back->height()/2); - back->setTransform(mat); -} - -/*! - \qmlproperty real Flipable::rotation - The angle to rotate the flipable. For example, to show the back side of the flipable - you can set the rotation to 180. -*/ -qreal QFxFlipable::rotation() const -{ - Q_D(const QFxFlipable); - return d->rotation; -} - -void QFxFlipable::setRotation(qreal angle) -{ - Q_D(QFxFlipable); - d->rotation = angle; - d->axisRotation.setAngle(angle); - setTransform(d->axisRotation.transform()); - - - int simpleAngle = int(angle) % 360; - - Side newSide; - if (simpleAngle < 91 || simpleAngle > 270) { - newSide = Front; - } else { - newSide = Back; - } - - if (newSide != d->current) { - d->current = newSide; - if (d->front) - d->front->setOpacity((d->current==Front)?1.:0.); - if (d->back) { - d->setBackTransform(); - d->back->setOpacity((d->current==Back)?1.:0.); - } - emit sideChanged(); - } -} - -/*! \qmlproperty enumeration Flipable::side The side of the Flippable currently visible. Possible values are \c @@ -280,50 +179,55 @@ void QFxFlipable::setRotation(qreal angle) QFxFlipable::Side QFxFlipable::side() const { Q_D(const QFxFlipable); + if (d->dirtySceneTransform) + const_cast(d)->updateSceneTransformFromParent(); + return d->current; } -//in some cases the user may want to specify a more complex transformation. -//in that case, we still allow the generic use of transform. -//(the logic here should be kept in sync with setBackTransform and setRotation) -void QFxFlipable::transformChanged(const QTransform &trans) +// determination on the currently visible side of the flipable +// has to be done on the complete scene transform to give +// correct results. +void QFxFlipablePrivate::updateSceneTransformFromParent() { - Q_D(QFxFlipable); + Q_Q(QFxFlipable); + + QFxItemPrivate::updateSceneTransformFromParent(); QPointF p1(0, 0); QPointF p2(1, 0); QPointF p3(1, 1); - p1 = trans.map(p1); - p2 = trans.map(p2); - p3 = trans.map(p3); + p1 = sceneTransform.map(p1); + p2 = sceneTransform.map(p2); + p3 = sceneTransform.map(p3); qreal cross = (p1.x() - p2.x()) * (p3.y() - p2.y()) - (p1.y() - p2.y()) * (p3.x() - p2.x()); - Side newSide; + QFxFlipable::Side newSide; if (cross > 0) { - newSide = Back; + newSide = QFxFlipable::Back; } else { - newSide = Front; + newSide = QFxFlipable::Front; } - if (newSide != d->current) { - d->current = newSide; - if (d->current==Back) { + if (newSide != current) { + current = newSide; + if (current == QFxFlipable::Back) { QTransform mat; - mat.translate(d->back->width()/2,d->back->height()/2); - if (d->back->width() && p1.x() >= p2.x()) + mat.translate(back->width()/2,back->height()/2); + if (back->width() && p1.x() >= p2.x()) mat.rotate(180, Qt::YAxis); - if (d->back->height() && p2.y() >= p3.y()) + if (back->height() && p2.y() >= p3.y()) mat.rotate(180, Qt::XAxis); - mat.translate(-d->back->width()/2,-d->back->height()/2); - d->back->setTransform(mat); + mat.translate(-back->width()/2,-back->height()/2); + back->setTransform(mat); } - if (d->front) - d->front->setOpacity((d->current==Front)?1.:0.); - if (d->back) - d->back->setOpacity((d->current==Back)?1.:0.); - emit sideChanged(); + if (front) + front->setOpacity((current==QFxFlipable::Front)?1.:0.); + if (back) + back->setOpacity((current==QFxFlipable::Back)?1.:0.); + emit q->sideChanged(); } } diff --git a/src/declarative/fx/qfxflipable.h b/src/declarative/fx/qfxflipable.h index 4306e9f..0ab8fd2 100644 --- a/src/declarative/fx/qfxflipable.h +++ b/src/declarative/fx/qfxflipable.h @@ -45,6 +45,7 @@ #include #include #include +#include QT_BEGIN_HEADER @@ -52,7 +53,6 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QGraphicsAxis; class QFxFlipablePrivate; class Q_DECLARATIVE_EXPORT QFxFlipable : public QFxItem { @@ -61,8 +61,6 @@ class Q_DECLARATIVE_EXPORT QFxFlipable : public QFxItem Q_ENUMS(Side) Q_PROPERTY(QFxItem *front READ front WRITE setFront) Q_PROPERTY(QFxItem *back READ back WRITE setBack) - Q_PROPERTY(QGraphicsAxis *axis READ axis WRITE setAxis) - Q_PROPERTY(qreal rotation READ rotation WRITE setRotation) Q_PROPERTY(Side side READ side NOTIFY sideChanged) public: QFxFlipable(QFxItem *parent=0); @@ -74,23 +72,13 @@ public: QFxItem *back(); void setBack(QFxItem *); - QGraphicsAxis *axis(); - void setAxis(QGraphicsAxis *axis); - - qreal rotation() const; - void setRotation(qreal angle); - enum Side { Front, Back }; Side side() const; -protected: - virtual void transformChanged(const QTransform &); - Q_SIGNALS: void sideChanged(); private: - Q_PRIVATE_SLOT(d_func(), void _q_updateAxis()) Q_DISABLE_COPY(QFxFlipable) Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxFlipable) }; -- cgit v0.12 From 27015a7662a8a1b2852f2d43d948c51ac4e90070 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 27 Jul 2009 12:39:07 +0200 Subject: fixes in examples and demos Fixed all examples and demos to work after the changes to Flipable and Rotation3D. --- demos/declarative/flickr/content/ImageDetails.qml | 7 ++++++- demos/declarative/flickr/flickr.qml | 2 +- demos/declarative/flickr/flickr2.qml | 2 +- examples/declarative/minehunt/minehunt.qml | 15 ++++++++------- examples/declarative/snow/snow.qml | 2 +- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/demos/declarative/flickr/content/ImageDetails.qml b/demos/declarative/flickr/content/ImageDetails.qml index 9ff560a..5e3460a 100644 --- a/demos/declarative/flickr/content/ImageDetails.qml +++ b/demos/declarative/flickr/content/ImageDetails.qml @@ -15,10 +15,15 @@ Flipable { property string photoUrl property int rating: 2 property var prevScale: 1.0 + property int rotation: 0 signal closed - axis: Axis { startX: Container.width / 2; endX: Container.width / 2; endY: 1 } + transform: Rotation3D { + originX: Container.width / 2; + axis.y: 1; + angle: Container.rotation; + } front: Item { id: ContainerFront; anchors.fill: Container diff --git a/demos/declarative/flickr/flickr.qml b/demos/declarative/flickr/flickr.qml index f498462..72513a0 100644 --- a/demos/declarative/flickr/flickr.qml +++ b/demos/declarative/flickr/flickr.qml @@ -34,7 +34,7 @@ Item { scale: Wrapper.PathView.scale; z: Wrapper.PathView.z transform: [ - Rotation3D { id: Rotation; axis.startX: 30; axis.endX: 30; axis.endY: 60; angle: Wrapper.PathView.angle } + Rotation3D { id: Rotation; originX: 30; axis.x: 30; axis.y: 60; angle: Wrapper.PathView.angle } ] Connection { diff --git a/demos/declarative/flickr/flickr2.qml b/demos/declarative/flickr/flickr2.qml index 06b425c..36cf87e 100644 --- a/demos/declarative/flickr/flickr2.qml +++ b/demos/declarative/flickr/flickr2.qml @@ -37,7 +37,7 @@ Item { transform: [ Rotation3D { - id: Rotation; axis.startX: 30; axis.endX: 30; axis.endY: 60 + id: Rotation; originX: 30; axis.x: 30; axis.y: 60 angle: Wrapper.angle } ] diff --git a/examples/declarative/minehunt/minehunt.qml b/examples/declarative/minehunt/minehunt.qml index 6220d96..df5c077 100644 --- a/examples/declarative/minehunt/minehunt.qml +++ b/examples/declarative/minehunt/minehunt.qml @@ -15,11 +15,12 @@ Item { id: flipable width: 40 height: 40 - axis: Axis { - startX: 20 - startY: 20 - endX: 20 - endY: 0 + property int angle: 0; + transform: Rotation3D { + originX: 20 + originY: 20 + axis.x: 1 + angle: flipable.angle; } front: Image { source: "pics/front.png" @@ -67,7 +68,7 @@ Item { State { name: "back" when: modelData.flipped - SetProperties { target: flipable; rotation: 180 } + SetProperties { target: flipable; angle: 180 } } ] transitions: [ @@ -90,7 +91,7 @@ Item { } NumberAnimation { easing: "easeInOutQuad" - properties: "rotation" + properties: "angle" } RunScriptAction{ script: if(modelData.hasMine && modelData.flipped) diff --git a/examples/declarative/snow/snow.qml b/examples/declarative/snow/snow.qml index aaed619..aa5185f 100644 --- a/examples/declarative/snow/snow.qml +++ b/examples/declarative/snow/snow.qml @@ -42,7 +42,7 @@ Rect { } transform: Rotation3D { - axis { startX: 0; startY: 0; endX: 0; endY: 1 } + axis.y: 1 angle: MyLayout.deform * 100 } } -- cgit v0.12 From e494fef4cd3fd2dbec273fc48c49f8d15469bc96 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 27 Jul 2009 13:10:04 +0200 Subject: add support for points and fix rect The value bindings for rects where using integers. Use floats instead (as JS only knows about floats anyway) and make it work with both QRect and QRectF. Add valuse bindings for QPoint and QPointF. --- src/declarative/qml/qmlvaluetype.cpp | 57 +++++++++++++++++++++++++++++++----- src/declarative/qml/qmlvaluetype_p.h | 46 +++++++++++++++++++++-------- 2 files changed, 82 insertions(+), 21 deletions(-) diff --git a/src/declarative/qml/qmlvaluetype.cpp b/src/declarative/qml/qmlvaluetype.cpp index 571263e..e93fbc1 100644 --- a/src/declarative/qml/qmlvaluetype.cpp +++ b/src/declarative/qml/qmlvaluetype.cpp @@ -59,7 +59,11 @@ QmlValueTypeFactory::~QmlValueTypeFactory() QmlValueType *QmlValueTypeFactory::valueType(int t) { switch (t) { + case QVariant::Point: + case QVariant::PointF: + return new QmlPointValueType; case QVariant::Rect: + case QVariant::RectF: return new QmlRectValueType; case QVariant::Vector3D: return new QmlVector3DValueType; @@ -73,6 +77,43 @@ QmlValueType::QmlValueType(QObject *parent) { } +QmlPointValueType::QmlPointValueType(QObject *parent) +: QmlValueType(parent) +{ +} + +void QmlPointValueType::read(QObject *obj, int idx) +{ + void *a[] = { &point, 0 }; + QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a); +} + +void QmlPointValueType::write(QObject *obj, int idx) +{ + void *a[] = { &point, 0 }; + QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a); +} + +qreal QmlPointValueType::x() const +{ + return point.x(); +} + +qreal QmlPointValueType::y() const +{ + return point.y(); +} + +void QmlPointValueType::setX(qreal x) +{ + point.setX(x); +} + +void QmlPointValueType::setY(qreal y) +{ + point.setY(y); +} + QmlRectValueType::QmlRectValueType(QObject *parent) : QmlValueType(parent) { @@ -90,42 +131,42 @@ void QmlRectValueType::write(QObject *obj, int idx) QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a); } -int QmlRectValueType::x() const +qreal QmlRectValueType::x() const { return rect.x(); } -int QmlRectValueType::y() const +qreal QmlRectValueType::y() const { return rect.y(); } -void QmlRectValueType::setX(int x) +void QmlRectValueType::setX(qreal x) { rect.moveLeft(x); } -void QmlRectValueType::setY(int y) +void QmlRectValueType::setY(qreal y) { rect.moveTop(y); } -int QmlRectValueType::width() const +qreal QmlRectValueType::width() const { return rect.width(); } -int QmlRectValueType::height() const +qreal QmlRectValueType::height() const { return rect.height(); } -void QmlRectValueType::setWidth(int w) +void QmlRectValueType::setWidth(qreal w) { rect.setWidth(w); } -void QmlRectValueType::setHeight(int h) +void QmlRectValueType::setHeight(qreal h) { rect.setHeight(h); } diff --git a/src/declarative/qml/qmlvaluetype_p.h b/src/declarative/qml/qmlvaluetype_p.h index b19c1ba..9195c61 100644 --- a/src/declarative/qml/qmlvaluetype_p.h +++ b/src/declarative/qml/qmlvaluetype_p.h @@ -80,12 +80,32 @@ public: QmlValueType *operator[](int idx) const { return valueTypes[idx]; } }; +class QmlPointValueType : public QmlValueType +{ + Q_PROPERTY(qreal x READ x WRITE setX); + Q_PROPERTY(qreal y READ y WRITE setY); + Q_OBJECT +public: + QmlPointValueType(QObject *parent = 0); + + virtual void read(QObject *, int); + virtual void write(QObject *, int); + + qreal x() const; + qreal y() const; + void setX(qreal); + void setY(qreal); + +private: + QPointF point; +}; + class QmlRectValueType : public QmlValueType { - Q_PROPERTY(int x READ x WRITE setX); - Q_PROPERTY(int y READ y WRITE setY); - Q_PROPERTY(int width READ width WRITE setWidth); - Q_PROPERTY(int height READ height WRITE setHeight); + Q_PROPERTY(qreal x READ x WRITE setX); + Q_PROPERTY(qreal y READ y WRITE setY); + Q_PROPERTY(qreal width READ width WRITE setWidth); + Q_PROPERTY(qreal height READ height WRITE setHeight); Q_OBJECT public: QmlRectValueType(QObject *parent = 0); @@ -93,18 +113,18 @@ public: virtual void read(QObject *, int); virtual void write(QObject *, int); - int x() const; - int y() const; - void setX(int); - void setY(int); + qreal x() const; + qreal y() const; + void setX(qreal); + void setY(qreal); - int width() const; - int height() const; - void setWidth(int); - void setHeight(int); + qreal width() const; + qreal height() const; + void setWidth(qreal); + void setHeight(qreal); private: - QRect rect; + QRectF rect; }; class QmlVector3DValueType : public QmlValueType -- cgit v0.12 From 3de172e037eef64a5b7065dc574f761818d95bbb Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 27 Jul 2009 13:20:46 +0200 Subject: fix all examples after change to QGraphicsTransform::origin. --- demos/declarative/flickr/content/ImageDetails.qml | 2 +- demos/declarative/flickr/flickr.qml | 2 +- demos/declarative/flickr/flickr2.qml | 2 +- examples/declarative/clock/Clock.qml | 6 +++--- examples/declarative/dial/DialLibrary/Dial.qml | 4 ++-- examples/declarative/minehunt/minehunt.qml | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/demos/declarative/flickr/content/ImageDetails.qml b/demos/declarative/flickr/content/ImageDetails.qml index 5e3460a..1649b44 100644 --- a/demos/declarative/flickr/content/ImageDetails.qml +++ b/demos/declarative/flickr/content/ImageDetails.qml @@ -20,7 +20,7 @@ Flipable { signal closed transform: Rotation3D { - originX: Container.width / 2; + origin.x: Container.width / 2; axis.y: 1; angle: Container.rotation; } diff --git a/demos/declarative/flickr/flickr.qml b/demos/declarative/flickr/flickr.qml index 72513a0..eba65c0 100644 --- a/demos/declarative/flickr/flickr.qml +++ b/demos/declarative/flickr/flickr.qml @@ -34,7 +34,7 @@ Item { scale: Wrapper.PathView.scale; z: Wrapper.PathView.z transform: [ - Rotation3D { id: Rotation; originX: 30; axis.x: 30; axis.y: 60; angle: Wrapper.PathView.angle } + Rotation3D { id: Rotation; origin.x: 30; axis.x: 30; axis.y: 60; angle: Wrapper.PathView.angle } ] Connection { diff --git a/demos/declarative/flickr/flickr2.qml b/demos/declarative/flickr/flickr2.qml index 36cf87e..136e604 100644 --- a/demos/declarative/flickr/flickr2.qml +++ b/demos/declarative/flickr/flickr2.qml @@ -37,7 +37,7 @@ Item { transform: [ Rotation3D { - id: Rotation; originX: 30; axis.x: 30; axis.y: 60 + id: Rotation; origin.x: 30; axis.x: 30; axis.y: 60 angle: Wrapper.angle } ] diff --git a/examples/declarative/clock/Clock.qml b/examples/declarative/clock/Clock.qml index 9720d0b..d73f7ca 100644 --- a/examples/declarative/clock/Clock.qml +++ b/examples/declarative/clock/Clock.qml @@ -26,7 +26,7 @@ Item { smooth: true transform: Rotation { id: HourRotation - originX: 4; originY: 45 + origin.x: 4; origin.y: 45 angle: 0 angle: Follow { spring: 2 @@ -42,7 +42,7 @@ Item { smooth: true transform: Rotation { id: MinuteRotation - originX: 4; originY: 70 + origin.x: 4; origin.y: 70 angle: 0 angle: Follow { spring: 2 @@ -58,7 +58,7 @@ Item { smooth: true transform: Rotation { id: SecondRotation - originX: 2; originY: 60 + origin.x: 2; origin.y: 60 angle: 0 angle: Follow { spring: 5 diff --git a/examples/declarative/dial/DialLibrary/Dial.qml b/examples/declarative/dial/DialLibrary/Dial.qml index e3ea530..eb9ed3a 100644 --- a/examples/declarative/dial/DialLibrary/Dial.qml +++ b/examples/declarative/dial/DialLibrary/Dial.qml @@ -12,7 +12,7 @@ Item { y: 35 source: "needle_shadow.png" transform: Rotation { - originX: 11; originY: 67 + origin.x: 11; origin.y: 67 angle: NeedleRotation.angle } } @@ -23,7 +23,7 @@ Item { source: "needle.png" transform: Rotation { id: NeedleRotation - originX: 7; originY: 65 + origin.x: 7; origin.y: 65 angle: -130 angle: Follow { spring: 1.4 diff --git a/examples/declarative/minehunt/minehunt.qml b/examples/declarative/minehunt/minehunt.qml index df5c077..e1f48ef 100644 --- a/examples/declarative/minehunt/minehunt.qml +++ b/examples/declarative/minehunt/minehunt.qml @@ -17,8 +17,8 @@ Item { height: 40 property int angle: 0; transform: Rotation3D { - originX: 20 - originY: 20 + origin.x: 20 + origin.y: 20 axis.x: 1 angle: flipable.angle; } -- cgit v0.12 From 9684a3aa09878fe305ca22fad85617fe7ac37786 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 28 Jul 2009 06:11:27 +0200 Subject: Fix graphics transform handling after latest changes. --- src/declarative/fx/qfxitem.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 5978e73..df1aea0 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -654,12 +654,7 @@ int QFxItemPrivate::transform_count() const void QFxItemPrivate::transform_append(QGraphicsTransform *item) { - if (!transformData) - transformData = new QGraphicsItemPrivate::TransformData; - if (!transformData->graphicsTransforms.contains(item)) - transformData->graphicsTransforms.append(item); - transformData->onlyTransform = false; - dirtySceneTransform = 1; + appendGraphicsTransform(item); } void QFxItemPrivate::transform_insert(int, QGraphicsTransform *) @@ -678,8 +673,8 @@ void QFxItemPrivate::transform_clear() { if (!transformData) return; - transformData->graphicsTransforms.clear(); - dirtySceneTransform = 1; + Q_Q(QFxItem); + q->setTransformations(QList()); } /*! -- cgit v0.12 From 804bac13d742251f5665dbddc32ff00c4ab86b39 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 28 Jul 2009 08:34:46 +0200 Subject: simplify the code. --- demos/declarative/flickr/content/ImageDetails.qml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/demos/declarative/flickr/content/ImageDetails.qml b/demos/declarative/flickr/content/ImageDetails.qml index 1649b44..26bac32 100644 --- a/demos/declarative/flickr/content/ImageDetails.qml +++ b/demos/declarative/flickr/content/ImageDetails.qml @@ -15,14 +15,13 @@ Flipable { property string photoUrl property int rating: 2 property var prevScale: 1.0 - property int rotation: 0 signal closed transform: Rotation3D { + id: Rotation origin.x: Container.width / 2; axis.y: 1; - angle: Container.rotation; } front: Item { @@ -137,7 +136,7 @@ Flipable { states: [ State { name: "Back" - SetProperties { target: Container; rotation: 180 } + SetProperties { target: Rotation; angle: 180 } } ] @@ -149,7 +148,7 @@ Flipable { property: "smooth" value: false } - NumberAnimation { easing: "easeInOutQuad"; properties: "rotation"; duration: 500 } + NumberAnimation { easing: "easeInOutQuad"; properties: "angle"; duration: 500 } SetPropertyAction { target: BigImage property: "smooth" -- cgit v0.12 From 282e9bf50ac0c9a33338816968edc64a4f528b91 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 29 Jul 2009 06:18:18 +0200 Subject: fix merge error. --- src/declarative/fx/qfxitem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index df1aea0..a65b51a 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -859,7 +859,7 @@ void QFxItem::qmlLoaded() QObject* o = c ? c->create(ctxt):0; QFxItem* ret = qobject_cast(o); if (ret) { - ret->setItemParent(this); + ret->setParentItem(this); QScriptValue v = QmlEnginePrivate::getScriptEngine(qmlEngine(this))->newQObject(ret); emit newChildCreated(d->_qmlnewloading.at(i).toString(),v); } -- cgit v0.12