Files
tinyblocks/libraries/tinyblocks-editor/include/tb_editor_modules.h
T
mguinhosandClaude Opus 5.5 0cb2019704 Editor: redesign visual no Material 3 (Roboto, Material Symbols, cores de sempre)
- Fontes em assets/fonts (Roboto Regular/Medium, Material Symbols contorno e
  preenchido; Apache 2.0). TB_DRAW_TEXT escolhe a fonte pelo param
  (tb_draw_text_font, TB_FONT_*); backend SDL2 com cache por familia e
  DejaVu de reserva. Pacotes AppImage/Android/Windows levam as fontes.
- tb_editor_m3.h: papeis de cor do M3 sobre a paleta do editor, formas,
  tipografia, camadas de estado, elevacao, icones e componentes (botoes,
  icon button, menu, campo, dialogo, chip, snackbar, switch).
- Top app bar, abas primarias, navigation rail das categorias, FAB de
  extensoes, palco, saida, menus, snackbars, dialogos, explorador,
  Bibliotecas, Configuracoes, previa scratchblocks, editores de codigo e
  de imagem no estilo M3.
- Widgets: icon, text_f e shadow. Backend: TINYBLOCKS_SHOT salva a janela
  (conferir o visual); editor: TINYBLOCKS_OPEN abre uma tela no inicio.
- Console: linhas roladas continuam na arvore acessivel (OFFSCREEN).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 21:34:04 -03:00

120 lines
4.5 KiB
C

/*
* 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);
void (*text_f) (TinyBlocks_RenderableBlock*, float, float, const char*, TbEwColor, float, int);
void (*icon) (TinyBlocks_RenderableBlock*, float, float, unsigned, float, TbEwColor, bool);
void (*shadow) (TinyBlocks_RenderableBlock*, float, float, float, float, float, int);
} 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 */