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:
mguinhosandClaude Opus 5.5 committed 2026-10-23 07:41:12 -03:00
1 parent 600c4fc520
commit 8f046833e7
10 files changed
+953 -747

No files matched your search

+189 -90
View File
@@ -884,7 +884,7 @@ static void draw_slot(TinyBlocks_RenderableBlock* rb, const EdBlock* b, int s,
* nome, valor, estados, acoes e retangulo. A arvore serve ao narrador (por
* uma ponte) e aos testes (acham componentes por papel + nome). So o
* desenho da janela principal monta a arvore (ed->ax_on). */
static TinyBlocks_A11yTree* ax(Ed* ed) { return ed->ax_on ? ed->ax_tree : NULL; }
static TinyBlocks_A11yTree* ax(Ed* ed) { return ed_ax(ed); }
static int ax_push(Ed* ed, TinyBlocks_A11yRole r, const char* name, float x, float y, float w, float h) {
return tb_a11y_push(ax(ed), r, name, x, y, w, h);
@@ -969,7 +969,9 @@ static void ax_block(Ed* ed, Tab* T, int bi, float ox, float oy, uint32_t acts)
int n = tb_a11y_push(t, TB_A11Y_BLOCK, label, x, y, b->w, b->h);
tb_a11y_set_key(t, n, b->type_name); /* o id nao muda ao editar */
tb_a11y_set_point(t, n, x + fminf(8.f, b->w * 0.5f), y + b->row_y + b->row_h * 0.5f);
tb_a11y_set_actions(t, n, acts);
bool in_ws = T == &CT && (acts & TB_A11Y_ACT_MENU); /* na area de scripts */
tb_a11y_set_actions(t, n, acts | (in_ws && !shape_is_value(shape_of(b->type)) && !is_cap(b->type)
? TB_A11Y_ACT_DROP : 0)); /* solta embaixo dele */
if (T == &CT && (x + b->w < WS_X || x > WS_X + WS_W || y + b->h < WS_Y || y > WS_Y + WS_H))
tb_a11y_add_states(t, n, TB_A11Y_OFFSCREEN); /* existe, mas a aba esta rolada */
const TinyBlocks_BlockMeta* meta = tb_meta_find(b->type_name);
@@ -1006,7 +1008,8 @@ static void ax_block(Ed* ed, Tab* T, int bi, float ox, float oy, uint32_t acts)
}
for (int k = 0; k < shape_mouths(shape_of(b->type)); k++) {
const char* mn = k == 0 ? "dentro" : mouth_label(b->type, k - 1);
tb_a11y_push(t, TB_A11Y_GROUP, mn, x + ARM_W, y + b->sub_y[k], b->w - ARM_W, b->sub_h[k]);
int mg = tb_a11y_push(t, TB_A11Y_GROUP, mn, x + ARM_W, y + b->sub_y[k], b->w - ARM_W, b->sub_h[k]);
if (in_ws) tb_a11y_set_actions(t, mg, TB_A11Y_ACT_DROP); /* solta dentro da boca */
if (b->sub[k] >= 0) ax_chain(ed, T, b->sub[k], ox, oy, acts);
tb_a11y_pop(t);
}
@@ -2353,6 +2356,9 @@ static void draw_detach_btn(Ed* ed, TinyBlocks_RenderableBlock* rb, int v) {
bool hov = in_rect(ed->mouse_x, ed->mouse_y, bx, by, DETACH_S, DETACH_S);
if (hov) rb_fill_rrect(rb, bx, by, DETACH_S, DETACH_S, 5, COL_HOVER);
draw_window_icon(rb, bx - 2, by, DETACH_S + 4, ed->area[v].detached, hov ? COL_MENU : COL_TEXT_DIM);
char nm[64];
snprintf(nm, sizeof(nm), "%s a área %s", ed->area[v].detached ? "Recolher" : "Destacar", view_name(v));
ax_button(ed, nm, bx, by, DETACH_S, DETACH_S);
}
static void draw_grip(Ed* ed, TinyBlocks_RenderableBlock* rb, int v) {
@@ -2360,6 +2366,11 @@ static void draw_grip(Ed* ed, TinyBlocks_RenderableBlock* rb, int v) {
if (!ed->area[v].shown) return;
float gx, gy;
grip_pos(ed, v, &gx, &gy);
{ /* alca: arraste e solte sobre outra area (PANE) para trocar de lugar */
char nm[64];
snprintf(nm, sizeof(nm), "Mover a área %s", view_name(v));
tb_a11y_set_actions(ax(ed), ax_add(ed, TB_A11Y_BUTTON, nm, gx, gy, GRIP_S, GRIP_S), TB_A11Y_ACT_DRAG);
}
bool hov = ed->area_drag == v || in_rect(ed->mouse_x, ed->mouse_y, gx, gy, GRIP_S, GRIP_S);
if (hov) rb_fill_rrect(rb, gx - 2, gy - 2, GRIP_S + 4, GRIP_S + 4, 5, COL_HOVER);
Col c = hov ? COL_MENU : COL_TEXT_DIM;
@@ -2368,6 +2379,37 @@ static void draw_grip(Ed* ed, TinyBlocks_RenderableBlock* rb, int v) {
rb_fill_circle(rb, gx + 6 + i * 6, gy + 3 + j * 6, 1.6f, c);
}
/* Primeira area (folha) de um no do layout, para dar nome as bordas */
static int lay_first_view(Ed* ed, int n) {
for (int k = 0; k < LAY_MAX && n >= 0 && n < ed->lay_n; k++) {
if (ed->lay[n].kind == LN_LEAF) return ed->lay[n].view;
n = ed->lay[n].a;
}
return -1;
}
/* Bordas arrastaveis entre as areas: "Borda entre Blocos e Scripts". Para
* mover, solte a borda sobre ela mesma com um deslocamento (drop_at). */
static void ax_separators(Ed* ed) {
TinyBlocks_A11yTree* t = ax(ed);
if (!t) return;
for (int n = 0; n < ed->lay_n; n++) {
const LayNode* N = &ed->lay[n];
if (N->kind == LN_LEAF || N->w <= 0 || N->h <= 0) continue;
int va = lay_first_view(ed, N->a), vb = lay_first_view(ed, N->b);
char name[96];
snprintf(name, sizeof(name), "Borda entre %s e %s", view_name(va), view_name(vb));
bool hz = N->kind == LN_HSPLIT;
int s = hz ? tb_a11y_add(t, TB_A11Y_SEPARATOR, name, N->pos - 3, N->y, 6, N->h)
: tb_a11y_add(t, TB_A11Y_SEPARATOR, name, N->x, N->pos - 3, N->w, 6);
tb_a11y_set_actions(t, s, TB_A11Y_ACT_DRAG | TB_A11Y_ACT_DROP);
char val[16];
snprintf(val, sizeof(val), "%.0f", N->pos - (hz ? N->x : N->y));
tb_a11y_set_value(t, s, val);
tb_a11y_set_description(t, s, hz ? "vertical" : "horizontal");
}
}
/* Borda sob o mouse e alvo da troca de areas */
static void render_areas_overlay(Ed* ed, TinyBlocks_RenderableBlock* rb) {
int sp = ed->split_drag >= 0 ? ed->split_drag : ed->split_hover;
@@ -3886,6 +3928,11 @@ static void render_toasts(Ed* ed, TinyBlocks_RenderableBlock* rb) {
/* temporizador: barra que encolhe (para com o mouse em cima) */
int an = ax_push(ed, TB_A11Y_STATUS, t->text, t->x, t->y, w, h);
tb_a11y_set_description(ax(ed), an, t->ok ? "aviso" : "erro");
if (t->count > 1) {
char cnt[32];
snprintf(cnt, sizeof(cnt), "%d vezes", t->count);
tb_a11y_set_value(ax(ed), an, cnt);
}
ax_button(ed, "Fechar aviso", cx - 11, cy - 11, 22, 22);
ax_pop(ed);
float k = t->total_ms > 0 ? fmaxf(0.f, t->left_ms / t->total_ms) : 0.f;
@@ -3943,7 +3990,8 @@ static void render_tab_bar(Ed* ed, TinyBlocks_RenderableBlock* rb) {
int an = ax_push(ed, TB_A11Y_TAB, ed->tabs[i].name, tx, y0 + 6, TAB_W - 4, TAB_H - 6);
tb_a11y_set_point(ax(ed), an, tx + 14, cy);
tb_a11y_set_states(ax(ed), an, cur ? TB_A11Y_SELECTED : 0);
tb_a11y_set_actions(ax(ed), an, TB_A11Y_ACT_ACTIVATE | TB_A11Y_ACT_MENU | TB_A11Y_ACT_DRAG);
tb_a11y_set_actions(ax(ed), an, TB_A11Y_ACT_ACTIVATE | TB_A11Y_ACT_MENU | TB_A11Y_ACT_DRAG |
TB_A11Y_ACT_DROP);
tb_a11y_set_description(ax(ed), an, tab_class(&ed->tabs[i])->name);
if (ed->tab_n > 1 && ed->tabctx < 0) { /* fechar: um X desenhado */
float qx = tx + TAB_W - 18;
@@ -4011,7 +4059,8 @@ static void render_flyout(Ed* ed, TinyBlocks_RenderableBlock* rb) {
rb_line(rb, FLY_R-1, PAL_Y, FLY_R-1, PAL_B, 1.f, COL_BORDER);
clip_set(ed, rb, FLY_X, PAL_Y, FLY_R - FLY_X - 1, PAL_B-PAL_Y);
float oy = PAL_Y - ed->fly_scroll;
ax_push(ed, TB_A11Y_LIST, "Paleta", FLY_X, PAL_Y, FLY_R - FLY_X, PAL_B - PAL_Y);
tb_a11y_set_actions(ax(ed), ax_push(ed, TB_A11Y_LIST, "Paleta", FLY_X, PAL_Y, FLY_R - FLY_X, PAL_B - PAL_Y),
TB_A11Y_ACT_DROP); /* bloco solto aqui e apagado */
bool ax_grp = false;
for (int i = 0; i < ed->fly_n; i++) {
FlyItem* it = &ed->fly_items[i];
@@ -4569,6 +4618,12 @@ void render_tooltip(Ed* ed, TinyBlocks_RenderableBlock* rb) {
p = nl + 1;
}
rb_text_c(rb, x + 12, y + h - 8, "clique para abrir o codigo nesta linha", COL_TEXT_DIM, 9.f);
int tn = ax_push(ed, TB_A11Y_TOOLTIP, ed->tip_title, x, y, w, h);
tb_a11y_set_value(ax(ed), tn, ed->tip_loc);
tb_a11y_set_description(ax(ed), tn, ed->tip_doc);
tb_a11y_set_value(ax(ed), ax_button(ed, "Abrir o código nesta linha", x + 6, ed->tip_prev_y - 2, w - 12,
ed->tip_prev_h + 4), ed->tip_preview);
ax_pop(ed);
}
/* == Classes de aba (ver TabClass) ===================================== */
@@ -4640,22 +4695,13 @@ static void code_tab_a11y(Ed* ed) {
tb_a11y_set_description(ax(ed), n, desc);
}
/* Aba de imagem: a tela de desenho, com o tamanho como valor */
static void image_tab_a11y(Ed* ed) {
char val[32];
snprintf(val, sizeof(val), "%d x %d", CT.img_w, CT.img_h);
int n = ax_add(ed, TB_A11Y_CANVAS, "Imagem", WS_X, WS_Y, WS_W, WS_H);
tb_a11y_set_value(ax(ed), n, val);
tb_a11y_set_description(ax(ed), n, CT.img_path[0] ? CT.img_path : "sem arquivo");
}
static const TabClass s_tab_classes[] = {
[TK_BLOCKS] = { "Blocos", true, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL },
[TK_CODE] = { "Código", false, NULL, render_code_tab, code_tab_click, NULL, NULL,
code_key, code_text, code_tab_scroll, code_tab_icon, code_tab_a11y },
[TK_IMAGE] = { "Imagem", false, image_tab_init, image_tab_render, image_tab_click,
image_tab_release, image_tab_motion, image_tab_key, NULL,
image_tab_scroll, image_tab_icon, image_tab_a11y },
image_tab_scroll, image_tab_icon, NULL }, /* o modulo se descreve */
};
const TabClass* tab_class(const Tab* T) {
@@ -4794,6 +4840,7 @@ static void render_workspace(Ed* ed, TinyBlocks_RenderableBlock* rb) {
const TabClass* tc = tab_class(&CT);
int panel = ax_push(ed, TB_A11Y_TAB_PANEL, CT.name, WS_X, WS_Y, WS_W, WS_H);
tb_a11y_set_description(ax(ed), panel, tc->name);
tb_a11y_set_actions(ax(ed), panel, tc->blocks ? TB_A11Y_ACT_DROP : 0); /* solta solto (drop_at) */
if (tc->a11y) tc->a11y(ed);
if (tc->render) { tc->render(ed, rb); ax_pop(ed); return; }
float ox = WS_X - CT.ws_sx, oy = WS_Y - CT.ws_sy;
@@ -5001,7 +5048,7 @@ static void render_stage(Ed* ed, TinyBlocks_RenderableBlock* rb) {
rb_fill_rrect(rb, bx, by, bw, ph, 8, COL_BORDER);
TinyBlocks_RenderableBlock* sub = NULL;
tb_stage_set_view(bw-2, ph-2);
ax_add(ed, TB_A11Y_CANVAS, "Palco", bx, by, bw, ph);
ax_add(ed, TB_A11Y_CANVAS, "Palco", bx + 1, by + 1, bw - 2, ph - 2); /* a vista do palco */
clip_set(ed, rb, bx+1, by+1, bw-2, ph-2);
if (ed->stage->type->on_draw(ed->stage, ed->rt, &sub) && sub) {
tb_draw_merge_offset(rb, sub, bx+1, by+1);
@@ -6185,14 +6232,7 @@ static void libman_scroll_m(Ed* ed, float dy) { libman_scroll_by(ed, dy); }
/* o explorador vem do modulo do editor (pode faltar) */
static bool files_is_open(Ed* ed) { return ed->fdlg.open; }
static void files_render_m(Ed* ed, TinyBlocks_RenderableBlock* rb) {
if (!files_view) return;
files_view(ed, rb);
/* o modulo desenha; aqui so o dialogo e o caminho (o conteudo fica para o modulo) */
tb_a11y_set_states(ax(ed), ax_push(ed, TB_A11Y_DIALOG, ed->fdlg.mode == PM_LOAD ? "Abrir" : "Salvar",
0, 0, WIN_W, WIN_H), TB_A11Y_MODAL);
ax_pop(ed);
}
static void files_render_m(Ed* ed, TinyBlocks_RenderableBlock* rb) { if (files_view) files_view(ed, rb); }
static void files_click_m(Ed* ed, float mx, float my) { if (files_click) files_click(ed, mx, my); }
static void files_key_m(Ed* ed, int sc, bool ctrl) { if (files_key) files_key(ed, sc, ctrl); else ed->fdlg.open = false; }
static void files_text_m(Ed* ed, const char* t) { if (files_text) files_text(ed, t); }
@@ -6794,38 +6834,104 @@ static void hover_update(Ed* ed, float mx, float my) {
}
}
/* Ponteiro se moveu: bordas e areas, aba arrastada, bloco arrastado,
* grupo, rolagem da area e a aba (imagem). `from` = janela do evento. */
static void pointer_motion(Ed* ed, float mx, float my, int from) {
/* == Areas: borda sendo arrastada / area levada pela alca === */
if (ed->split_drag >= 0) { split_drag_to(ed, ed->split_drag, mx, my); lay_compute(ed); }
if (ed->area_drag >= 0) ed->area_drop = view_at(ed, mx, my);
bool modal = modal_top(ed) != NULL;
ed->split_hover = modal ? -1 : split_at(ed, mx, my);
/* == Aba sendo arrastada: reordena ao passar do meio da vizinha === */
if (ed->tab_press >= 0 && (ed->capture_view == -2 || ed->capture_view == from)) {
if (!ed->tab_drag && fabsf(mx - ed->tab_press_x) + fabsf(my - ed->tab_press_y) > 6.f)
ed->tab_drag = true;
if (ed->tab_drag) {
int vis[MAX_TABS], vn = tabs_visible_list(ed, vis);
int slot = (int)floorf((mx - ed->tab_grab_dx - (WS_X + 8) + TAB_W * 0.5f) / TAB_W);
if (slot < 0) slot = 0;
if (slot >= vn) slot = vn - 1;
if (vn > 1 && vis[slot] != ed->tab_press) {
int to = vis[slot];
tab_move(ed, ed->tab_press, to);
ed->tab_press = to;
}
}
}
/* == Movimento === */
if (ed->state == ES_PRESS && fabsf(mx - ed->press_mx) + fabsf(my - ed->press_my) > 4.f &&
(ed->capture_view == -2 || ed->capture_view == from))
start_drag(ed);
if (ed->state == ES_DRAG && ed->drag_bi >= 0 && (ed->capture_view == -2 || ed->capture_view == from)) {
EdBlock* b = &CT.ws[ed->drag_bi];
ed->drag_tab = ed->cur_tab;
ed->drag_ws_x = WS_X; ed->drag_ws_y = WS_Y;
b->x = mx - ed->drag_ox - WS_X + CT.ws_sx;
b->y = my - ed->drag_oy - WS_Y + CT.ws_sy;
layout_tab(&CT);
compute_snap(ed);
}
if (ed->grp_drag >= 0 && (ed->capture_view == -2 || ed->capture_view == from))
group_motion(ed, mx, my);
if (ed->state == ES_PAN && (ed->capture_view == -2 || ed->capture_view == from)) {
CT.ws_sx = ed->pan_sx - (mx - ed->pan_mx);
CT.ws_sy = ed->pan_sy - (my - ed->pan_my);
}
if (tab_class(&CT)->motion) tab_class(&CT)->motion(ed, mx, my);
}
/* Acoes da arvore acessivel: agem como o mouse no ponto do componente
* (o mesmo caminho do clique, entao narrador, testes e mouse nao divergem) */
static bool ax_perform(void* user, const TinyBlocks_A11yTree* t, int node, TinyBlocks_A11yAction a) {
/* Area rolavel de um no: TAB_PANEL (scripts), LIST "Paleta" ou NONE */
static TinyBlocks_A11yRole ax_area(const TinyBlocks_A11yTree* t, int node) {
for (int p = node; p >= 0; p = tb_a11y_node(t, p)->parent) {
const TinyBlocks_A11yNode* nd = tb_a11y_node(t, p);
if (nd->role == TB_A11Y_TAB_PANEL) return nd->role;
if (nd->role == TB_A11Y_LIST && !strcmp(nd->name, "Paleta")) return nd->role;
}
return TB_A11Y_NONE;
}
/* Rola a area do no ate o ponto (x, y) ficar visivel; devolve o deslocamento
* aplicado (o que estava naquela area se move junto) */
static void ax_scroll_into_view(Ed* ed, TinyBlocks_A11yRole area, float x, float y, float* dx, float* dy) {
*dx = *dy = 0;
if (area == TB_A11Y_TAB_PANEL) {
*dx = x - (WS_X + WS_W * 0.5f);
*dy = y - (WS_Y + WS_H * 0.5f);
CT.ws_sx += *dx; CT.ws_sy += *dy;
} else if (area == TB_A11Y_LIST) {
float before = ed->fly_scroll;
ed->fly_scroll += y - (PAL_Y + (PAL_B - PAL_Y) * 0.5f);
if (ed->fly_scroll > fly_max_scroll(ed)) ed->fly_scroll = fly_max_scroll(ed);
if (ed->fly_scroll < 0) ed->fly_scroll = 0;
*dy = ed->fly_scroll - before;
}
}
/* Acoes da arvore acessivel: agem como o mouse no ponto do componente (o
* mesmo caminho do clique e do arrasto, entao narrador, testes e mouse nao
* divergem). Componente fora da vista: rola ate ele antes, como o GTK. */
static bool ax_perform(void* user, const TinyBlocks_A11yTree* t, int node, const TinyBlocks_A11yRequest* req) {
Ed* ed = user;
const TinyBlocks_A11yNode* src = tb_a11y_node(t, node);
float x, y;
tb_a11y_point(t, node, &x, &y);
float offx = x - src->x, offy = y - src->y; /* ponto de pegar, relativo ao canto */
TinyBlocks_A11yRole sarea = ax_area(t, node);
g_active_ed = ed;
lay_compute(ed);
if (tb_a11y_node(t, node)->states & TB_A11Y_OFFSCREEN) {
/* fora da vista: rola ate ele antes (como o GTK faz) */
TinyBlocks_A11yRole area = TB_A11Y_NONE;
for (int p = node; p >= 0 && area == TB_A11Y_NONE; p = tb_a11y_node(t, p)->parent) {
const TinyBlocks_A11yNode* nd = tb_a11y_node(t, p);
if (nd->role == TB_A11Y_TAB_PANEL || (nd->role == TB_A11Y_LIST && !strcmp(nd->name, "Paleta")))
area = nd->role;
}
if (area == TB_A11Y_TAB_PANEL) {
float dx = x - (WS_X + WS_W * 0.5f), dy = y - (WS_Y + WS_H * 0.5f);
CT.ws_sx += dx; CT.ws_sy += dy;
x -= dx; y -= dy;
} else if (area == TB_A11Y_LIST) {
float before = ed->fly_scroll;
ed->fly_scroll += y - (PAL_Y + (PAL_B - PAL_Y) * 0.5f);
if (ed->fly_scroll > fly_max_scroll(ed)) ed->fly_scroll = fly_max_scroll(ed);
if (ed->fly_scroll < 0) ed->fly_scroll = 0;
y -= ed->fly_scroll - before;
}
float sdx = 0, sdy = 0;
if (src->states & TB_A11Y_OFFSCREEN) {
ax_scroll_into_view(ed, sarea, x, y, &sdx, &sdy);
x -= sdx; y -= sdy;
}
ed->mouse_x = x; ed->mouse_y = y;
layout_tab(&CT);
hover_update(ed, x, y);
switch (a) {
switch (req->action) {
case TB_A11Y_ACT_ACTIVATE:
case TB_A11Y_ACT_EDIT:
ed->capture_view = -1;
@@ -6836,8 +6942,41 @@ static bool ax_perform(void* user, const TinyBlocks_A11yTree* t, int node, TinyB
case TB_A11Y_ACT_MENU:
on_rmb_down(ed, x, y);
return true;
case TB_A11Y_ACT_DRAG: {
const TinyBlocks_A11yNode* dst = tb_a11y_node(t, req->target);
if (!dst) return false;
float dxr = dst->x, dyr = dst->y, dpx = dst->px, dpy = dst->py;
TinyBlocks_A11yRole darea = ax_area(t, req->target);
if (darea == sarea) { dxr -= sdx; dyr -= sdy; dpx -= sdx; dpy -= sdy; } /* rolou junto */
if (!req->at && (dst->states & TB_A11Y_OFFSCREEN) && darea == TB_A11Y_TAB_PANEL) {
float ddx, ddy; /* destino fora da vista: rola ate ele */
ax_scroll_into_view(ed, darea, dpx, dpy, &ddx, &ddy);
dxr -= ddx; dyr -= ddy; dpx -= ddx; dpy -= ddy;
if (sarea == darea) { x -= ddx; y -= ddy; }
}
/* onde o canto da origem vai parar: pelo papel do destino, ou (x, y) dado */
bool corner = true;
float cx = dxr, cy = dyr;
if (req->at) { cx = dxr + req->x; cy = dyr + req->y; }
else if (dst->role == TB_A11Y_BLOCK) cy = dyr + dst->h; /* embaixo do bloco */
else if (dst->role != TB_A11Y_TEXT_FIELD && dst->role != TB_A11Y_SLOT &&
dst->role != TB_A11Y_GROUP) corner = false; /* sobre o destino */
float x1 = corner ? cx + offx : dpx, y1 = corner ? cy + offy : dpy;
ed->capture_view = -1;
ed->mouse_x = x; ed->mouse_y = y;
on_lmb_down(ed, x, y);
float mx1 = x + 8, my1 = y + 8; /* passa do limiar de arrasto */
ed->mouse_x = mx1; ed->mouse_y = my1;
pointer_motion(ed, mx1, my1, -1);
ed->mouse_x = x1; ed->mouse_y = y1;
hover_update(ed, x1, y1);
pointer_motion(ed, x1, y1, -1);
on_lmb_up(ed, x1, y1);
ed->capture_view = -2;
return true;
}
default:
return false; /* arrastar precisa de um destino: use o retangulo */
return false;
}
}
@@ -6909,49 +7048,7 @@ static void ed_handle_input(Ed* ed, TinyBlocks_Block* evb, int from) {
update_tooltip(ed, (ev_int(evb, GFX_IN_MOD_STATE) & TB_MOD_ALT) != 0);
/* == Areas: borda sendo arrastada / area levada pela alca === */
if (ed->split_drag >= 0) { split_drag_to(ed, ed->split_drag, mx, my); lay_compute(ed); }
if (ed->area_drag >= 0) ed->area_drop = view_at(ed, mx, my);
bool modal = modal_top(ed) != NULL;
ed->split_hover = modal ? -1 : split_at(ed, mx, my);
/* == Aba sendo arrastada: reordena ao passar do meio da vizinha === */
if (ed->tab_press >= 0 && (ed->capture_view == -2 || ed->capture_view == from)) {
if (!ed->tab_drag && fabsf(mx - ed->tab_press_x) + fabsf(my - ed->tab_press_y) > 6.f)
ed->tab_drag = true;
if (ed->tab_drag) {
int vis[MAX_TABS], vn = tabs_visible_list(ed, vis);
int slot = (int)floorf((mx - ed->tab_grab_dx - (WS_X + 8) + TAB_W * 0.5f) / TAB_W);
if (slot < 0) slot = 0;
if (slot >= vn) slot = vn - 1;
if (vn > 1 && vis[slot] != ed->tab_press) {
int to = vis[slot];
tab_move(ed, ed->tab_press, to);
ed->tab_press = to;
}
}
}
/* == Movimento === */
if (ed->state == ES_PRESS && fabsf(mx - ed->press_mx) + fabsf(my - ed->press_my) > 4.f &&
(ed->capture_view == -2 || ed->capture_view == from))
start_drag(ed);
if (ed->state == ES_DRAG && ed->drag_bi >= 0 && (ed->capture_view == -2 || ed->capture_view == from)) {
EdBlock* b = &CT.ws[ed->drag_bi];
ed->drag_tab = ed->cur_tab;
ed->drag_ws_x = WS_X; ed->drag_ws_y = WS_Y;
b->x = mx - ed->drag_ox - WS_X + CT.ws_sx;
b->y = my - ed->drag_oy - WS_Y + CT.ws_sy;
layout_tab(&CT);
compute_snap(ed);
}
if (ed->grp_drag >= 0 && (ed->capture_view == -2 || ed->capture_view == from))
group_motion(ed, mx, my);
if (ed->state == ES_PAN && (ed->capture_view == -2 || ed->capture_view == from)) {
CT.ws_sx = ed->pan_sx - (mx - ed->pan_mx);
CT.ws_sy = ed->pan_sy - (my - ed->pan_my);
}
if (tab_class(&CT)->motion) tab_class(&CT)->motion(ed, mx, my);
pointer_motion(ed, mx, my, from);
/* == Scroll === */
double sdx = ev_real(evb, GFX_IN_SCROLL_DX);
@@ -7177,10 +7274,12 @@ static bool editor_on_draw(TinyBlocks_Block* self, TinyBlocks* rt,
tb_a11y_begin(ax(ed), "TinyBlocks", WIN_W, WIN_H);
for (int v = 0; v < V_COUNT; v++) { /* as escondidas nao desenham */
bool shown = AREA(v).shown;
if (shown) ax_push(ed, TB_A11Y_PANE, view_name(v), AREA(v).x, AREA(v).y, AREA(v).w, AREA(v).h);
if (shown) tb_a11y_set_actions(ax(ed), ax_push(ed, TB_A11Y_PANE, view_name(v), AREA(v).x, AREA(v).y,
AREA(v).w, AREA(v).h), TB_A11Y_ACT_DROP); /* troca */
view_class(v)->render(ed, rb);
if (shown) ax_pop(ed);
}
ax_separators(ed);
render_menu(ed, rb);
/* A pilha arrastada fica por cima de tudo (pode passar sobre a paleta) */