mirror of
https://bitbucket.org/mfeemster/fractorium.git
synced 2025-01-21 21:20:07 -05:00
--Code changes
-Cleanup and small bug fix for the new animation preview feature.
This commit is contained in:
parent
4bbc8466e2
commit
2909af2408
@ -668,18 +668,10 @@ void XmlToEmber<T>::ScanForEmberNodes(xmlNode* curNode, const char* parentFile,
|
|||||||
static const char* CheckNameVal(xmlNode* node, const char* name)
|
static const char* CheckNameVal(xmlNode* node, const char* name)
|
||||||
{
|
{
|
||||||
if (const auto att = node->properties)
|
if (const auto att = node->properties)
|
||||||
{
|
|
||||||
if (!Compare(att->name, "name"))
|
if (!Compare(att->name, "name"))
|
||||||
{
|
|
||||||
if (const auto attStr = XC(xmlGetProp(node, att->name)))
|
if (const auto attStr = XC(xmlGetProp(node, att->name)))
|
||||||
{
|
|
||||||
if (!Compare(attStr, name))
|
if (!Compare(attStr, name))
|
||||||
{
|
|
||||||
return CCX(attStr);
|
return CCX(attStr);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -179,19 +179,17 @@ template <typename T>
|
|||||||
void FractoriumEmberController<T>::FillLibraryTree(int selectIndex)
|
void FractoriumEmberController<T>::FillLibraryTree(int selectIndex)
|
||||||
{
|
{
|
||||||
StopAllPreviewRenderers();
|
StopAllPreviewRenderers();
|
||||||
|
|
||||||
const uint size = PREVIEW_SIZE;
|
const uint size = PREVIEW_SIZE;
|
||||||
vector<byte> empy_preview(size * size * 4);
|
vector<byte> empy_preview(size * size * 4);
|
||||||
const auto tree = m_Fractorium->ui.LibraryTree;
|
const auto tree = m_Fractorium->ui.LibraryTree;
|
||||||
tree->clear();
|
tree->clear();
|
||||||
|
|
||||||
auto fileItem = new QTreeWidgetItem(tree);
|
auto fileItem = new QTreeWidgetItem(tree);
|
||||||
QFileInfo info(m_EmberFile.m_Filename);
|
QFileInfo info(m_EmberFile.m_Filename);
|
||||||
fileItem->setText(0, info.fileName());
|
fileItem->setText(0, info.fileName());
|
||||||
fileItem->setToolTip(0, m_EmberFile.m_Filename);
|
fileItem->setToolTip(0, m_EmberFile.m_Filename);
|
||||||
fileItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled);
|
fileItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled);
|
||||||
|
|
||||||
uint i = 0;
|
uint i = 0;
|
||||||
|
|
||||||
for (auto& it : m_EmberFile.m_Embers)
|
for (auto& it : m_EmberFile.m_Embers)
|
||||||
{
|
{
|
||||||
auto emberItem = new EmberTreeWidgetItem<T>(&it, fileItem);
|
auto emberItem = new EmberTreeWidgetItem<T>(&it, fileItem);
|
||||||
@ -432,6 +430,7 @@ template <typename T>
|
|||||||
void FractoriumEmberController<T>::RenderPreviews(QTreeWidget* tree, TreePreviewRenderer<T>* renderer, EmberFile<T>& file, uint start, uint end)
|
void FractoriumEmberController<T>::RenderPreviews(QTreeWidget* tree, TreePreviewRenderer<T>* renderer, EmberFile<T>& file, uint start, uint end)
|
||||||
{
|
{
|
||||||
renderer->Stop();
|
renderer->Stop();
|
||||||
|
|
||||||
if (start == UINT_MAX && end == UINT_MAX)
|
if (start == UINT_MAX && end == UINT_MAX)
|
||||||
{
|
{
|
||||||
// Animated item might be at index 0, previews go in last item.
|
// Animated item might be at index 0, previews go in last item.
|
||||||
@ -482,11 +481,9 @@ void FractoriumEmberController<T>::AddAnimationItem()
|
|||||||
fileItem->setText(0, "Rendered Animation");
|
fileItem->setText(0, "Rendered Animation");
|
||||||
fileItem->setToolTip(0, "Rendered frames can be animated here");
|
fileItem->setToolTip(0, "Rendered frames can be animated here");
|
||||||
fileItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
fileItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
||||||
|
|
||||||
auto emberItem = new EmberTreeWidgetItemBase(fileItem);
|
auto emberItem = new EmberTreeWidgetItemBase(fileItem);
|
||||||
emberItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
emberItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
||||||
emberItem->setToolTip(0, "Animated Frame");
|
emberItem->setToolTip(0, "Animated Frame");
|
||||||
|
|
||||||
const uint size = PREVIEW_SIZE;
|
const uint size = PREVIEW_SIZE;
|
||||||
vector<byte> empy_preview(size * size * 4);
|
vector<byte> empy_preview(size * size * 4);
|
||||||
emberItem->SetImage(empy_preview, size, size);
|
emberItem->SetImage(empy_preview, size, size);
|
||||||
@ -501,22 +498,19 @@ template <typename T>
|
|||||||
void FractoriumEmberController<T>::FillSequenceTree()
|
void FractoriumEmberController<T>::FillSequenceTree()
|
||||||
{
|
{
|
||||||
StopAllPreviewRenderers();
|
StopAllPreviewRenderers();
|
||||||
|
|
||||||
const uint size = PREVIEW_SIZE;
|
const uint size = PREVIEW_SIZE;
|
||||||
vector<byte> empy_preview(size * size * 4);
|
vector<byte> empy_preview(size * size * 4);
|
||||||
const auto tree = m_Fractorium->ui.SequenceTree;
|
const auto tree = m_Fractorium->ui.SequenceTree;
|
||||||
tree->clear();
|
tree->clear();
|
||||||
|
|
||||||
// Add extra TreeWidget for animation at index 0
|
// Add extra TreeWidget for animation at index 0
|
||||||
AddAnimationItem();
|
AddAnimationItem();
|
||||||
|
|
||||||
auto fileItem = new QTreeWidgetItem(tree);
|
auto fileItem = new QTreeWidgetItem(tree);
|
||||||
QFileInfo info(m_SequenceFile.m_Filename);
|
QFileInfo info(m_SequenceFile.m_Filename);
|
||||||
fileItem->setText(0, info.fileName());
|
fileItem->setText(0, info.fileName());
|
||||||
fileItem->setToolTip(0, m_SequenceFile.m_Filename);
|
fileItem->setToolTip(0, m_SequenceFile.m_Filename);
|
||||||
fileItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable);
|
fileItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable);
|
||||||
|
|
||||||
uint i = 0;
|
uint i = 0;
|
||||||
|
|
||||||
for (auto& it : m_SequenceFile.m_Embers)
|
for (auto& it : m_SequenceFile.m_Embers)
|
||||||
{
|
{
|
||||||
auto emberItem = new EmberTreeWidgetItemBase(fileItem);
|
auto emberItem = new EmberTreeWidgetItemBase(fileItem);
|
||||||
@ -535,7 +529,6 @@ void FractoriumEmberController<T>::FillSequenceTree()
|
|||||||
tree->expandAll();
|
tree->expandAll();
|
||||||
// Hide the animation item
|
// Hide the animation item
|
||||||
tree->collapseItem(tree->topLevelItem(0));
|
tree->collapseItem(tree->topLevelItem(0));
|
||||||
|
|
||||||
RenderSequencePreviews(0, uint(m_SequenceFile.Size()));
|
RenderSequencePreviews(0, uint(m_SequenceFile.Size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -570,11 +563,13 @@ void Fractorium::OnSequenceTreeItemChanged(QTreeWidgetItem* item, int col)
|
|||||||
/// <param name="start">Ignored, render all.</param>
|
/// <param name="start">Ignored, render all.</param>
|
||||||
/// <param name="end">Ignored, render all.</param>
|
/// <param name="end">Ignored, render all.</param>
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void FractoriumEmberController<T>::RenderSequencePreviews(uint start, uint end) {
|
void FractoriumEmberController<T>::RenderSequencePreviews(uint start, uint end)
|
||||||
|
{
|
||||||
RenderPreviews(m_Fractorium->ui.SequenceTree, m_SequencePreviewRenderer.get(), m_SequenceFile, start, 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();
|
m_Controller->RenderSequencePreviews();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -812,6 +807,7 @@ template <typename T>
|
|||||||
void FractoriumEmberController<T>::SequenceAnimateNextFrame()
|
void FractoriumEmberController<T>::SequenceAnimateNextFrame()
|
||||||
{
|
{
|
||||||
const auto tree = m_Fractorium->ui.SequenceTree;
|
const auto tree = m_Fractorium->ui.SequenceTree;
|
||||||
|
|
||||||
if (const auto renders = tree->topLevelItem(1))
|
if (const auto renders = tree->topLevelItem(1))
|
||||||
{
|
{
|
||||||
if (renders->childCount())
|
if (renders->childCount())
|
||||||
@ -819,6 +815,7 @@ void FractoriumEmberController<T>::SequenceAnimateNextFrame()
|
|||||||
const auto animate = dynamic_cast<EmberTreeWidgetItemBase*>(tree->topLevelItem(0)->child(0));
|
const auto animate = dynamic_cast<EmberTreeWidgetItemBase*>(tree->topLevelItem(0)->child(0));
|
||||||
const auto frame = m_AnimateFrame++ % renders->childCount();
|
const auto frame = m_AnimateFrame++ % renders->childCount();
|
||||||
const auto nth = dynamic_cast<EmberTreeWidgetItemBase*>(renders->child(frame));
|
const auto nth = dynamic_cast<EmberTreeWidgetItemBase*>(renders->child(frame));
|
||||||
|
|
||||||
if (animate && nth)
|
if (animate && nth)
|
||||||
{
|
{
|
||||||
if (!nth->m_Rendered)
|
if (!nth->m_Rendered)
|
||||||
@ -843,7 +840,7 @@ void FractoriumEmberController<T>::SequenceAnimateButtonClicked()
|
|||||||
{
|
{
|
||||||
if (const auto animation = m_Fractorium->ui.SequenceTree->topLevelItem(0))
|
if (const auto animation = m_Fractorium->ui.SequenceTree->topLevelItem(0))
|
||||||
{
|
{
|
||||||
if (animation->isExpanded())
|
if (animation->isExpanded() && m_AnimateTimer->isActive())
|
||||||
{
|
{
|
||||||
animation->setExpanded(false);
|
animation->setExpanded(false);
|
||||||
m_AnimateTimer->stop();
|
m_AnimateTimer->stop();
|
||||||
@ -852,9 +849,7 @@ void FractoriumEmberController<T>::SequenceAnimateButtonClicked()
|
|||||||
{
|
{
|
||||||
animation->setExpanded(true);
|
animation->setExpanded(true);
|
||||||
m_AnimateFrame = 0;
|
m_AnimateFrame = 0;
|
||||||
|
const auto fps = 30;//TODO Make this a UI Parameter
|
||||||
// TODO Make this a UI Parameter
|
|
||||||
const auto fps = 30;
|
|
||||||
m_AnimateTimer->start(1000 / fps);
|
m_AnimateTimer->start(1000 / fps);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -868,9 +863,8 @@ void Fractorium::OnSequenceAnimateButtonClicked(bool checked) { m_Controller->Se
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
void FractoriumEmberController<T>::SequenceClearButtonClicked()
|
void FractoriumEmberController<T>::SequenceClearButtonClicked()
|
||||||
{
|
{
|
||||||
const auto tree = m_Fractorium->ui.SequenceTree;
|
|
||||||
m_SequencePreviewRenderer->Stop();
|
m_SequencePreviewRenderer->Stop();
|
||||||
tree->clear();
|
m_Fractorium->ui.SequenceTree->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fractorium::OnSequenceClearButtonClicked(bool checked) { m_Controller->SequenceClearButtonClicked(); }
|
void Fractorium::OnSequenceClearButtonClicked(bool checked) { m_Controller->SequenceClearButtonClicked(); }
|
||||||
|
Loading…
Reference in New Issue
Block a user