ObjectEditorCardPool.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <Editor/ObjectEditorCardPool.h>
  9. #include <Editor/ObjectEditorCard.h>
  10. #include <QLabel>
  11. #include <QFrame>
  12. #include <QVBoxLayout>
  13. namespace EMStudio
  14. {
  15. ObjectEditorCard* ObjectEditorCardPool::GetFree(AZ::SerializeContext* serializeContext, QWidget* parent)
  16. {
  17. ObjectEditorCard* rpeCard = nullptr;
  18. if (m_availableRpeCards.empty())
  19. {
  20. rpeCard = new ObjectEditorCard(serializeContext, parent);
  21. }
  22. else
  23. {
  24. rpeCard = m_availableRpeCards.top().release();
  25. m_availableRpeCards.pop();
  26. rpeCard->setParent(parent);
  27. rpeCard->show();
  28. }
  29. m_usedRpeCards.push_back(rpeCard);
  30. return rpeCard;
  31. }
  32. void ObjectEditorCardPool::ReturnAllCards()
  33. {
  34. for (ObjectEditorCard* rpeCard : m_usedRpeCards)
  35. {
  36. rpeCard->hide();
  37. rpeCard->setParent(nullptr);
  38. m_availableRpeCards.push(AZStd::unique_ptr<ObjectEditorCard>(rpeCard));
  39. }
  40. m_usedRpeCards.clear();
  41. }
  42. } // namespace EMStudio