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
@@ -57,6 +57,28 @@ TB_API bool tb_api_unload(int idx);
|
||||
TB_API bool tb_api_reload(int idx);
|
||||
TB_API bool tb_api_is_loaded(const char* name);
|
||||
|
||||
/* -- Modulos de codigo (bundle de um app, ex: libraries privadas do editor)
|
||||
* Nao registram libraries/blocos: sao so codigo (.so) carregado por dlopen.
|
||||
* Usados para HOT RELOAD: recompile a parte que mudou e o app recarrega. --- */
|
||||
#define TB_API_MAX_CODE 32
|
||||
TB_API int tb_api_code_load(const char* name, const char* path); /* idx ou -1 */
|
||||
TB_API bool tb_api_code_unload(const char* name);
|
||||
TB_API void tb_api_code_unload_all(void);
|
||||
TB_API int tb_api_code_count(void);
|
||||
TB_API const char* tb_api_code_name(int i);
|
||||
TB_API const char* tb_api_code_path(int i);
|
||||
TB_API void* tb_api_code_handle(const char* name);
|
||||
TB_API void* tb_api_code_symbol(const char* name, const char* symbol);
|
||||
/* Recarrega TODOS os modulos de codigo na ordem de carga (unload inverso,
|
||||
* load direto) - resolve dependencias entre eles. Retorna quantos voltaram. */
|
||||
TB_API int tb_api_code_reload_all(void);
|
||||
/* true se algum modulo de codigo mudou no disco (usa watcher/mtime). */
|
||||
TB_API bool tb_api_code_changed(void);
|
||||
|
||||
/* -- Watcher de arquivos (inotify quando disponivel, senao mtime) --- */
|
||||
TB_API bool tb_api_watch(const char* path);
|
||||
TB_API int tb_api_poll_watch(void); /* eventos pendentes (0 = nada) */
|
||||
|
||||
/* Hot reload: true se algum .so mudou no disco desde o ultimo load. */
|
||||
TB_API bool tb_api_any_changed(void);
|
||||
/* Recarrega os .so que mudaram; retorna quantos. */
|
||||
|
||||
@@ -7,9 +7,11 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef __linux__
|
||||
# include <dlfcn.h>
|
||||
# include <sys/inotify.h>
|
||||
#endif
|
||||
|
||||
#include <tinyblocks/tinyblocks.h>
|
||||
@@ -28,6 +30,230 @@ static time_t file_mtime(const char* p) {
|
||||
return (stat(p, &st) == 0) ? st.st_mtime : 0;
|
||||
}
|
||||
|
||||
static void set_err(const char* fmt, const char* a);
|
||||
static void path_dirname(const char* p, char* out, size_t cap);
|
||||
|
||||
static const char* path_basename(const char* p) {
|
||||
const char* s = strrchr(p, '/');
|
||||
return s ? s + 1 : p;
|
||||
}
|
||||
|
||||
/* -- Modulos de codigo (bundle) e watcher de arquivos ------------------- */
|
||||
|
||||
typedef struct {
|
||||
char name[64];
|
||||
char path[TB_API_PATH_LEN];
|
||||
void* handle;
|
||||
time_t mtime;
|
||||
bool dirty;
|
||||
} TbApiCode;
|
||||
|
||||
static TbApiCode s_code[TB_API_MAX_CODE];
|
||||
static int s_cn = 0;
|
||||
|
||||
static int code_find(const char* name) {
|
||||
if (!name) return -1;
|
||||
for (int i = 0; i < s_cn; i++) if (strcmp(s_code[i].name, name) == 0) return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
# define TB_API_WATCH_MAX 64
|
||||
typedef struct {
|
||||
int wd;
|
||||
int idx; /* indice em s_code (-1 = so diretorio) */
|
||||
char base[128]; /* nome do arquivo vigiado */
|
||||
char dir[TB_API_PATH_LEN];
|
||||
} TbWatch;
|
||||
static TbWatch s_watch[TB_API_WATCH_MAX];
|
||||
static int s_wn = 0;
|
||||
static int s_inot = -1;
|
||||
|
||||
/* Vigia o DIRETORIO do arquivo: cobre tanto escrita no lugar quanto
|
||||
"make" (escreve num temp e renomeia por cima). */
|
||||
static int watch_add(const char* path) {
|
||||
if (s_inot < 0) return -1;
|
||||
char dir[TB_API_PATH_LEN];
|
||||
path_dirname(path, dir, sizeof(dir));
|
||||
if (s_wn > 0 && strcmp(s_watch[s_wn - 1].dir, dir) == 0) {
|
||||
/* mesmo diretorio: reaproveita o wd */
|
||||
snprintf(s_watch[s_wn - 1].base, sizeof(s_watch[s_wn-1].base), "%s", path_basename(path));
|
||||
return s_watch[s_wn - 1].wd;
|
||||
}
|
||||
if (s_wn >= TB_API_WATCH_MAX) return -1;
|
||||
int wd = inotify_add_watch(s_inot, dir,
|
||||
IN_CLOSE_WRITE | IN_MOVED_TO | IN_CREATE | IN_ATTRIB);
|
||||
if (wd < 0) return -1;
|
||||
TbWatch* w = &s_watch[s_wn++];
|
||||
w->wd = wd;
|
||||
w->idx = -1;
|
||||
snprintf(w->dir, sizeof(w->dir), "%s", dir);
|
||||
snprintf(w->base, sizeof(w->base), "%s", path_basename(path));
|
||||
return wd;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool tb_api_watch(const char* path) {
|
||||
if (!path || !path[0]) return false;
|
||||
#ifdef __linux__
|
||||
if (s_inot < 0) {
|
||||
s_inot = inotify_init1(IN_NONBLOCK);
|
||||
if (s_inot < 0) return false;
|
||||
}
|
||||
return watch_add(path) >= 0;
|
||||
#else
|
||||
(void)path;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
int tb_api_poll_watch(void) {
|
||||
#ifdef __linux__
|
||||
if (s_inot < 0 || s_wn <= 0) return 0;
|
||||
char buf[4096] __attribute__((aligned(8)));
|
||||
ssize_t n;
|
||||
int changed = 0;
|
||||
while ((n = read(s_inot, buf, sizeof(buf))) > 0) {
|
||||
for (char* p = buf; p < buf + n; ) {
|
||||
struct inotify_event* ev = (struct inotify_event*)p;
|
||||
p += sizeof(*ev) + ev->len;
|
||||
if (!ev->len) continue;
|
||||
for (int i = 0; i < s_cn; i++) {
|
||||
if (strcmp(ev->name, path_basename(s_code[i].path)) != 0) continue;
|
||||
char d[TB_API_PATH_LEN];
|
||||
path_dirname(s_code[i].path, d, sizeof(d));
|
||||
for (int k = 0; k < s_wn; k++)
|
||||
if (s_watch[k].wd == ev->wd && strcmp(s_watch[k].dir, d) == 0) {
|
||||
s_code[i].dirty = true;
|
||||
changed++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void path_dirname(const char* p, char* out, size_t cap) {
|
||||
snprintf(out, cap, "%s", p);
|
||||
char* sl = strrchr(out, '/');
|
||||
if (sl) *sl = 0; else snprintf(out, cap, ".");
|
||||
}
|
||||
|
||||
static bool code_changed_mtime(void) {
|
||||
bool any = false;
|
||||
for (int i = 0; i < s_cn; i++) {
|
||||
time_t mt = file_mtime(s_code[i].path);
|
||||
if (mt && mt != s_code[i].mtime) { s_code[i].dirty = true; any = true; }
|
||||
}
|
||||
return any;
|
||||
}
|
||||
|
||||
int tb_api_code_load(const char* name, const char* path) {
|
||||
if (!name || !name[0] || !path || !path[0]) {
|
||||
set_err("%s", "tb_api: nome/caminho invalido");
|
||||
return -1;
|
||||
}
|
||||
int ex = code_find(name);
|
||||
if (ex >= 0 && s_code[ex].handle && strcmp(s_code[ex].path, path) == 0)
|
||||
return ex;
|
||||
if (ex >= 0) tb_api_code_unload(name);
|
||||
if (s_cn >= TB_API_MAX_CODE) { set_err("%s", "tb_api: limite de modulos de codigo"); return -1; }
|
||||
#ifdef __linux__
|
||||
void* dl = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
|
||||
if (!dl) { set_err("dlopen: %s", dlerror()); return -1; }
|
||||
TbApiCode* c = &s_code[s_cn];
|
||||
memset(c, 0, sizeof(*c));
|
||||
snprintf(c->name, sizeof(c->name), "%s", name);
|
||||
snprintf(c->path, sizeof(c->path), "%s", path);
|
||||
c->handle = dl;
|
||||
c->mtime = file_mtime(path);
|
||||
c->dirty = false;
|
||||
/* watcher: registro por arquivo, apontando para o modulo */
|
||||
if (tb_api_watch(path)) {
|
||||
for (int k = s_wn - 1; k >= 0; k--) {
|
||||
if (strcmp(s_watch[k].base, path_basename(path)) == 0) { s_watch[k].idx = s_cn; break; }
|
||||
}
|
||||
}
|
||||
s_err[0] = 0;
|
||||
return s_cn++;
|
||||
#else
|
||||
(void)name; (void)path;
|
||||
set_err("%s", "tb_api: dlopen nao suportado nesta plataforma");
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool tb_api_code_unload(const char* name) {
|
||||
int i = code_find(name);
|
||||
if (i < 0) return false;
|
||||
#ifdef __linux__
|
||||
if (s_code[i].handle) dlclose(s_code[i].handle);
|
||||
#endif
|
||||
for (int k = i; k < s_cn - 1; k++) s_code[k] = s_code[k + 1];
|
||||
s_cn--;
|
||||
return true;
|
||||
}
|
||||
|
||||
void tb_api_code_unload_all(void) {
|
||||
for (int i = s_cn - 1; i >= 0; i--) {
|
||||
#ifdef __linux__
|
||||
if (s_code[i].handle) dlclose(s_code[i].handle);
|
||||
#endif
|
||||
s_code[i].handle = NULL;
|
||||
}
|
||||
s_cn = 0;
|
||||
}
|
||||
|
||||
int tb_api_code_count(void) { return s_cn; }
|
||||
const char* tb_api_code_name(int i) { return (i >= 0 && i < s_cn) ? s_code[i].name : NULL; }
|
||||
const char* tb_api_code_path(int i) { return (i >= 0 && i < s_cn) ? s_code[i].path : NULL; }
|
||||
|
||||
void* tb_api_code_handle(const char* name) {
|
||||
int i = code_find(name);
|
||||
return i >= 0 ? s_code[i].handle : NULL;
|
||||
}
|
||||
|
||||
void* tb_api_code_symbol(const char* name, const char* symbol) {
|
||||
void* h = tb_api_code_handle(name);
|
||||
#ifdef __linux__
|
||||
if (!h || !symbol) return NULL;
|
||||
return dlsym(h, symbol);
|
||||
#else
|
||||
(void)h; (void)symbol;
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
int tb_api_code_reload_all(void) {
|
||||
char names[TB_API_MAX_CODE][64];
|
||||
char paths[TB_API_MAX_CODE][TB_API_PATH_LEN];
|
||||
int n = s_cn;
|
||||
for (int i = 0; i < n; i++) {
|
||||
snprintf(names[i], sizeof(names[i]), "%s", s_code[i].name);
|
||||
snprintf(paths[i], sizeof(paths[i]), "%s", s_code[i].path);
|
||||
}
|
||||
tb_api_code_unload_all(); /* ordem inversa de dependencia */
|
||||
int ok = 0;
|
||||
for (int i = 0; i < n; i++)
|
||||
if (tb_api_code_load(names[i], paths[i]) >= 0) ok++;
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool tb_api_code_changed(void) {
|
||||
bool any = false;
|
||||
#ifdef __linux__
|
||||
if (tb_api_poll_watch() > 0) any = true;
|
||||
#endif
|
||||
if (code_changed_mtime()) any = true;
|
||||
if (!any) {
|
||||
for (int i = 0; i < s_cn; i++) if (s_code[i].dirty) { any = true; break; }
|
||||
}
|
||||
return any;
|
||||
}
|
||||
|
||||
static void set_err(const char* fmt, const char* a) {
|
||||
snprintf(s_err, sizeof(s_err), fmt, a ? a : "");
|
||||
}
|
||||
@@ -53,6 +279,11 @@ bool tb_api_init(TinyBlocks* rt) {
|
||||
|
||||
void tb_api_shutdown(void) {
|
||||
/* O runtime e o dono dos blocos; aqui so esquecemos os modulos. */
|
||||
tb_api_code_unload_all();
|
||||
#ifdef __linux__
|
||||
if (s_inot >= 0) { close(s_inot); s_inot = -1; }
|
||||
s_wn = 0;
|
||||
#endif
|
||||
s_n = 0;
|
||||
s_rt = NULL;
|
||||
}
|
||||
@@ -170,6 +401,9 @@ bool tb_api_any_changed(void) {
|
||||
|
||||
int tb_api_poll_reload(void) {
|
||||
int n = 0;
|
||||
#ifdef __linux__
|
||||
tb_api_poll_watch();
|
||||
#endif
|
||||
for (int i = 0; i < s_n; i++) {
|
||||
TbApiModule* m = &s_mods[i];
|
||||
if (!m->path[0]) continue;
|
||||
|
||||
@@ -13,9 +13,17 @@ CFLAGS := -std=c11 -Wall -Wextra -pedantic -fvisibility=hidden \
|
||||
-I../tinyblocks-blueprint/include \
|
||||
-I../tinyblocks-environ/include \
|
||||
-I../tinyblocks-api/include \
|
||||
-I../tinyblocks-libman/include
|
||||
-I../tinyblocks-libman/include \
|
||||
-I../tinyblocks-syntax/include \
|
||||
-Ilibraries/tinyblocks-editor-widgets/include \
|
||||
-Ilibraries/tinyblocks-editor-image/include
|
||||
|
||||
OBJ := $(BUILD)/tb_editor.o $(BUILD)/tb_stage_widget.o
|
||||
WIDGETS_DIR := libraries/tinyblocks-editor-widgets
|
||||
WIDGETS_A := $(WIDGETS_DIR)/build/libtinyblocks-editor-widgets.a
|
||||
IMG_DIR := libraries/tinyblocks-editor-image
|
||||
IMG_A := $(IMG_DIR)/build/libtinyblocks-editor-image.a
|
||||
|
||||
OBJ := $(BUILD)/tb_editor.o $(BUILD)/tb_stage_widget.o $(BUILD)/tb_editor_modules.o
|
||||
LIB_A := $(BUILD)/libtinyblocks-editor.a
|
||||
LIB_SO := $(BUILD)/libtinyblocks-editor.so
|
||||
|
||||
@@ -24,13 +32,17 @@ all: static shared
|
||||
static: $(LIB_A)
|
||||
shared: $(LIB_SO)
|
||||
|
||||
$(BUILD)/tb_editor.o: src/tb_editor.c include/tb_editor.h src/tb_stage_widget.h \
|
||||
$(BUILD)/tb_editor.o: src/tb_editor.c include/tb_editor.h internal/tb_editor_internal.h \
|
||||
src/tb_stage_widget.h \
|
||||
$(WIDGETS_DIR)/include/tb_editor_widgets.h \
|
||||
$(IMG_DIR)/include/tb_editor_image.h \
|
||||
../tinyblocks-graphics/include/tb_graphics.h \
|
||||
../tinyblocks-variables/include/tb_variables.h \
|
||||
../tinyblocks-blueprint/include/tb_blueprint.h \
|
||||
../tinyblocks-environ/include/tb_environ.h \
|
||||
../tinyblocks-api/include/tb_api.h \
|
||||
../tinyblocks-libman/include/tb_libman.h
|
||||
../tinyblocks-libman/include/tb_libman.h \
|
||||
../tinyblocks-syntax/include/tb_syntax.h
|
||||
@mkdir -p $(BUILD)
|
||||
$(CC) $(CFLAGS) -fPIC -c $< -o $@
|
||||
|
||||
@@ -39,8 +51,23 @@ $(BUILD)/tb_stage_widget.o: src/tb_stage_widget.c src/tb_stage_widget.h \
|
||||
@mkdir -p $(BUILD)
|
||||
$(CC) $(CFLAGS) -fPIC -c $< -o $@
|
||||
|
||||
$(LIB_A): $(OBJ)
|
||||
ar rcs $@ $^
|
||||
$(BUILD)/tb_editor_modules.o: src/tb_editor_modules.c internal/tb_editor_modules.h \
|
||||
internal/tb_editor_internal.h
|
||||
@mkdir -p $(BUILD)
|
||||
$(CC) $(CFLAGS) -fPIC -c $< -o $@
|
||||
|
||||
# Sempre delega para o make das libraries privadas (elas sabem o que mudou):
|
||||
# assim o editor nunca fica com um modulo velho.
|
||||
.PHONY: FORCE
|
||||
FORCE:
|
||||
|
||||
$(WIDGETS_A): FORCE
|
||||
$(MAKE) -C $(WIDGETS_DIR)
|
||||
$(IMG_A): FORCE
|
||||
$(MAKE) -C $(IMG_DIR)
|
||||
|
||||
$(LIB_A): $(OBJ) $(WIDGETS_A) $(IMG_A)
|
||||
ar rcs $@ $(OBJ)
|
||||
|
||||
$(LIB_SO): $(OBJ)
|
||||
$(CC) -shared -o $@ $^ -ldl
|
||||
|
||||
@@ -0,0 +1,704 @@
|
||||
/*
|
||||
* TinyBlocks - tb_editor_internal.h
|
||||
* Tipos, constantes de layout, tema e prototipos compartilhados entre o
|
||||
* editor (tb_editor.c) e as libraries privadas do editor
|
||||
* (libraries/tinyblocks-editor-*). Estas libraries sao um bundle privado:
|
||||
* vem juntas com o editor e podem compartilhar este cabecalho.
|
||||
*/
|
||||
#ifndef TB_EDITOR_INTERNAL_H
|
||||
#define TB_EDITOR_INTERNAL_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <tinyblocks/tinyblocks.h>
|
||||
#include <tinyblocks/tb_renderable_block.h>
|
||||
#include <tinyblocks/tb_json_block.h>
|
||||
#include <tb_graphics.h>
|
||||
#include <tinyblocks/tb_stage.h>
|
||||
#include <tb_variables.h>
|
||||
#include <tb_blueprint.h>
|
||||
#include <tb_api.h>
|
||||
#include <tb_libman.h>
|
||||
#include <tb_environ.h>
|
||||
#include <tb_syntax.h>
|
||||
#include <tb_editor_widgets.h>
|
||||
#include <tb_editor_image.h>
|
||||
#include "../internal/tb_editor_modules.h"
|
||||
|
||||
#ifndef TB_EW_UNUSED
|
||||
#define TB_EW_UNUSED __attribute__((unused))
|
||||
#endif
|
||||
|
||||
/* ===
|
||||
* Layout da janela
|
||||
*
|
||||
* ==== barra de menu (azul) ====
|
||||
* == abas ===== [flag] [run] ====
|
||||
* =cat= flyout (blocos) - área de scripts - palco / saída =
|
||||
* =================
|
||||
* === */
|
||||
#define WIN_W_DEFAULT 1280
|
||||
#define WIN_H_DEFAULT 720
|
||||
#define MENU_H 44
|
||||
#define TAB_H 36
|
||||
#define CAT_W 68
|
||||
#define FLY_W 250
|
||||
#define FLY_PAD 12
|
||||
#define FLY_BTN_W 150
|
||||
#define PALETTE_W (CAT_W + FLY_W)
|
||||
#define STAGE_W 360
|
||||
#define STAGE_BAR_H 44
|
||||
#define PAL_Y (MENU_H + TAB_H)
|
||||
#define WS_X PALETTE_W
|
||||
#define WS_Y (MENU_H + TAB_H)
|
||||
#define WIN_W (ed->win_w)
|
||||
#define WIN_H (ed->win_h)
|
||||
#define WS_W (ed->win_w - PALETTE_W - STAGE_W)
|
||||
#define WS_H (ed->win_h - WS_Y)
|
||||
#define TAB_W 150
|
||||
#define PLUS_W 28
|
||||
|
||||
/* Menu do botao "+" (nova aba) */
|
||||
#define PLUS_MENU_W 208
|
||||
#define PLUS_MENU_ITEM_H 36
|
||||
|
||||
/* Editor de codigo (aba de codigo) */
|
||||
#define CODE_FS 13
|
||||
#define CODE_GUTTER_W 46
|
||||
#define CODE_LINE_H 18
|
||||
#define CODE_PAD_Y 6
|
||||
#define CODE_PAD_X 8
|
||||
|
||||
/* Tipos de aba */
|
||||
enum { TK_BLOCKS, TK_CODE, TK_IMAGE };
|
||||
|
||||
/* Aba de imagem: editor de pintura com camadas (visual estilo Scratch) */
|
||||
/* Medidas da aba de imagem ficam no modulo (tinyblocks-editor-image);
|
||||
aqui so o que o estado (Tab) precisa. */
|
||||
#define IMG_UNDO_MAX 6
|
||||
#define IMG_MAX_LAYERS 8
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
enum { IMG_L_RASTER = 0, IMG_L_VECTOR };
|
||||
|
||||
/* Camada do documento de imagem (rasterizada; SVG entra como vetor) */
|
||||
typedef struct {
|
||||
TinyBlocks_Image* img;
|
||||
TinyBlocks_Image* thumb; /* miniatura do painel "Camadas" */
|
||||
unsigned thumb_rev;/* revisao em que a miniatura foi feita */
|
||||
char name[48];
|
||||
char src[192];
|
||||
int kind;
|
||||
int visible;
|
||||
} ImgLayer;
|
||||
|
||||
/* Selecao da ferramenta "selecionar" (mover/redimensionar pixels) */
|
||||
typedef struct {
|
||||
int on; /* ha selecao ativa */
|
||||
TinyBlocks_Image* buf; /* pixels retirados da camada (flutuantes) */
|
||||
int ox, oy, ow, oh; /* regiao original (ancora do arrasto / tamanho) */
|
||||
int x, y, w, h; /* retangulo atual */
|
||||
int mode; /* 0 = nada, 1 = mover, 2 = redimensionar, 3 = novo */
|
||||
int hnd; /* indice da alca (0..8) */
|
||||
int px, py; /* ultimo ponto em coords da imagem */
|
||||
} ImgSel;
|
||||
|
||||
enum { IT_SEL = 0, IT_BRUSH, IT_LINE, IT_RECT, IT_ELLIPSE,
|
||||
IT_FILL, IT_ERASER, IT_PICK, IT_N };
|
||||
|
||||
/* Botoes de projeto no menu (geometria) */
|
||||
#define OPEN_BTN_X 150
|
||||
#define OPEN_BTN_W 64
|
||||
#define SAVE_BTN_X 218
|
||||
#define SAVE_BTN_W 70
|
||||
#define EXP_BTN_X 296
|
||||
#define EXP_BTN_W 84
|
||||
#define LIBM_BTN_X 388
|
||||
#define LIBM_BTN_W 104
|
||||
#define LIB_BTN_X 500
|
||||
#define LIB_BTN_W 200
|
||||
|
||||
/* Botao "Config" (settings) ancorado a direita do menu */
|
||||
#define CFG_BTN_W 78
|
||||
#define CFG_BTN_X (WIN_W - CFG_BTN_W - 10)
|
||||
|
||||
/* Botao de buscar/adicionar library no fim da coluna de categorias */
|
||||
#define LIBMAN_BTN_H 56
|
||||
|
||||
/* == Geometria dos blocos === */
|
||||
#define FS 12 /* texto dos blocos */
|
||||
#define FS_UI 13 /* texto da interface */
|
||||
#define FS_SM 11
|
||||
#define BLK_GAP 5 /* espaço entre partes do rótulo */
|
||||
#define BLK_PAD 10
|
||||
#define ROW_MIN_STACK 36
|
||||
#define ROW_MIN_REP 24
|
||||
#define SLOT_MIN_H 20
|
||||
#define SLOT_MIN_W 28
|
||||
#define SLOT_LINE_H 15
|
||||
#define HAT_CAP 18 /* altura do "chapéu" acima da linha do rótulo */
|
||||
#define HAT_CAP_W 96
|
||||
#define ARM_W 16 /* braço esquerdo dos blocos C */
|
||||
#define BOT_H 22 /* braço inferior dos blocos C */
|
||||
#define MID_H 26 /* braço "senão" */
|
||||
#define MOUTH_MIN 22
|
||||
#define NOTCH_X 12 /* encaixe (macho) sob os comandos */
|
||||
#define NOTCH_W 18
|
||||
#define NOTCH_D 4
|
||||
#define PREVIEW_H 64 /* área de on_draw */
|
||||
#define PREVIEW_W 168
|
||||
#define SNAP_R 28.f
|
||||
|
||||
#define MAX_WS 256
|
||||
#define MAX_INPUTS 16
|
||||
#define MAX_PARTS 40
|
||||
#define MAX_TABS 8
|
||||
#define MAX_FLY 192
|
||||
#define MAX_CATS 24
|
||||
#define MAX_CALL_DEPTH 32
|
||||
#define MAX_STEPS 500000L
|
||||
#define MAX_RUN_BLOCKS 200000
|
||||
#define STAGE_BUF 16384
|
||||
#define LIT_TEXT_CAP 512
|
||||
#define MAX_HOT_TYPES 64
|
||||
#define MAX_USER_BLOCKS 16
|
||||
#define MAX_UBLK_SLOTS 8
|
||||
#define MAX_UBLK_PARTS 16
|
||||
|
||||
/* ===
|
||||
* Cores (paleta do Scratch 3) - componentes 0..1
|
||||
* === */
|
||||
/* Copia de string com limite (helper compartilhado, sem estado) */
|
||||
static inline void scopy(char* dst, size_t cap, const char* src) {
|
||||
if (!dst || !cap) return;
|
||||
if (!src) { dst[0] = 0; return; }
|
||||
size_t n = strlen(src);
|
||||
if (n >= cap) n = cap - 1;
|
||||
memcpy(dst, src, n);
|
||||
dst[n] = 0;
|
||||
}
|
||||
|
||||
/* Cores e primitivas de desenho vem da library privada
|
||||
tinyblocks-editor-widgets (ver tb_editor_widgets.h). Aqui so mantemos os
|
||||
nomes curtos usados no codigo do editor. */
|
||||
typedef TbEwColor Col;
|
||||
#define C(r,g,b) TB_EW_RGB(r,g,b)
|
||||
#define COLA(r,g,b,a) TB_EW_RGBA(r,g,b,a)
|
||||
#define col_mul tb_ed_w.col_mul
|
||||
/* O desenho do editor passa pela library privada widgets. Chamamos pela
|
||||
tabela (tb_ed_w) para poder recarregar o .so em execucao (hot reload). */
|
||||
#define rb_fill_rect tb_ed_w.fill_rect
|
||||
#define rb_fill_rrect tb_ed_w.fill_rrect
|
||||
#define rb_fill_circle tb_ed_w.fill_circle
|
||||
#define rb_stroke_rect tb_ed_w.stroke_rect
|
||||
#define rb_stroke_circle tb_ed_w.stroke_circle
|
||||
#define rb_line tb_ed_w.line
|
||||
#define rb_text_c tb_ed_w.text_c
|
||||
#define tw tb_ed_w.text_width
|
||||
#define in_rect tb_ed_w.in_rect
|
||||
|
||||
static const Col COL_MENU TB_EW_UNUSED = C( 76,151,255); /* #4C97FF */
|
||||
static const Col COL_MENU_DARK TB_EW_UNUSED = C( 61,121,204);
|
||||
static const Col COL_UI_BG TB_EW_UNUSED = C(229,240,255); /* #E5F0FF */
|
||||
static const Col COL_PANEL TB_EW_UNUSED = C(255,255,255);
|
||||
static const Col COL_FLY TB_EW_UNUSED = C(249,249,249);
|
||||
static const Col COL_WS_BG TB_EW_UNUSED = C(249,249,249);
|
||||
static const Col COL_GRID TB_EW_UNUSED = C(221,221,221);
|
||||
static const Col COL_BORDER TB_EW_UNUSED = C(217,217,217);
|
||||
static const Col COL_TEXT TB_EW_UNUSED = C( 87, 94,117); /* #575E75 */
|
||||
static const Col COL_TEXT_DIM TB_EW_UNUSED = C(150,155,175);
|
||||
static const Col COL_TAB_OFF TB_EW_UNUSED = C(217,227,242);
|
||||
static const Col COL_HOVER TB_EW_UNUSED = C(214,228,248);
|
||||
static const Col COL_FLAG TB_EW_UNUSED = C( 76,191, 86); /* #4CBF56 */
|
||||
static const Col COL_FLAG_DARK TB_EW_UNUSED = C( 69,153, 61);
|
||||
static const Col COL_STOP TB_EW_UNUSED = C(236, 89, 89); /* #EC5959 */
|
||||
static const Col COL_STOP_DARK TB_EW_UNUSED = C(184, 60, 60);
|
||||
static const Col COL_WHITE TB_EW_UNUSED = C(255,255,255);
|
||||
static const Col COL_MISSING TB_EW_UNUSED = C(170,170,170);
|
||||
static const Col COL_EXT TB_EW_UNUSED = C( 15,189,140); /* extensões */
|
||||
static const Col COL_EXT_DARK TB_EW_UNUSED = C( 11,142,105);
|
||||
static const Col COL_LIBBTN TB_EW_UNUSED = C(255, 76, 76); /* botao de extensoes */
|
||||
static const Col COL_LIBBTN_DARK TB_EW_UNUSED = C(211, 47, 47);
|
||||
static const Col COL_VAR TB_EW_UNUSED = C(255,140, 26);
|
||||
|
||||
/* Tema escuro do editor de codigo */
|
||||
static const Col COL_CODE_BG TB_EW_UNUSED = C( 40, 44, 52);
|
||||
static const Col COL_CODE_GUTTER TB_EW_UNUSED = C( 33, 37, 43);
|
||||
static const Col COL_CODE_CURLINE TB_EW_UNUSED = C( 51, 57, 67);
|
||||
static const Col COL_CODE_FOCUS TB_EW_UNUSED = C( 62, 74, 53);
|
||||
static const Col COL_CODE_BAR TB_EW_UNUSED = C( 33, 37, 43);
|
||||
static const Col COL_CODE_TEXT TB_EW_UNUSED = C(212, 212, 212);
|
||||
static const Col COL_TIP_BG TB_EW_UNUSED = C( 37, 37, 38);
|
||||
static const Col COL_TIP_BORDER TB_EW_UNUSED = C( 69, 69, 69);
|
||||
static const Col COL_TIP_LINK TB_EW_UNUSED = C( 74,158,255);
|
||||
static const Col COL_MON_BG TB_EW_UNUSED = C(230,240,255);
|
||||
static const Col COL_MON_BORDER TB_EW_UNUSED = C(195,204,217);
|
||||
static const Col COL_ERR_MENU TB_EW_UNUSED = C(255,215,215);
|
||||
static const Col COL_ERR_TEXT TB_EW_UNUSED = C(204, 60, 60);
|
||||
|
||||
/* == Categorias (vêm das libraries; "Meus Blocos" é do editor) === */
|
||||
static const Col COL_MYBLOCKS_COL TB_EW_UNUSED = C(255,102,128);
|
||||
static const Col COL_MYBLOCKS_DARK TB_EW_UNUSED = C(255, 51, 85);
|
||||
|
||||
#define USER_COLOR_COUNT 8
|
||||
static const Col s_user_colors[USER_COLOR_COUNT] TB_EW_UNUSED = {
|
||||
C(255,102,128), C( 76,151,255), C(153,102,255), C(207, 99,207),
|
||||
C(255,191, 0), C(255,171, 25), C( 89,192, 89), C( 15,189,140),
|
||||
};
|
||||
|
||||
/* == Rótulos dos blocos (%N - campo de entrada N) === */
|
||||
typedef struct {
|
||||
const char* type;
|
||||
const char* label;
|
||||
const char* defs; /* valores iniciais dos campos, separados por '|' */
|
||||
} BlockSpec;
|
||||
|
||||
static const BlockSpec s_specs[] = {
|
||||
{"Events.WhenRun", "quando a bandeira for clicado", NULL},
|
||||
{"Control.Repeat", "repita %1 vezes", "10"},
|
||||
{"Control.RepeatUntil", "repita até que %1", NULL},
|
||||
{"Control.If", "se %1 então", NULL},
|
||||
{"Control.IfElse", "se %1 então", NULL},
|
||||
{"Operators.Lt", "%1 < %2", "|50"},
|
||||
{"Operators.Eq", "%1 = %2", "|50"},
|
||||
{"Operators.Gt", "%1 > %2", "|50"},
|
||||
{"Operators.And", "%1 e %2", NULL},
|
||||
{"Operators.Or", "%1 ou %2", NULL},
|
||||
{"Operators.Not", "não %1", NULL},
|
||||
{"Operators.Random", "número aleatório entre %1 e %2", "1|10"},
|
||||
{"Math.Add", "%1 + %2", NULL},
|
||||
{"Math.Sub", "%1 - %2", NULL},
|
||||
{"Math.Mul", "%1 * %2", NULL},
|
||||
{"Math.Div", "%1 / %2", NULL},
|
||||
{"Math.Mod", "resto de %1 por %2", NULL},
|
||||
{"Math.Abs", "valor absoluto de %1", NULL},
|
||||
{"Math.Max", "maior entre %1 e %2", NULL},
|
||||
{"Math.Min", "menor entre %1 e %2", NULL},
|
||||
{"Text.Concat", "junte %1 com %2", "maçã|banana"},
|
||||
{"Text.Length", "tamanho de %1", "maçã"},
|
||||
{"Literal.Text", "texto %1", NULL},
|
||||
{"Variables.Set", "mude %1 para %2", "x|0"},
|
||||
{"Variables.Change", "adicione %2 a %1", "x|1"},
|
||||
{"Variables.Get", "%1", "x"},
|
||||
{"IO.Print", "escreva %1 %2", "Olá!|"},
|
||||
{"IO.PrintInt", "escreva o número %1", NULL},
|
||||
{"Port.In", "parâmetro %1", "x"},
|
||||
{"Port.Out", "devolva %1 = %2", "resultado|"},
|
||||
{"Stage.Clear", "apague tudo", NULL},
|
||||
{"Stage.Background", "mude o fundo para r %1 g %2 b %3", "255|255|255"},
|
||||
{"Stage.PenColor", "mude a cor da caneta para r %1 g %2 b %3", "76|151|255"},
|
||||
{"Stage.PenSize", "mude o tamanho da caneta para %1", "4"},
|
||||
{"Stage.Line", "desenhe linha de x %1 y %2 até x %3 y %4", "-100|0|100|0"},
|
||||
{"Stage.Rect", "desenhe retângulo em x %1 y %2 largura %3 altura %4", "0|0|120|80"},
|
||||
{"Stage.Circle", "desenhe círculo em x %1 y %2 raio %3", "0|0|50"},
|
||||
{"Stage.Text", "escreva %1 no palco em x %2 y %3", "Olá!|-40|0"},
|
||||
/* Curvas (lista de pontos [x,y]) */
|
||||
{"Curves.Line", "reta de x %1 y %2 até x %3 y %4 com %5 passos", "0|0|100|0|20"},
|
||||
{"Curves.Bezier", "bezier de x %1 y %2 controles (%3,%4) (%5,%6) até x %7 y %8 com %9 passos", "0|0|0|80|100|80|100|0|20"},
|
||||
{"Curves.Quadratic", "curva quadrática de x %1 y %2 controle (%3,%4) até x %5 y %6 com %7 passos", "0|0|50|80|100|0|20"},
|
||||
{"Curves.Arc", "arco em (%1,%2) raio %3 de %4 a %5 graus com %6 passos", "0|0|50|0|180|24"},
|
||||
{"Curves.Circle", "círculo em (%1,%2) raio %3 com %4 passos", "0|0|50|36"},
|
||||
{"Curves.Count", "quantos pontos em %1", NULL},
|
||||
{"Curves.PointX", "x do ponto %2 de %1", "|0"},
|
||||
{"Curves.PointY", "y do ponto %2 de %1", "|0"},
|
||||
/* Base64 */
|
||||
{"Base64.Encode", "codifique em base64 %1", NULL},
|
||||
{"Base64.Decode", "decodifique base64 %1", NULL},
|
||||
/* Imagens PPM (tipo imagem do core) */
|
||||
{"PPM.Load", "carregue a imagem %1", "imagem.ppm"},
|
||||
{"PPM.Save", "grave a imagem %1 em %2", "|saida.ppm"},
|
||||
{"PPM.New", "nova imagem(%1 x %2) cor r %3 g %4 b %5", "32|32|255|0|0"},
|
||||
{"PPM.Width", "largura de %1", NULL},
|
||||
{"PPM.Height", "altura de %1", NULL},
|
||||
{"PPM.SetPixel", "pinte %1 em (%2,%3) de r %4 g %5 b %6", "|0|0|0|0|0"},
|
||||
{"PPM.GetPixel", "cor de %1 em (%2,%3)", "|0|0"},
|
||||
{"BMP.Load", "carregue o BMP %1", "imagem.bmp"},
|
||||
{"BMP.Save", "grave o BMP %1 em %2", "|saida.bmp"},
|
||||
{"PNG.Load", "carregue o PNG %1", "imagem.png"},
|
||||
{"PNG.Save", "grave o PNG %1 em %2", "|saida.png"},
|
||||
/* Imagem (ops genericas) */
|
||||
{"Image.New", "nova imagem(%1 x %2) cor r %3 g %4 b %5", "32|32|255|0|0"},
|
||||
{"Image.Width", "largura da imagem %1", NULL},
|
||||
{"Image.Height", "altura da imagem %1", NULL},
|
||||
{"Image.GetPixel", "cor da imagem %1 em (%2,%3)", "|0|0"},
|
||||
{"Image.SetPixel", "pinte a imagem %1 em (%2,%3) com r %4 g %5 b %6", "|0|0|0|0|0"},
|
||||
{"Image.Fill", "preencha a imagem %1 com r %2 g %3 b %4", "|255|255|255"},
|
||||
{"Image.Clone", "copie a imagem %1", NULL},
|
||||
{"Image.Crop", "recorte da imagem %1 em (%2,%3) tamanho %4 x %5", "|0|0|16|16"},
|
||||
{"Image.Scale", "escale a imagem %1 para %2 x %3", "|64|64"},
|
||||
{"Image.Load", "carregue a imagem %1", "imagem.png"},
|
||||
{"Image.Save", "grave a imagem %1 em %2", "|saida.png"},
|
||||
/* Vetor (vg) */
|
||||
{"VG.New", "novo desenho vetorial", NULL},
|
||||
{"VG.Line", "linha do vetor %1 de (%2,%3) a (%4,%5) cor r %6 g %7 b %8 esp %9", "|0|0|50|50|0|0|0|2"},
|
||||
{"VG.Rect", "retangulo no vetor %1 em (%2,%3) %4 x %5 cor r %6 g %7 b %8", "|0|0|40|40|255|0|0"},
|
||||
{"VG.Circle", "circulo no vetor %1 em (%2,%3) raio %4 cor r %5 g %6 b %7", "|20|20|15|0|0|255"},
|
||||
{"VG.Polygon", "poligono no vetor %1 pontos %2 fechar %3 cor r %4 g %5 b %6", "||1|0|255|0"},
|
||||
{"VG.Render", "rasterize o vetor %1 em %2 x %3 escala %4", "|64|64|1"},
|
||||
/* SVG */
|
||||
{"SVG.Parse", "interprete o SVG %1", NULL},
|
||||
{"SVG.Render", "desenhe o SVG %1 em %2 x %3", "|64|64"},
|
||||
{"SVG.Load", "carregue o SVG %1", "desenho.svg"},
|
||||
};
|
||||
|
||||
/* ===
|
||||
* Estruturas de dados
|
||||
* === */
|
||||
typedef enum { SH_STACK, SH_HAT, SH_C1, SH_C2, SH_REPORTER, SH_BOOL } Shape;
|
||||
|
||||
/* Relação de um bloco com o pai */
|
||||
#define REL_NONE (-1)
|
||||
#define REL_NEXT 0
|
||||
#define REL_SUB0 1 /* REL_SUB0 + k: boca k de um bloco C */
|
||||
#define REL_ARG0 3 /* REL_ARG0 + i: campo de entrada i */
|
||||
|
||||
typedef struct {
|
||||
int16_t arg; /* -1 = texto; senão índice do campo */
|
||||
int16_t len;
|
||||
const char* txt;
|
||||
float x, w;
|
||||
} Part;
|
||||
|
||||
typedef struct {
|
||||
bool used;
|
||||
bool dragging;
|
||||
TinyBlocks_TypeBlock* type;
|
||||
char type_name[64];
|
||||
float x, y; /* posição (só para o topo de uma pilha) */
|
||||
int parent, prel;
|
||||
int next;
|
||||
int sub[2];
|
||||
int args[MAX_INPUTS];
|
||||
char in_text[MAX_INPUTS][64];
|
||||
char lit_text[LIT_TEXT_CAP];
|
||||
|
||||
/* layout - recalculado a cada frame */
|
||||
float ax, ay, w, h;
|
||||
float row_y, row_h, prev_y;
|
||||
float sub_y[2], sub_h[2];
|
||||
float slot_x[MAX_INPUTS], slot_y[MAX_INPUTS], slot_w[MAX_INPUTS], slot_h[MAX_INPUTS];
|
||||
int part_n;
|
||||
Part parts[MAX_PARTS];
|
||||
|
||||
TinyBlocks_Block* live_rt; /* última instância no runtime (não-owning) */
|
||||
} EdBlock;
|
||||
|
||||
/* Um trecho colorido do editor de codigo (vindo do tinyblocks-syntax). */
|
||||
typedef struct { int line; char* text; char color[12]; } CodeTok;
|
||||
|
||||
typedef struct Tab {
|
||||
EdBlock ws[MAX_WS];
|
||||
int top[MAX_WS]; /* pilhas de topo, em ordem de desenho */
|
||||
int top_n;
|
||||
float ws_sx, ws_sy;
|
||||
char name[48];
|
||||
bool is_composite;
|
||||
int comp_id;
|
||||
int color_idx;
|
||||
|
||||
int kind; /* TK_BLOCKS, TK_CODE, TK_IMAGE */
|
||||
|
||||
/* -- aba de codigo -- */
|
||||
char* code_text;
|
||||
int code_len, code_cap;
|
||||
int code_caret; /* posicao do cursor (offset em bytes) */
|
||||
int code_scroll; /* primeira linha visivel (0-based) */
|
||||
int code_focus; /* linha destacada (1-based), -1 = nenhuma */
|
||||
char code_path[256];
|
||||
char code_lang[16];
|
||||
char* code_hl; /* XML do realce (cache) */
|
||||
CodeTok* code_toks;
|
||||
int code_tok_n;
|
||||
bool code_hl_dirty;
|
||||
|
||||
/* -- aba de imagem: documento com camadas -- */
|
||||
ImgLayer img_layers[IMG_MAX_LAYERS];
|
||||
int img_layer_n;
|
||||
int img_layer_cur;
|
||||
int img_w, img_h; /* tamanho do documento em pixels */
|
||||
char img_path[256]; /* arquivo do documento (salvar) */
|
||||
int img_tool; /* IT_* */
|
||||
int img_rgb[3]; /* cor atual (0..255) */
|
||||
int img_swatch; /* paleta selecionada; -1 = cor propria */
|
||||
float img_hue, img_sat, img_val; /* HSV da cor atual (roda de cor) */
|
||||
int img_cdrag; /* arrasto na roda: 0=nada 1=matiz 2=SV */
|
||||
float img_zoom; /* escala de exibicao (1.0 = 1:1) */
|
||||
int img_drag; /* traco em andamento */
|
||||
int img_drag_x, img_drag_y;
|
||||
TinyBlocks_Image* img_undo[IMG_UNDO_MAX];
|
||||
int img_undo_layer[IMG_UNDO_MAX];
|
||||
int img_undo_n;
|
||||
TinyBlocks_Image* img_prev; /* miniatura (cache) */
|
||||
unsigned img_prev_rev;
|
||||
unsigned img_rev; /* muda a cada alteracao do documento */
|
||||
ImgSel img_sel;
|
||||
} Tab;
|
||||
|
||||
typedef enum { PARAM_NUM, PARAM_BOOL, PARAM_LABEL } ParamKind;
|
||||
typedef struct { ParamKind kind; char name[32]; } UserParam;
|
||||
|
||||
typedef struct {
|
||||
char name[48];
|
||||
int input_count, output_count;
|
||||
char input_names[MAX_UBLK_SLOTS][32];
|
||||
char output_names[MAX_UBLK_SLOTS][32];
|
||||
UserParam parts[MAX_UBLK_PARTS]; /* protótipo: entradas, booleanas e rótulos */
|
||||
int part_n;
|
||||
Tab* snap; /* cópia da aba no momento do "Salvar" */
|
||||
TinyBlocks_TypeBlock* reg_type;
|
||||
int tab_idx;
|
||||
int color_idx;
|
||||
} UserBlockDef;
|
||||
|
||||
typedef struct {
|
||||
UserBlockDef* def;
|
||||
TinyBlocks_Value in[MAX_UBLK_SLOTS];
|
||||
TinyBlocks_Value out[MAX_UBLK_SLOTS];
|
||||
} CallFrame;
|
||||
|
||||
typedef struct { char name[32]; char prefix[32]; Col col, dark; float fly_y;
|
||||
const TinyBlocks_LibraryBlock* lib; } Cat;
|
||||
|
||||
typedef enum { FI_HEADER, FI_BUTTON, FI_BLOCK } FlyKind;
|
||||
typedef struct { FlyKind kind; int cat; int bi; float y, h; } FlyItem;
|
||||
|
||||
typedef enum { ES_IDLE, ES_PRESS, ES_DRAG, ES_PAN } EdSt;
|
||||
typedef enum { SN_NONE, SN_NEXT, SN_SUB, SN_ABOVE, SN_ARG } SnapKind;
|
||||
enum { CM_DUPLICATE, CM_DELETE, CM_EDIT_DEF, CM_CLEANUP, CM_NEW_COMPOSITE,
|
||||
CM_EXP_JSON, CM_EXP_XML, CM_EXP_CSV };
|
||||
|
||||
/* Modos da barra de caminho do menu (path_input) */
|
||||
enum { PM_NONE, PM_LIB, PM_LOAD, PM_SAVE, PM_EXP_JSON, PM_EXP_XML, PM_EXP_CSV,
|
||||
PM_IMGLOAD, PM_IMSAVE, PM_IMADDR, PM_IMADDV, PM_CODELOAD, PM_CODESAVE };
|
||||
|
||||
/* Formatos de exportacao */
|
||||
enum { EX_JSON, EX_XML, EX_CSV };
|
||||
|
||||
typedef struct Ed {
|
||||
TinyBlocks* rt;
|
||||
|
||||
Cat cats[MAX_CATS];
|
||||
int cat_n;
|
||||
int myblocks_cat; /* índice da categoria "Meus Blocos" */
|
||||
Tab fly; /* blocos-modelo do flyout */
|
||||
FlyItem fly_items[MAX_FLY];
|
||||
int fly_n;
|
||||
float fly_scroll, fly_total_h;
|
||||
|
||||
Tab tabs[MAX_TABS];
|
||||
int tab_n;
|
||||
int cur_tab;
|
||||
|
||||
UserBlockDef user_blocks[MAX_USER_BLOCKS];
|
||||
int user_block_n;
|
||||
|
||||
char comp_name_buf[48];
|
||||
int comp_name_len;
|
||||
|
||||
/* Diálogo modal "Criar um Bloco" (estilo Scratch) */
|
||||
bool comp_dialog_open;
|
||||
int comp_dialog_def; /* -1 = novo; senão índice em user_blocks */
|
||||
bool comp_dialog_editing; /* true = edição de nome/rótulo em andamento */
|
||||
int comp_dialog_edit_part; /* índice da parte em edição, -1 = nome do bloco */
|
||||
char comp_dialog_name[48];
|
||||
UserParam comp_dialog_parts[MAX_UBLK_PARTS];
|
||||
int comp_dialog_part_n;
|
||||
int comp_dialog_sel; /* parte selecionada (-1 = nenhuma) */
|
||||
int comp_dialog_color;
|
||||
float comp_dialog_geom[MAX_UBLK_PARTS][2]; /* x,w desenhados (para hit test) */
|
||||
float comp_dialog_name_x, comp_dialog_name_w;
|
||||
|
||||
bool ctx_menu_open;
|
||||
bool ctx_export; /* menu de contexto aberto e o de exportacao */
|
||||
int ctx_menu_bi;
|
||||
int ctx_menu_x, ctx_menu_y;
|
||||
int ctx_menu_hover;
|
||||
int ctx_items[8];
|
||||
int ctx_n;
|
||||
|
||||
EdSt state;
|
||||
int press_bi;
|
||||
float press_mx, press_my;
|
||||
int drag_bi;
|
||||
float drag_ox, drag_oy;
|
||||
SnapKind snap_kind;
|
||||
int snap_bi, snap_idx;
|
||||
float pan_mx, pan_my, pan_sx, pan_sy;
|
||||
|
||||
bool editing;
|
||||
int edit_bi, edit_in;
|
||||
|
||||
int bubble_bi;
|
||||
char bubble_text[128];
|
||||
TinyBlocks_JsonValue* bubble_json; /* lista de pontos (retida) ou NULL */
|
||||
TinyBlocks_Image* bubble_img; /* imagem (retida) ou NULL */
|
||||
int last_click_bi;
|
||||
unsigned last_click_ms;
|
||||
|
||||
char stage_buf[STAGE_BUF];
|
||||
|
||||
/* Execução */
|
||||
CallFrame frames[MAX_CALL_DEPTH];
|
||||
int frame_n;
|
||||
long steps;
|
||||
bool abort;
|
||||
char abort_msg[160];
|
||||
TinyBlocks_Block** run_blocks; /* instâncias criadas na última execução */
|
||||
int run_n, run_cap;
|
||||
Tab* live_tab;
|
||||
FILE* cap_file;
|
||||
int cap_saved;
|
||||
|
||||
float mouse_x, mouse_y;
|
||||
bool flag_hover, stop_hover, lib_hover, detach_hover;
|
||||
|
||||
/* Palco: embutido no painel ou numa janela própria (Graphics.Window) */
|
||||
TinyBlocks_Block* stage;
|
||||
TinyBlocks_Block* stage_win;
|
||||
TinyBlocks_Block* stage_in;
|
||||
|
||||
bool clip_on;
|
||||
float clip[4];
|
||||
|
||||
TbEdModules mods; /* libraries privadas (bundle) por dlopen */
|
||||
int hot_check_frame; /* contador para checar hot reload */
|
||||
char hot_status[256];
|
||||
bool hot_status_ok;
|
||||
|
||||
bool path_input_active;
|
||||
char path_input_buf[512];
|
||||
int path_input_len;
|
||||
int path_mode; /* PM_* - o que fazer no Enter */
|
||||
|
||||
/* Gestor de libraries (tinyblocks-libman); a UI e desenhada aqui */
|
||||
bool libman_open;
|
||||
char libman_query[128];
|
||||
int libman_query_len;
|
||||
bool libman_search_focus;
|
||||
int libman_filter; /* -1 = Tudo; senao indice em libman_cats */
|
||||
char libman_cats[MAX_CATS][48];
|
||||
int libman_cat_n;
|
||||
int libman_scroll;
|
||||
int libman_hover;
|
||||
|
||||
/* Configuracoes (settings) - store da tinyblocks-environ */
|
||||
bool settings_open;
|
||||
int settings_sel; /* linha selecionada (-1 = nenhuma) */
|
||||
bool settings_path_focus; /* campo de caminho do CSV em foco */
|
||||
bool settings_use_env; /* caminho vindo de TINYBLOCKS_SETTINGS */
|
||||
bool settings_value_edit; /* editando o valor da linha sel. */
|
||||
bool settings_new_key; /* digitando o nome de uma nova chave */
|
||||
char settings_path[256];
|
||||
char settings_edit[256]; /* buffer do valor em edicao */
|
||||
char settings_key[64]; /* buffer da nova chave */
|
||||
int settings_scroll;
|
||||
int settings_hover;
|
||||
|
||||
/* Menu do botao "+" (nova aba) */
|
||||
bool plus_menu_open;
|
||||
int plus_menu_hover;
|
||||
float plus_menu_x, plus_menu_y;
|
||||
|
||||
/* Tooltip de metadados do bloco (Alt + hover) */
|
||||
bool tip_open;
|
||||
int tip_bi;
|
||||
float tip_x, tip_y, tip_w, tip_h;
|
||||
float tip_prev_y, tip_prev_h; /* area clicavel (previa do codigo) */
|
||||
char tip_title[256]; /* assinatura da funcao */
|
||||
char tip_loc[320]; /* arquivo:linha */
|
||||
char tip_doc[256];
|
||||
char tip_file[256]; /* arquivo resolvivel */
|
||||
int tip_line;
|
||||
char tip_preview[768];
|
||||
|
||||
float img_mx, img_my; /* ultimo ponto do traco (aba de imagem) */
|
||||
|
||||
int win_w, win_h;
|
||||
} Ed;
|
||||
|
||||
#define CT (ed->tabs[ed->cur_tab])
|
||||
|
||||
/* Ponteiro global para o editor ativo - os eval_fn dos blocos do editor
|
||||
* (variáveis, compostos, portas) só recebem (self, rt). */
|
||||
static Ed* g_active_ed TB_EW_UNUSED = NULL;
|
||||
|
||||
void bubble_clear(Ed* ed);
|
||||
|
||||
void palette_rebuild(Ed* ed);
|
||||
void utf8_pop(char* s);
|
||||
void append_text(char* dst, size_t cap, const char* add);
|
||||
void dlg_open(Ed* ed, int def_idx);
|
||||
void dlg_render(Ed* ed, TinyBlocks_RenderableBlock* rb);
|
||||
bool dlg_click(Ed* ed, float mx, float my);
|
||||
void dlg_key(Ed* ed, int sc);
|
||||
void dlg_text(Ed* ed, const char* typed);
|
||||
|
||||
/* Gestor de libraries (tinyblocks-libman) - UI desenhada pelo editor */
|
||||
void libman_show(Ed* ed);
|
||||
void libman_click(Ed* ed, float mx, float my);
|
||||
void libman_key(Ed* ed, int sc);
|
||||
void libman_text(Ed* ed, const char* typed);
|
||||
void libman_scroll_by(Ed* ed, float dy);
|
||||
void libman_render(Ed* ed, TinyBlocks_RenderableBlock* rb);
|
||||
bool hit_libman_foot(Ed* ed, float mx, float my);
|
||||
|
||||
/* Abas de codigo/imagem + tooltip de metadados */
|
||||
bool tab_new_kind(Ed* ed, const char* name, bool is_composite, int kind);
|
||||
void tab_doc_free(Tab* T);
|
||||
void code_rehighlight(Tab* T);
|
||||
void open_code_at(Ed* ed, const char* file, int line);
|
||||
void render_code_tab(Ed* ed, TinyBlocks_RenderableBlock* rb);
|
||||
void render_tooltip(Ed* ed, TinyBlocks_RenderableBlock* rb);
|
||||
void render_plus_menu(Ed* ed, TinyBlocks_RenderableBlock* rb);
|
||||
bool code_click(Ed* ed, float mx, float my);
|
||||
bool code_key(Ed* ed, int sc, bool ctrl);
|
||||
bool code_text(Ed* ed, const char* typed);
|
||||
/* Recorte (clip) do desenho - vive no editor, usado tambem pela aba de imagem.
|
||||
TB_ED_API: precisa ser visivel para os modulos carregados por dlopen. */
|
||||
TB_ED_API void clip_set(Ed* ed, TinyBlocks_RenderableBlock* rb, float x, float y, float w, float h);
|
||||
TB_ED_API void clip_clear(Ed* ed, TinyBlocks_RenderableBlock* rb);
|
||||
TB_ED_API void clip_restore(Ed* ed, TinyBlocks_RenderableBlock* rb);
|
||||
TB_ED_API void start_path(Ed* ed, int mode, const char* def);
|
||||
|
||||
/* Aba de imagem: library privada carregada por dlopen (hot reload).
|
||||
As chamadas passam pela tabela tb_ed_img, entao trocar o .so em execucao
|
||||
ja muda o comportamento - sem reiniciar o editor.
|
||||
Quando compilando o proprio modulo, usa os nomes reais. */
|
||||
#ifdef TB_EDITOR_IMAGE_BUILD
|
||||
# define render_image_tab tb_editor_image_view
|
||||
# define image_click tb_editor_image_click
|
||||
# define image_drag tb_editor_image_drag
|
||||
# define image_release tb_editor_image_release
|
||||
# define img_load_file tb_editor_image_load_file
|
||||
# define img_save_out tb_editor_image_save
|
||||
# define img_ensure tb_editor_image_ensure
|
||||
# define img_sel_reset tb_editor_image_sel_reset
|
||||
# define img_sel_commit tb_editor_image_sel_commit
|
||||
#else
|
||||
# define render_image_tab tb_ed_img.view
|
||||
# define image_click tb_ed_img.click
|
||||
# define image_drag tb_ed_img.drag
|
||||
# define image_release tb_ed_img.release
|
||||
# define img_load_file tb_ed_img.load_file
|
||||
# define img_save_out tb_ed_img.save
|
||||
# define img_ensure tb_ed_img.ensure
|
||||
# define img_sel_reset tb_ed_img.sel_reset
|
||||
# define img_sel_commit tb_ed_img.sel_commit
|
||||
#endif
|
||||
|
||||
/* Configuracoes (settings) - UI desenhada pelo editor */
|
||||
void settings_show(Ed* ed);
|
||||
void settings_click(Ed* ed, float mx, float my);
|
||||
void settings_key(Ed* ed, int sc, bool ctrl);
|
||||
void settings_text(Ed* ed, const char* typed);
|
||||
void settings_scroll_by(Ed* ed, float dy);
|
||||
void settings_render(Ed* ed, TinyBlocks_RenderableBlock* rb);
|
||||
|
||||
#endif /* TB_EDITOR_INTERNAL_H */
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* TinyBlocks - tb_editor_modules.h
|
||||
* Carga dinamica das libraries privadas do editor (bundle) para permitir
|
||||
* HOT RELOAD: recompile so a parte que mudou (make -C libraries/... ) e o
|
||||
* editor em execucao recarrega o .so sem reiniciar.
|
||||
*
|
||||
* O estado da interface vive em Ed/Tab (no editor), por isso trocar o modulo
|
||||
* nao perde nada: so os codigos das funcoes sao substituidos.
|
||||
*/
|
||||
#ifndef TB_EDITOR_MODULES_H
|
||||
#define TB_EDITOR_MODULES_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <tinyblocks/tb_renderable_block.h>
|
||||
#include <tb_editor_widgets.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct Ed;
|
||||
struct Tab;
|
||||
typedef struct Ed Ed;
|
||||
typedef struct Tab Tab;
|
||||
|
||||
/* Visibilidade dos simbolos do editor usados pelos modulos */
|
||||
#define TB_ED_API __attribute__((visibility("default")))
|
||||
|
||||
#define TB_ED_MODULE_MAX 8
|
||||
|
||||
/* API da library privada tinyblocks-editor-widgets */
|
||||
typedef struct {
|
||||
TbEwColor (*col_mul) (TbEwColor, float);
|
||||
void (*fill_rect) (TinyBlocks_RenderableBlock*, float, float, float, float, TbEwColor);
|
||||
void (*fill_rrect) (TinyBlocks_RenderableBlock*, float, float, float, float, float, TbEwColor);
|
||||
void (*fill_circle) (TinyBlocks_RenderableBlock*, float, float, float, TbEwColor);
|
||||
void (*stroke_rect) (TinyBlocks_RenderableBlock*, float, float, float, float, float, TbEwColor);
|
||||
void (*stroke_circle)(TinyBlocks_RenderableBlock*, float, float, float, float, TbEwColor);
|
||||
void (*line) (TinyBlocks_RenderableBlock*, float, float, float, float, float, TbEwColor);
|
||||
void (*text_c) (TinyBlocks_RenderableBlock*, float, float, const char*, TbEwColor, float);
|
||||
float (*text_width) (const char*, float);
|
||||
bool (*in_rect) (float, float, float, float, float, float);
|
||||
} TbEdWidgetsApi;
|
||||
|
||||
/* API da library privada tinyblocks-editor-image */
|
||||
typedef struct {
|
||||
void (*view) (Ed*, TinyBlocks_RenderableBlock*);
|
||||
bool (*click) (Ed*, float, float);
|
||||
void (*drag) (Ed*, float, float);
|
||||
void (*release) (Ed*, float, float);
|
||||
void (*load_file) (Ed*, const char*, int);
|
||||
void (*save) (Ed*, const char*);
|
||||
void (*ensure) (Ed*, Tab*);
|
||||
void (*sel_reset) (Tab*);
|
||||
void (*sel_commit)(Tab*);
|
||||
} TbEdImageApi;
|
||||
|
||||
typedef struct {
|
||||
const char* name; /* tinyblocks-editor-image */
|
||||
const char* file; /* libtinyblocks-editor-image.so */
|
||||
void* handle;
|
||||
int64_t mtime;
|
||||
int ok;
|
||||
} TbEdModule;
|
||||
|
||||
typedef struct {
|
||||
TbEdModule list[TB_ED_MODULE_MAX];
|
||||
TbEdWidgetsApi widgets;
|
||||
int n;
|
||||
TbEdImageApi image;
|
||||
bool loaded;
|
||||
int reloads;
|
||||
char dir[512]; /* pasta dos modulos */
|
||||
char info[160]; /* ultimo evento (status bar) */
|
||||
} TbEdModules;
|
||||
|
||||
/* Tabelas vivas: o editor chama por aqui, entao a troca e instantanea */
|
||||
TB_ED_API extern TbEdImageApi tb_ed_img;
|
||||
TB_ED_API extern TbEdWidgetsApi tb_ed_w;
|
||||
|
||||
/* Carrega (ou recarrega) os modulos. Sempre que um .so muda de mtime
|
||||
recarrega todos os modulos, na ordem. Retorna true se algo foi carregado. */
|
||||
bool tb_ed_modules_load(Ed* ed);
|
||||
/* Verificacao barata (inotify/mtime): recarrega se algum .so mudou. */
|
||||
bool tb_ed_modules_check(Ed* ed);
|
||||
/* Esquece os modulos carregados (nao mexe no state do editor) */
|
||||
void tb_ed_modules_clear(void);
|
||||
/* Caminho de origem dos modulos (para mensagens/uso no Makefile) */
|
||||
const char* tb_ed_modules_dir(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* TB_EDITOR_MODULES_H */
|
||||
@@ -0,0 +1,42 @@
|
||||
# Makefile da library privada tinyblocks-editor-image
|
||||
# Bundle "tinyblocks-editor". Constroi .a e .so.
|
||||
CC := gcc
|
||||
BUILD := build
|
||||
|
||||
CFLAGS := -std=c11 -Wall -Wextra -pedantic \
|
||||
-DTB_EDITOR_IMAGE_BUILD \
|
||||
-D_POSIX_C_SOURCE=200809L \
|
||||
-I../../../../include -Iinclude \
|
||||
-I../../internal \
|
||||
-I../tinyblocks-editor-widgets/include \
|
||||
-I../../../tinyblocks-graphics/include \
|
||||
-I../../../tinyblocks-variables/include \
|
||||
-I../../../tinyblocks-blueprint/include \
|
||||
-I../../../tinyblocks-environ/include \
|
||||
-I../../../tinyblocks-api/include \
|
||||
-I../../../tinyblocks-libman/include \
|
||||
-I../../../tinyblocks-syntax/include
|
||||
|
||||
OBJS := $(BUILD)/tb_editor_image.o
|
||||
LIB_A := $(BUILD)/libtinyblocks-editor-image.a
|
||||
LIB_SO := $(BUILD)/libtinyblocks-editor-image.so
|
||||
|
||||
.PHONY: all static shared clean
|
||||
all: static shared
|
||||
static: $(LIB_A)
|
||||
shared: $(LIB_SO)
|
||||
|
||||
$(BUILD)/tb_editor_image.o: src/tb_editor_image.c include/tb_editor_image.h \
|
||||
../../internal/tb_editor_internal.h \
|
||||
../tinyblocks-editor-widgets/include/tb_editor_widgets.h
|
||||
@mkdir -p $(BUILD)
|
||||
$(CC) $(CFLAGS) -fPIC -c $< -o $@
|
||||
|
||||
$(LIB_A): $(OBJS)
|
||||
ar rcs $@ $^
|
||||
|
||||
$(LIB_SO): $(OBJS)
|
||||
$(CC) -shared -o $@ $^ -Wl,-z,lazy
|
||||
|
||||
clean:
|
||||
$(RM) -r $(BUILD)
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* TinyBlocks - tb_editor_image.h
|
||||
* Aba "Imagem" do editor (library privada do bundle tinyblocks-editor).
|
||||
*
|
||||
* O estado de cada aba mora em Tab (img_layers/img_sel/...), definido no
|
||||
* cabecalho interno do editor. Estas funcoes recebem o Ed dono da aba e
|
||||
* operam sempre na aba corrente (CT).
|
||||
*/
|
||||
#ifndef TB_EDITOR_IMAGE_H
|
||||
#define TB_EDITOR_IMAGE_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <tinyblocks/tb_renderable_block.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct Ed;
|
||||
struct Tab;
|
||||
typedef struct Ed Ed;
|
||||
typedef struct Tab Tab;
|
||||
|
||||
/* Desenha a aba de imagem inteira (painel, ferramentas, pagina, rodape) */
|
||||
void tb_editor_image_view(Ed* ed, TinyBlocks_RenderableBlock* rb);
|
||||
|
||||
/* Entrada: clique, arrasto e soltura do botao esquerdo */
|
||||
bool tb_editor_image_click (Ed* ed, float mx, float my);
|
||||
void tb_editor_image_drag (Ed* ed, float mx, float my);
|
||||
void tb_editor_image_release(Ed* ed, float mx, float my);
|
||||
|
||||
/* Arquivo: kind < 0 abre como documento, senao adiciona uma camada
|
||||
(0 = raster, 1 = vetor). Salvaguarda achata as camadas. */
|
||||
void tb_editor_image_load_file(Ed* ed, const char* path, int kind);
|
||||
void tb_editor_image_save (Ed* ed, const char* path);
|
||||
|
||||
/* Garante um documento vazio (usado ao criar a aba) e limpa selecao */
|
||||
void tb_editor_image_ensure (Ed* ed, Tab* T);
|
||||
void tb_editor_image_sel_reset (Tab* T);
|
||||
void tb_editor_image_sel_commit(Tab* T);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* TB_EDITOR_IMAGE_H */
|
||||
@@ -0,0 +1,17 @@
|
||||
# Editor de imagem do editor (bundle "tinyblocks-editor").
|
||||
[library]
|
||||
name = "tinyblocks-editor-image"
|
||||
bundle = "tinyblocks-editor"
|
||||
private = true
|
||||
version = "1.0.0"
|
||||
category = "Editor"
|
||||
description = "Aba Imagem: pintura com camadas raster/vetor"
|
||||
color = [255, 152, 0, 255]
|
||||
dark = [230, 119, 0, 255]
|
||||
|
||||
[build]
|
||||
sources = ["src/tb_editor_image.c"]
|
||||
includes = ["include"]
|
||||
shared = "build/libtinyblocks-editor-image.so"
|
||||
static = "build/libtinyblocks-editor-image.a"
|
||||
depends = ["tinyblocks-editor-widgets"]
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,31 @@
|
||||
# Makefile da library privada tinyblocks-editor-widgets
|
||||
# Bundle "tinyblocks-editor": vem junto com o editor.
|
||||
# Constroi build/libtinyblocks-editor-widgets.a e .so
|
||||
CC := gcc
|
||||
BUILD := build
|
||||
|
||||
CFLAGS := -std=c11 -Wall -Wextra -pedantic \
|
||||
-D_POSIX_C_SOURCE=200809L \
|
||||
-I../../../../include -Iinclude -I../../../tinyblocks-graphics/include
|
||||
|
||||
OBJS := $(BUILD)/tb_editor_widgets.o
|
||||
LIB_A := $(BUILD)/libtinyblocks-editor-widgets.a
|
||||
LIB_SO := $(BUILD)/libtinyblocks-editor-widgets.so
|
||||
|
||||
.PHONY: all static shared clean
|
||||
all: static shared
|
||||
static: $(LIB_A)
|
||||
shared: $(LIB_SO)
|
||||
|
||||
$(BUILD)/tb_editor_widgets.o: src/tb_editor_widgets.c include/tb_editor_widgets.h
|
||||
@mkdir -p $(BUILD)
|
||||
$(CC) $(CFLAGS) -fPIC -c $< -o $@
|
||||
|
||||
$(LIB_A): $(OBJS)
|
||||
ar rcs $@ $^
|
||||
|
||||
$(LIB_SO): $(OBJS)
|
||||
$(CC) -shared -o $@ $^
|
||||
|
||||
clean:
|
||||
$(RM) -r $(BUILD)
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* TinyBlocks - tb_editor_widgets.h
|
||||
* Library privada do editor: primitivas de desenho e "tema" (cores).
|
||||
*
|
||||
* E o tijolo mais baixo do editor: emite TinyBlocks_DrawCmd num
|
||||
* TinyBlocks_RenderableBlock e nao guarda estado. Nao conhece o editor
|
||||
* (Ed/Tab) nem o backend grafico, por isso pode ser usada por qualquer
|
||||
* library do bundle do editor (blocos, imagem, codigo, dialogo...).
|
||||
*/
|
||||
#ifndef TB_EDITOR_WIDGETS_H
|
||||
#define TB_EDITOR_WIDGETS_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <tinyblocks/tb_renderable_block.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Cor RGBA (0..1) */
|
||||
typedef struct { float r, g, b, a; } TbEwColor;
|
||||
|
||||
#define TB_EW_RGB(r,g,b) {(r)/255.0f,(g)/255.0f,(b)/255.0f,1.0f}
|
||||
#define TB_EW_RGBA(r,g,b,a) ((TbEwColor){(r)/255.0f,(g)/255.0f,(b)/255.0f,(a)/255.0f})
|
||||
|
||||
TbEwColor tb_ew_col_mul(TbEwColor c, float k);
|
||||
|
||||
/* Primitivas: espelham tb_draw_* mas com TbEwColor */
|
||||
void tb_ew_fill_rect (TinyBlocks_RenderableBlock* rb, float x, float y, float w, float h, TbEwColor c);
|
||||
void tb_ew_fill_rrect (TinyBlocks_RenderableBlock* rb, float x, float y, float w, float h, float rad, TbEwColor c);
|
||||
void tb_ew_fill_circle(TinyBlocks_RenderableBlock* rb, float cx, float cy, float rad, TbEwColor c);
|
||||
void tb_ew_stroke_rect(TinyBlocks_RenderableBlock* rb, float x, float y, float w, float h, float t, TbEwColor c);
|
||||
void tb_ew_stroke_circle(TinyBlocks_RenderableBlock* rb, float cx, float cy, float rad, float t, TbEwColor c);
|
||||
void tb_ew_line (TinyBlocks_RenderableBlock* rb, float x0, float y0, float x1, float y1, float w, TbEwColor c);
|
||||
/* Texto alinhado a esquerda em x, centrado verticalmente em cy */
|
||||
void tb_ew_text_c (TinyBlocks_RenderableBlock* rb, float x, float cy, const char* s, TbEwColor c, float fs);
|
||||
/* Largura real do texto, medida pelo backend grafico */
|
||||
float tb_ew_text_width(const char* s, float fs);
|
||||
|
||||
bool tb_ew_in_rect(float mx, float my, float x, float y, float w, float h);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* TB_EDITOR_WIDGETS_H */
|
||||
@@ -0,0 +1,17 @@
|
||||
# Widgets privados do editor (bundle "tinyblocks-editor").
|
||||
[library]
|
||||
name = "tinyblocks-editor-widgets"
|
||||
bundle = "tinyblocks-editor"
|
||||
private = true
|
||||
version = "1.0.0"
|
||||
category = "Editor"
|
||||
description = "Primitivas de desenho e tema do editor"
|
||||
color = [76, 151, 255, 255]
|
||||
dark = [61, 121, 204, 255]
|
||||
|
||||
[build]
|
||||
sources = ["src/tb_editor_widgets.c"]
|
||||
includes = ["include"]
|
||||
shared = "build/libtinyblocks-editor-widgets.so"
|
||||
static = "build/libtinyblocks-editor-widgets.a"
|
||||
depends = []
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* TinyBlocks - tb_editor_widgets.c
|
||||
* Implementacao das primitivas de desenho do editor. Sem estado: apenas
|
||||
* traduz chamadas em TinyBlocks_DrawCmd.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <tb_graphics.h>
|
||||
#include "tb_editor_widgets.h"
|
||||
|
||||
TbEwColor tb_ew_col_mul(TbEwColor c, float k) {
|
||||
TbEwColor r;
|
||||
r.r = c.r * k; r.g = c.g * k; r.b = c.b * k; r.a = c.a;
|
||||
return r;
|
||||
}
|
||||
|
||||
void tb_ew_fill_rect(TinyBlocks_RenderableBlock* rb, float x, float y, float w, float h, TbEwColor c)
|
||||
{ tb_draw_fill_rect(rb, x, y, w, h, c.r, c.g, c.b, c.a); }
|
||||
|
||||
void tb_ew_fill_rrect(TinyBlocks_RenderableBlock* rb, float x, float y, float w, float h, float rad, TbEwColor c)
|
||||
{ tb_draw_fill_rrect(rb, x, y, w, h, rad < 0 ? 0 : rad, c.r, c.g, c.b, c.a); }
|
||||
|
||||
void tb_ew_fill_circle(TinyBlocks_RenderableBlock* rb, float cx, float cy, float rad, TbEwColor c)
|
||||
{ tb_draw_fill_circle(rb, cx, cy, rad, c.r, c.g, c.b, c.a); }
|
||||
|
||||
void tb_ew_stroke_rect(TinyBlocks_RenderableBlock* rb, float x, float y, float w, float h, float t, TbEwColor c)
|
||||
{ tb_draw_stroke_rect(rb, x, y, w, h, t, c.r, c.g, c.b, c.a); }
|
||||
|
||||
void tb_ew_stroke_circle(TinyBlocks_RenderableBlock* rb, float cx, float cy, float rad, float t, TbEwColor c)
|
||||
{ tb_draw_stroke_circle(rb, cx, cy, rad, t, c.r, c.g, c.b, c.a); }
|
||||
|
||||
void tb_ew_line(TinyBlocks_RenderableBlock* rb, float x0, float y0, float x1, float y1, float w, TbEwColor c)
|
||||
{ tb_draw_stroke_line(rb, x0, y0, x1, y1, w, c.r, c.g, c.b, c.a); }
|
||||
|
||||
void tb_ew_text_c(TinyBlocks_RenderableBlock* rb, float x, float cy, const char* s, TbEwColor c, float fs) {
|
||||
if (!s || !s[0]) return;
|
||||
tb_draw_text(rb, x, cy + fs * 0.36f, s, fs, c.r, c.g, c.b, c.a);
|
||||
}
|
||||
|
||||
float tb_ew_text_width(const char* s, float fs) {
|
||||
return tb_graphics_measure_text(s, fs);
|
||||
}
|
||||
|
||||
bool tb_ew_in_rect(float mx, float my, float x, float y, float w, float h)
|
||||
{ return mx >= x && mx < x + w && my >= y && my < y + h; }
|
||||
@@ -7,9 +7,12 @@ description = "Editor visual e blocos compostos"
|
||||
color = [255, 102, 128, 255]
|
||||
dark = [255, 51, 85, 255]
|
||||
|
||||
# O editor e um bundle: as libraries privadas em libraries/ vem junto.
|
||||
bundle_members = ["tinyblocks-editor-widgets", "tinyblocks-editor-image"]
|
||||
|
||||
[build]
|
||||
sources = ["src/tb_editor.c", "src/tb_stage_widget.c"]
|
||||
includes = ["include"]
|
||||
shared = "build/libtinyblocks-editor.so"
|
||||
static = "build/libtinyblocks-editor.a"
|
||||
depends = []
|
||||
depends = ["tinyblocks-editor-widgets", "tinyblocks-editor-image"]
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,209 @@
|
||||
/*
|
||||
* TinyBlocks - tb_editor_modules.c
|
||||
* Carrega as libraries privadas do editor (bundle) por dlopen, usando o
|
||||
* tinyblocks-api como gestor de modulos, para permitir HOT RELOAD:
|
||||
*
|
||||
* 1. edite uma library privada (ex: libraries/tinyblocks-editor-image)
|
||||
* 2. rode "make" (so a parte que mudou e recompilada)
|
||||
* 3. o editor em execucao detecta (inotify/mtime) e recarrega sozinho
|
||||
*
|
||||
* O estado da interface vive em Ed/Tab (no editor), entao trocar o codigo
|
||||
* nao perde nada. As chamadas passam por tabelas de ponteiros (tb_ed_w,
|
||||
* tb_ed_img), por isso a troca vale imediatamente para o editor inteiro.
|
||||
*/
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "../internal/tb_editor_internal.h"
|
||||
|
||||
/* Este arquivo nomeia os campos das tabelas (w.fill_rect, ...), entao os
|
||||
apelidos curtos do editor atrapalham: remove-os aqui. */
|
||||
#undef col_mul
|
||||
#undef rb_fill_rect
|
||||
#undef rb_fill_rrect
|
||||
#undef rb_fill_circle
|
||||
#undef rb_stroke_rect
|
||||
#undef rb_stroke_circle
|
||||
#undef rb_line
|
||||
#undef rb_text_c
|
||||
#undef tw
|
||||
#undef in_rect
|
||||
|
||||
/* Tabelas vivas (preenchidas aqui, usadas pelo editor) */
|
||||
TbEdImageApi tb_ed_img;
|
||||
TbEdWidgetsApi tb_ed_w;
|
||||
|
||||
/* Ordem = dependencia: widgets e a base (a imagem usa as primitivas dela) */
|
||||
static const char* s_mod_name[2] = { "tinyblocks-editor-widgets",
|
||||
"tinyblocks-editor-image" };
|
||||
static const char* s_mod_file[2] = { "libtinyblocks-editor-widgets.so",
|
||||
"libtinyblocks-editor-image.so" };
|
||||
static const int s_mod_n = 2;
|
||||
|
||||
static char s_dir[512] = "";
|
||||
|
||||
const char* tb_ed_modules_dir(void) { return s_dir; }
|
||||
|
||||
/* -- utilidades ---------------------------------------------------------- */
|
||||
|
||||
static bool file_exists(const char* p) {
|
||||
struct stat st;
|
||||
return p && stat(p, &st) == 0 && S_ISREG(st.st_mode);
|
||||
}
|
||||
|
||||
static void dir_of_exe(char* out, size_t cap) {
|
||||
char buf[512];
|
||||
ssize_t n = readlink("/proc/self/exe", buf, sizeof(buf) - 1);
|
||||
if (n <= 0) { snprintf(out, cap, "."); return; }
|
||||
buf[n] = 0;
|
||||
char* slash = strrchr(buf, '/');
|
||||
if (slash) *slash = 0;
|
||||
snprintf(out, cap, "%s", buf);
|
||||
}
|
||||
|
||||
/* Procura o .so nos lugares conhecidos (arvore do projeto, AppImage, cwd) */
|
||||
static bool find_module(const char* name, const char* file, char* out, size_t cap) {
|
||||
char exe[512];
|
||||
dir_of_exe(exe, sizeof(exe));
|
||||
const char* env = getenv("TINYBLOCKS_ED_MODULES");
|
||||
static char c[6][1024];
|
||||
snprintf(c[0], sizeof(c[0]), "libraries/tinyblocks-editor/libraries/%s/build/%s", name, file);
|
||||
snprintf(c[1], sizeof(c[1]), "%s/../libraries/tinyblocks-editor/libraries/%s/build/%s",
|
||||
exe, name, file);
|
||||
snprintf(c[2], sizeof(c[2]), "%s/../lib/tinyblocks-editor/%s", exe, file);
|
||||
snprintf(c[3], sizeof(c[3]), "%s/%s", exe, file);
|
||||
snprintf(c[4], sizeof(c[4]), "%s/%s", s_dir[0] ? s_dir : ".", file);
|
||||
if (env && env[0]) snprintf(c[5], sizeof(c[5]), "%s/%s", env, file);
|
||||
else c[5][0] = 0;
|
||||
for (int i = 0; i < 6; i++) {
|
||||
if (!c[i][0]) continue;
|
||||
if (file_exists(c[i])) {
|
||||
snprintf(out, cap, "%s", c[i]);
|
||||
char* sl = strrchr(out, '/');
|
||||
if (sl) { *sl = 0; snprintf(s_dir, sizeof(s_dir), "%s", out); *sl = '/'; }
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Copia o endereco do simbolo para o ponteiro de funcao (sem casts fora de
|
||||
padrao: dlsym devolve void*, o ponteiro de funcao tem o mesmo tamanho). */
|
||||
static void sym_fn(void* dst, const char* mod, const char* name) {
|
||||
void* p = tb_api_code_symbol(mod, name);
|
||||
memcpy(dst, &p, sizeof(p));
|
||||
}
|
||||
|
||||
/* Resolve as funcoes da library de widgets */
|
||||
static bool resolve_widgets(void) {
|
||||
TbEdWidgetsApi w;
|
||||
memset(&w, 0, sizeof(w));
|
||||
sym_fn(&w.col_mul, "tinyblocks-editor-widgets", "tb_ew_col_mul");
|
||||
sym_fn(&w.fill_rect, "tinyblocks-editor-widgets", "tb_ew_fill_rect");
|
||||
sym_fn(&w.fill_rrect, "tinyblocks-editor-widgets", "tb_ew_fill_rrect");
|
||||
sym_fn(&w.fill_circle, "tinyblocks-editor-widgets", "tb_ew_fill_circle");
|
||||
sym_fn(&w.stroke_rect, "tinyblocks-editor-widgets", "tb_ew_stroke_rect");
|
||||
sym_fn(&w.stroke_circle, "tinyblocks-editor-widgets", "tb_ew_stroke_circle");
|
||||
sym_fn(&w.line, "tinyblocks-editor-widgets", "tb_ew_line");
|
||||
sym_fn(&w.text_c, "tinyblocks-editor-widgets", "tb_ew_text_c");
|
||||
sym_fn(&w.text_width, "tinyblocks-editor-widgets", "tb_ew_text_width");
|
||||
sym_fn(&w.in_rect, "tinyblocks-editor-widgets", "tb_ew_in_rect");
|
||||
bool ok = w.col_mul && w.fill_rect && w.fill_rrect && w.fill_circle && w.stroke_rect &&
|
||||
w.stroke_circle && w.line && w.text_c && w.text_width && w.in_rect;
|
||||
if (ok) tb_ed_w = w;
|
||||
return ok;
|
||||
}
|
||||
|
||||
/* Resolve as funcoes da aba Imagem */
|
||||
static bool resolve_image(void) {
|
||||
TbEdImageApi a;
|
||||
memset(&a, 0, sizeof(a));
|
||||
sym_fn(&a.view, "tinyblocks-editor-image", "tb_editor_image_view");
|
||||
sym_fn(&a.click, "tinyblocks-editor-image", "tb_editor_image_click");
|
||||
sym_fn(&a.drag, "tinyblocks-editor-image", "tb_editor_image_drag");
|
||||
sym_fn(&a.release, "tinyblocks-editor-image", "tb_editor_image_release");
|
||||
sym_fn(&a.load_file, "tinyblocks-editor-image", "tb_editor_image_load_file");
|
||||
sym_fn(&a.save, "tinyblocks-editor-image", "tb_editor_image_save");
|
||||
sym_fn(&a.ensure, "tinyblocks-editor-image", "tb_editor_image_ensure");
|
||||
sym_fn(&a.sel_reset, "tinyblocks-editor-image", "tb_editor_image_sel_reset");
|
||||
sym_fn(&a.sel_commit, "tinyblocks-editor-image", "tb_editor_image_sel_commit");
|
||||
bool ok = a.view && a.click && a.drag && a.release && a.load_file && a.save &&
|
||||
a.ensure && a.sel_reset && a.sel_commit;
|
||||
if (ok) tb_ed_img = a;
|
||||
return ok;
|
||||
}
|
||||
|
||||
/* -- carga --------------------------------------------------------------- */
|
||||
|
||||
bool tb_ed_modules_load(Ed* ed) {
|
||||
if (!tb_api_runtime()) tb_api_init(ed->rt);
|
||||
tb_ed_modules_clear();
|
||||
|
||||
/* ordem de dependencia: widgets antes da imagem */
|
||||
for (int i = 0; i < s_mod_n; i++) {
|
||||
char path[1024];
|
||||
if (!find_module(s_mod_name[i], s_mod_file[i], path, sizeof(path))) {
|
||||
snprintf(ed->mods.info, sizeof(ed->mods.info),
|
||||
"modulo nao encontrado: %s", s_mod_file[i]);
|
||||
return false;
|
||||
}
|
||||
if (tb_api_code_load(s_mod_name[i], path) < 0) {
|
||||
snprintf(ed->mods.info, sizeof(ed->mods.info), "%.120s", tb_api_last_error());
|
||||
return false;
|
||||
}
|
||||
ed->mods.list[ed->mods.n].name = s_mod_name[i];
|
||||
ed->mods.list[ed->mods.n].file = s_mod_file[i];
|
||||
ed->mods.list[ed->mods.n].ok = 1;
|
||||
ed->mods.n++;
|
||||
}
|
||||
bool ok = resolve_widgets() && resolve_image();
|
||||
ed->mods.loaded = ok;
|
||||
if (ok) {
|
||||
snprintf(ed->mods.info, sizeof(ed->mods.info),
|
||||
"Bundle do editor carregado (%.100s)", tb_api_code_count() ? s_dir : "?");
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
void tb_ed_modules_clear(void) {
|
||||
tb_api_code_unload_all();
|
||||
memset(&tb_ed_img, 0, sizeof(tb_ed_img));
|
||||
memset(&tb_ed_w, 0, sizeof(tb_ed_w));
|
||||
}
|
||||
|
||||
bool tb_ed_modules_check(Ed* ed) {
|
||||
if (!ed->mods.loaded) return false;
|
||||
if (!tb_api_code_changed()) return false;
|
||||
|
||||
/* Recarrega o bundle inteiro, em ordem: descarrega na ordem inversa
|
||||
(para as dependencias soltarem) e carrega na ordem de dependencia. */
|
||||
int n = tb_api_code_count();
|
||||
char names[8][64], paths[8][512];
|
||||
int keep = n < 8 ? n : 8;
|
||||
for (int i = 0; i < keep; i++) {
|
||||
snprintf(names[i], sizeof(names[i]), "%s", tb_api_code_name(i));
|
||||
snprintf(paths[i], sizeof(paths[i]), "%s", tb_api_code_path(i));
|
||||
}
|
||||
tb_api_code_reload_all();
|
||||
(void)names; (void)paths;
|
||||
|
||||
ed->mods.n = 0;
|
||||
for (int i = 0; i < s_mod_n; i++) {
|
||||
ed->mods.list[ed->mods.n].name = s_mod_name[i];
|
||||
ed->mods.list[ed->mods.n].file = s_mod_file[i];
|
||||
ed->mods.list[ed->mods.n].ok = 1;
|
||||
ed->mods.n++;
|
||||
}
|
||||
bool ok = resolve_widgets() && resolve_image();
|
||||
ed->mods.loaded = ok;
|
||||
ed->mods.reloads++;
|
||||
snprintf(ed->mods.info, sizeof(ed->mods.info), "Editor recarregado (%d)%s",
|
||||
ed->mods.reloads, ok ? "" : " - FALHOU");
|
||||
snprintf(ed->hot_status, sizeof(ed->hot_status), "%s", ed->mods.info);
|
||||
ed->hot_status_ok = ok;
|
||||
return true;
|
||||
}
|
||||
@@ -35,6 +35,8 @@ typedef struct TbLibmanEntry {
|
||||
char shared[TBLM_PATH_LEN]; /* caminho do .so (pode nao existir) */
|
||||
char staticlib[TBLM_PATH_LEN]; /* caminho do .a */
|
||||
char depends[160];
|
||||
char bundle[48]; /* grupo (ex: "tinyblocks-editor") */
|
||||
bool private_lib; /* library interna do bundle (nao listar)*/
|
||||
} TbLibmanEntry;
|
||||
|
||||
/* -- Ciclo de vida --- */
|
||||
@@ -63,6 +65,9 @@ TB_API int tb_libman_install(int i); /* tb_api_load(entry->shared) */
|
||||
* Retorna quantos indices foram escritos (ate 'max'). */
|
||||
TB_API int tb_libman_search(const char* query, const char* category,
|
||||
int* out, int max);
|
||||
/* Igual, mas permite incluir as libraries privadas de bundle (private=true). */
|
||||
TB_API int tb_libman_search_ex(const char* query, const char* category,
|
||||
bool include_private, int* out, int max);
|
||||
/* Categorias distintas encontradas (sem repeticao). Retorna n. */
|
||||
TB_API int tb_libman_categories(char out[][48], int max);
|
||||
|
||||
|
||||
@@ -55,6 +55,9 @@ static void entry_from_toml(const char* tomlpath, const char* dir) {
|
||||
copy_str(e->description, sizeof(e->description),
|
||||
tb_toml_str(doc, "library.description", ""));
|
||||
copy_str(e->depends, sizeof(e->depends), tb_toml_str(doc, "build.depends", ""));
|
||||
copy_str(e->bundle, sizeof(e->bundle), tb_toml_str(doc, "library.bundle", ""));
|
||||
e->private_lib = tb_toml_int(doc, "library.private", 0) != 0 ||
|
||||
strcmp(tb_toml_str(doc, "library.private", "0"), "true") == 0;
|
||||
|
||||
int col[4];
|
||||
tb_toml_int_array(doc, "library.color", col, 4, 255);
|
||||
@@ -185,14 +188,16 @@ static bool contains_ci(const char* hay, const char* needle) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int tb_libman_search(const char* query, const char* category,
|
||||
int* out, int max) {
|
||||
int n = 0;
|
||||
int tb_libman_search_ex(const char* query, const char* category,
|
||||
bool include_private, int* out, int max) {
|
||||
bool allcat = !category || !category[0] || strcmp(category, "Tudo") == 0;
|
||||
int n = 0;
|
||||
for (int i = 0; i < s_n && n < max; i++) {
|
||||
const TbLibmanEntry* e = &s_e[i];
|
||||
if (e->private_lib && !include_private) continue;
|
||||
if (!allcat && strcmp(e->category, category) != 0) continue;
|
||||
if (!contains_ci(e->name, query) &&
|
||||
if (query && query[0] &&
|
||||
!contains_ci(e->name, query) &&
|
||||
!contains_ci(e->category, query) &&
|
||||
!contains_ci(e->description, query)) continue;
|
||||
out[n++] = i;
|
||||
@@ -200,6 +205,10 @@ int tb_libman_search(const char* query, const char* category,
|
||||
return n;
|
||||
}
|
||||
|
||||
int tb_libman_search(const char* query, const char* category, int* out, int max) {
|
||||
return tb_libman_search_ex(query, category, false, out, max);
|
||||
}
|
||||
|
||||
int tb_libman_categories(char out[][48], int max) {
|
||||
int n = 0;
|
||||
for (int i = 0; i < s_n && n < max; i++) {
|
||||
|
||||
@@ -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