Tipo diz o texto do seu bloco-handle; paleta sem teto de 192 itens

value_text no TypeBlock: um bloco-handle (TB_VALUE_BLOCK) aparece como
a library quiser ("tensor [3, 32, 32]") em vez de "[bloco Tipo]".
fly_items vira vetor que cresce: as libraries de categoria ja ocupavam
185 dos 192 itens e as variaveis empurravam categorias inteiras para fora.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mguinhosandClaude Opus 5.5 committed 2026-10-23 22:44:21 -03:00
1 parent 34c9a39c2c
commit 3dd132d12d
6 files changed
+52 -9

No files matched your search

@@ -187,7 +187,6 @@ enum { IT_SEL = 0, IT_BRUSH, IT_LINE, IT_RECT, IT_ELLIPSE,
#define MAX_GROUPS 32
#define GRP_HEAD_H 28 /* faixa do titulo (arrastar = mover tudo) */
#define GRP_GRIP 16 /* canto de baixo a direita: redimensionar */
#define MAX_FLY 192
#define MAX_CATS 24
#define MAX_CALL_DEPTH 32
#define MAX_RUN_BLOCKS 200000
@@ -791,8 +790,8 @@ typedef struct Ed {
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;
FlyItem* fly_items; /* itens da paleta (vetor que cresce) */
int fly_n, fly_cap;
float fly_scroll, fly_total_h;
Tab tabs[MAX_TABS];
+18 -6
View File
@@ -2052,15 +2052,26 @@ static void cats_rebuild(Ed* ed) {
}
}
/* Mais um item na paleta (o vetor cresce: libraries e variaveis nao tem teto) */
static bool fly_push(Ed* ed, FlyItem it) {
if (ed->fly_n == ed->fly_cap) {
int nc = ed->fly_cap ? ed->fly_cap * 2 : 256;
FlyItem* p = realloc(ed->fly_items, (size_t)nc * sizeof(*p));
if (!p) return false;
ed->fly_items = p; ed->fly_cap = nc;
}
ed->fly_items[ed->fly_n++] = it;
return true;
}
static void fly_add_block(Ed* ed, int cat, TinyBlocks_TypeBlock* t, const char* first, float* y) {
if (ed->fly_n >= MAX_FLY) return;
int bi = blk_new(&ed->fly, t);
if (bi < 0) return;
if (first) strncpy(ed->fly.ws[bi].in_text[0], first, 63);
measure(&ed->fly, bi);
place(&ed->fly, bi, FLY_PAD, *y);
float h = ed->fly.ws[bi].h;
ed->fly_items[ed->fly_n++] = (FlyItem){FI_BLOCK, cat, bi, *y, h + NOTCH_D};
fly_push(ed, (FlyItem){FI_BLOCK, cat, bi, *y, h + NOTCH_D});
*y += h + 14;
}
@@ -2079,12 +2090,12 @@ void palette_rebuild(Ed* ed) {
float y = 8;
TinyBlocks_TypeBlock* var_get = tb_type_block_find(ed->rt, "Variables.Get");
int var_cat = cat_of(ed, "Variables.Get");
for (int c = 0; c < ed->cat_n && ed->fly_n < MAX_FLY; c++) {
for (int c = 0; c < ed->cat_n; c++) {
ed->cats[c].fly_y = y;
ed->fly_items[ed->fly_n++] = (FlyItem){FI_HEADER, c, -1, y, 34};
fly_push(ed, (FlyItem){FI_HEADER, c, -1, y, 34});
y += 34;
if (c == ed->myblocks_cat && ed->fly_n < MAX_FLY) {
ed->fly_items[ed->fly_n++] = (FlyItem){FI_BUTTON, c, -1, y, 42};
if (c == ed->myblocks_cat) {
fly_push(ed, (FlyItem){FI_BUTTON, c, -1, y, 42});
y += 42;
}
for (uint32_t i = 0; i < tb_rt_type_count(ed->rt); i++) {
@@ -7705,6 +7716,7 @@ static void editor_instance_deinit(TinyBlocks_Block* self, TinyBlocks* rt) {
bubble_clear(ed);
for (int i = 0; i < ed->tab_n; i++) tab_doc_free(&ed->tabs[i]);
tab_doc_free(&ed->fly); /* pool da paleta */
free(ed->fly_items);
free(ed->fdlg.ents);
free(ed->sbp_text);
free(ed->run_blocks);