From 22f96b7c64c98b9fb438a0b652e0f5f20d912d17 Mon Sep 17 00:00:00 2001 From: Herace Siinclaiir Date: Tue, 7 Aug 2018 06:02:20 -0400 Subject: [PATCH 01/39] Resource Dialog Loads more then one file. --- src/gui/ResourceDialog.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gui/ResourceDialog.cpp b/src/gui/ResourceDialog.cpp index 97a97970..b3f446d9 100644 --- a/src/gui/ResourceDialog.cpp +++ b/src/gui/ResourceDialog.cpp @@ -25,7 +25,7 @@ ResourceDialog::ResourceDialog(ViaPoint& aViaPoint, bool aModal, QWidget* aParen { auto menuBar = new QMenuBar(this); auto fileMenu = new QMenu(tr("File"), menuBar); - auto addResource = new QAction(tr("Add Resource"), fileMenu); + auto addResource = new QAction(tr("Add Resources"), fileMenu); connect(addResource, &QAction::triggered, this, &ResourceDialog::onAddResourceTriggered); fileMenu->addAction(addResource); menuBar->setNativeMenuBar(false); @@ -100,11 +100,13 @@ void ResourceDialog::onAddResourceTriggered(bool) { if (!mProject) return; - const QString fileName = QFileDialog::getOpenFileName( - this, tr("Open File"), "", "ImageFile (*.psd *.jpg *.jpeg *.png *.gif)"); + const QStringList fileName = QFileDialog::getOpenFileNames( + this, tr("Open Files"), "", "ImageFile (*.psd *.jpg *.jpeg *.png *.gif)"); if (fileName.isEmpty()) return; - mTree->load(fileName); + for(int i = 0; i < fileName.count();i++){ + mTree->load(fileName[i]); + } } void ResourceDialog::keyPressEvent(QKeyEvent* aEvent) From e720e03a652ef1e0e380a6f8f019b98e1c00c481 Mon Sep 17 00:00:00 2001 From: Herace Siinclaiir Date: Tue, 7 Aug 2018 07:10:50 -0400 Subject: [PATCH 02/39] "create layer object" now titled file base name instead of "topnode" --- src/gui/res/res_ResourceUpdater.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/res/res_ResourceUpdater.cpp b/src/gui/res/res_ResourceUpdater.cpp index a16a302c..e414714b 100644 --- a/src/gui/res/res_ResourceUpdater.cpp +++ b/src/gui/res/res_ResourceUpdater.cpp @@ -364,7 +364,7 @@ img::ResourceNode* ResourceUpdater::createQImageTree(const QString& aFilePath, b tr("Failed to load image file.")); return nullptr; } - return img::Util::createResourceNode(image, "topnode", aLoadImage); + return img::Util::createResourceNode(image, fileInfo.baseName(), aLoadImage); } img::ResourceNode* ResourceUpdater::createPsdTree(const QString& aFilePath, bool aLoadImage) From b2a349f0ff9dec5cf5e509a74cc7aabeb83966c8 Mon Sep 17 00:00:00 2001 From: Herace Siinclaiir Date: Sun, 6 Oct 2019 01:31:28 -0400 Subject: [PATCH 03/39] More then one layer can be created from resource list. --- src/gui/ObjectTreeWidget.cpp | 73 +++++++++++++++++++----------------- src/gui/ResourceDialog.cpp | 2 + 2 files changed, 40 insertions(+), 35 deletions(-) diff --git a/src/gui/ObjectTreeWidget.cpp b/src/gui/ObjectTreeWidget.cpp index 8386e6fc..bb51dbee 100644 --- a/src/gui/ObjectTreeWidget.cpp +++ b/src/gui/ObjectTreeWidget.cpp @@ -567,41 +567,44 @@ void ObjectTreeWidget::onObjectActionTriggered(bool) // create command if (dialog->hasValidNode()) { - // get resource - auto resNode = dialog->nodeList().first(); - if (!resNode) return; - XC_ASSERT(resNode->data().hasImage()); - - // create node - core::LayerNode* ptr = new core::LayerNode( - resNode->data().identifier(), - mProject->objectTree().shaderHolder()); - ptr->setVisibility(true); - ptr->setDefaultImage(resNode->handle()); - ptr->setDefaultPosture(QVector2D()); - ptr->setDefaultDepth(depth); - ptr->setDefaultOpacity(1.0f); // @todo support default opacity - - - cmnd::ScopedMacro macro(mProject->commandStack(), - CmndName::tr("create a layer object")); - // notifier - { - auto coreNotifier = new core::ObjectTreeNotifier(*mProject); - coreNotifier->event().setType(core::ObjectTreeEvent::Type_Add); - coreNotifier->event().pushTarget(parent, *ptr); - macro.grabListener(coreNotifier); - } - macro.grabListener(new obj::RestructureNotifier(*this)); - - // create commands - mProject->commandStack().push(new cmnd::GrabNewObject(ptr)); - mProject->commandStack().push(new cmnd::InsertTree(&(parent->children()), index, ptr)); - - // create gui commands - auto itemPtr = createFileItem(*ptr); - mProject->commandStack().push(new cmnd::GrabNewObject(itemPtr)); - mProject->commandStack().push(new obj::InsertItem(*parentItem, itemIndex, *itemPtr)); + int node_count = dialog->nodeList().count(); + for(int i = 0; i < node_count; i++){ + // get resource + auto resNode = dialog->nodeList().at(i); + if (!resNode) return; + XC_ASSERT(resNode->data().hasImage()); + + // create node + core::LayerNode* ptr = new core::LayerNode( + resNode->data().identifier(), + mProject->objectTree().shaderHolder()); + ptr->setVisibility(true); + ptr->setDefaultImage(resNode->handle()); + ptr->setDefaultPosture(QVector2D()); + ptr->setDefaultDepth(depth); + ptr->setDefaultOpacity(1.0f); // @todo support default opacity + + + cmnd::ScopedMacro macro(mProject->commandStack(), + CmndName::tr("create a layer object")); + // notifier + { + auto coreNotifier = new core::ObjectTreeNotifier(*mProject); + coreNotifier->event().setType(core::ObjectTreeEvent::Type_Add); + coreNotifier->event().pushTarget(parent, *ptr); + macro.grabListener(coreNotifier); + } + macro.grabListener(new obj::RestructureNotifier(*this)); + + // create commands + mProject->commandStack().push(new cmnd::GrabNewObject(ptr)); + mProject->commandStack().push(new cmnd::InsertTree(&(parent->children()), index, ptr)); + + // create gui commands + auto itemPtr = createFileItem(*ptr); + mProject->commandStack().push(new cmnd::GrabNewObject(itemPtr)); + mProject->commandStack().push(new obj::InsertItem(*parentItem, itemIndex, *itemPtr)); + } } } } diff --git a/src/gui/ResourceDialog.cpp b/src/gui/ResourceDialog.cpp index b3f446d9..3a0a0b97 100644 --- a/src/gui/ResourceDialog.cpp +++ b/src/gui/ResourceDialog.cpp @@ -44,6 +44,8 @@ ResourceDialog::ResourceDialog(ViaPoint& aViaPoint, bool aModal, QWidget* aParen // resource tree mTree = new ResourceTreeWidget(aViaPoint, !aModal, this); + mTree->setSelectionMode(QAbstractItemView::ExtendedSelection); + this->setMainWidget(mTree, false); // modal only From 485468fb6f53c49ad89011c43ed8881ee34ac02e Mon Sep 17 00:00:00 2001 From: lmp Date: Thu, 17 Oct 2019 10:28:02 +0200 Subject: [PATCH 04/39] Fix a few compiler warnings --- src/gui/ObjectTreeWidget.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gui/ObjectTreeWidget.cpp b/src/gui/ObjectTreeWidget.cpp index bb51dbee..774c013f 100644 --- a/src/gui/ObjectTreeWidget.cpp +++ b/src/gui/ObjectTreeWidget.cpp @@ -40,8 +40,8 @@ ObjectTreeWidget::ObjectTreeWidget(ViaPoint& aViaPoint, GUIResources& aResources , mProject() , mTimeLineSlot() , mStoreInsert(false) - , mInsertedPositions() , mRemovedPositions() + , mInsertedPositions() , mMacroScope() , mObjTreeNotifier() , mDragIndex() @@ -124,7 +124,7 @@ void ObjectTreeWidget::setProject(core::Project* aProject) trees->push_back(this->takeTopLevelItem(0)); } // save - auto hook = (ProjectHook*)mProject->hook(); + auto hook = static_cast(mProject->hook()); hook->grabObjectTrees(trees.take()); } } @@ -148,7 +148,7 @@ void ObjectTreeWidget::setProject(core::Project* aProject) mTimeLineSlot = mProject->onTimeLineModified.connect( this, &ObjectTreeWidget::onTimeLineModified); - auto hook = (ProjectHook*)mProject->hook(); + auto hook = static_cast(mProject->hook()); // load trees if (hook && hook->hasObjectTrees()) { @@ -531,7 +531,7 @@ void ObjectTreeWidget::onObjectActionTriggered(bool) parent = mProject->objectTree().topNode(); XC_PTR_ASSERT(parent); - index = (int)parent->children().size(); + index = static_cast(parent->children().size()); if (index > 0) { auto prevNode = parent->children().back(); @@ -628,7 +628,7 @@ void ObjectTreeWidget::onFolderActionTriggered(bool) parent = mProject->objectTree().topNode(); XC_PTR_ASSERT(parent); - index = (int)parent->children().size(); + index = static_cast(parent->children().size()); if (index > 0) { auto prevNode = parent->children().back(); From 0f2d2e464c57c021369aa86b57d3935d96ccd957 Mon Sep 17 00:00:00 2001 From: lmp Date: Thu, 17 Oct 2019 11:55:39 +0200 Subject: [PATCH 05/39] * Add Qt::KeypadModifier to known modifier keys * Add Rotate Canvas (Anti) Clockwise key bindings * Start of WIP showing Key Bindings in tool tips --- src/ctrl/KeyBinding.cpp | 13 +++++++++++-- src/ctrl/KeyBinding.h | 1 + src/gui/KeyCommandMap.cpp | 6 ++++++ src/gui/MainDisplayWidget.cpp | 34 +++++++++++++++++++++++++++++++--- src/gui/MainDisplayWidget.h | 1 + src/gui/MainWindow.cpp | 2 +- src/gui/MainWindow.h | 2 +- src/gui/ToolWidget.cpp | 14 ++++++++++---- src/gui/ToolWidget.h | 3 ++- 9 files changed, 64 insertions(+), 12 deletions(-) diff --git a/src/ctrl/KeyBinding.cpp b/src/ctrl/KeyBinding.cpp index 3bedf8f4..e73e94e4 100644 --- a/src/ctrl/KeyBinding.cpp +++ b/src/ctrl/KeyBinding.cpp @@ -42,7 +42,7 @@ KeyBinding::KeyBinding(int aKeyCode, Qt::KeyboardModifiers aModifiers, int aSubK , mSubKeyCode(aSubKeyCode) , mModifiers() { - mModifiers = aModifiers & (Qt::ControlModifier | Qt::ShiftModifier | Qt::AltModifier | Qt::MetaModifier); + mModifiers = aModifiers & (Qt::ControlModifier | Qt::ShiftModifier | Qt::AltModifier | Qt::MetaModifier | Qt::KeypadModifier); } void KeyBinding::setSubKeyCode(int aSubKeyCode) @@ -53,7 +53,12 @@ void KeyBinding::setSubKeyCode(int aSubKeyCode) bool KeyBinding::isValidBinding() const { return getKeyValidity(mKeyCode) && - (mSubKeyCode == -1 || getKeyValidity(mSubKeyCode)); + (mSubKeyCode == -1 || getKeyValidity(mSubKeyCode)); +} + +bool KeyBinding::hasKeypadModifier() const +{ + return mModifiers & Qt::KeypadModifier; } bool KeyBinding::hasControlModifier() const @@ -97,6 +102,8 @@ QString KeyBinding::text() const if (hasShiftModifier()) t += "Shift + "; if (hasAltModifier()) t += "Alt + "; + if (hasKeypadModifier()) t += "Keypad + "; + if (mKeyCode != -1) { t += QKeySequence(mKeyCode).toString(); @@ -148,6 +155,7 @@ void KeyBinding::setSerialValue(const QString& aValue) if (mod & 0x01) mModifiers |= Qt::ControlModifier; if (mod & 0x02) mModifiers |= Qt::ShiftModifier; if (mod & 0x04) mModifiers |= Qt::AltModifier; + if (mod & 0x06) mModifiers |= Qt::KeypadModifier; if (mod & 0x08) mModifiers |= Qt::MetaModifier; if (!isValidBinding()) @@ -164,6 +172,7 @@ QString KeyBinding::serialValue() const mod |= mModifiers.testFlag(Qt::ControlModifier) ? 0x01 : 0x00; mod |= mModifiers.testFlag(Qt::ShiftModifier) ? 0x02 : 0x00; mod |= mModifiers.testFlag(Qt::AltModifier) ? 0x04 : 0x00; + mod |= mModifiers.testFlag(Qt::KeypadModifier) ? 0x06 : 0x00; mod |= mModifiers.testFlag(Qt::MetaModifier) ? 0x08 : 0x00; return QString::number(mKeyCode) + "," + QString::number(mod) + "," + QString::number(mSubKeyCode); } diff --git a/src/ctrl/KeyBinding.h b/src/ctrl/KeyBinding.h index 79f48d1a..acbf8e5a 100644 --- a/src/ctrl/KeyBinding.h +++ b/src/ctrl/KeyBinding.h @@ -23,6 +23,7 @@ class KeyBinding int subKeyCode() const { return mSubKeyCode; } bool hasSubKeyCode() const { return mSubKeyCode != -1; } bool isValidBinding() const; + bool hasKeypadModifier() const; bool hasControlModifier() const; bool hasShiftModifier() const; bool hasAltModifier() const; diff --git a/src/gui/KeyCommandMap.cpp b/src/gui/KeyCommandMap.cpp index dfce21ab..52c0617b 100644 --- a/src/gui/KeyCommandMap.cpp +++ b/src/gui/KeyCommandMap.cpp @@ -55,6 +55,12 @@ KeyCommandMap::KeyCommandMap(QWidget& aParent) addNewKey("RotateCanvas", view, tr("Rotate canvas"), ctrl::KeyBinding(Qt::Key_Space, Qt::ShiftModifier)); + addNewKey("RotateCanvas15Clockwise", view, tr("Rotate canvas 15° clockwise"), + ctrl::KeyBinding(Qt::Key_6, Qt::KeypadModifier)); + + addNewKey("RotateCanvas15AntiClockwise", view, tr("Rotate canvas 15° anti clockwise"), + ctrl::KeyBinding(Qt::Key_4, Qt::KeypadModifier)); + addNewKey("ResetCanvasAngle", view, tr("Reset canvas angle"), ctrl::KeyBinding(Qt::Key_Space, Qt::NoModifier, Qt::Key_F1)); diff --git a/src/gui/MainDisplayWidget.cpp b/src/gui/MainDisplayWidget.cpp index 88164835..2a72e226 100644 --- a/src/gui/MainDisplayWidget.cpp +++ b/src/gui/MainDisplayWidget.cpp @@ -97,6 +97,34 @@ MainDisplayWidget::MainDisplayWidget(ViaPoint& aViaPoint, QWidget* aParent) } } + // rotate canvas clockwise + { + auto key = mViaPoint.keyCommandMap()->get("RotateCanvas15Clockwise"); + if (key) + { + + key->invoker = [=]() + { + mCanvasMover.rotate(qDegreesToRadians(15.0f)); + updateRender(); + }; + } + } + + // rotate canvas anti-clockwise + { + auto key = mViaPoint.keyCommandMap()->get("RotateCanvas15AntiClockwise"); + if (key) + { + + key->invoker = [=]() + { + mCanvasMover.rotate(qDegreesToRadians(-15.0f)); + updateRender(); + }; + } + } + // reset canvas angle { auto key = mViaPoint.keyCommandMap()->get("ResetCanvasAngle"); @@ -161,7 +189,7 @@ void MainDisplayWidget::resetCamera() camera.setCenter(QVector2D(scrSize.width() * 0.5f, scrSize.height() * 0.5f)); if (scrSize.width() > 0 && scrSize.height() > 0 && imgSize.width() > 0 && imgSize.height() > 0) { - auto scaleX = (float)scrSize.width() / imgSize.width(); + auto scaleX = (float)scrSize.width() / imgSize.width(); auto scaleY = (float)scrSize.height() / imgSize.height(); auto minScale = scaleX < scaleY ? scaleX : scaleY; camera.setScale(minScale); @@ -490,11 +518,11 @@ void MainDisplayWidget::onViewSettingChanged(const MainViewSetting& aSetting) } else if (mViewSetting.rotateViewACW) { - mCanvasMover.rotate((float)(-M_PI / 18.0)); + mCanvasMover.rotate(qDegreesToRadians(-15.0f)); } else if (mViewSetting.rotateViewCW) { - mCanvasMover.rotate((float)(M_PI / 18.0)); + mCanvasMover.rotate(qDegreesToRadians(15.0f)); } updateRender(); diff --git a/src/gui/MainDisplayWidget.h b/src/gui/MainDisplayWidget.h index 9f7b3a53..8799e361 100644 --- a/src/gui/MainDisplayWidget.h +++ b/src/gui/MainDisplayWidget.h @@ -6,6 +6,7 @@ #include #include #include +#include #include "util/LinkPointer.h" #include "gl/Global.h" #include "gl/Root.h" diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 424f5762..90ed63e3 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -212,7 +212,7 @@ MainWindow::MainWindow(ctrl::System& aSystem, GUIResources& aResources, const Lo { dockWidget->setStyleSheet(QTextStream(&stylesheet).readAll()); } - mTool = new ToolWidget(mViaPoint, mGUIResources, QSize(192, 136), dockWidget); + mTool = new ToolWidget(mViaPoint, mGUIResources, *mKeyCommandMap, QSize(192, 136), dockWidget); dockWidget->setWidget(mTool); } diff --git a/src/gui/MainWindow.h b/src/gui/MainWindow.h index 2a50eb28..2308648b 100644 --- a/src/gui/MainWindow.h +++ b/src/gui/MainWindow.h @@ -66,7 +66,7 @@ class MainWindow : public QMainWindow ctrl::System& mSystem; GUIResources& mGUIResources; ViaPoint mViaPoint; - QScopedPointer mKeyCommandMap; + QScopedPointer mKeyCommandMap; QScopedPointer mKeyCommandInvoker; MouseSetting mMouseSetting; MainMenuBar* mMainMenuBar; diff --git a/src/gui/ToolWidget.cpp b/src/gui/ToolWidget.cpp index 3a2a79f1..6b0b2c76 100644 --- a/src/gui/ToolWidget.cpp +++ b/src/gui/ToolWidget.cpp @@ -5,11 +5,12 @@ namespace gui { -ToolWidget::ToolWidget(ViaPoint& aViaPoint, GUIResources& aResources, - const QSize& aSizeHint, QWidget* aParent) +ToolWidget::ToolWidget(ViaPoint& aViaPoint, GUIResources& aResources, KeyCommandMap &aKeyCommandMap, + const QSize& aSizeHint, QWidget* aParent) : QWidget(aParent) , mViaPoint(aViaPoint) , mResources(aResources) + , mKeyCommandMap(aKeyCommandMap) , mSizeHint(aSizeHint) , mViewPanel() , mModePanel() @@ -108,19 +109,24 @@ void ToolWidget::createViewPanel() this->viewSetting().cutImagesByTheFrame = aChecked; this->onViewSettingChanged(this->viewSetting()); }); - mViewPanel->addButton("rotateac", false, tr("Rotate the View Anticlockwise"), [=](bool) + + QString _rotateViewAntiClockwiseText = this->mKeyCommandMap.get("RotateCanvas15AntiClockwise")->binding.text(); + mViewPanel->addButton("rotateac", false, tr("Rotate the View Anticlockwise (%1").arg(_rotateViewAntiClockwiseText), [=](bool) { this->viewSetting().rotateViewACW = true; this->onViewSettingChanged(this->viewSetting()); this->viewSetting().rotateViewACW = false; }); + mViewPanel->addButton("resetrot", false, tr("Reset Rotation of the View"), [=](bool) { this->viewSetting().resetRotateView = true; this->onViewSettingChanged(this->viewSetting()); this->viewSetting().resetRotateView = false; }); - mViewPanel->addButton("rotatecw", false, tr("Rotate the View Clockwise"), [=](bool) + + QString _rotateViewClockwiseText = this->mKeyCommandMap.get("RotateCanvas15Clockwise")->binding.text(); + mViewPanel->addButton("rotatecw", false, tr("Rotate the View Clockwise (%1)").arg(_rotateViewClockwiseText), [=](bool) { this->viewSetting().rotateViewCW = true; this->onViewSettingChanged(this->viewSetting()); diff --git a/src/gui/ToolWidget.h b/src/gui/ToolWidget.h index 96bdac06..af782add 100644 --- a/src/gui/ToolWidget.h +++ b/src/gui/ToolWidget.h @@ -25,7 +25,7 @@ class ToolWidget : public QWidget { Q_OBJECT public: - ToolWidget(ViaPoint& aViaPoint, GUIResources& aResources, + ToolWidget(ViaPoint& aViaPoint, GUIResources& aResources, KeyCommandMap& aKeyCommandMap, const QSize& aSizeHint, QWidget* aParent); void setDriver(ctrl::Driver* aDriver); @@ -51,6 +51,7 @@ class ToolWidget : public QWidget ViaPoint& mViaPoint; GUIResources& mResources; + KeyCommandMap& mKeyCommandMap; const QSize mSizeHint; tool::ViewPanel* mViewPanel; tool::ModePanel* mModePanel; From 144c58bd50bbef63533cf21805ea7ccefac07f51 Mon Sep 17 00:00:00 2001 From: lmp Date: Wed, 13 Nov 2019 10:58:25 +0100 Subject: [PATCH 06/39] Fixes #4 and fixes saved tabs issue --- src/ctrl/KeyBinding.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ctrl/KeyBinding.cpp b/src/ctrl/KeyBinding.cpp index e73e94e4..cea38dcf 100644 --- a/src/ctrl/KeyBinding.cpp +++ b/src/ctrl/KeyBinding.cpp @@ -152,11 +152,12 @@ void KeyBinding::setSerialValue(const QString& aValue) mKeyCode = key; mSubKeyCode = subKey; mModifiers = Qt::NoModifier; + // Values (0x01, 0x02, etc.) are short versions of the Qt modifier enums (Qt::) if (mod & 0x01) mModifiers |= Qt::ControlModifier; if (mod & 0x02) mModifiers |= Qt::ShiftModifier; if (mod & 0x04) mModifiers |= Qt::AltModifier; - if (mod & 0x06) mModifiers |= Qt::KeypadModifier; if (mod & 0x08) mModifiers |= Qt::MetaModifier; + if (mod & 0x20) mModifiers |= Qt::KeypadModifier; if (!isValidBinding()) { @@ -172,8 +173,8 @@ QString KeyBinding::serialValue() const mod |= mModifiers.testFlag(Qt::ControlModifier) ? 0x01 : 0x00; mod |= mModifiers.testFlag(Qt::ShiftModifier) ? 0x02 : 0x00; mod |= mModifiers.testFlag(Qt::AltModifier) ? 0x04 : 0x00; - mod |= mModifiers.testFlag(Qt::KeypadModifier) ? 0x06 : 0x00; mod |= mModifiers.testFlag(Qt::MetaModifier) ? 0x08 : 0x00; + mod |= mModifiers.testFlag(Qt::KeypadModifier) ? 0x20 : 0x00; return QString::number(mKeyCode) + "," + QString::number(mod) + "," + QString::number(mSubKeyCode); } From 2d1682218eef36efe7311fe988b3ed4a8540cafe Mon Sep 17 00:00:00 2001 From: lmp Date: Wed, 13 Nov 2019 11:20:58 +0100 Subject: [PATCH 07/39] WIP: Fix old-style cast warnings --- src/gui/TimeLineWidget.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/gui/TimeLineWidget.cpp b/src/gui/TimeLineWidget.cpp index 06afb4e8..9e221c12 100644 --- a/src/gui/TimeLineWidget.cpp +++ b/src/gui/TimeLineWidget.cpp @@ -43,7 +43,7 @@ void TimeLineWidget::setPlayBackActivity(bool aIsActive) { if (aIsActive) { - mTimer.setInterval((int)getOneFrameTime()); + mTimer.setInterval(static_cast(getOneFrameTime())); mTimer.start(); mElapsed.start(); mBeginFrame = currentFrame(); @@ -140,14 +140,14 @@ void TimeLineWidget::onPlayBackUpdated() { const double oneFrameTime = getOneFrameTime(); const core::Frame curFrame = currentFrame(); - double nextFrame = curFrame.getDecimal() + 1.0; + double nextFrame = static_cast(curFrame.getDecimal()) + 1.0; if (mDoesLoop && nextFrame > mInner->maxFrame()) { nextFrame = 0.0; mBeginFrame.set(0); mElapsed.restart(); - mTimer.setInterval((int)oneFrameTime); + mTimer.setInterval(static_cast(oneFrameTime)); } else { @@ -155,17 +155,17 @@ void TimeLineWidget::onPlayBackUpdated() { const int elapsedTime = mElapsed.elapsed(); const double elapsedFrame = elapsedTime / oneFrameTime; - nextFrame = mBeginFrame.getDecimal() + elapsedFrame; + nextFrame = static_cast(mBeginFrame.getDecimal()) + elapsedFrame; - const double nextUpdateTime = oneFrameTime * ((int)elapsedFrame + 1); + const double nextUpdateTime = oneFrameTime * (static_cast(elapsedFrame) + 1); const double intervalTime = nextUpdateTime - elapsedTime; - mTimer.setInterval(std::max((int)intervalTime, 1)); + mTimer.setInterval(std::max(static_cast(intervalTime), 1)); } else { mBeginFrame = curFrame; mElapsed.restart(); - mTimer.setInterval((int)oneFrameTime); + mTimer.setInterval(static_cast(oneFrameTime)); } } @@ -173,8 +173,8 @@ void TimeLineWidget::onPlayBackUpdated() setFrame(core::Frame::fromDecimal(nextFrame)); mLastFrame = core::Frame::fromDecimal(nextFrame); #else - setFrame(core::Frame((int)nextFrame)); - mLastFrame = core::Frame((int)nextFrame); + setFrame(core::Frame(static_cast(nextFrame))); + mLastFrame = core::Frame(static_cast(nextFrame)); #endif } } @@ -230,8 +230,8 @@ void TimeLineWidget::wheelEvent(QWheelEvent* aEvent) mInner->updateWheel(aEvent); const QRect rectNext = mInner->rect(); - const double scale = (double)rectNext.width() / rectPrev.width(); - viewTrans.setX(cursor.x() + scale * (viewTrans.x() - cursor.x())); + const double scale = static_cast(rectNext.width() / rectPrev.width()); + viewTrans.setX(static_cast(cursor.x() + scale * (viewTrans.x() - cursor.x()))); setScrollBarValue(viewTrans); updateCamera(); } From 72f3fe4b3e31311ee4acf9721b833c2e59664b00 Mon Sep 17 00:00:00 2001 From: lmp Date: Sat, 23 Nov 2019 11:56:09 +0100 Subject: [PATCH 08/39] Add InfoLabelWidget --- src/gui/InfoLabelWidget.cpp | 23 +++++++++++++++++++++++ src/gui/InfoLabelWidget.h | 31 +++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 src/gui/InfoLabelWidget.cpp create mode 100644 src/gui/InfoLabelWidget.h diff --git a/src/gui/InfoLabelWidget.cpp b/src/gui/InfoLabelWidget.cpp new file mode 100644 index 00000000..d4ac891b --- /dev/null +++ b/src/gui/InfoLabelWidget.cpp @@ -0,0 +1,23 @@ +#include "gui/InfoLabelWidget.h" + +namespace gui +{ + +InfoLabelWidget::InfoLabelWidget(ViaPoint& aViaPoint, GUIResources& aResources, QWidget* aParent) + : QLabel(aParent) + , mResources(aResources) + , mProject() + , mIsFirstTime(true) + , mSuspendCount(0) +{ + + this->setTextInteractionFlags(Qt::LinksAccessibleByMouse | Qt::TextSelectableByMouse); + this->setText(""); // TODO fill with juicy info about timeline properties +} + +void InfoLabelWidget::setProject(core::Project* aProject) +{ + mProject = aProject; +} + +} // namespace gui diff --git a/src/gui/InfoLabelWidget.h b/src/gui/InfoLabelWidget.h new file mode 100644 index 00000000..094bf6c6 --- /dev/null +++ b/src/gui/InfoLabelWidget.h @@ -0,0 +1,31 @@ +#ifndef GUI_INFOLABELWIDGET_H +#define GUI_INFOLABELWIDGET_H + +#include +#include "gui/GUIResources.h" +#include "gui/ViaPoint.h" +#include "core/Project.h" +#include "core/Animator.h" + +namespace gui +{ + +class InfoLabelWidget + : public QLabel +{ +public: + InfoLabelWidget(ViaPoint& aViaPoint, GUIResources& aResources, QWidget* aParent); + void setProject(core::Project* aProject); + +private: + GUIResources& mResources; + + core::Project* mProject; + + bool mIsFirstTime; + int mSuspendCount; +}; + +} // namespace gui + +#endif // GUI_INFOLABELWIDGET_H From 601650300dba25b30571671c7cf5138e466815f0 Mon Sep 17 00:00:00 2001 From: lmp Date: Sat, 23 Nov 2019 11:56:52 +0100 Subject: [PATCH 09/39] Add and use priliminary InfoLabelWidget --- src/gui/InfoLabelWidget.cpp | 2 +- src/gui/TargetWidget.cpp | 24 +++++++++++++++--------- src/gui/TargetWidget.h | 3 +++ src/gui/gui.pro | 2 ++ 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/gui/InfoLabelWidget.cpp b/src/gui/InfoLabelWidget.cpp index d4ac891b..0dc254d9 100644 --- a/src/gui/InfoLabelWidget.cpp +++ b/src/gui/InfoLabelWidget.cpp @@ -12,7 +12,7 @@ InfoLabelWidget::InfoLabelWidget(ViaPoint& aViaPoint, GUIResources& aResources, { this->setTextInteractionFlags(Qt::LinksAccessibleByMouse | Qt::TextSelectableByMouse); - this->setText(""); // TODO fill with juicy info about timeline properties + this->setText(" "); // TODO fill with juicy info about timeline properties } void InfoLabelWidget::setProject(core::Project* aProject) diff --git a/src/gui/TargetWidget.cpp b/src/gui/TargetWidget.cpp index cccfb372..60cd450d 100644 --- a/src/gui/TargetWidget.cpp +++ b/src/gui/TargetWidget.cpp @@ -4,23 +4,29 @@ namespace gui { TargetWidget::TargetWidget(ViaPoint& aViaPoint, GUIResources& aResources, QWidget* aParent, const QSize& aSizeHint) - : QSplitter(aParent) + : QSplitter(Qt::Vertical, aParent) , mProject() , mResources(aResources) , mSizeHint(aSizeHint) , mIsFirstTime(true) , mSuspendCount(0) { + mHorizontalSplitter = new QSplitter(this); mObjTree = new ObjectTreeWidget(aViaPoint, aResources, this); mTimeLine = new TimeLineWidget(aViaPoint, *this, this); mPlayBack = new PlayBackWidget(aResources, this); - this->addWidget(mObjTree); - this->addWidget(mTimeLine); - this->addWidget(mPlayBack); - this->setCollapsible(0, false); - this->setCollapsible(1, false); - this->setCollapsible(2, false); + mInfoLabel = new InfoLabelWidget(aViaPoint, aResources, this); + + mHorizontalSplitter->addWidget(mObjTree); + mHorizontalSplitter->addWidget(mTimeLine); + mHorizontalSplitter->addWidget(mPlayBack); + mHorizontalSplitter->setCollapsible(0, false); + mHorizontalSplitter->setCollapsible(1, false); + mHorizontalSplitter->setCollapsible(2, false); + + this->addWidget(mHorizontalSplitter); + this->addWidget(mInfoLabel); mPlayBack->setPushDelegate([=](PlayBackWidget::PushType aType) { @@ -34,9 +40,9 @@ void TargetWidget::resizeEvent(QResizeEvent* aEvent) if (mIsFirstTime) { mIsFirstTime = false; - this->moveSplitter(this->geometry().width() / 4, 1); + //mHorizontalSplitter->moveSplitter(this->geometry().width() / 4, 1); } - this->moveSplitter(this->geometry().width() - mPlayBack->constantWidth(), 2); + //mHorizontalSplitter->moveSplitter(this->geometry().width() - mPlayBack->constantWidth(), 2); } void TargetWidget::setProject(core::Project* aProject) diff --git a/src/gui/TargetWidget.h b/src/gui/TargetWidget.h index 40312b8e..be603d56 100644 --- a/src/gui/TargetWidget.h +++ b/src/gui/TargetWidget.h @@ -6,6 +6,7 @@ #include "gui/TimeLineWidget.h" #include "gui/GUIResources.h" #include "gui/PlayBackWidget.h" +#include "gui/InfoLabelWidget.h" #include "gui/ViaPoint.h" #include "core/Project.h" #include "core/Animator.h" @@ -46,9 +47,11 @@ class TargetWidget core::Project* mProject; GUIResources& mResources; const QSize mSizeHint; + QSplitter* mHorizontalSplitter; ObjectTreeWidget* mObjTree; TimeLineWidget* mTimeLine; PlayBackWidget* mPlayBack; + InfoLabelWidget* mInfoLabel; bool mIsFirstTime; int mSuspendCount; }; diff --git a/src/gui/gui.pro b/src/gui/gui.pro index 78e5e3ca..abf5a04e 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -60,6 +60,7 @@ SOURCES += \ MainWindow.cpp \ ObjectTreeWidget.cpp \ PlayBackWidget.cpp \ + InfoLabelWidget.cpp \ PropertyWidget.cpp \ TimeLineWidget.cpp \ ToolWidget.cpp \ @@ -124,6 +125,7 @@ HEADERS += \ MainWindow.h \ ObjectTreeWidget.h \ PlayBackWidget.h \ + InfoLabelWidget.h \ PropertyWidget.h \ TimeLineWidget.h \ ToolWidget.h \ From 18bf893c44e2b665a0de51d23df4236486b91a60 Mon Sep 17 00:00:00 2001 From: lmp Date: Sat, 23 Nov 2019 16:48:08 +0100 Subject: [PATCH 10/39] Add TimeFormat class --- src/core/TimeFormat.cpp | 29 +++++++++++++++++++++++++++++ src/core/TimeFormat.h | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 src/core/TimeFormat.cpp create mode 100644 src/core/TimeFormat.h diff --git a/src/core/TimeFormat.cpp b/src/core/TimeFormat.cpp new file mode 100644 index 00000000..ace49549 --- /dev/null +++ b/src/core/TimeFormat.cpp @@ -0,0 +1,29 @@ +#include "TimeFormat.h" +#include "XC.h" + +namespace core +{ + +TimeFormat::TimeFormat(util::Range aRange, int aFps) +{ + mRange = aRange; + mFps = aFps; +} + +const QString TimeFormat::frameToString(const int aFrame, const TimeFormatType aTimeFormatType) const +{ + switch (aTimeFormatType) + { + case TimeFormatType_Frames_From1: return QString::number(aFrame+1); + case TimeFormatType_Relative_FPS: { + QString number; + return number.sprintf("%.1f", static_cast(aFrame) / mFps); + } + case TimeFormatType_Seconds_Frames: return ""; + case TimeFormatType_Timecode_SMPTE: return ""; + default: return QString::number(aFrame); + } +} + +} // namespace core + diff --git a/src/core/TimeFormat.h b/src/core/TimeFormat.h new file mode 100644 index 00000000..6a65834a --- /dev/null +++ b/src/core/TimeFormat.h @@ -0,0 +1,33 @@ +#ifndef CORE_TIMEFORMAT_H +#define CORE_TIMEFORMAT_H + +#include +#include "util/Range.h" + +namespace core +{ + +enum TimeFormatType +{ + TimeFormatType_Frames_From0, + TimeFormatType_Frames_From1, + TimeFormatType_Relative_FPS, + TimeFormatType_Seconds_Frames, + TimeFormatType_Timecode_SMPTE +}; + +class TimeFormat +{ +public: + TimeFormat(util::Range aRange, int aFps); + + const QString frameToString(const int aFrame, const TimeFormatType aTimeFormatType) const; + +private: + util::Range mRange; + int mFps; +}; + +} // namespace core + +#endif // CORE_TIMEFORMAT_H From 8722730962dfef4d40f4d7da7b02eb5068920f02 Mon Sep 17 00:00:00 2001 From: lmp Date: Sat, 23 Nov 2019 16:49:24 +0100 Subject: [PATCH 11/39] Add General Setting for Time format display type. Use TimeFormat on Timeline header and In InfoLabelWidget --- src/core/core.pro | 6 +++-- src/ctrl/time/time_Renderer.cpp | 7 ++++-- src/ctrl/time/time_Renderer.h | 2 ++ src/gui/GeneralSettingDialog.cpp | 39 +++++++++++++++++++++++++++-- src/gui/GeneralSettingDialog.h | 4 +++ src/gui/InfoLabelWidget.cpp | 43 +++++++++++++++++++++++++++++--- src/gui/InfoLabelWidget.h | 9 ++++++- src/gui/TargetWidget.cpp | 6 ++++- src/gui/TargetWidget.h | 3 +++ src/gui/TimeLineWidget.cpp | 1 + src/gui/TimeLineWidget.h | 1 + 11 files changed, 110 insertions(+), 11 deletions(-) diff --git a/src/core/core.pro b/src/core/core.pro index 5309a855..aed44191 100644 --- a/src/core/core.pro +++ b/src/core/core.pro @@ -94,7 +94,8 @@ SOURCES += \ RotateKey.cpp \ ScaleKey.cpp \ SRTExpans.cpp \ - DepthKey.cpp + DepthKey.cpp \ + TimeFormat.cpp HEADERS += \ AbstractCursor.h \ @@ -157,4 +158,5 @@ HEADERS += \ MoveKey.h \ RotateKey.h \ ScaleKey.h \ - DepthKey.h + DepthKey.h\ + TimeFormat.h diff --git a/src/ctrl/time/time_Renderer.cpp b/src/ctrl/time/time_Renderer.cpp index 6a96824d..49c9c2f3 100644 --- a/src/ctrl/time/time_Renderer.cpp +++ b/src/ctrl/time/time_Renderer.cpp @@ -89,6 +89,7 @@ void Renderer::renderLines(const QVector& aRows, const QRect& aCame void Renderer::renderHeader(int aHeight, int aFps) { const QRect cameraRect(-mCamera.leftTopPos().toPoint(), mCamera.screenSize()); + const QSettings settings; mPainter.setRenderHint(QPainter::Antialiasing, false); @@ -110,6 +111,9 @@ void Renderer::renderHeader(int aHeight, int aFps) const QPoint lt(mMargin, cameraRect.top()); const QPoint rb = lt + QPoint(mScale->maxPixelWidth(), aHeight); + const TimeFormat timeFormat(mRange,aFps); + const TimeFormatType timeScaleFormatVar = static_cast(settings.value("generalsettings/ui/timescaleformat").toInt()); + mPainter.setPen(QPen(kBrush, 1)); for (int i = mRange.min(); i <= mRange.max(); ++i) @@ -121,8 +125,7 @@ void Renderer::renderHeader(int aHeight, int aFps) if (attr.showNumber) { - QString number; - number.sprintf("%.1f", (float)i / aFps); + QString number = timeFormat.frameToString(i, timeScaleFormatVar); const int width = numberWidth * number.size(); const int left = pos.x() - (width >> 1); const int top = lt.y() - 1; diff --git a/src/ctrl/time/time_Renderer.h b/src/ctrl/time/time_Renderer.h index 266372ea..6a7d46df 100644 --- a/src/ctrl/time/time_Renderer.h +++ b/src/ctrl/time/time_Renderer.h @@ -3,9 +3,11 @@ #include #include +#include #include "util/Range.h" #include "core/CameraInfo.h" #include "core/ObjectNode.h" +#include "core/TimeFormat.h" #include "ctrl/TimeLineRow.h" #include "ctrl/time/time_Scaler.h" diff --git a/src/gui/GeneralSettingDialog.cpp b/src/gui/GeneralSettingDialog.cpp index 9ecdb936..58b48b38 100644 --- a/src/gui/GeneralSettingDialog.cpp +++ b/src/gui/GeneralSettingDialog.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -9,6 +10,7 @@ namespace { static const int kLanguageTypeCount = 3; +static const int kTimeScaleFormatTypeCount = 5; int languageToIndex(const QString& aLanguage) { @@ -29,6 +31,19 @@ QString indexToLanguage(int aIndex) } } +QString indexToTimeScaleFormat(int aIndex) +{ + switch (aIndex) + { + case core::TimeFormatType::TimeFormatType_Frames_From0: return QCoreApplication::translate("GeneralSettingsDialog", "Frame number (from 0)"); + case core::TimeFormatType::TimeFormatType_Frames_From1: return QCoreApplication::translate("GeneralSettingsDialog", "Frame number (from 1)"); + case core::TimeFormatType::TimeFormatType_Relative_FPS: return QCoreApplication::translate("GeneralSettingsDialog", "Relative to FPS (1.0 = 60.0)"); + case core::TimeFormatType::TimeFormatType_Seconds_Frames: return QCoreApplication::translate("GeneralSettingsDialog", "Seconds + Frame"); + case core::TimeFormatType::TimeFormatType_Timecode_SMPTE: return QCoreApplication::translate("GeneralSettingsDialog", "Timecode (SMPTE) (HH:MM:SS:FF)"); + default: return ""; + } +} + } namespace gui @@ -38,6 +53,8 @@ GeneralSettingDialog::GeneralSettingDialog(QWidget* aParent) : EasyDialog(tr("General Settings"), aParent) , mInitialLanguageIndex() , mLanguageBox() + , mInitialTimeScaleFormatIndex() + , mTimeScaleFormatBox() { // read current settings { @@ -48,6 +65,12 @@ GeneralSettingDialog::GeneralSettingDialog(QWidget* aParent) { mInitialLanguageIndex = languageToIndex(language.toString()); } + + auto timeScale = settings.value("generalsettings/ui/timescaleformat"); + if (timeScale.isValid()) + { + mInitialTimeScaleFormatIndex = timeScale.toInt(); + } } auto form = new QFormLayout(); @@ -62,7 +85,15 @@ GeneralSettingDialog::GeneralSettingDialog(QWidget* aParent) mLanguageBox->addItem(indexToLanguage(i)); } mLanguageBox->setCurrentIndex(mInitialLanguageIndex); - form->addRow(tr("language (needs restarting) :"), mLanguageBox); + form->addRow(tr("Language (needs restarting) :"), mLanguageBox); + + mTimeScaleFormatBox = new QComboBox(); + for (int i = 0; i < kTimeScaleFormatTypeCount; ++i) + { + mTimeScaleFormatBox->addItem(indexToTimeScaleFormat(i)); + } + mTimeScaleFormatBox->setCurrentIndex(mInitialTimeScaleFormatIndex); + form->addRow(tr("Time scale format :"), mTimeScaleFormatBox); } auto group = new QGroupBox(tr("Parameters")); @@ -81,12 +112,16 @@ GeneralSettingDialog::GeneralSettingDialog(QWidget* aParent) void GeneralSettingDialog::saveSettings() { + QSettings settings; auto newLangIndex = mLanguageBox->currentIndex(); if (mInitialLanguageIndex != newLangIndex) { - QSettings settings; settings.setValue("generalsettings/language", indexToLanguage(newLangIndex)); } + + auto newTimeScaleFormatIndex = mTimeScaleFormatBox->currentIndex(); + settings.setValue("generalsettings/ui/timescaleformat", newTimeScaleFormatIndex); + } } // namespace gui diff --git a/src/gui/GeneralSettingDialog.h b/src/gui/GeneralSettingDialog.h index 18fb65be..536aaf8f 100644 --- a/src/gui/GeneralSettingDialog.h +++ b/src/gui/GeneralSettingDialog.h @@ -3,6 +3,7 @@ #include #include "gui/EasyDialog.h" +#include "core/TimeFormat.h" namespace gui { @@ -18,6 +19,9 @@ class GeneralSettingDialog : public EasyDialog int mInitialLanguageIndex; QComboBox* mLanguageBox; + + int mInitialTimeScaleFormatIndex; + QComboBox* mTimeScaleFormatBox; }; } // namespace gui diff --git a/src/gui/InfoLabelWidget.cpp b/src/gui/InfoLabelWidget.cpp index 0dc254d9..5f187fc9 100644 --- a/src/gui/InfoLabelWidget.cpp +++ b/src/gui/InfoLabelWidget.cpp @@ -3,21 +3,58 @@ namespace gui { -InfoLabelWidget::InfoLabelWidget(ViaPoint& aViaPoint, GUIResources& aResources, QWidget* aParent) +InfoLabelWidget::InfoLabelWidget(GUIResources& aResources, QWidget* aParent) : QLabel(aParent) , mResources(aResources) , mProject() , mIsFirstTime(true) , mSuspendCount(0) { - this->setTextInteractionFlags(Qt::LinksAccessibleByMouse | Qt::TextSelectableByMouse); - this->setText(" "); // TODO fill with juicy info about timeline properties + this->setContentsMargins(2,0,2,2); } void InfoLabelWidget::setProject(core::Project* aProject) { mProject = aProject; + onUpdate(); +} + +void InfoLabelWidget::onUpdate() +{ + if(mProject != nullptr) { + core::TimeInfo timeInfo = mProject->currentTimeInfo(); + + const int frameMax = timeInfo.frameMax; + const int fps = timeInfo.fps; + const int currentFrame = timeInfo.frame.get(); + + const core::TimeFormat timeFormat(util::Range(0,frameMax),fps); + auto timeScaleFormatVar = mSettings.value("generalsettings/ui/timescaleformat"); + core::TimeFormatType timeScaleFormat = timeScaleFormatVar.isValid() ? static_cast(timeScaleFormatVar.toInt()) : core::TimeFormatType::TimeFormatType_Frames_From0; + + QString frameNumber = timeFormat.frameToString(currentFrame, timeScaleFormat); + QString frameMaxNumber = timeFormat.frameToString(frameMax, timeScaleFormat); + + /* + if(timeScaleFormat == core::TimeFormatType_Relative_FPS) { + QString number; + frameNumber = number.sprintf("%.1f", static_cast(currentFrame) / fps); + } + */ + + /* + QSettings settings; + auto timeScaleFormatVar = settings.value("generalsettings/ui/timescaleformat"); + auto timeScaleFormat = timeScaleFormatVar.isValid() ? timeScaleFormatVar.toString() : QString(); + */ + + //QString number; + //number.sprintf("%.2f", static_cast( timeInfo.frame.getDecimal() / timeInfo.fps )); + //qDebug() << number; + + this->setText(frameNumber.rightJustified(frameMaxNumber.length()+1, ' ')+" / "+frameMaxNumber+" @"+QString::number(fps)+" "+tr("fps")); + } } } // namespace gui diff --git a/src/gui/InfoLabelWidget.h b/src/gui/InfoLabelWidget.h index 094bf6c6..864d4470 100644 --- a/src/gui/InfoLabelWidget.h +++ b/src/gui/InfoLabelWidget.h @@ -2,10 +2,14 @@ #define GUI_INFOLABELWIDGET_H #include +#include #include "gui/GUIResources.h" #include "gui/ViaPoint.h" #include "core/Project.h" +#include "core/TimeInfo.h" +#include "core/TimeFormat.h" #include "core/Animator.h" +#include "util/Range.h" namespace gui { @@ -14,14 +18,17 @@ class InfoLabelWidget : public QLabel { public: - InfoLabelWidget(ViaPoint& aViaPoint, GUIResources& aResources, QWidget* aParent); + InfoLabelWidget(GUIResources& aResources, QWidget* aParent); void setProject(core::Project* aProject); + void onUpdate(); + private: GUIResources& mResources; core::Project* mProject; + QSettings mSettings; bool mIsFirstTime; int mSuspendCount; }; diff --git a/src/gui/TargetWidget.cpp b/src/gui/TargetWidget.cpp index 60cd450d..0aa576bd 100644 --- a/src/gui/TargetWidget.cpp +++ b/src/gui/TargetWidget.cpp @@ -16,7 +16,10 @@ TargetWidget::TargetWidget(ViaPoint& aViaPoint, GUIResources& aResources, QWidge mTimeLine = new TimeLineWidget(aViaPoint, *this, this); mPlayBack = new PlayBackWidget(aResources, this); - mInfoLabel = new InfoLabelWidget(aViaPoint, aResources, this); + mInfoLabel = new InfoLabelWidget(aResources, this); + + mTimeLine->onFrameUpdated.connect(mInfoLabel, &InfoLabelWidget::onUpdate); + //mTimeLine->onProjectAttributeUpdated.connect(mInfoLabel, &InfoLabelWidget::onUpdate); mHorizontalSplitter->addWidget(mObjTree); mHorizontalSplitter->addWidget(mTimeLine); @@ -51,6 +54,7 @@ void TargetWidget::setProject(core::Project* aProject) mProject = aProject; mObjTree->setProject(aProject); mTimeLine->setProject(aProject); + mInfoLabel->setProject(aProject); } core::Frame TargetWidget::currentFrame() const diff --git a/src/gui/TargetWidget.h b/src/gui/TargetWidget.h index be603d56..fbba1952 100644 --- a/src/gui/TargetWidget.h +++ b/src/gui/TargetWidget.h @@ -31,6 +31,9 @@ class TargetWidget PlayBackWidget& playBackWidget() { return *mPlayBack; } const PlayBackWidget& playBackWidget() const { return *mPlayBack; } + //InfoLabelWidget& infoLabelWidget() { return *mInfoLabel; } + //const InfoLabelWidget& infoLabelWidget() const { return *mInfoLabel; } + // from Animator virtual core::Frame currentFrame() const; virtual void stop(); diff --git a/src/gui/TimeLineWidget.cpp b/src/gui/TimeLineWidget.cpp index 9e221c12..465b52da 100644 --- a/src/gui/TimeLineWidget.cpp +++ b/src/gui/TimeLineWidget.cpp @@ -110,6 +110,7 @@ void TimeLineWidget::updateCamera() void TimeLineWidget::updateCursor(const core::AbstractCursor& aCursor) { + onCursorUpdated(); if (mInner->updateCursor(aCursor)) { onFrameUpdated(); diff --git a/src/gui/TimeLineWidget.h b/src/gui/TimeLineWidget.h index 55fe1d86..fd2ae598 100644 --- a/src/gui/TimeLineWidget.h +++ b/src/gui/TimeLineWidget.h @@ -34,6 +34,7 @@ class TimeLineWidget : public QScrollArea void setFrame(core::Frame aFrame); core::Frame currentFrame() const; + util::Signaler onCursorUpdated; util::Signaler onFrameUpdated; util::Signaler onPlayBackStateChanged; From ed146ca3bc06c3c83aa66983b76bc7292e7e9995 Mon Sep 17 00:00:00 2001 From: lmp Date: Sat, 23 Nov 2019 17:30:38 +0100 Subject: [PATCH 12/39] Add conversion pseudo code --- src/core/TimeFormat.cpp | 64 +++++++++++++++++++++++++++++++++++++++-- src/core/TimeFormat.h | 14 +++++---- 2 files changed, 71 insertions(+), 7 deletions(-) diff --git a/src/core/TimeFormat.cpp b/src/core/TimeFormat.cpp index ace49549..50de7ba0 100644 --- a/src/core/TimeFormat.cpp +++ b/src/core/TimeFormat.cpp @@ -1,5 +1,4 @@ #include "TimeFormat.h" -#include "XC.h" namespace core { @@ -20,7 +19,68 @@ const QString TimeFormat::frameToString(const int aFrame, const TimeFormatType a return number.sprintf("%.1f", static_cast(aFrame) / mFps); } case TimeFormatType_Seconds_Frames: return ""; - case TimeFormatType_Timecode_SMPTE: return ""; + + case TimeFormatType_Timecode_SMPTE: { // (HH:MM:SS:FF) + double min = 0.0; //static_cast(mRange.min()) / mFps; + double max = 60.0; //static_cast(mRange.max()) / mFps; + double v = static_cast(aFrame); //static_cast(aFrame) / mFps; + + double nMin = 0; + double nMax = 1000.0; + + double ms = ((((v - min) * (nMax - nMin)) / (max - min)) + nMin); + + QString n; + n.sprintf("%.3f", v); + qDebug() << n; + + /* + function remap(oldValue,oldMin,oldMax,newMin,newMax) { + if(oldMin === newMin && oldMax === newMax) + return oldValue + // Linear conversion formular + // NewValue = (((OldValue - OldMin) * (NewMax - NewMin)) / (OldMax - OldMin)) + NewMin + return (((oldValue - oldMin) * (newMax - newMin)) / (oldMax - oldMin)) + newMin; + } + */ + + /* + function to24HClockObject(ms) { + + var d = 0 + var h = 0 + var mi = 0 + var s = 0 + + if(ms >= (86400*1000)) { + d = Math.floor((((ms/1000)/60)/60)/24) + ms = (ms-(d*(86400*1000))) + } + if(ms >= (3600*1000)) { + h = Math.floor(((ms/1000)/60)/60) + ms = (ms-(h*(3600*1000))) + } + if(ms >= (60*1000)) { + mi = Math.floor((ms/1000)/60) + ms = (ms-(mi*(60*1000))) + } + if(ms >= 1000) { + s = Math.floor(ms/1000) + ms = (ms-(s*1000)) + } + + var arr = {} + arr.days = pad(d,2) + arr.hours = pad(h,2) + arr.minutes = pad(mi,2) + arr.seconds = pad(s,2) + arr.milliseconds = pad(ms,3,0) + return arr + } + */ + + return n; + } default: return QString::number(aFrame); } } diff --git a/src/core/TimeFormat.h b/src/core/TimeFormat.h index 6a65834a..23a3b5b7 100644 --- a/src/core/TimeFormat.h +++ b/src/core/TimeFormat.h @@ -1,6 +1,8 @@ #ifndef CORE_TIMEFORMAT_H #define CORE_TIMEFORMAT_H +#include + #include #include "util/Range.h" @@ -9,11 +11,11 @@ namespace core enum TimeFormatType { - TimeFormatType_Frames_From0, - TimeFormatType_Frames_From1, - TimeFormatType_Relative_FPS, - TimeFormatType_Seconds_Frames, - TimeFormatType_Timecode_SMPTE + TimeFormatType_Frames_From0, // (FF) + TimeFormatType_Frames_From1, // (FF+1) + TimeFormatType_Relative_FPS, // (FF / FPS) + TimeFormatType_Seconds_Frames, // (SS:FF) + TimeFormatType_Timecode_SMPTE // (HH:MM:SS:FF) }; class TimeFormat @@ -24,6 +26,8 @@ class TimeFormat const QString frameToString(const int aFrame, const TimeFormatType aTimeFormatType) const; private: + + util::Range mRange; int mFps; }; From ad9f13c1b4e7ee2d27be398298cfa587a4b8afbb Mon Sep 17 00:00:00 2001 From: lmp Date: Sun, 24 Nov 2019 12:27:34 +0100 Subject: [PATCH 13/39] Add HH:MM:SS:mmm time format option --- src/core/TimeFormat.cpp | 137 +++++++++++++++++++------------ src/core/TimeFormat.h | 24 ++++-- src/gui/GeneralSettingDialog.cpp | 5 +- src/gui/InfoLabelWidget.cpp | 17 ---- 4 files changed, 104 insertions(+), 79 deletions(-) diff --git a/src/core/TimeFormat.cpp b/src/core/TimeFormat.cpp index 50de7ba0..b1206ab0 100644 --- a/src/core/TimeFormat.cpp +++ b/src/core/TimeFormat.cpp @@ -13,77 +13,106 @@ const QString TimeFormat::frameToString(const int aFrame, const TimeFormatType a { switch (aTimeFormatType) { - case TimeFormatType_Frames_From1: return QString::number(aFrame+1); + case TimeFormatType_Frames_From1: + return QString::number(aFrame+1); + case TimeFormatType_Relative_FPS: { QString number; return number.sprintf("%.1f", static_cast(aFrame) / mFps); } - case TimeFormatType_Seconds_Frames: return ""; + + case TimeFormatType_Seconds_Frames: { // (SS:FF) + double min = 0.0; + double max = 60.0; + double v = static_cast(aFrame); + + double nMin = 0; + double nMax = 1; + + double rangeMaxSeconds = remap(static_cast(mRange.max()),min,max,nMin,nMax); + double s = remap(v,min,max,nMin,nMax); + + QString n; + n.sprintf("%0*d:%0*d", QString::number(rangeMaxSeconds).length(),static_cast(s) ,QString::number(mRange.max()).length(),aFrame); + + return n; + } case TimeFormatType_Timecode_SMPTE: { // (HH:MM:SS:FF) - double min = 0.0; //static_cast(mRange.min()) / mFps; - double max = 60.0; //static_cast(mRange.max()) / mFps; - double v = static_cast(aFrame); //static_cast(aFrame) / mFps; + double min = 0.0; + double max = 60.0; + double v = static_cast(aFrame); + + double nMin = 0; + double nMax = 1000.0; + + double ms = remap(v,min,max,nMin,nMax); + + DDHHMMSSmmm timeStruct = msToDDHHMMSSmmm(ms); + + QString n; + n.sprintf("%02d:%02d:%02d:%0*d", timeStruct.hours, timeStruct.minutes,timeStruct.seconds,QString::number(mRange.max()).length(),aFrame); + + return n; + } + + case TimeFormatType_Timecode_HHMMSSmmm: { // (HH:MM:SS:mmm) + double min = 0.0; + double max = 60.0; + double v = static_cast(aFrame); double nMin = 0; double nMax = 1000.0; - double ms = ((((v - min) * (nMax - nMin)) / (max - min)) + nMin); + double ms = remap(v,min,max,nMin,nMax); + + DDHHMMSSmmm timeStruct = msToDDHHMMSSmmm(ms); QString n; - n.sprintf("%.3f", v); - qDebug() << n; - - /* - function remap(oldValue,oldMin,oldMax,newMin,newMax) { - if(oldMin === newMin && oldMax === newMax) - return oldValue - // Linear conversion formular - // NewValue = (((OldValue - OldMin) * (NewMax - NewMin)) / (OldMax - OldMin)) + NewMin - return (((oldValue - oldMin) * (newMax - newMin)) / (oldMax - oldMin)) + newMin; - } - */ - - /* - function to24HClockObject(ms) { - - var d = 0 - var h = 0 - var mi = 0 - var s = 0 - - if(ms >= (86400*1000)) { - d = Math.floor((((ms/1000)/60)/60)/24) - ms = (ms-(d*(86400*1000))) - } - if(ms >= (3600*1000)) { - h = Math.floor(((ms/1000)/60)/60) - ms = (ms-(h*(3600*1000))) - } - if(ms >= (60*1000)) { - mi = Math.floor((ms/1000)/60) - ms = (ms-(mi*(60*1000))) - } - if(ms >= 1000) { - s = Math.floor(ms/1000) - ms = (ms-(s*1000)) - } - - var arr = {} - arr.days = pad(d,2) - arr.hours = pad(h,2) - arr.minutes = pad(mi,2) - arr.seconds = pad(s,2) - arr.milliseconds = pad(ms,3,0) - return arr - } - */ + n.sprintf("%02d:%02d:%02d:%03d", timeStruct.hours, timeStruct.minutes,timeStruct.seconds,timeStruct.milliseconds); return n; } - default: return QString::number(aFrame); + + default: + return QString::number(aFrame); } } +double TimeFormat::remap(double value, double min, double max, double nMin, double nMax) +{ + // Linear range conversion + return (((value - min) * (nMax - nMin)) / (max - min)) + nMin; +} + +DDHHMMSSmmm TimeFormat::msToDDHHMMSSmmm(double ms) +{ + int d = 0, h = 0, m = 0, s = 0, mi = 0; + if(ms >= (86400*1000)) { + d = qFloor( ((((ms/1000)/60)/60)/24) ); + ms = ( ms-(d*(86400*1000)) ); + } + if(ms >= (3600*1000)) { + h = qFloor( ((ms/1000)/60)/60 ); + ms = ( ms-(h*(3600*1000)) ); + } + if(ms >= (60*1000)) { + mi = qFloor( (ms/1000)/60 ); + ms = ( ms-(mi*(60*1000)) ); + } + if(ms >= 1000) { + s = qFloor(ms/1000); + ms = ( ms-(s*1000) ); + } + DDHHMMSSmmm timeStruct; + timeStruct.days = d; + timeStruct.hours = h; + timeStruct.minutes = m; + timeStruct.seconds = s; + timeStruct.milliseconds = static_cast(ms); + + return timeStruct; +} + } // namespace core diff --git a/src/core/TimeFormat.h b/src/core/TimeFormat.h index 23a3b5b7..052e9271 100644 --- a/src/core/TimeFormat.h +++ b/src/core/TimeFormat.h @@ -2,6 +2,7 @@ #define CORE_TIMEFORMAT_H #include +#include #include #include "util/Range.h" @@ -11,11 +12,20 @@ namespace core enum TimeFormatType { - TimeFormatType_Frames_From0, // (FF) - TimeFormatType_Frames_From1, // (FF+1) - TimeFormatType_Relative_FPS, // (FF / FPS) - TimeFormatType_Seconds_Frames, // (SS:FF) - TimeFormatType_Timecode_SMPTE // (HH:MM:SS:FF) + TimeFormatType_Frames_From0, // (FF) + TimeFormatType_Frames_From1, // (FF+1) + TimeFormatType_Relative_FPS, // (FF / FPS) + TimeFormatType_Seconds_Frames, // (SS:FF) + TimeFormatType_Timecode_SMPTE, // (HH:MM:SS:FF) + TimeFormatType_Timecode_HHMMSSmmm // (HH:MM:SS:mmm) +}; + +struct DDHHMMSSmmm { + int days = 0; + int hours = 0; + int minutes = 0; + int seconds = 0; + int milliseconds = 0; }; class TimeFormat @@ -25,9 +35,11 @@ class TimeFormat const QString frameToString(const int aFrame, const TimeFormatType aTimeFormatType) const; -private: + static double remap(double value, double min, double max, double nMin, double nMax); + static DDHHMMSSmmm msToDDHHMMSSmmm(double ms); +private: util::Range mRange; int mFps; }; diff --git a/src/gui/GeneralSettingDialog.cpp b/src/gui/GeneralSettingDialog.cpp index 58b48b38..ce22a523 100644 --- a/src/gui/GeneralSettingDialog.cpp +++ b/src/gui/GeneralSettingDialog.cpp @@ -10,7 +10,7 @@ namespace { static const int kLanguageTypeCount = 3; -static const int kTimeScaleFormatTypeCount = 5; +static const int kTimeScaleFormatTypeCount = 6; int languageToIndex(const QString& aLanguage) { @@ -38,8 +38,9 @@ QString indexToTimeScaleFormat(int aIndex) case core::TimeFormatType::TimeFormatType_Frames_From0: return QCoreApplication::translate("GeneralSettingsDialog", "Frame number (from 0)"); case core::TimeFormatType::TimeFormatType_Frames_From1: return QCoreApplication::translate("GeneralSettingsDialog", "Frame number (from 1)"); case core::TimeFormatType::TimeFormatType_Relative_FPS: return QCoreApplication::translate("GeneralSettingsDialog", "Relative to FPS (1.0 = 60.0)"); - case core::TimeFormatType::TimeFormatType_Seconds_Frames: return QCoreApplication::translate("GeneralSettingsDialog", "Seconds + Frame"); + case core::TimeFormatType::TimeFormatType_Seconds_Frames: return QCoreApplication::translate("GeneralSettingsDialog", "Seconds : Frame"); case core::TimeFormatType::TimeFormatType_Timecode_SMPTE: return QCoreApplication::translate("GeneralSettingsDialog", "Timecode (SMPTE) (HH:MM:SS:FF)"); + case core::TimeFormatType::TimeFormatType_Timecode_HHMMSSmmm: return QCoreApplication::translate("GeneralSettingsDialog", "Timecode (HH:MM:SS:mmm)"); default: return ""; } } diff --git a/src/gui/InfoLabelWidget.cpp b/src/gui/InfoLabelWidget.cpp index 5f187fc9..ca718e77 100644 --- a/src/gui/InfoLabelWidget.cpp +++ b/src/gui/InfoLabelWidget.cpp @@ -36,23 +36,6 @@ void InfoLabelWidget::onUpdate() QString frameNumber = timeFormat.frameToString(currentFrame, timeScaleFormat); QString frameMaxNumber = timeFormat.frameToString(frameMax, timeScaleFormat); - /* - if(timeScaleFormat == core::TimeFormatType_Relative_FPS) { - QString number; - frameNumber = number.sprintf("%.1f", static_cast(currentFrame) / fps); - } - */ - - /* - QSettings settings; - auto timeScaleFormatVar = settings.value("generalsettings/ui/timescaleformat"); - auto timeScaleFormat = timeScaleFormatVar.isValid() ? timeScaleFormatVar.toString() : QString(); - */ - - //QString number; - //number.sprintf("%.2f", static_cast( timeInfo.frame.getDecimal() / timeInfo.fps )); - //qDebug() << number; - this->setText(frameNumber.rightJustified(frameMaxNumber.length()+1, ' ')+" / "+frameMaxNumber+" @"+QString::number(fps)+" "+tr("fps")); } } From 8275b23e9fbd3b4a014fb84efe3fe8920c2d64c0 Mon Sep 17 00:00:00 2001 From: lmp Date: Sun, 24 Nov 2019 12:58:54 +0100 Subject: [PATCH 14/39] Add onApplicationSettingUpdated signal to MainMenuBar --- src/gui/MainMenuBar.cpp | 3 ++- src/gui/MainMenuBar.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/MainMenuBar.cpp b/src/gui/MainMenuBar.cpp index 6579a7f9..a7195e8f 100644 --- a/src/gui/MainMenuBar.cpp +++ b/src/gui/MainMenuBar.cpp @@ -175,7 +175,8 @@ MainMenuBar::MainMenuBar(MainWindow& aMainWindow, ViaPoint& aViaPoint, QWidget* { QScopedPointer dialog( new GeneralSettingDialog(this)); - dialog->exec(); + if(dialog->exec() == QDialog::DialogCode::Accepted) + this->onApplicationSettingUpdated(); }); connect(mouse, &QAction::triggered, [&](bool) diff --git a/src/gui/MainMenuBar.h b/src/gui/MainMenuBar.h index 6e117525..3498ff01 100644 --- a/src/gui/MainMenuBar.h +++ b/src/gui/MainMenuBar.h @@ -26,6 +26,7 @@ class MainMenuBar : public QMenuBar // signals util::Signaler onVisualUpdated; util::Signaler onProjectAttributeUpdated; + util::Signaler onApplicationSettingUpdated; private: void loadVideoFormats(); From 4f267a982869981b098391cb6b528d45eeb505f9 Mon Sep 17 00:00:00 2001 From: lmp Date: Sun, 24 Nov 2019 13:01:21 +0100 Subject: [PATCH 15/39] Add onApplicationSettingUpdated signal and signal trigger to TimeLineWidget --- src/gui/TimeLineWidget.cpp | 6 ++++++ src/gui/TimeLineWidget.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/src/gui/TimeLineWidget.cpp b/src/gui/TimeLineWidget.cpp index 465b52da..df04910b 100644 --- a/src/gui/TimeLineWidget.cpp +++ b/src/gui/TimeLineWidget.cpp @@ -185,6 +185,12 @@ void TimeLineWidget::onProjectAttributeUpdated() mInner->updateProjectAttribute(); } +void TimeLineWidget::triggerOnApplicationSettingUpdated() +{ + onApplicationSettingUpdated(); + updateCamera(); +} + //------------------------------------------------------------------------------------------------- void TimeLineWidget::mouseMoveEvent(QMouseEvent* aEvent) { diff --git a/src/gui/TimeLineWidget.h b/src/gui/TimeLineWidget.h index fd2ae598..6408318f 100644 --- a/src/gui/TimeLineWidget.h +++ b/src/gui/TimeLineWidget.h @@ -36,13 +36,16 @@ class TimeLineWidget : public QScrollArea util::Signaler onCursorUpdated; util::Signaler onFrameUpdated; + util::Signaler onApplicationSettingUpdated; util::Signaler onPlayBackStateChanged; + public: void onTreeViewUpdated(QTreeWidgetItem* aTopNode); void onScrollUpdated(int aValue); void onSelectionChanged(core::ObjectNode* aRepresent); void onProjectAttributeUpdated(); + void triggerOnApplicationSettingUpdated(); private: virtual void mouseMoveEvent(QMouseEvent* aEvent); From b12781283f56ebddb0d49847cb3fee789c793b3a Mon Sep 17 00:00:00 2001 From: lmp Date: Sun, 24 Nov 2019 13:03:23 +0100 Subject: [PATCH 16/39] Connect onApplicationSettingUpdated to InfoLabelWidget::onUpdate to get notified when some setting is updated --- src/gui/TargetWidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/TargetWidget.cpp b/src/gui/TargetWidget.cpp index 0aa576bd..d83164da 100644 --- a/src/gui/TargetWidget.cpp +++ b/src/gui/TargetWidget.cpp @@ -19,7 +19,7 @@ TargetWidget::TargetWidget(ViaPoint& aViaPoint, GUIResources& aResources, QWidge mInfoLabel = new InfoLabelWidget(aResources, this); mTimeLine->onFrameUpdated.connect(mInfoLabel, &InfoLabelWidget::onUpdate); - //mTimeLine->onProjectAttributeUpdated.connect(mInfoLabel, &InfoLabelWidget::onUpdate); + mTimeLine->onApplicationSettingUpdated.connect(mInfoLabel, &InfoLabelWidget::onUpdate); mHorizontalSplitter->addWidget(mObjTree); mHorizontalSplitter->addWidget(mTimeLine); From 25060507e19433eb1e0b439f3e92b022813ea72f Mon Sep 17 00:00:00 2001 From: lmp Date: Sun, 24 Nov 2019 13:04:52 +0100 Subject: [PATCH 17/39] Connect TimeLineWidget::triggerOnApplicationSettingUpdated to MainWindow::onApplicationSettingUpdated to be able to propergate setting changes to child widgets --- src/gui/MainWindow.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 90ed63e3..6bdc13fc 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -264,6 +264,7 @@ MainWindow::MainWindow(ctrl::System& aSystem, GUIResources& aResources, const Lo menu.onProjectAttributeUpdated.connect(&disp, &MainDisplayWidget::onProjectAttributeUpdated); menu.onProjectAttributeUpdated.connect(&timeLine, &TimeLineWidget::onProjectAttributeUpdated); menu.onProjectAttributeUpdated.connect(&driver, &DriverHolder::onProjectAttributeUpdated); + menu.onApplicationSettingUpdated.connect(&timeLine, &TimeLineWidget::triggerOnApplicationSettingUpdated); mSystem.setAnimator(*mTarget); } From 6575efe1cce28873946af6a11bb42dd32cd65d31 Mon Sep 17 00:00:00 2001 From: lmp Date: Sun, 24 Nov 2019 15:35:41 +0100 Subject: [PATCH 18/39] Add keymapping to tooltip for reseting the canvas and be a little more explicit in the tooltip variable names --- src/gui/ToolWidget.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/gui/ToolWidget.cpp b/src/gui/ToolWidget.cpp index 6b0b2c76..211fdca5 100644 --- a/src/gui/ToolWidget.cpp +++ b/src/gui/ToolWidget.cpp @@ -110,23 +110,24 @@ void ToolWidget::createViewPanel() this->onViewSettingChanged(this->viewSetting()); }); - QString _rotateViewAntiClockwiseText = this->mKeyCommandMap.get("RotateCanvas15AntiClockwise")->binding.text(); - mViewPanel->addButton("rotateac", false, tr("Rotate the View Anticlockwise (%1").arg(_rotateViewAntiClockwiseText), [=](bool) + QString _rotateViewAntiClockwiseKeyBindingText = this->mKeyCommandMap.get("RotateCanvas15AntiClockwise")->binding.text(); + mViewPanel->addButton("rotateac", false, tr("Rotate the View Anticlockwise (%1").arg(_rotateViewAntiClockwiseKeyBindingText), [=](bool) { this->viewSetting().rotateViewACW = true; this->onViewSettingChanged(this->viewSetting()); this->viewSetting().rotateViewACW = false; }); - mViewPanel->addButton("resetrot", false, tr("Reset Rotation of the View"), [=](bool) + QString _rotateResetKeyBindingText = this->mKeyCommandMap.get("ResetCanvasAngle")->binding.text(); + mViewPanel->addButton("resetrot", false, tr("Reset Rotation of the View (%1)").arg(_rotateResetKeyBindingText), [=](bool) { this->viewSetting().resetRotateView = true; this->onViewSettingChanged(this->viewSetting()); this->viewSetting().resetRotateView = false; }); - QString _rotateViewClockwiseText = this->mKeyCommandMap.get("RotateCanvas15Clockwise")->binding.text(); - mViewPanel->addButton("rotatecw", false, tr("Rotate the View Clockwise (%1)").arg(_rotateViewClockwiseText), [=](bool) + QString _rotateViewClockwiseKeyBindingText = this->mKeyCommandMap.get("RotateCanvas15Clockwise")->binding.text(); + mViewPanel->addButton("rotatecw", false, tr("Rotate the View Clockwise (%1)").arg(_rotateViewClockwiseKeyBindingText), [=](bool) { this->viewSetting().rotateViewCW = true; this->onViewSettingChanged(this->viewSetting()); From 6cf525b797c6c5e7ef9926abf63021019f0a142c Mon Sep 17 00:00:00 2001 From: lmp Date: Sun, 24 Nov 2019 15:50:57 +0100 Subject: [PATCH 19/39] Add option to move canvas with middle-mouse button --- src/gui/CanvasMover.cpp | 6 +++--- src/gui/CanvasMover.h | 2 +- src/gui/MainDisplayWidget.cpp | 13 +++++++++++++ src/gui/MainDisplayWidget.h | 1 + src/gui/MouseSetting.cpp | 7 ++++++- src/gui/MouseSetting.h | 1 + src/gui/MouseSettingDialog.cpp | 6 ++++++ src/gui/MouseSettingDialog.h | 1 + 8 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/gui/CanvasMover.cpp b/src/gui/CanvasMover.cpp index c87f501c..269a8505 100644 --- a/src/gui/CanvasMover.cpp +++ b/src/gui/CanvasMover.cpp @@ -82,12 +82,12 @@ void CanvasMover::setDragAndRotate(bool aIsActive) } bool CanvasMover::updateByMove(const QVector2D& aCursorPos, const QVector2D& aMoved, - bool aPressedL, bool aPressedR) + bool aPressedL, bool aPressedM, bool aPressedR) { if (mCamera) { // translate canvas - if (mMoving && aPressedL) + if (mMoving && (aPressedL || aPressedM)) { mCamera->setCenter(mCamera->center() + aMoved); mResetRotationOrigin = true; @@ -96,7 +96,7 @@ bool CanvasMover::updateByMove(const QVector2D& aCursorPos, const QVector2D& aMo else if (mMoving || mRotating) { // rotate canvas - const bool isPressed = mMoving ? aPressedR : aPressedL; + const bool isPressed = mMoving ? aPressedR : (aPressedL || aPressedM); if (isPressed) { diff --git a/src/gui/CanvasMover.h b/src/gui/CanvasMover.h index 0e558b50..4db79a08 100644 --- a/src/gui/CanvasMover.h +++ b/src/gui/CanvasMover.h @@ -18,7 +18,7 @@ class CanvasMover void setDragAndRotate(bool aIsActive); bool updateByMove(const QVector2D& aCursorPos, const QVector2D& aMoved, - bool aPressedL, bool aPressedR); + bool aPressedL, bool aPressedM, bool aPressedR); bool updateByWheel(const QVector2D& aCursorPos, int aDelta, bool aInvertScaling); void rotate(float aRotateRad); diff --git a/src/gui/MainDisplayWidget.cpp b/src/gui/MainDisplayWidget.cpp index 2a72e226..bb974e4c 100644 --- a/src/gui/MainDisplayWidget.cpp +++ b/src/gui/MainDisplayWidget.cpp @@ -42,6 +42,7 @@ MainDisplayWidget::MainDisplayWidget(ViaPoint& aViaPoint, QWidget* aParent) , mCanvasMover() , mMovingCanvasByTool(false) , mMovingCanvasByKey(false) + , mMovingCanvasByMiddleMouseButton(false) , mDevicePixelRatio(1.0) { #ifdef USE_GL_CORE_PROFILE @@ -416,6 +417,7 @@ void MainDisplayWidget::mouseMoveEvent(QMouseEvent* aEvent) if (mCanvasMover.updateByMove(mAbstractCursor.screenPos(), mAbstractCursor.screenVel(), mAbstractCursor.isPressedLeft(), + mAbstractCursor.isPressedMiddle(), mAbstractCursor.isPressedRight())) { updateRender(); @@ -431,6 +433,11 @@ void MainDisplayWidget::mousePressEvent(QMouseEvent* aEvent) { updateCursor(); //if (!mUsingTablet) qDebug() << "press"; + + if(mViaPoint.mouseSetting().middleMouseMoveCanvas && aEvent->button() == Qt::MouseButton::MidButton) { + mMovingCanvasByMiddleMouseButton = true; + mCanvasMover.setDragAndMove(mMovingCanvasByKey || mMovingCanvasByTool || mMovingCanvasByMiddleMouseButton); + } } } } @@ -443,6 +450,11 @@ void MainDisplayWidget::mouseReleaseEvent(QMouseEvent* aEvent) { updateCursor(); //if (!mUsingTablet) qDebug() << "release"; + + if(aEvent->button() == Qt::MouseButton::MidButton) { + mMovingCanvasByMiddleMouseButton = false; + mCanvasMover.setDragAndMove(mMovingCanvasByKey || mMovingCanvasByTool || mMovingCanvasByMiddleMouseButton); + } } } } @@ -471,6 +483,7 @@ void MainDisplayWidget::tabletEvent(QTabletEvent* aEvent) if (mCanvasMover.updateByMove(mAbstractCursor.screenPos(), mAbstractCursor.screenVel(), mAbstractCursor.isPressedLeft(), + mAbstractCursor.isPressedMiddle(), mAbstractCursor.isPressedRight())) { updateRender(); diff --git a/src/gui/MainDisplayWidget.h b/src/gui/MainDisplayWidget.h index 8799e361..a007d606 100644 --- a/src/gui/MainDisplayWidget.h +++ b/src/gui/MainDisplayWidget.h @@ -97,6 +97,7 @@ class MainDisplayWidget : public QOpenGLWidget CanvasMover mCanvasMover; bool mMovingCanvasByTool; bool mMovingCanvasByKey; + bool mMovingCanvasByMiddleMouseButton; double mDevicePixelRatio; }; diff --git a/src/gui/MouseSetting.cpp b/src/gui/MouseSetting.cpp index 66e9806d..9ce2ea7c 100644 --- a/src/gui/MouseSetting.cpp +++ b/src/gui/MouseSetting.cpp @@ -8,13 +8,15 @@ namespace gui MouseSetting::MouseSetting() : invertMainViewScaling() , invertTimeLineScaling() + , middleMouseMoveCanvas() { } bool MouseSetting::operator==(const MouseSetting& aRhs) const { return invertMainViewScaling == aRhs.invertMainViewScaling && - invertTimeLineScaling == aRhs.invertTimeLineScaling; + invertTimeLineScaling == aRhs.invertTimeLineScaling && + middleMouseMoveCanvas == aRhs.middleMouseMoveCanvas; } void MouseSetting::load() @@ -26,9 +28,11 @@ void MouseSetting::load() auto invMVScale = settings.value("InvertMainViewScaling"); auto invTLScale = settings.value("InvertTimeLineScaling"); + auto mmMoveCanvas = settings.value("MiddleMouseMovesCanvas"); invertMainViewScaling = invMVScale.isValid() ? invMVScale.toBool() : false; invertTimeLineScaling = invTLScale.isValid() ? invTLScale.toBool() : false; + middleMouseMoveCanvas = mmMoveCanvas.isValid() ? mmMoveCanvas.toBool() : false; } void MouseSetting::save() @@ -40,6 +44,7 @@ void MouseSetting::save() settings.setValue("InvertMainViewScaling", invertMainViewScaling); settings.setValue("InvertTimeLineScaling", invertTimeLineScaling); + settings.setValue("MiddleMouseMovesCanvas", middleMouseMoveCanvas); } } // namespace gui diff --git a/src/gui/MouseSetting.h b/src/gui/MouseSetting.h index a9b14fd8..75a50fc6 100644 --- a/src/gui/MouseSetting.h +++ b/src/gui/MouseSetting.h @@ -16,6 +16,7 @@ class MouseSetting void save(); bool invertMainViewScaling; bool invertTimeLineScaling; + bool middleMouseMoveCanvas; }; } // namespace gui diff --git a/src/gui/MouseSettingDialog.cpp b/src/gui/MouseSettingDialog.cpp index 12e2ac2f..184bd685 100644 --- a/src/gui/MouseSettingDialog.cpp +++ b/src/gui/MouseSettingDialog.cpp @@ -12,6 +12,7 @@ MouseSettingDialog::MouseSettingDialog(ViaPoint& aViaPoint, QWidget* aParent) , mInitialValues() , mInvertMainViewScalingBox() , mInvertTimeLineScalingBox() + , mMiddleMouseMoveCanvas() { // read current settings mInitialValues.load(); @@ -29,6 +30,10 @@ MouseSettingDialog::MouseSettingDialog(ViaPoint& aViaPoint, QWidget* aParent) mInvertTimeLineScalingBox = new QCheckBox(); mInvertTimeLineScalingBox->setChecked(mInitialValues.invertTimeLineScaling); form->addRow(tr("invert timeline scaling :"), mInvertTimeLineScalingBox); + + mMiddleMouseMoveCanvas = new QCheckBox(); + mMiddleMouseMoveCanvas->setChecked(mInitialValues.middleMouseMoveCanvas); + form->addRow(tr("middle mouse moves canvas :"), mMiddleMouseMoveCanvas); } auto group = new QGroupBox(tr("Parameters")); @@ -50,6 +55,7 @@ void MouseSettingDialog::saveSettings() MouseSetting newValues; newValues.invertMainViewScaling = mInvertMainViewScalingBox->isChecked(); newValues.invertTimeLineScaling = mInvertTimeLineScalingBox->isChecked(); + newValues.middleMouseMoveCanvas = mMiddleMouseMoveCanvas->isChecked(); if (mInitialValues != newValues) { diff --git a/src/gui/MouseSettingDialog.h b/src/gui/MouseSettingDialog.h index d54a8384..6188a01d 100644 --- a/src/gui/MouseSettingDialog.h +++ b/src/gui/MouseSettingDialog.h @@ -22,6 +22,7 @@ class MouseSettingDialog : public EasyDialog MouseSetting mInitialValues; QCheckBox* mInvertMainViewScalingBox; QCheckBox* mInvertTimeLineScalingBox; + QCheckBox* mMiddleMouseMoveCanvas; }; } // namespace gui From 5f58843bdf820d1f346edaa9743b6f53c9e22aaf Mon Sep 17 00:00:00 2001 From: lmp Date: Sun, 24 Nov 2019 16:27:40 +0100 Subject: [PATCH 20/39] Fix a few warnings in core A to B* source files --- src/core/AbstractCursor.cpp | 12 ++++++------ src/core/Bone2.cpp | 8 ++++---- src/core/BoneInfluenceMap.cpp | 10 +++++----- src/core/BoneKey.cpp | 2 +- src/core/BoneKeyUpdater.cpp | 10 +++++----- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/core/AbstractCursor.cpp b/src/core/AbstractCursor.cpp index c131d994..ad36e22a 100644 --- a/src/core/AbstractCursor.cpp +++ b/src/core/AbstractCursor.cpp @@ -30,7 +30,7 @@ AbstractCursor::AbstractCursor() , mSuspendedCount(0) , mBlankAfterSuspending() { - for (int i = 0; i < Button_TERM; ++i) + for (unsigned int i = 0; i < Button_TERM; ++i) { mIsPressed[i] = false; mIsDouble[i] = false; @@ -197,13 +197,13 @@ void AbstractCursor::setTabletPressure(QTabletEvent* aEvent) if (type == QEvent::TabletPress) { mIsPressedTablet = true; - mPressure = pressure; + mPressure = static_cast(pressure); } else if (type == QEvent::TabletMove) { if (mIsPressedTablet) { - mPressure = 0.5f * mPressure + 0.5f * pressure; + mPressure = 0.5f * mPressure + 0.5f * static_cast(pressure); } } else if (type == QEvent::TabletRelease) @@ -220,12 +220,12 @@ void AbstractCursor::suspendEvent(const std::function& aEventReflector) ++mSuspendedCount; if (mSuspendedCount == 1) { - for (int i = 0; i < Button_TERM; ++i) + for (unsigned int i = 0; i < Button_TERM; ++i) { if (mIsPressed[i]) // invoke a release event { mEventType = Event_Release; - mEventButton = (Button)i; + mEventButton = static_cast