editor: roda do mouse da zoom na aba de imagem e nao pinta mais
- Aba de imagem: roda do mouse = zoom centrado no ponteiro (como no Krita), com deslocamento (pan) para nao perder o ponto de referencia; com zoom <= 100% a pagina volta ao centro. O scroll nao pinta nem move blocos. - tinyblocks-editor-image exporta tb_editor_image_zoom e a tabela da API (tb_ed_img.zoom) faz a ponte, entao o editor so chama por ponteiro. - Removida a barra cinza decorativa no fim da tela (parecia uma barra de rolagem falsa). - harness: scroll() e testes 'roda do mouse aproxima/afasta/nao pinta'.
This commit is contained in:
1 parent
0143d3efd5
commit
2b6bc65062
7 files changed
+77
-7
No files matched your search
+18
-1
@@ -37,6 +37,7 @@ static void draw(void) {
|
||||
tb_renderable_release_all();
|
||||
}
|
||||
|
||||
static float g_scroll_dy = 0.f;
|
||||
static void frame(float mx, float my, int ld, int lu, int rd, int sc, const char* text) {
|
||||
tb_block_set_output(ev, GFX_IN_MOUSE_X, tb_value_real(mx));
|
||||
tb_block_set_output(ev, GFX_IN_MOUSE_Y, tb_value_real(my));
|
||||
@@ -49,11 +50,17 @@ static void frame(float mx, float my, int ld, int lu, int rd, int sc, const char
|
||||
tb_block_set_output(ev, GFX_IN_TEXT, tb_value_text(text ? text : ""));
|
||||
tb_block_set_output(ev, GFX_IN_DROP_FILE, tb_value_text(""));
|
||||
tb_block_set_output(ev, GFX_IN_SCROLL_DX, tb_value_real(0));
|
||||
tb_block_set_output(ev, GFX_IN_SCROLL_DY, tb_value_real(0));
|
||||
tb_block_set_output(ev, GFX_IN_SCROLL_DY, tb_value_real(g_scroll_dy));
|
||||
tb_block_set_output(ev, GFX_IN_WIN_W, tb_value_integer(1280));
|
||||
tb_block_set_output(ev, GFX_IN_WIN_H, tb_value_integer(720));
|
||||
tb_block_eval(scene, rt);
|
||||
draw();
|
||||
g_scroll_dy = 0.f;
|
||||
}
|
||||
/* Roda do mouse (usada para o zoom na aba de imagem) */
|
||||
static void scroll(float mx, float my, float dy) {
|
||||
g_scroll_dy = dy;
|
||||
frame(mx, my, 0, 0, 0, 0, NULL);
|
||||
}
|
||||
|
||||
enum { R_ANY, R_CAT, R_FLY, R_WS, R_STAGE };
|
||||
@@ -114,6 +121,16 @@ static bool find_sub(const char* sub, float* x, float* y) {
|
||||
return false;
|
||||
}
|
||||
/* Conta pixels nao-brancos da ultima imagem desenhada no workspace */
|
||||
/* Largura da maior imagem do workspace (a folha de desenho) */
|
||||
static float img_draw_w(void) {
|
||||
float best = 0, w = 0;
|
||||
for (uint32_t i = 0; i < ncmd; i++) {
|
||||
if (cmds[i].kind != TB_DRAW_IMAGE || !cmds[i].image || !in_region(cmds[i].x, R_WS)) continue;
|
||||
float a = cmds[i].w * cmds[i].h;
|
||||
if (a > best) { best = a; w = cmds[i].w; }
|
||||
}
|
||||
return w;
|
||||
}
|
||||
static int img_nonwhite(void) {
|
||||
/* A folha de desenho e a MAIOR imagem do workspace (miniaturas sao pequenas) */
|
||||
const TinyBlocks_Image* im = NULL;
|
||||
|
||||
Reference in new issue
Block a user