Skip to content

Commit e601288

Browse files
committed
Add color() method to extensions
Resolves: #582
1 parent 2ed0bf3 commit e601288

34 files changed

+101
-3
lines changed

include/scratchcpp/iextension.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
#pragma once
44

5-
#include <string>
6-
7-
#include "global.h"
5+
#include "value_functions.h"
86

97
namespace libscratchcpp
108
{
@@ -27,6 +25,9 @@ class LIBSCRATCHCPP_EXPORT IExtension
2725
/*! Returns the description of the extension. */
2826
virtual std::string description() const = 0;
2927

28+
/*! Returns the block color of the extension. */
29+
virtual Rgb color() const = 0;
30+
3031
/*! Override this method to register blocks. */
3132
virtual void registerBlocks(IEngine *engine) = 0;
3233

src/blocks/controlblocks.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ std::string ControlBlocks::description() const
2626
return name() + " blocks";
2727
}
2828

29+
Rgb ControlBlocks::color() const
30+
{
31+
return rgb(255, 171, 25);
32+
}
33+
2934
void ControlBlocks::registerBlocks(IEngine *engine)
3035
{
3136
engine->addCompileFunction(this, "control_forever", &compileForever);

src/blocks/controlblocks.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class ControlBlocks : public IExtension
1212
public:
1313
std::string name() const override;
1414
std::string description() const override;
15+
Rgb color() const override;
1516

1617
void registerBlocks(IEngine *engine) override;
1718

src/blocks/customblocks.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ std::string CustomBlocks::description() const
2020
return name();
2121
}
2222

23+
Rgb CustomBlocks::color() const
24+
{
25+
return rgb(255, 102, 128);
26+
}
27+
2328
void CustomBlocks::registerBlocks(IEngine *engine)
2429
{
2530
engine->addCompileFunction(this, "procedures_definition", [](Compiler *) -> CompilerValue * { return nullptr; });

src/blocks/customblocks.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class CustomBlocks : public IExtension
1212
public:
1313
std::string name() const override;
1414
std::string description() const override;
15+
Rgb color() const override;
1516

1617
void registerBlocks(IEngine *engine) override;
1718

src/blocks/eventblocks.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ std::string libscratchcpp::EventBlocks::description() const
2424
return "Event blocks";
2525
}
2626

27+
Rgb EventBlocks::color() const
28+
{
29+
return rgb(255, 191, 0);
30+
}
31+
2732
void EventBlocks::registerBlocks(IEngine *engine)
2833
{
2934
engine->addCompileFunction(this, "event_whentouchingobject", &compileWhenTouchingObject);

src/blocks/eventblocks.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class EventBlocks : public IExtension
1212
public:
1313
std::string name() const override;
1414
std::string description() const override;
15+
Rgb color() const override;
1516

1617
void registerBlocks(IEngine *engine) override;
1718

src/blocks/listblocks.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ std::string ListBlocks::description() const
2020
return "List blocks";
2121
}
2222

23+
Rgb ListBlocks::color() const
24+
{
25+
return rgb(255, 102, 26);
26+
}
27+
2328
void ListBlocks::registerBlocks(IEngine *engine)
2429
{
2530
engine->addCompileFunction(this, "data_addtolist", &compileAddToList);

src/blocks/listblocks.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class ListBlocks : public IExtension
1414
public:
1515
std::string name() const override;
1616
std::string description() const override;
17+
Rgb color() const override;
1718

1819
void registerBlocks(IEngine *engine) override;
1920

src/blocks/looksblocks.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ std::string LooksBlocks::description() const
1414
return name() + " blocks";
1515
}
1616

17+
Rgb LooksBlocks::color() const
18+
{
19+
return rgb(153, 102, 255);
20+
}
21+
1722
void LooksBlocks::registerBlocks(IEngine *engine)
1823
{
1924
}

0 commit comments

Comments
 (0)