Skip to content

Commit 119aa26

Browse files
committed
Use parent block to determine whether a block is top level
1 parent 3f29771 commit 119aa26

File tree

4 files changed

+1
-15
lines changed

4 files changed

+1
-15
lines changed

include/scratchcpp/block.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ class LIBSCRATCHCPP_EXPORT Block : public Entity
5353
void setShadow(bool newShadow);
5454

5555
bool topLevel() const;
56-
void setTopLevel(bool newTopLevel);
5756

5857
void setEngine(IEngine *newEngine);
5958

src/internal/scratch3reader.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,6 @@ bool Scratch3Reader::load()
177177
READER_STEP(step, "target -> block -> shadow");
178178
block->setShadow(blockInfo["shadow"]);
179179

180-
// topLevel
181-
READER_STEP(step, "target -> block -> topLevel");
182-
block->setTopLevel(blockInfo["topLevel"]);
183-
184180
target->addBlock(block);
185181
}
186182

src/scratch/block.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -222,15 +222,7 @@ void Block::setShadow(bool newShadow)
222222
/*! Returns true if this is a top level block. */
223223
bool Block::topLevel() const
224224
{
225-
// TODO: Return true if parentId() == ""
226-
// and remove the setter
227-
return impl->topLevel;
228-
}
229-
230-
/*! Toggles whether this block is a top level block. */
231-
void Block::setTopLevel(bool newTopLevel)
232-
{
233-
impl->topLevel = newTopLevel;
225+
return (impl->parentId == "" && !impl->parent);
234226
}
235227

236228
/*! Sets the Engine. */

src/scratch/block_p.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ struct BlockPrivate
2929
std::vector<std::shared_ptr<Field>> fields;
3030
std::unordered_map<int, Field *> fieldMap;
3131
bool shadow = false;
32-
bool topLevel = false;
3332
IEngine *engine = nullptr;
3433
Target *target = nullptr;
3534
BlockPrototype mutationPrototype;

0 commit comments

Comments
 (0)