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,40 @@
|
||||
/*
|
||||
* TinyBlocks - tb_events.c
|
||||
* Categoria "Eventos": blocos que iniciam scripts. A execução é conduzida
|
||||
* pelo editor (run_chain); aqui só registramos os tipos e a categoria.
|
||||
*/
|
||||
#include <tinyblocks/tinyblocks.h>
|
||||
#include "tb_events.h"
|
||||
|
||||
static void eval_noop(TinyBlocks_Block* self, TinyBlocks* rt) {
|
||||
(void)rt;
|
||||
self->dirty = false;
|
||||
}
|
||||
|
||||
static bool events_init(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib) {
|
||||
static const TinyBlocks_Category cat = {
|
||||
"Eventos",
|
||||
{255/255.f, 191/255.f, 0/255.f, 1.f},
|
||||
{204/255.f, 153/255.f, 0/255.f, 1.f},
|
||||
};
|
||||
tb_library_set_category(lib, &cat);
|
||||
|
||||
TinyBlocks_TypeBlock* t = tb_type_block_create(rt, "Events.WhenRun",
|
||||
NULL, 0, NULL, 0, eval_noop);
|
||||
if (!t) return false;
|
||||
return tb_library_add(lib, &t->base);
|
||||
}
|
||||
|
||||
static void events_deinit(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib) {
|
||||
(void)rt; (void)lib;
|
||||
}
|
||||
|
||||
TINYBLOCKS_DEFINE_LIBRARY(events,
|
||||
"tinyblocks-events",
|
||||
"1.0.0",
|
||||
events_init,
|
||||
events_deinit)
|
||||
|
||||
const TinyBlocks_LibraryDescriptor* tb_events_get_library(void) {
|
||||
return &_tb_lib_desc_events;
|
||||
}
|
||||
Reference in new issue
Block a user