editor: bundle com libraries privadas + hot reload (tinyblocks-api) e aba de imagem estilo Krita
- tinyblocks-editor agora e um bundle: libraries privadas em
libraries/tinyblocks-editor-{widgets,image} (.a + .so), com library.toml
(bundle = tinyblocks-editor, private = true -> nao aparecem no libman).
- O editor carrega os modulos por dlopen via tinyblocks-api e chama tudo por
tabelas de ponteiros (tb_ed_w, tb_ed_img): da para recompilar so a parte que
mudou e o editor recarrega ao vivo (make ed-modules), sem reiniciar.
- tinyblocks-api ganhou modulos de codigo (tb_api_code_*) e watcher de
arquivos (inotify, com mtime como reserva).
- libman: entradas com bundle/private nao sao listadas como extensao.
- Aba de imagem: layout estilo Krita - ferramentas na esquerda, tela no meio,
roda de cores + paleta + camadas na coluna da direita; miniatura por camada
(como as fantasias do Scratch); rodape enxuto (Desfazer/Limpar/zoom).
- Ferramenta selecionar (mover/redimensionar/excluir pixels) e consertada a
geometria da folha (doc = area de desenho, zoom puro).
- Makefile: alvo ed-modules; AppImage empacota os .so do bundle.
- harness: testes de imagem atualizados + testes de cores na lateral.
This commit is contained in:
1 parent
036162280d
commit
0143d3efd5
21 files changed
+3775
-557
No files matched your search
@@ -503,6 +503,41 @@ static bool reg(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib, const char* name,
|
||||
return t && tb_library_add(lib, &t->base);
|
||||
}
|
||||
|
||||
/* Decodificador de imagem registrado no core: permite usar um .svg como
|
||||
documento ou camada no editor de imagem (rasterizado no carregamento). */
|
||||
#define SVG_FILE_MAX (4u * 1024u * 1024u)
|
||||
static TinyBlocks_Image* svg_image_load(const char* path) {
|
||||
FILE* f = fopen(path, "rb");
|
||||
if (!f) { snprintf(s_err, sizeof(s_err), "nao consegui abrir '%s'", path); return NULL; }
|
||||
if (fseek(f, 0, SEEK_END) != 0) {
|
||||
fclose(f);
|
||||
snprintf(s_err, sizeof(s_err), "arquivo invalido");
|
||||
return NULL;
|
||||
}
|
||||
long sz = ftell(f);
|
||||
if (sz <= 0 || (unsigned long)sz > SVG_FILE_MAX) {
|
||||
fclose(f);
|
||||
snprintf(s_err, sizeof(s_err), "tamanho invalido (%ld bytes)", sz);
|
||||
return NULL;
|
||||
}
|
||||
fseek(f, 0, SEEK_SET);
|
||||
char* buf = (char*)malloc((size_t)sz + 1);
|
||||
if (!buf) { fclose(f); snprintf(s_err, sizeof(s_err), "sem memoria"); return NULL; }
|
||||
size_t rd = fread(buf, 1, (size_t)sz, f);
|
||||
fclose(f);
|
||||
buf[rd] = 0;
|
||||
int W = 0, H = 0;
|
||||
tb_svg_parse(buf, &W, &H);
|
||||
if (W <= 0) W = 512;
|
||||
if (H <= 0) H = 512;
|
||||
if (W > 4096) W = 4096;
|
||||
if (H > 4096) H = 4096;
|
||||
TinyBlocks_Image* im = tb_svg_render(buf, W, H);
|
||||
free(buf);
|
||||
if (!im) snprintf(s_err, sizeof(s_err), "nao consegui rasterizar '%s'", path);
|
||||
return im;
|
||||
}
|
||||
|
||||
static bool svg_init(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib) {
|
||||
static const TinyBlocks_Category cat = {
|
||||
"SVG",
|
||||
@@ -510,6 +545,7 @@ static bool svg_init(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib) {
|
||||
{ 255/255.f, 160/255.f, 0/255.f, 1.f},
|
||||
};
|
||||
tb_library_set_category(lib, &cat);
|
||||
tb_image_register_format("svg", svg_image_load, NULL);
|
||||
|
||||
static const TinyBlocks_SlotDesc out_vec[] = {{"vetor", TB_VALUE_VECTOR}};
|
||||
static const TinyBlocks_SlotDesc out_img[] = {{"imagem", TB_VALUE_IMAGE}};
|
||||
|
||||
Reference in new issue
Block a user