Balao de previa: adiciona a perninha (seta) apontando para o bloco

This commit is contained in:
mguinhos committed 2026-10-20 21:44:19 -03:00
1 parent e36fbc43e1
commit 30c283aaa4
1 file changed
+16 -3
+16 -3
View File
@@ -553,6 +553,19 @@ static inline void rb_stroke_rect(TinyBlocks_RenderableBlock* rb, float x,float
static inline void rb_line(TinyBlocks_RenderableBlock* rb, float x0,float y0,float x1,float y1,float w, Col c) static inline void rb_line(TinyBlocks_RenderableBlock* rb, float x0,float y0,float x1,float y1,float w, Col c)
{ tb_draw_stroke_line(rb,x0,y0,x1,y1,w,c.r,c.g,c.b,c.a); } { tb_draw_stroke_line(rb,x0,y0,x1,y1,w,c.r,c.g,c.b,c.a); }
/* Perninha (triangulo) do balao de previa, apontando para baixo.
* bottom = linha de baixo da borda do balao. */
static void rb_bubble_tail(TinyBlocks_RenderableBlock* rb, float cx, float bottom, Col fill) {
for (int k = 0; k < 9; k++) {
float hw = 7.0f * (1.0f - (float)k / 9.0f);
rb_fill_rect(rb, cx - hw, bottom + k, hw * 2.0f, 1.0f, COL_BORDER);
}
for (int k = 0; k < 7; k++) {
float hw = 5.0f * (1.0f - (float)k / 7.0f);
rb_fill_rect(rb, cx - hw, bottom - 2 + k, hw * 2.0f, 1.0f, fill);
}
}
static inline bool in_rect(float mx, float my, float x, float y, float w, float h) static inline bool in_rect(float mx, float my, float x, float y, float w, float h)
{ return mx>=x && mx<x+w && my>=y && my<y+h; } { return mx>=x && mx<x+w && my>=y && my<y+h; }
@@ -2847,7 +2860,7 @@ static void render_workspace(Ed* ed, TinyBlocks_RenderableBlock* rb) {
float bx = b->ax + ox + 8, by = b->ay + oy - (BH + 6); float bx = b->ax + ox + 8, by = b->ay + oy - (BH + 6);
rb_fill_rrect(rb, bx, by, BW, BH, 10, COL_BORDER); rb_fill_rrect(rb, bx, by, BW, BH, 10, COL_BORDER);
rb_fill_rrect(rb, bx+1, by+1, BW-2, BH-2, 9, COL_WHITE); rb_fill_rrect(rb, bx+1, by+1, BW-2, BH-2, 9, COL_WHITE);
rb_fill_rect(rb, bx + 16, by + BH - 2, 10, 5, COL_WHITE); rb_bubble_tail(rb, bx + 22, by + BH - 1, COL_WHITE);
int iw = tb_image_width(ed->bubble_img); int iw = tb_image_width(ed->bubble_img);
int ih = tb_image_height(ed->bubble_img); int ih = tb_image_height(ed->bubble_img);
if (iw > 0 && ih > 0) { if (iw > 0 && ih > 0) {
@@ -2863,7 +2876,7 @@ static void render_workspace(Ed* ed, TinyBlocks_RenderableBlock* rb) {
float bx = b->ax + ox + 8, by = b->ay + oy - (BH + 6); float bx = b->ax + ox + 8, by = b->ay + oy - (BH + 6);
rb_fill_rrect(rb, bx, by, BW, BH, 10, COL_BORDER); rb_fill_rrect(rb, bx, by, BW, BH, 10, COL_BORDER);
rb_fill_rrect(rb, bx+1, by+1, BW-2, BH-2, 9, COL_WHITE); rb_fill_rrect(rb, bx+1, by+1, BW-2, BH-2, 9, COL_WHITE);
rb_fill_rect(rb, bx + 16, by + BH - 2, 10, 5, COL_WHITE); rb_bubble_tail(rb, bx + 22, by + BH - 1, COL_WHITE);
int n = (int)tb_json_array_length(ed->bubble_json); int n = (int)tb_json_array_length(ed->bubble_json);
double minx = 1e30, maxx = -1e30, miny = 1e30, maxy = -1e30; double minx = 1e30, maxx = -1e30, miny = 1e30, maxy = -1e30;
@@ -2902,7 +2915,7 @@ static void render_workspace(Ed* ed, TinyBlocks_RenderableBlock* rb) {
float bx = b->ax + ox + 8, by = b->ay + oy - 32; float bx = b->ax + ox + 8, by = b->ay + oy - 32;
rb_fill_rrect(rb, bx, by, w, 26, 8, COL_BORDER); rb_fill_rrect(rb, bx, by, w, 26, 8, COL_BORDER);
rb_fill_rrect(rb, bx+1, by+1, w-2, 24, 7, COL_WHITE); rb_fill_rrect(rb, bx+1, by+1, w-2, 24, 7, COL_WHITE);
rb_fill_rect(rb, bx + 12, by + 25, 8, 4, COL_WHITE); rb_bubble_tail(rb, bx + 16, by + 25, COL_WHITE);
rb_text_c(rb, bx + 10, by + 13, ed->bubble_text, COL_TEXT, FS); rb_text_c(rb, bx + 10, by + 13, ed->bubble_text, COL_TEXT, FS);
} }
} }