add unsaved indicator
parent
2db02dc89a
commit
2bf2e5d2e4
BIN
art/demo.ecotex
BIN
art/demo.ecotex
Binary file not shown.
13934
art/gen/demo.h
13934
art/gen/demo.h
File diff suppressed because it is too large
Load Diff
BIN
art/gen/demo.png
BIN
art/gen/demo.png
Binary file not shown.
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 9.0 KiB |
|
@ -16,18 +16,20 @@
|
|||
#define GUI_TEXTBOX_EXTENDED_IMPLEMENTATION
|
||||
#include "gui_textbox_extended.h"
|
||||
|
||||
static uint16_t screenWidth = 1280;
|
||||
static uint16_t screenHeight = 720;
|
||||
static float zoom = 4.0f;
|
||||
static Texture2D checker_tex;
|
||||
static uint16_t old_screen_w;
|
||||
static uint16_t old_screen_h;
|
||||
static bool is_repaint_locked = false;
|
||||
|
||||
#define TD_DEFAULT_IMG_WIDTH 64
|
||||
#define TD_DEFAULT_IMG_HEIGHT 64
|
||||
#define TD_UI_PADDING 5.0f
|
||||
#define TD_UI_PREVIEW_BORDER 4.0f
|
||||
#define TD_UI_DEFAULT_ZOOM 4.0f
|
||||
|
||||
static uint16_t screenWidth = 1280;
|
||||
static uint16_t screenHeight = 720;
|
||||
static float zoom = TD_UI_DEFAULT_ZOOM;
|
||||
static float old_zoom = TD_UI_DEFAULT_ZOOM;
|
||||
static Texture2D checker_tex;
|
||||
static uint16_t old_screen_w;
|
||||
static uint16_t old_screen_h;
|
||||
static bool is_repaint_locked = false;
|
||||
|
||||
typedef enum {
|
||||
TPARAM_FLOAT,
|
||||
|
@ -83,6 +85,7 @@ typedef struct {
|
|||
Image img;
|
||||
Texture2D tex;
|
||||
GuiFileDialogState fileDialog;
|
||||
bool is_saved;
|
||||
|
||||
td_op *ops; //< zpl_array
|
||||
int selected_op;
|
||||
|
@ -272,6 +275,7 @@ void texed_new(int32_t w, int32_t h) {
|
|||
texed_repaint_preview();
|
||||
|
||||
ctx.fileDialog = InitGuiFileDialog(420, 310, zpl_bprintf("%s/art", GetWorkingDirectory()), false);
|
||||
ctx.is_saved = true;
|
||||
}
|
||||
|
||||
void texed_destroy(void) {
|
||||
|
@ -301,6 +305,7 @@ void texed_repaint_preview(void) {
|
|||
|
||||
void texed_compose_image(void) {
|
||||
if (is_repaint_locked) return;
|
||||
ctx.is_saved = false;
|
||||
texed_process_params();
|
||||
texed_process_ops();
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ void texed_load(void) {
|
|||
is_repaint_locked = false;
|
||||
texed_repaint_preview();
|
||||
UnloadFileData(databuf);
|
||||
ctx.is_saved = true;
|
||||
}
|
||||
|
||||
void texed_save(void) {
|
||||
|
@ -98,4 +99,5 @@ void texed_save(void) {
|
|||
}
|
||||
|
||||
SaveFileData(zpl_bprintf("art/%s", ctx.filepath), databuf, pc.current - pc.start);
|
||||
ctx.is_saved = true;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,10 @@ void texed_draw_topbar(zpl_aabb2 r) {
|
|||
zpl_aabb2 zoom_ctrl_r = zpl_aabb2_cut_left(&r, 150.0f);
|
||||
|
||||
zoom = GuiSlider(aabb2_ray(zoom_ctrl_r), "zoom: ", zpl_bprintf("%.02f x", zoom), zoom, 1.0f, 16.0f);
|
||||
if (zoom != old_zoom) {
|
||||
ctx.is_saved = false;
|
||||
old_zoom = zoom;
|
||||
}
|
||||
|
||||
zpl_aabb2_cut_left(&r, 100.0f);
|
||||
|
||||
|
@ -58,18 +62,22 @@ void texed_draw_topbar(zpl_aabb2 r) {
|
|||
|
||||
if (ctx.fileDialog.SelectFilePressed && save_as_pending) {
|
||||
ctx.fileDialog.SelectFilePressed = false;
|
||||
if (!IsFileExtension(ctx.fileDialog.fileNameText, ".ecotex")) {
|
||||
zpl_strcpy(ctx.fileDialog.fileNameText, zpl_bprintf("%s.ecotex", ctx.fileDialog.fileNameText));
|
||||
if (TextLength(ctx.fileDialog.fileNameText)) {
|
||||
if (!IsFileExtension(ctx.fileDialog.fileNameText, ".ecotex")) {
|
||||
zpl_strcpy(ctx.fileDialog.fileNameText, zpl_bprintf("%s.ecotex", ctx.fileDialog.fileNameText));
|
||||
}
|
||||
zpl_strcpy(filename, ctx.fileDialog.fileNameText);
|
||||
ctx.filepath = filename;
|
||||
save_as_pending = false;
|
||||
texed_save();
|
||||
} else {
|
||||
ctx.fileDialog.fileDialogActive = true;
|
||||
}
|
||||
zpl_strcpy(filename, ctx.fileDialog.fileNameText);
|
||||
ctx.filepath = filename;
|
||||
save_as_pending = false;
|
||||
texed_save();
|
||||
}
|
||||
|
||||
zpl_aabb2 prj_name_r = zpl_aabb2_cut_right(&r, 200.0f);
|
||||
GuiSetStyle(LABEL, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_RIGHT);
|
||||
GuiDrawText(zpl_bprintf("Project: %s", ctx.filepath ? ctx.filepath : "(unnamed)"), 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(BLACK, guiAlpha));
|
||||
GuiSetStyle(LABEL, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_LEFT);
|
||||
}
|
||||
|
||||
|
@ -88,7 +96,7 @@ void texed_draw_oplist_pane(zpl_aabb2 r) {
|
|||
|
||||
for (int i = 0, cnt = 0; i < DEF_OPS_LEN; i += 1) {
|
||||
if (ctx.ops[i].is_locked) continue;
|
||||
zpl_strcat(add_op_list, zpl_bprintf("%.*s%s", cnt == 0 ? 0 : 1, ";", default_ops[i].name));
|
||||
zpl_strcat(add_op_list, zpl_bprintf("%s%s", cnt == 0 ? "" : ";", default_ops[i].name));
|
||||
cnt += 1;
|
||||
}
|
||||
}
|
||||
|
@ -157,6 +165,7 @@ void texed_draw_oplist_pane(zpl_aabb2 r) {
|
|||
|
||||
if (GuiButton(aabb2_ray(select_r), "#141#")) {
|
||||
ctx.selected_op = i;
|
||||
ctx.is_saved = false;
|
||||
}
|
||||
GuiSetState(GUI_STATE_NORMAL);
|
||||
|
||||
|
@ -165,6 +174,7 @@ void texed_draw_oplist_pane(zpl_aabb2 r) {
|
|||
if (default_ops[ctx.ops[i].kind].is_locked) GuiSetState(GUI_STATE_DISABLED);
|
||||
if (GuiButton(aabb2_ray(lock_r), ctx.ops[i].is_locked ? "#137#" : "#138#")) {
|
||||
ctx.ops[i].is_locked = !ctx.ops[i].is_locked;
|
||||
ctx.is_saved = false;
|
||||
}
|
||||
GuiSetState(GUI_STATE_NORMAL);
|
||||
|
||||
|
|
Loading…
Reference in New Issue