add tiling preview
parent
5c063fb0b7
commit
c7f7b123bb
|
@ -31,6 +31,7 @@ static Texture2D checker_tex;
|
|||
static uint16_t old_screen_w;
|
||||
static uint16_t old_screen_h;
|
||||
static bool is_repaint_locked = false;
|
||||
static int render_tiles = 0;
|
||||
|
||||
typedef enum {
|
||||
TPARAM_FLOAT,
|
||||
|
@ -294,12 +295,16 @@ void texed_run(int argc, char **argv) {
|
|||
DrawTextureEx(checker_tex, (Vector2){ preview_window.min.x, preview_window.min.y}, 0.0f, 1.0f, WHITE);
|
||||
|
||||
Rectangle tex_rect = aabb2_ray(preview_window);
|
||||
DrawTextureEx(ctx.tex, (Vector2){
|
||||
tex_rect.x + zpl_max(0.0f, tex_rect.width/2.0f - (ctx.tex.width*zoom)/2.0f),
|
||||
tex_rect.y + zpl_max(0.0f, tex_rect.height/2.0f - (ctx.tex.height*zoom)/2.0f),
|
||||
}, 0.0f, zoom, WHITE);
|
||||
float tile_x = tex_rect.x + zpl_max(0.0f, tex_rect.width/2.0f - (ctx.tex.width*zoom)/2.0f);
|
||||
float tile_y = tex_rect.y + zpl_max(0.0f, tex_rect.height/2.0f - (ctx.tex.height*zoom)/2.0f);
|
||||
|
||||
DrawAABB(topbar, RAYWHITE);
|
||||
for (int x = -render_tiles; x <= render_tiles; x++) {
|
||||
for (int y = -render_tiles; y <= render_tiles; y++) {
|
||||
DrawTextureEx(ctx.tex, (Vector2){tile_x + (ctx.tex.width*zoom) * x, tile_y + (ctx.tex.height*zoom)*y}, 0.0f, zoom, WHITE);
|
||||
}
|
||||
}
|
||||
|
||||
DrawAABB(topbar, BLACK);
|
||||
DrawAABB(property_pane, GetColor(0x422060));
|
||||
DrawAABB(oplist_pane, GetColor(0x425060));
|
||||
|
||||
|
|
|
@ -19,6 +19,12 @@ void texed_draw_topbar(zpl_aabb2 r) {
|
|||
|
||||
zpl_aabb2_cut_left(&r, 100.0f);
|
||||
|
||||
zpl_aabb2 render_tiles_ctrl_r = zpl_aabb2_cut_left(&r, 150.0f);
|
||||
|
||||
render_tiles = (int)GuiSlider(aabb2_ray(render_tiles_ctrl_r), "tiles: ", zpl_bprintf("%d", render_tiles+1), render_tiles, 0.0f, 50.0f);
|
||||
|
||||
zpl_aabb2_cut_left(&r, 100.0f);
|
||||
|
||||
zpl_aabb2 new_prj_r = zpl_aabb2_cut_left(&r, 60.0f);
|
||||
static bool new_pending = false;
|
||||
|
||||
|
@ -127,7 +133,7 @@ void texed_draw_topbar(zpl_aabb2 r) {
|
|||
zpl_aabb2 prj_name_r = zpl_aabb2_cut_right(&r, 200.0f);
|
||||
zpl_aabb2_cut_right(&prj_name_r, 15.0f);
|
||||
GuiSetStyle(LABEL, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_RIGHT);
|
||||
GuiDrawText(zpl_bprintf("Project: %s%s", ctx.filepath ? ctx.filepath : "(unnamed)", ctx.is_saved ? "" : "*"), GetTextBounds(LABEL, aabb2_ray(prj_name_r)), GuiGetStyle(LABEL, TEXT_ALIGNMENT), Fade(BLACK, guiAlpha));
|
||||
GuiDrawText(zpl_bprintf("Project: %s%s", ctx.filepath ? ctx.filepath : "(unnamed)", ctx.is_saved ? "" : "*"), GetTextBounds(LABEL, aabb2_ray(prj_name_r)), GuiGetStyle(LABEL, TEXT_ALIGNMENT), Fade(GREEN, guiAlpha));
|
||||
GuiSetStyle(LABEL, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_LEFT);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue