Acessibilidade: arrastar e soltar como ação; harness inteiro pela árvore
tb_a11y_drop(origem, destino) e tb_a11y_drop_at(origem, destino, x, y): o editor encaixa pelo papel do destino (campo, embaixo de um bloco, dentro de uma boca, sobre a paleta para apagar, aba sobre aba, área sobre área) pelo mesmo caminho do mouse (pointer_motion, extraído do tratamento de entrada); origem ou destino fora da vista rolam antes. A árvore passa a cobrir o explorador de arquivos (trilha, locais, arquivos, nome, opções, confirmação de substituir), a aba de imagem (ferramentas, folha, rodapé, cores, paleta, camadas), a dica (Alt), as bordas entre áreas, as alças e os botões de destacar. O retângulo do palco é a vista dele; avisos repetidos dizem quantas vezes no valor. O harness não acha mais nada por texto desenhado nem por coordenada fixa: categorias, blocos, campos, menus, diálogos, saída e avisos vêm da árvore. Só pintar na folha e soltar em lugar livre usam posição, e relativa a um componente. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
600c4fc520
commit
8f046833e7
10 files changed
+953
-747
No files matched your search
@@ -55,6 +55,8 @@ typedef enum TinyBlocks_A11yRole {
|
||||
TB_A11Y_STATUS, /* aviso / mensagem (regiao "viva") */
|
||||
TB_A11Y_BLOCK, /* um bloco de programacao */
|
||||
TB_A11Y_SLOT, /* encaixe vazio de um bloco (ex.: booleano) */
|
||||
TB_A11Y_SEPARATOR, /* borda arrastavel entre areas */
|
||||
TB_A11Y_TOOLTIP, /* dica flutuante */
|
||||
TB_A11Y_ROLE_COUNT
|
||||
} TinyBlocks_A11yRole;
|
||||
|
||||
@@ -78,10 +80,19 @@ typedef enum TinyBlocks_A11yAction {
|
||||
TB_A11Y_ACT_ACTIVATE = 1u << 0, /* clicar / pressionar */
|
||||
TB_A11Y_ACT_MENU = 1u << 1, /* abrir o menu de contexto */
|
||||
TB_A11Y_ACT_EDIT = 1u << 2, /* comecar a editar o texto */
|
||||
TB_A11Y_ACT_DRAG = 1u << 3, /* pode ser arrastado */
|
||||
TB_A11Y_ACT_DRAG = 1u << 3, /* pode ser arrastado (tb_a11y_drop) */
|
||||
TB_A11Y_ACT_DROP = 1u << 4, /* aceita algo solto em cima */
|
||||
} TinyBlocks_A11yAction;
|
||||
|
||||
/* Pedido de acao entregue a quem desenha a interface */
|
||||
typedef struct TinyBlocks_A11yRequest {
|
||||
TinyBlocks_A11yAction action;
|
||||
int target; /* DRAG: no de destino (-1 = nenhum) */
|
||||
bool at; /* DRAG: o canto da origem vai para destino + (x, y) */
|
||||
float x, y; /* (sem `at`, quem desenha escolhe pelo papel do *
|
||||
* destino: encaixar no campo, embaixo do bloco...) */
|
||||
} TinyBlocks_A11yRequest;
|
||||
|
||||
#define TB_A11Y_NAME_MAX 128
|
||||
#define TB_A11Y_DESC_MAX 192
|
||||
#define TB_A11Y_VALUE_MAX 128
|
||||
@@ -134,9 +145,9 @@ typedef struct TinyBlocks_A11yBridge {
|
||||
void* user;
|
||||
} TinyBlocks_A11yBridge;
|
||||
|
||||
/* == Quem desenha a interface executa as acoes (ex.: clicar no centro) */
|
||||
/* == Quem desenha a interface executa as acoes (ex.: clicar no ponto) */
|
||||
typedef bool (*TinyBlocks_A11yPerform)(void* user, const TinyBlocks_A11yTree* tree,
|
||||
int node, TinyBlocks_A11yAction action);
|
||||
int node, const TinyBlocks_A11yRequest* req);
|
||||
|
||||
/* -- Ciclo de vida --- */
|
||||
TB_API TinyBlocks_A11yTree* tb_a11y_tree_new(void);
|
||||
@@ -191,6 +202,11 @@ TB_API void tb_a11y_dump(const TinyBlocks_A11yTree* tree, int from, FILE* out);
|
||||
|
||||
/* -- Acoes e eventos --- */
|
||||
TB_API bool tb_a11y_do_action(TinyBlocks_A11yTree* tree, int node, TinyBlocks_A11yAction action);
|
||||
/* Arrasta `node` (acao DRAG) e solta sobre `target` (acao DROP). Quem desenha
|
||||
* decide onde pelo papel do destino (ex.: um bloco solto num campo encaixa). */
|
||||
TB_API bool tb_a11y_drop(TinyBlocks_A11yTree* tree, int node, int target);
|
||||
/* Idem, levando o canto de `node` para (x, y) relativo ao canto de `target` */
|
||||
TB_API bool tb_a11y_drop_at(TinyBlocks_A11yTree* tree, int node, int target, float x, float y);
|
||||
/* Eventos do ultimo tb_a11y_end (tambem enviados a ponte) */
|
||||
TB_API int tb_a11y_event_count(const TinyBlocks_A11yTree* tree);
|
||||
TB_API const TinyBlocks_A11yEvent* tb_a11y_event(const TinyBlocks_A11yTree* tree, int i);
|
||||
|
||||
@@ -390,6 +390,8 @@ const char* tb_a11y_role_name(TinyBlocks_A11yRole r) {
|
||||
[TB_A11Y_STATUS] = "aviso",
|
||||
[TB_A11Y_BLOCK] = "bloco",
|
||||
[TB_A11Y_SLOT] = "encaixe",
|
||||
[TB_A11Y_SEPARATOR] = "divisória",
|
||||
[TB_A11Y_TOOLTIP] = "dica",
|
||||
};
|
||||
return r >= 0 && r < TB_A11Y_ROLE_COUNT ? names[r] : "";
|
||||
}
|
||||
@@ -434,7 +436,24 @@ void tb_a11y_dump(const TinyBlocks_A11yTree* t, int from, FILE* out) {
|
||||
/* -- Acoes --- */
|
||||
bool tb_a11y_do_action(TinyBlocks_A11yTree* t, int node, TinyBlocks_A11yAction a) {
|
||||
if (!valid(t, node) || !t->perform || !(t->nodes[node].actions & (uint32_t)a)) return false;
|
||||
return t->perform(t->perform_user, t, node, a);
|
||||
TinyBlocks_A11yRequest req = { a, -1, false, 0, 0 };
|
||||
return t->perform(t->perform_user, t, node, &req);
|
||||
}
|
||||
|
||||
static bool drop_impl(TinyBlocks_A11yTree* t, int node, int target, bool at, float x, float y) {
|
||||
if (!valid(t, node) || !valid(t, target) || !t->perform) return false;
|
||||
if (!(t->nodes[node].actions & TB_A11Y_ACT_DRAG) || !(t->nodes[target].actions & TB_A11Y_ACT_DROP))
|
||||
return false;
|
||||
TinyBlocks_A11yRequest req = { TB_A11Y_ACT_DRAG, target, at, x, y };
|
||||
return t->perform(t->perform_user, t, node, &req);
|
||||
}
|
||||
|
||||
bool tb_a11y_drop(TinyBlocks_A11yTree* t, int node, int target) {
|
||||
return drop_impl(t, node, target, false, 0, 0);
|
||||
}
|
||||
|
||||
bool tb_a11y_drop_at(TinyBlocks_A11yTree* t, int node, int target, float x, float y) {
|
||||
return drop_impl(t, node, target, true, x, y);
|
||||
}
|
||||
|
||||
/* -- Ponte de texto --- */
|
||||
|
||||
Reference in new issue
Block a user