Criar um Bloco: ícones desenhados e espaçamentos; parâmetro só com o nome, mais escuro

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mguinhosandClaude Opus 5.5 committed 2026-10-23 07:02:26 -03:00
1 parent fce274f85e
commit 6729ce11fa
2 files changed
+56 -30

No files matched your search

+12 -4
View File
@@ -122,6 +122,12 @@ static bool ws_has(const char* s) {
if (cmds[i].kind == TB_DRAW_TEXT && in_region(cmds[i].x, R_WS) && strcmp(cmds[i].text, s) == 0) return true;
return false;
}
static int ws_count(const char* s) {
int n = 0;
for (uint32_t i = 0; i < ncmd; i++)
if (cmds[i].kind == TB_DRAW_TEXT && in_region(cmds[i].x, R_WS) && strcmp(cmds[i].text, s) == 0) n++;
return n;
}
static bool find_tabbar(const char* s, float* x, float* y) {
for (uint32_t i = 0; i < ncmd; i++) {
TinyBlocks_DrawCmd* c = &cmds[i];
@@ -313,11 +319,11 @@ int main(void) {
if (need("Criar um Bloco", R_FLY, 0, &x, &y)) click(x, y);
if (need("nome do bloco", R_WS, 0, &x, &y)) click(x, y);
type("dobro");
if (need("numérica ou texto", R_WS, 0, &x, &y)) click(x, y);
if (need("número ou texto", R_WS, 0, &x, &y)) click(x, y);
type("n");
key(TB_KEY_RETURN, 0, 0); /* OK no diálogo */
/* como no Scratch: o "defina" aparece na própria aba, com o parâmetro ao lado */
CHECK(ws_has("defina") && !ws_has("parâmetro"), "Criar um Bloco põe \"defina dobro\" na mesma aba (sem parâmetros soltos)");
CHECK(ws_has("defina") && ws_count("n") == 1, "Criar um Bloco põe \"defina dobro\" na mesma aba (sem parâmetros soltos)");
CHECK(ws_has("quando a bandeira for clicado"), "sem abrir aba nova: os scripts continuam ali");
hx = 0; hy = 0;
need("defina", R_WS, 0, &hx, &hy);
@@ -341,7 +347,7 @@ int main(void) {
if (!got) { printf("FAIL slot esquerdo do + (+ em %.0f,%.0f)\n", x, y); fails++; }
else drag(px, py, zx - 3, zy);
}
CHECK(ws_has("parâmetro"), "arrastar o parâmetro do defina cria \"parâmetro n\"");
CHECK(ws_count("n") == 2, "arrastar o parâmetro do defina cria o reporter \"n\"");
}
/* digita 1 no slot direito do "+" */
if (block_plus(&x, &y, hy + 20)) {
@@ -353,7 +359,9 @@ int main(void) {
}
if (block_plus(&x, &y, hy + 20) && need("=", R_WS, 0, &x2, &y2)) {
float rep_left = x - 3 - 10;
{ float px, py; if (find("parâmetro", R_WS, 0, &px, &py)) rep_left = px - 3 - 10 - 10; }
/* o reporter "n" (o outro "n" esta no defina) */
{ float px, py; for (int k = 0; find("n", R_WS, k, &px, &py); k++)
if (py > hy + 10) { rep_left = px - 3 - 10; break; } }
drag(x, y, x + ((x2 + 12) - rep_left), y + (y2 - y));
}
if (need("Meus Blocos", R_CAT, 0, &x, &y)) click(x, y);