Headers do editor em include/, com a API privada atrás de um guard
- tb_editor_internal.h e tb_editor_modules.h (antes em internal/) e tb_stage_widget.h (antes em src/) foram para libraries/tinyblocks-editor/include/. - Os três são API privada: só compilam com TB_EDITOR_PRIVATE_API (o editor, os módulos do bundle e o harness definem); fora disso um #error manda incluir tb_editor.h. - Includes viraram <tb_editor_internal.h> etc.; Makefiles sem -Isrc / -Iinternal; library.toml descreve os fontes e o define. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b610a05904
commit
81f198f189
13 files changed
+44
-21
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
/* API PRIVADA do editor: so o editor, os modulos do bundle dele
|
||||
(libraries/tinyblocks-editor-*) e o harness de testes compilam com
|
||||
TB_EDITOR_PRIVATE_API. Para usar o editor, inclua tb_editor.h. */
|
||||
#ifndef TB_EDITOR_PRIVATE_API
|
||||
# error "API privada do editor: inclua tb_editor.h (ou compile com -DTB_EDITOR_PRIVATE_API)"
|
||||
#endif
|
||||
|
||||
#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*);
|
||||
void (*zoom) (Ed*, float, float, int); /* roda do mouse = zoom */
|
||||
} TbEdImageApi;
|
||||
|
||||
/* API da library privada tinyblocks-editor-files (explorador de arquivos) */
|
||||
typedef struct {
|
||||
void (*open) (Ed*, int, const char*);
|
||||
void (*close) (Ed*);
|
||||
void (*view) (Ed*, TinyBlocks_RenderableBlock*);
|
||||
bool (*click) (Ed*, float, float);
|
||||
void (*key) (Ed*, int, bool);
|
||||
void (*text) (Ed*, const char*);
|
||||
void (*scroll)(Ed*, float);
|
||||
} TbEdFilesApi;
|
||||
|
||||
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;
|
||||
TB_ED_API extern TbEdFilesApi tb_ed_files;
|
||||
|
||||
/* 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,20 @@
|
||||
/*
|
||||
* TinyBlocks - tb_stage_widget.h (editor)
|
||||
* Widget Editor.Stage: exibe o palco logico do runtime (tb_stage.h).
|
||||
*/
|
||||
#ifndef TINYBLOCKS_EDITOR_STAGE_WIDGET_H
|
||||
#define TINYBLOCKS_EDITOR_STAGE_WIDGET_H
|
||||
|
||||
/* API PRIVADA do editor: so o editor, os modulos do bundle dele
|
||||
(libraries/tinyblocks-editor-*) e o harness de testes compilam com
|
||||
TB_EDITOR_PRIVATE_API. Para usar o editor, inclua tb_editor.h. */
|
||||
#ifndef TB_EDITOR_PRIVATE_API
|
||||
# error "API privada do editor: inclua tb_editor.h (ou compile com -DTB_EDITOR_PRIVATE_API)"
|
||||
#endif
|
||||
|
||||
#include <tinyblocks/tinyblocks.h>
|
||||
|
||||
/* Registra o TypeBlock Editor.Stage na library do editor */
|
||||
bool tb_stage_register(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib);
|
||||
|
||||
#endif /* TINYBLOCKS_EDITOR_STAGE_WIDGET_H */
|
||||
Reference in new issue
Block a user