Skip to content

Commit 49764d8

Browse files
committed
Add bubbleLayer property to SpriteModel
1 parent 8492868 commit 49764d8

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

src/spritemodel.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,4 +261,9 @@ const QString &SpriteModel::bubbleText() const
261261
return m_bubbleText;
262262
}
263263

264+
int SpriteModel::bubbleLayer() const
265+
{
266+
return m_sprite ? m_sprite->bubble()->layerOrder() : 0;
267+
}
268+
264269
} // namespace scratchcpprender

src/spritemodel.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class SpriteModel
2828
Q_PROPERTY(IPenLayer *penLayer READ penLayer WRITE setPenLayer NOTIFY penLayerChanged)
2929
Q_PROPERTY(TextBubbleShape::Type bubbleType READ bubbleType NOTIFY bubbleTypeChanged)
3030
Q_PROPERTY(QString bubbleText READ bubbleText NOTIFY bubbleTextChanged)
31+
Q_PROPERTY(int bubbleLayer READ bubbleLayer NOTIFY bubbleLayerChanged)
3132

3233
public:
3334
SpriteModel(QObject *parent = nullptr);
@@ -82,13 +83,16 @@ class SpriteModel
8283

8384
const QString &bubbleText() const;
8485

86+
int bubbleLayer() const;
87+
8588
signals:
8689
void renderedTargetChanged();
8790
void penLayerChanged();
8891
void bubbleTypeChanged();
8992
void bubbleTextChanged();
9093
void cloned(SpriteModel *cloneModel);
9194
void cloneDeleted(SpriteModel *clone);
95+
void bubbleLayerChanged();
9296

9397
private:
9498
libscratchcpp::Sprite *m_sprite = nullptr;

test/target_models/spritemodel_test.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,3 +466,15 @@ TEST(SpriteModelTest, PenDown)
466466
ASSERT_FALSE(model.penDown());
467467
ASSERT_FALSE(model.penState().penDown);
468468
}
469+
470+
TEST(SpriteModelTest, BubbleLayer)
471+
{
472+
SpriteModel model;
473+
Sprite sprite;
474+
model.init(&sprite);
475+
QSignalSpy spy(&model, &SpriteModel::bubbleLayerChanged);
476+
477+
sprite.bubble()->setLayerOrder(5);
478+
ASSERT_EQ(model.bubbleLayer(), 5);
479+
// TODO: Use spy here
480+
}

0 commit comments

Comments
 (0)