Editor: animacoes M3, compartilhar/receber blocos por QR e ver codigo-fonte
- Animacoes (curvas do M3): blocos criados por codigo surgem em cascata, apagados saem de cena (fantasma que encolhe), os de baixo deslizam ao mudar de lugar na pilha; rolagem e zoom suaves. TINYBLOCKS_REDUCE_MOTION=1 desliga (o harness usa). Texto respeita a opacidade no backend SDL2. - Botao direito: "Ver codigo-fonte" (funcao C do bloco na aba de codigo), "Compartilhar pilha/blueprint (QR)" (scratchblocks em partes de 220 bytes, "TB1|id|parte|total|", em loop de 1 s) e "Receber blocos (QR)" (camera, partes em qualquer ordem, importa onde clicou). - tinyblocks-qr: qrcodegen (MIT) + quirc (ISC) e camera em cinza: V4L2 no Linux, Camera2 do NDK no Android (sem Java), nada no Windows. - Captura de desenvolvimento: TINYBLOCKS_SHOT_COUNT/STEP salvam sequencias. - Testes: test-qr (ida e volta) e harness cenario 35. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
70c819393c
commit
4f6a68c22c
31 files changed
+5789
-49
No files matched your search
@@ -40,6 +40,9 @@ TB_API void tb_editor_preload(const char* path);
|
||||
* NULL se a acessibilidade estiver desligada (TINYBLOCKS_A11Y=0). */
|
||||
typedef struct TinyBlocks_A11yTree TinyBlocks_A11yTree;
|
||||
TB_API TinyBlocks_A11yTree* tb_editor_accessible(TinyBlocks_Block* scene);
|
||||
/* Para testes: entrega ao leitor de QR aberto um texto como se a camera o
|
||||
* tivesse lido ("Receber blocos") */
|
||||
TB_API void tb_editor_qr_feed(TinyBlocks_Block* scene, const char* text);
|
||||
|
||||
/* Servidor MCP do editor (tb_mcp_server.h, da tinyblocks-mcp-server): as
|
||||
* ferramentas para agentes lerem e editarem as pilhas. Escuta em
|
||||
|
||||
@@ -552,6 +552,20 @@ typedef struct {
|
||||
float x, w;
|
||||
} Part;
|
||||
|
||||
/* Rolagem animada: de `from` a `to` a partir de t0 (curva standard do M3) */
|
||||
typedef struct { bool on; float from, to; unsigned t0; } ScrollAnim;
|
||||
|
||||
/* Bloco apagado saindo de cena: os comandos de desenho dele (na tela) */
|
||||
#define GHOST_MAX 8
|
||||
typedef struct {
|
||||
TinyBlocks_DrawCmd* cmds;
|
||||
int n;
|
||||
float cx, cy;
|
||||
unsigned t0;
|
||||
bool clip;
|
||||
float clip_r[4];
|
||||
} Ghost;
|
||||
|
||||
typedef struct {
|
||||
bool used;
|
||||
bool dragging;
|
||||
@@ -586,6 +600,13 @@ typedef struct {
|
||||
const void* jst_T;
|
||||
int jst_bi, jst_depth;
|
||||
uint32_t jst_gen;
|
||||
/* animacao: deslize ao mudar de lugar na pilha (offset que vai a zero) e
|
||||
surgir (blocos criados por codigo); l_* = o ultimo layout visto */
|
||||
float an_dx, an_dy;
|
||||
unsigned an_t0, ap_t0;
|
||||
bool l_ok;
|
||||
int l_root;
|
||||
float l_x, l_y, l_rx, l_ry;
|
||||
} EdBlock;
|
||||
|
||||
/* Um trecho colorido do editor de codigo (vindo do tinyblocks-syntax). */
|
||||
@@ -690,7 +711,8 @@ typedef enum { SN_NONE, SN_NEXT, SN_SUB, SN_ABOVE, SN_ARG, SN_STACK } SnapKind;
|
||||
enum { CM_DUPLICATE, CM_DELETE, CM_EDIT_DEF, CM_CLEANUP, CM_NEW_COMPOSITE,
|
||||
CM_EXP_JSON, CM_EXP_XML, CM_EXP_CSV, CM_EXP_SB, CM_PASTE_SB,
|
||||
CM_GROUP_NEW, CM_GROUP_STACK, CM_GROUP_RENAME, CM_GROUP_COLOR, CM_GROUP_DELETE,
|
||||
CM_MB_OPEN, CM_MB_SAVE, CM_MB_EXPORT, CM_MB_LIBMAN, CM_MB_LIB, CM_MB_CFG };
|
||||
CM_MB_OPEN, CM_MB_SAVE, CM_MB_EXPORT, CM_MB_LIBMAN, CM_MB_LIB, CM_MB_CFG,
|
||||
CM_SOURCE, CM_SHARE_STACK, CM_SHARE_TAB, CM_RECEIVE };
|
||||
|
||||
/* 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,
|
||||
@@ -1048,6 +1070,35 @@ typedef struct Ed {
|
||||
/* Servidor MCP: agentes leem e editam as pilhas por ferramentas */
|
||||
struct TbMcpServer* mcp;
|
||||
|
||||
/* Animacoes (curvas do M3). anim_off: TINYBLOCKS_REDUCE_MOTION=1 (e os
|
||||
testes): tudo vai direto ao fim */
|
||||
unsigned t_ms; /* relogio do quadro */
|
||||
bool anim_off;
|
||||
bool appear_batch; /* blocos criados agora surgem animados */
|
||||
int appear_k; /* ordem dentro do lote (cascata) */
|
||||
ScrollAnim sa_ws_x, sa_ws_y, sa_fly, sa_cat, sa_lm, sa_st;
|
||||
int sa_ws_tab;
|
||||
struct { bool on; float from, to, ax, ay; unsigned t0; int tab; } za; /* zoom */
|
||||
Ghost ghosts[GHOST_MAX]; /* blocos apagados saindo de cena */
|
||||
int ghost_n;
|
||||
|
||||
/* QR: compartilhar (painel com os QR em loop, 1 s cada) e receber (camera) */
|
||||
bool qrs_open;
|
||||
char* qrs_text; /* scratchblocks inteiro */
|
||||
int qrs_n; /* quantas partes */
|
||||
unsigned qrs_t0;
|
||||
char qrs_id[8];
|
||||
char qrs_title[64];
|
||||
bool qrr_open, qrr_cam;
|
||||
struct TbQrReader* qrr_reader;
|
||||
unsigned char* qrr_gray;
|
||||
TinyBlocks_Image* qrr_img; /* previa da camera */
|
||||
char qrr_id[8];
|
||||
int qrr_n, qrr_got;
|
||||
char** qrr_part;
|
||||
float qrr_x, qrr_y; /* onde os blocos recebidos entram */
|
||||
char qrr_msg[200];
|
||||
|
||||
/* Edicao de texto (te_*): o campo em edicao tem cursor e selecao; o
|
||||
editor de codigo tem os dele (code_caret/code_anchor). Alcas e barra
|
||||
de acoes (toque) servem aos dois (te_owner). */
|
||||
@@ -1090,6 +1141,8 @@ static Ed* g_active_ed TB_EW_UNUSED = NULL;
|
||||
void bubble_clear(Ed* ed);
|
||||
|
||||
void palette_rebuild(Ed* ed);
|
||||
/* Bloco (ou a pilha a partir dele) saindo de cena: fantasma animado */
|
||||
void ghost_capture(Ed* ed, Tab* T, int bi, bool chain, float wsx, float wsy, bool clip);
|
||||
void utf8_pop(char* s);
|
||||
void append_text(char* dst, size_t cap, const char* add);
|
||||
/* Campo de texto em edicao (cursor, selecao, Ctrl+A/C/X/V): as teclas e o
|
||||
|
||||
@@ -116,6 +116,10 @@
|
||||
#define MI_REFRESH 0xe5d5
|
||||
#define MI_SAVE 0xe161
|
||||
#define MI_SEARCH 0xef7a
|
||||
#define MI_SHARE 0xe80d
|
||||
#define MI_QR_CODE 0xe00a
|
||||
#define MI_QR_SCANNER 0xf206
|
||||
#define MI_SOURCE 0xf1c8
|
||||
#define MI_SELECT 0xf74d
|
||||
#define MI_SETTINGS 0xe8b8
|
||||
#define MI_STOP 0xe047
|
||||
@@ -130,6 +134,28 @@
|
||||
#define MI_ZOOM_IN 0xe8ff
|
||||
#define MI_ZOOM_OUT 0xe900
|
||||
|
||||
/* == Movimento: curvas do M3 (cubic-bezier, como no CSS) === */
|
||||
static inline float m3_bezier(float x1, float y1, float x2, float y2, float t) {
|
||||
if (t <= 0.f) return 0.f;
|
||||
if (t >= 1.f) return 1.f;
|
||||
float lo = 0.f, hi = 1.f, u = t;
|
||||
for (int i = 0; i < 24; i++) { /* acha u com x(u) = t (bissecao) */
|
||||
u = (lo + hi) * 0.5f;
|
||||
float iu = 1.f - u;
|
||||
float x = 3.f * iu * iu * u * x1 + 3.f * iu * u * u * x2 + u * u * u;
|
||||
if (x < t) lo = u; else hi = u;
|
||||
}
|
||||
float iu = 1.f - u;
|
||||
return 3.f * iu * iu * u * y1 + 3.f * iu * u * u * y2 + u * u * u;
|
||||
}
|
||||
#define M3_EASE_STANDARD(t) m3_bezier(0.2f, 0.f, 0.f, 1.f, (t))
|
||||
#define M3_EASE_EMPH_DECEL(t) m3_bezier(0.05f, 0.7f, 0.1f, 1.f, (t)) /* entrar */
|
||||
#define M3_EASE_EMPH_ACCEL(t) m3_bezier(0.3f, 0.f, 0.8f, 0.15f, (t)) /* sair */
|
||||
#define M3_DUR_SCROLL 260u /* ms */
|
||||
#define M3_DUR_SLIDE 280u
|
||||
#define M3_DUR_APPEAR 380u
|
||||
#define M3_DUR_EXIT 220u
|
||||
|
||||
/* == Utilitarios === */
|
||||
static inline Col m3_alpha(Col c, float a) { c.a = a; return c; }
|
||||
|
||||
|
||||
Reference in new issue
Block a user