Editor: teclado na tela nos campos, "Meus Blocos" sempre e "define" ao abrir .sb
- graphics: text_input(on, x, y, w, h) opcional no backend e tb_graphics_text_input. O editor avisa o campo em foco (e o cursor) quando muda ou quando o campo e tocado de novo; o SDL liga/desliga a entrada de texto (teclado na tela no Android) e posiciona o IME. No desktop a entrada de texto segue sempre ligada. O editor de codigo so pede o teclado depois de um toque nele. - Categorias: MAX_CATS 24 -> 64 e a ultima vaga reservada para "Meus Blocos" (com 3D, Shader, PNG... as ultimas categorias sumiam). - Abrir um .sb com "define": os tipos User.* sao criados ao carregar a aba, nao so ao apertar a bandeira (as chamadas apareciam como "User.<nome>"). - Harness: cenarios 37 (teclado) e 38 (.sb com define). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c9ff13bb77
commit
cea7cb5ba4
6 files changed
+125
-5
No files matched your search
@@ -2429,8 +2429,9 @@ static bool type_hidden(Ed* ed, const TinyBlocks_TypeBlock* t) {
|
||||
|
||||
static void cats_rebuild(Ed* ed) {
|
||||
ed->cat_n = 0;
|
||||
/* 1) Categoria declarada por cada library, na ordem de registro */
|
||||
for (uint32_t i = 0; i < tb_rt_library_count(ed->rt) && ed->cat_n < MAX_CATS; i++) {
|
||||
/* 1) Categoria declarada por cada library, na ordem de registro (a ultima
|
||||
vaga fica para "Meus Blocos", que nunca pode sumir) */
|
||||
for (uint32_t i = 0; i < tb_rt_library_count(ed->rt) && ed->cat_n < MAX_CATS - 1; i++) {
|
||||
TinyBlocks_LibraryBlock* lib = tb_rt_library_at(ed->rt, i);
|
||||
const TinyBlocks_Category* cat = tb_library_category(lib);
|
||||
if (!cat || !cat->name) continue;
|
||||
@@ -3986,6 +3987,7 @@ static bool sb_import_text_(Ed* ed, const char* text, const char* name) {
|
||||
}
|
||||
bp_tab_load(ed, B, &CT);
|
||||
bp_tab_dispose(B);
|
||||
define_sync(ed); /* tipos User.* dos "define" ja ao abrir, nao so na bandeira */
|
||||
layout_tab(&CT);
|
||||
cleanup_ws(ed); /* arruma as pilhas uma embaixo da outra */
|
||||
palette_rebuild(ed);
|
||||
@@ -7440,6 +7442,25 @@ static bool te_owner_xy(Ed* ed, int owner, int off, float* x, float* y, float* l
|
||||
te_field_xy(ed, off, x, y, lh);
|
||||
return true;
|
||||
}
|
||||
/* Avisa o SO do campo em foco: no celular o teclado na tela abre e fecha
|
||||
com o foco; no desktop o IME fica junto do cursor. O editor de codigo so
|
||||
pede o teclado depois de um toque nele (ver codigo nao abre o teclado), e
|
||||
tocar de novo num campo reabre o teclado que o usuario fechou. */
|
||||
static void te_sync_os(Ed* ed) {
|
||||
int owner = te_cur_owner(ed);
|
||||
bool want = owner == TE_FIELD || (owner == TE_CODE && (ed->ti_on || ed->ti_kick));
|
||||
float x = 0.f, y = 0.f, lh = 0.f;
|
||||
if (want) {
|
||||
int a, b;
|
||||
te_owner_sel(ed, owner, &a, &b);
|
||||
if (!te_owner_xy(ed, owner, owner == TE_FIELD ? ed->te_caret : b, &x, &y, &lh)) want = false;
|
||||
}
|
||||
bool moved = want && (fabsf(x - ed->ti_x) > 0.5f || fabsf(y - ed->ti_y) > 0.5f || fabsf(lh - ed->ti_h) > 0.5f);
|
||||
if (want != ed->ti_on || moved || (want && ed->ti_kick))
|
||||
tb_graphics_text_input(want, x, y, 2.f, lh);
|
||||
ed->ti_on = want; ed->ti_x = x; ed->ti_y = y; ed->ti_h = lh;
|
||||
ed->ti_kick = false;
|
||||
}
|
||||
static void te_owner_word(Ed* ed, int owner, int off) {
|
||||
if (owner == TE_CODE) code_select_word(&CT, off); else te_select_word(ed, off);
|
||||
}
|
||||
@@ -9361,6 +9382,7 @@ static void ed_handle_input(Ed* ed, TinyBlocks_Block* evb, int from) {
|
||||
}
|
||||
|
||||
if (ev_int(evb, GFX_IN_MOUSE_L_DOWN)) {
|
||||
ed->ti_kick = true; /* toque num campo reabre o teclado */
|
||||
const TinyBlocks_JsonValue* tj = ev_json(evb, GFX_IN_TOUCHES);
|
||||
ed->press_touch = tj && tb_json_array_length(tj) > 0; /* dedo, nao mouse */
|
||||
ed->press_t = now_ms();
|
||||
@@ -9641,6 +9663,7 @@ static bool editor_on_draw(TinyBlocks_Block* self, TinyBlocks* rt,
|
||||
render_ctx_menu(ed, rb);
|
||||
modals_render(ed, rb); /* de baixo para cima; configuracoes por cima de tudo */
|
||||
te_render_overlay(ed, rb); /* alcas e barra da selecao (toque) */
|
||||
te_sync_os(ed); /* teclado na tela / IME do campo em foco */
|
||||
render_toasts(ed, rb); /* avisos flutuam por cima de tudo */
|
||||
tb_a11y_end(ax(ed));
|
||||
ed->ax_on = false;
|
||||
|
||||
Reference in new issue
Block a user