From 2909af24083dc1f9ec619c72b97fc0e34c6aed02 Mon Sep 17 00:00:00 2001 From: Person Date: Mon, 28 Feb 2022 20:36:11 -0700 Subject: [PATCH] --Code changes -Cleanup and small bug fix for the new animation preview feature. --- Source/Ember/XmlToEmber.cpp | 8 ------- Source/Fractorium/FractoriumLibrary.cpp | 30 ++++++++++--------------- 2 files changed, 12 insertions(+), 26 deletions(-) diff --git a/Source/Ember/XmlToEmber.cpp b/Source/Ember/XmlToEmber.cpp index 1bbdb3e..f65a6bb 100644 --- a/Source/Ember/XmlToEmber.cpp +++ b/Source/Ember/XmlToEmber.cpp @@ -668,18 +668,10 @@ void XmlToEmber::ScanForEmberNodes(xmlNode* curNode, const char* parentFile, static const char* CheckNameVal(xmlNode* node, const char* name) { if (const auto att = node->properties) - { if (!Compare(att->name, "name")) - { if (const auto attStr = XC(xmlGetProp(node, att->name))) - { if (!Compare(attStr, name)) - { return CCX(attStr); - } - } - } - } return nullptr; } diff --git a/Source/Fractorium/FractoriumLibrary.cpp b/Source/Fractorium/FractoriumLibrary.cpp index af2e57f..7020aec 100644 --- a/Source/Fractorium/FractoriumLibrary.cpp +++ b/Source/Fractorium/FractoriumLibrary.cpp @@ -179,19 +179,17 @@ template void FractoriumEmberController::FillLibraryTree(int selectIndex) { StopAllPreviewRenderers(); - const uint size = PREVIEW_SIZE; vector empy_preview(size * size * 4); const auto tree = m_Fractorium->ui.LibraryTree; tree->clear(); - auto fileItem = new QTreeWidgetItem(tree); QFileInfo info(m_EmberFile.m_Filename); fileItem->setText(0, info.fileName()); fileItem->setToolTip(0, m_EmberFile.m_Filename); fileItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled); - uint i = 0; + for (auto& it : m_EmberFile.m_Embers) { auto emberItem = new EmberTreeWidgetItem(&it, fileItem); @@ -432,6 +430,7 @@ template void FractoriumEmberController::RenderPreviews(QTreeWidget* tree, TreePreviewRenderer* renderer, EmberFile& file, uint start, uint end) { renderer->Stop(); + if (start == UINT_MAX && end == UINT_MAX) { // Animated item might be at index 0, previews go in last item. @@ -482,11 +481,9 @@ void FractoriumEmberController::AddAnimationItem() fileItem->setText(0, "Rendered Animation"); fileItem->setToolTip(0, "Rendered frames can be animated here"); fileItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); - auto emberItem = new EmberTreeWidgetItemBase(fileItem); emberItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); emberItem->setToolTip(0, "Animated Frame"); - const uint size = PREVIEW_SIZE; vector empy_preview(size * size * 4); emberItem->SetImage(empy_preview, size, size); @@ -501,22 +498,19 @@ template void FractoriumEmberController::FillSequenceTree() { StopAllPreviewRenderers(); - const uint size = PREVIEW_SIZE; vector empy_preview(size * size * 4); const auto tree = m_Fractorium->ui.SequenceTree; tree->clear(); - // Add extra TreeWidget for animation at index 0 AddAnimationItem(); - auto fileItem = new QTreeWidgetItem(tree); QFileInfo info(m_SequenceFile.m_Filename); fileItem->setText(0, info.fileName()); fileItem->setToolTip(0, m_SequenceFile.m_Filename); fileItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable); - uint i = 0; + for (auto& it : m_SequenceFile.m_Embers) { auto emberItem = new EmberTreeWidgetItemBase(fileItem); @@ -535,7 +529,6 @@ void FractoriumEmberController::FillSequenceTree() tree->expandAll(); // Hide the animation item tree->collapseItem(tree->topLevelItem(0)); - RenderSequencePreviews(0, uint(m_SequenceFile.Size())); } @@ -570,11 +563,13 @@ void Fractorium::OnSequenceTreeItemChanged(QTreeWidgetItem* item, int col) /// Ignored, render all. /// Ignored, render all. template -void FractoriumEmberController::RenderSequencePreviews(uint start, uint end) { +void FractoriumEmberController::RenderSequencePreviews(uint start, uint end) +{ RenderPreviews(m_Fractorium->ui.SequenceTree, m_SequencePreviewRenderer.get(), m_SequenceFile, start, end); } -void Fractorium::OnSequenceStartPreviewsButtonClicked(bool checked) { +void Fractorium::OnSequenceStartPreviewsButtonClicked(bool checked) +{ m_Controller->RenderSequencePreviews(); } @@ -812,6 +807,7 @@ template void FractoriumEmberController::SequenceAnimateNextFrame() { const auto tree = m_Fractorium->ui.SequenceTree; + if (const auto renders = tree->topLevelItem(1)) { if (renders->childCount()) @@ -819,6 +815,7 @@ void FractoriumEmberController::SequenceAnimateNextFrame() const auto animate = dynamic_cast(tree->topLevelItem(0)->child(0)); const auto frame = m_AnimateFrame++ % renders->childCount(); const auto nth = dynamic_cast(renders->child(frame)); + if (animate && nth) { if (!nth->m_Rendered) @@ -843,7 +840,7 @@ void FractoriumEmberController::SequenceAnimateButtonClicked() { if (const auto animation = m_Fractorium->ui.SequenceTree->topLevelItem(0)) { - if (animation->isExpanded()) + if (animation->isExpanded() && m_AnimateTimer->isActive()) { animation->setExpanded(false); m_AnimateTimer->stop(); @@ -852,9 +849,7 @@ void FractoriumEmberController::SequenceAnimateButtonClicked() { animation->setExpanded(true); m_AnimateFrame = 0; - - // TODO Make this a UI Parameter - const auto fps = 30; + const auto fps = 30;//TODO Make this a UI Parameter m_AnimateTimer->start(1000 / fps); } } @@ -868,9 +863,8 @@ void Fractorium::OnSequenceAnimateButtonClicked(bool checked) { m_Controller->Se template void FractoriumEmberController::SequenceClearButtonClicked() { - const auto tree = m_Fractorium->ui.SequenceTree; m_SequencePreviewRenderer->Stop(); - tree->clear(); + m_Fractorium->ui.SequenceTree->clear(); } void Fractorium::OnSequenceClearButtonClicked(bool checked) { m_Controller->SequenceClearButtonClicked(); }