editor: bundle com libraries privadas + hot reload (tinyblocks-api) e aba de imagem estilo Krita
- tinyblocks-editor agora e um bundle: libraries privadas em
libraries/tinyblocks-editor-{widgets,image} (.a + .so), com library.toml
(bundle = tinyblocks-editor, private = true -> nao aparecem no libman).
- O editor carrega os modulos por dlopen via tinyblocks-api e chama tudo por
tabelas de ponteiros (tb_ed_w, tb_ed_img): da para recompilar so a parte que
mudou e o editor recarrega ao vivo (make ed-modules), sem reiniciar.
- tinyblocks-api ganhou modulos de codigo (tb_api_code_*) e watcher de
arquivos (inotify, com mtime como reserva).
- libman: entradas com bundle/private nao sao listadas como extensao.
- Aba de imagem: layout estilo Krita - ferramentas na esquerda, tela no meio,
roda de cores + paleta + camadas na coluna da direita; miniatura por camada
(como as fantasias do Scratch); rodape enxuto (Desfazer/Limpar/zoom).
- Ferramenta selecionar (mover/redimensionar/excluir pixels) e consertada a
geometria da folha (doc = area de desenho, zoom puro).
- Makefile: alvo ed-modules; AppImage empacota os .so do bundle.
- harness: testes de imagem atualizados + testes de cores na lateral.
This commit is contained in:
1 parent
036162280d
commit
0143d3efd5
21 files changed
+3775
-557
No files matched your search
@@ -0,0 +1,31 @@
|
||||
# Makefile da library privada tinyblocks-editor-widgets
|
||||
# Bundle "tinyblocks-editor": vem junto com o editor.
|
||||
# Constroi build/libtinyblocks-editor-widgets.a e .so
|
||||
CC := gcc
|
||||
BUILD := build
|
||||
|
||||
CFLAGS := -std=c11 -Wall -Wextra -pedantic \
|
||||
-D_POSIX_C_SOURCE=200809L \
|
||||
-I../../../../include -Iinclude -I../../../tinyblocks-graphics/include
|
||||
|
||||
OBJS := $(BUILD)/tb_editor_widgets.o
|
||||
LIB_A := $(BUILD)/libtinyblocks-editor-widgets.a
|
||||
LIB_SO := $(BUILD)/libtinyblocks-editor-widgets.so
|
||||
|
||||
.PHONY: all static shared clean
|
||||
all: static shared
|
||||
static: $(LIB_A)
|
||||
shared: $(LIB_SO)
|
||||
|
||||
$(BUILD)/tb_editor_widgets.o: src/tb_editor_widgets.c include/tb_editor_widgets.h
|
||||
@mkdir -p $(BUILD)
|
||||
$(CC) $(CFLAGS) -fPIC -c $< -o $@
|
||||
|
||||
$(LIB_A): $(OBJS)
|
||||
ar rcs $@ $^
|
||||
|
||||
$(LIB_SO): $(OBJS)
|
||||
$(CC) -shared -o $@ $^
|
||||
|
||||
clean:
|
||||
$(RM) -r $(BUILD)
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* TinyBlocks - tb_editor_widgets.h
|
||||
* Library privada do editor: primitivas de desenho e "tema" (cores).
|
||||
*
|
||||
* E o tijolo mais baixo do editor: emite TinyBlocks_DrawCmd num
|
||||
* TinyBlocks_RenderableBlock e nao guarda estado. Nao conhece o editor
|
||||
* (Ed/Tab) nem o backend grafico, por isso pode ser usada por qualquer
|
||||
* library do bundle do editor (blocos, imagem, codigo, dialogo...).
|
||||
*/
|
||||
#ifndef TB_EDITOR_WIDGETS_H
|
||||
#define TB_EDITOR_WIDGETS_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <tinyblocks/tb_renderable_block.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Cor RGBA (0..1) */
|
||||
typedef struct { float r, g, b, a; } TbEwColor;
|
||||
|
||||
#define TB_EW_RGB(r,g,b) {(r)/255.0f,(g)/255.0f,(b)/255.0f,1.0f}
|
||||
#define TB_EW_RGBA(r,g,b,a) ((TbEwColor){(r)/255.0f,(g)/255.0f,(b)/255.0f,(a)/255.0f})
|
||||
|
||||
TbEwColor tb_ew_col_mul(TbEwColor c, float k);
|
||||
|
||||
/* Primitivas: espelham tb_draw_* mas com TbEwColor */
|
||||
void tb_ew_fill_rect (TinyBlocks_RenderableBlock* rb, float x, float y, float w, float h, TbEwColor c);
|
||||
void tb_ew_fill_rrect (TinyBlocks_RenderableBlock* rb, float x, float y, float w, float h, float rad, TbEwColor c);
|
||||
void tb_ew_fill_circle(TinyBlocks_RenderableBlock* rb, float cx, float cy, float rad, TbEwColor c);
|
||||
void tb_ew_stroke_rect(TinyBlocks_RenderableBlock* rb, float x, float y, float w, float h, float t, TbEwColor c);
|
||||
void tb_ew_stroke_circle(TinyBlocks_RenderableBlock* rb, float cx, float cy, float rad, float t, TbEwColor c);
|
||||
void tb_ew_line (TinyBlocks_RenderableBlock* rb, float x0, float y0, float x1, float y1, float w, TbEwColor c);
|
||||
/* Texto alinhado a esquerda em x, centrado verticalmente em cy */
|
||||
void tb_ew_text_c (TinyBlocks_RenderableBlock* rb, float x, float cy, const char* s, TbEwColor c, float fs);
|
||||
/* Largura real do texto, medida pelo backend grafico */
|
||||
float tb_ew_text_width(const char* s, float fs);
|
||||
|
||||
bool tb_ew_in_rect(float mx, float my, float x, float y, float w, float h);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* TB_EDITOR_WIDGETS_H */
|
||||
@@ -0,0 +1,17 @@
|
||||
# Widgets privados do editor (bundle "tinyblocks-editor").
|
||||
[library]
|
||||
name = "tinyblocks-editor-widgets"
|
||||
bundle = "tinyblocks-editor"
|
||||
private = true
|
||||
version = "1.0.0"
|
||||
category = "Editor"
|
||||
description = "Primitivas de desenho e tema do editor"
|
||||
color = [76, 151, 255, 255]
|
||||
dark = [61, 121, 204, 255]
|
||||
|
||||
[build]
|
||||
sources = ["src/tb_editor_widgets.c"]
|
||||
includes = ["include"]
|
||||
shared = "build/libtinyblocks-editor-widgets.so"
|
||||
static = "build/libtinyblocks-editor-widgets.a"
|
||||
depends = []
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* TinyBlocks - tb_editor_widgets.c
|
||||
* Implementacao das primitivas de desenho do editor. Sem estado: apenas
|
||||
* traduz chamadas em TinyBlocks_DrawCmd.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <tb_graphics.h>
|
||||
#include "tb_editor_widgets.h"
|
||||
|
||||
TbEwColor tb_ew_col_mul(TbEwColor c, float k) {
|
||||
TbEwColor r;
|
||||
r.r = c.r * k; r.g = c.g * k; r.b = c.b * k; r.a = c.a;
|
||||
return r;
|
||||
}
|
||||
|
||||
void tb_ew_fill_rect(TinyBlocks_RenderableBlock* rb, float x, float y, float w, float h, TbEwColor c)
|
||||
{ tb_draw_fill_rect(rb, x, y, w, h, c.r, c.g, c.b, c.a); }
|
||||
|
||||
void tb_ew_fill_rrect(TinyBlocks_RenderableBlock* rb, float x, float y, float w, float h, float rad, TbEwColor c)
|
||||
{ tb_draw_fill_rrect(rb, x, y, w, h, rad < 0 ? 0 : rad, c.r, c.g, c.b, c.a); }
|
||||
|
||||
void tb_ew_fill_circle(TinyBlocks_RenderableBlock* rb, float cx, float cy, float rad, TbEwColor c)
|
||||
{ tb_draw_fill_circle(rb, cx, cy, rad, c.r, c.g, c.b, c.a); }
|
||||
|
||||
void tb_ew_stroke_rect(TinyBlocks_RenderableBlock* rb, float x, float y, float w, float h, float t, TbEwColor c)
|
||||
{ tb_draw_stroke_rect(rb, x, y, w, h, t, c.r, c.g, c.b, c.a); }
|
||||
|
||||
void tb_ew_stroke_circle(TinyBlocks_RenderableBlock* rb, float cx, float cy, float rad, float t, TbEwColor c)
|
||||
{ tb_draw_stroke_circle(rb, cx, cy, rad, t, c.r, c.g, c.b, c.a); }
|
||||
|
||||
void tb_ew_line(TinyBlocks_RenderableBlock* rb, float x0, float y0, float x1, float y1, float w, TbEwColor c)
|
||||
{ tb_draw_stroke_line(rb, x0, y0, x1, y1, w, c.r, c.g, c.b, c.a); }
|
||||
|
||||
void tb_ew_text_c(TinyBlocks_RenderableBlock* rb, float x, float cy, const char* s, TbEwColor c, float fs) {
|
||||
if (!s || !s[0]) return;
|
||||
tb_draw_text(rb, x, cy + fs * 0.36f, s, fs, c.r, c.g, c.b, c.a);
|
||||
}
|
||||
|
||||
float tb_ew_text_width(const char* s, float fs) {
|
||||
return tb_graphics_measure_text(s, fs);
|
||||
}
|
||||
|
||||
bool tb_ew_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; }
|
||||
Reference in new issue
Block a user