Skip to content

Commit

Permalink
Add component attribute: closed
Browse files Browse the repository at this point in the history
  • Loading branch information
huxingyi committed Feb 5, 2023
1 parent e6a7f31 commit cada405
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
19 changes: 19 additions & 0 deletions application/sources/document.cc
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,22 @@ void Document::setComponentExpandState(dust3d::Uuid componentId, bool expanded)
emit optionsChanged();
}

void Document::setComponentCloseState(const dust3d::Uuid& componentId, bool closed)
{
auto component = componentMap.find(componentId);
if (component == componentMap.end()) {
return;
}

if (component->second.closed == closed)
return;

component->second.dirty = true;
component->second.closed = closed;
emit componentCloseStateChanged(componentId);
emit skeletonChanged();
}

void Document::ungroupComponent(const dust3d::Uuid& componentId)
{
if (componentId.isNull())
Expand Down Expand Up @@ -1773,6 +1789,8 @@ void Document::toSnapshot(dust3d::Snapshot* snapshot, const std::set<dust3d::Uui
component["colorImageId"] = componentIt.second.colorImageId.toString();
if (componentIt.second.hasColor)
component["color"] = componentIt.second.color.name(QColor::HexArgb).toUtf8().constData();
if (componentIt.second.closed)
component["closed"] = componentIt.second.closed;
component["__dirty"] = componentIt.second.dirty ? "true" : "false";
std::vector<std::string> childIdList;
for (const auto& childId : componentIt.second.childrenIds) {
Expand Down Expand Up @@ -2038,6 +2056,7 @@ void Document::addFromSnapshot(const dust3d::Snapshot& snapshot, enum SnapshotSo
component.name = dust3d::String::valueOrEmpty(componentKv.second, "name").c_str();
component.expanded = dust3d::String::isTrue(dust3d::String::valueOrEmpty(componentKv.second, "expanded"));
component.combineMode = dust3d::CombineModeFromString(dust3d::String::valueOrEmpty(componentKv.second, "combineMode").c_str());
component.closed = dust3d::String::isTrue(dust3d::String::valueOrEmpty(componentKv.second, "closed"));
const auto& colorImageIt = componentKv.second.find("colorImageId");
if (colorImageIt != componentKv.second.end()) {
component.colorImageId = dust3d::Uuid(colorImageIt->second);
Expand Down
3 changes: 3 additions & 0 deletions application/sources/document.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ class Document : public QObject {
dust3d::Uuid colorImageId;
bool expanded = true;
dust3d::CombineMode combineMode = dust3d::CombineMode::Normal;
bool closed = false;
bool dirty = true;
std::vector<dust3d::Uuid> childrenIds;
bool isPreviewMeshObsolete = false;
Expand Down Expand Up @@ -272,6 +273,7 @@ class Document : public QObject {
void componentExpandStateChanged(dust3d::Uuid componentId);
void componentPreviewMeshChanged(const dust3d::Uuid& componentId);
void componentPreviewPixmapChanged(const dust3d::Uuid& componentId);
void componentCloseStateChanged(const dust3d::Uuid& componentId);
void nodeRemoved(dust3d::Uuid nodeId);
void edgeRemoved(dust3d::Uuid edgeId);
void nodeRadiusChanged(dust3d::Uuid nodeId);
Expand Down Expand Up @@ -499,6 +501,7 @@ public slots:
void ungroupComponent(const dust3d::Uuid& componentId);
void createNewChildComponent(dust3d::Uuid parentComponentId);
void setComponentExpandState(dust3d::Uuid componentId, bool expanded);
void setComponentCloseState(const dust3d::Uuid& componentId, bool closed);
void hideOtherComponents(dust3d::Uuid componentId);
void lockOtherComponents(dust3d::Uuid componentId);
void setComponentColorState(const dust3d::Uuid& componentId, bool hasColor, QColor color);
Expand Down

0 comments on commit cada405

Please sign in to comment.