Divide as seções da paleta em libraries de categoria
Cada seção (Eventos, Controle, Operadores, Variáveis, Aparência, Caneta) virou uma library própria, com seus blocos e eval. Foi adicionado um metadado opcional de categoria (TinyBlocks_Category) para a UI agrupar a paleta a partir das libraries registradas, sem hardcode no editor. - núcleo: tb_library_set_category() e campo category em LibraryBlock - editor: cats_rebuild/cat_of usam a library dona de cada TypeBlock; "Meus Blocos" (User./Port.) continua no editor - variáveis: armazenamento movido para tinyblocks-variables, com API de enumeração (tb_variables_count/name/value/reset_blocks) - palco: Editor.Stage continua no editor; a API de desenho (tb_stage_*) é usada pela library tinyblocks-pen - host/tests/Makefile: registram e linkam as novas libraries
This commit is contained in:
1 parent
278d3f4473
commit
1cc0ff9d02
20 files changed
+1063
-597
No files matched your search
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* TinyBlocks - tb_control.h
|
||||
* Library da categoria "Controle" (repita, se, se-senão, repita até que).
|
||||
*/
|
||||
#ifndef TINYBLOCKS_CONTROL_H
|
||||
#define TINYBLOCKS_CONTROL_H
|
||||
|
||||
#include <tinyblocks/tinyblocks.h>
|
||||
|
||||
TB_API const TinyBlocks_LibraryDescriptor* tb_control_get_library(void);
|
||||
|
||||
#endif /* TINYBLOCKS_CONTROL_H */
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* TinyBlocks - tb_control.c
|
||||
* Categoria "Controle": repita / repita até que / se / se-senão.
|
||||
* A semântica (bocas e sequência) é interpretada pelo editor; aqui só
|
||||
* registramos os tipos e a categoria.
|
||||
*/
|
||||
#include <tinyblocks/tinyblocks.h>
|
||||
#include "tb_control.h"
|
||||
|
||||
static void eval_noop(TinyBlocks_Block* self, TinyBlocks* rt) {
|
||||
(void)rt;
|
||||
self->dirty = false;
|
||||
}
|
||||
|
||||
static bool reg(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib, const char* name,
|
||||
const TinyBlocks_SlotDesc* in, uint32_t ni) {
|
||||
TinyBlocks_TypeBlock* t = tb_type_block_create(rt, name, in, ni, NULL, 0, eval_noop);
|
||||
return t && tb_library_add(lib, &t->base);
|
||||
}
|
||||
|
||||
static bool control_init(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib) {
|
||||
static const TinyBlocks_Category cat = {
|
||||
"Controle",
|
||||
{255/255.f, 171/255.f, 25/255.f, 1.f},
|
||||
{207/255.f, 139/255.f, 23/255.f, 1.f},
|
||||
};
|
||||
tb_library_set_category(lib, &cat);
|
||||
|
||||
static const TinyBlocks_SlotDesc times_in[] = {{"vezes", TB_VALUE_INTEGER}};
|
||||
static const TinyBlocks_SlotDesc cond_in[] = {{"condição", TB_VALUE_INTEGER}};
|
||||
return reg(rt, lib, "Control.Repeat", times_in, 1)
|
||||
&& reg(rt, lib, "Control.RepeatUntil", cond_in, 1)
|
||||
&& reg(rt, lib, "Control.If", cond_in, 1)
|
||||
&& reg(rt, lib, "Control.IfElse", cond_in, 1);
|
||||
}
|
||||
|
||||
static void control_deinit(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib) {
|
||||
(void)rt; (void)lib;
|
||||
}
|
||||
|
||||
TINYBLOCKS_DEFINE_LIBRARY(control,
|
||||
"tinyblocks-control",
|
||||
"1.0.0",
|
||||
control_init,
|
||||
control_deinit)
|
||||
|
||||
const TinyBlocks_LibraryDescriptor* tb_control_get_library(void) {
|
||||
return &_tb_lib_desc_control;
|
||||
}
|
||||
Reference in new issue
Block a user