paint: begin stages tab
This commit is contained in:
@@ -2104,7 +2104,7 @@ tab_draw_array_t_array_t *ui_base_init_hwnd_tabs() {
|
||||
tab_draw_array_t *a0 = any_array_create_from_raw(
|
||||
(void *[]){
|
||||
_draw_callback_create(tab_layers_draw),
|
||||
_draw_callback_create(tab_history_draw),
|
||||
_draw_callback_create(tab_stages_draw),
|
||||
_draw_callback_create(tab_scripts_draw),
|
||||
},
|
||||
3);
|
||||
|
||||
@@ -382,7 +382,7 @@ typedef enum {
|
||||
ICON_LAYER_NEW = 77,
|
||||
ICON_WINDOW = 78,
|
||||
ICON_GESTURE = 79,
|
||||
ICON_FLAG = 80,
|
||||
ICON_NODES = 80,
|
||||
ICON_CURVE = 81,
|
||||
ICON_PATH = 82,
|
||||
ICON_ACCOUNT = 83,
|
||||
|
||||
@@ -364,7 +364,7 @@ char *strings_failed_to_read_mesh_data();
|
||||
char *strings_check_internet_connection();
|
||||
char *strings_asset_already_imported();
|
||||
char *strings_graphics_api();
|
||||
void tab_history_draw(ui_handle_t *htab);
|
||||
void tab_stages_draw(ui_handle_t *htab);
|
||||
void project_open();
|
||||
void project_save(bool save_and_quit);
|
||||
void project_save_as(bool save_and_quit);
|
||||
|
||||
@@ -176,12 +176,12 @@
|
||||
#include "tab_console.c"
|
||||
#include "tab_debug.c"
|
||||
#include "tab_fonts.c"
|
||||
#include "tab_history.c"
|
||||
#include "tab_layers.c"
|
||||
#include "tab_materials.c"
|
||||
#include "tab_meshes.c"
|
||||
#include "tab_plugins.c"
|
||||
#include "tab_scripts.c"
|
||||
#include "tab_stages.c"
|
||||
#include "tab_swatches.c"
|
||||
#include "tab_textures.c"
|
||||
#include "tab_timeline.c"
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
|
||||
#include "global.h"
|
||||
|
||||
void tab_history_draw(ui_handle_t *htab) {
|
||||
if (ui_tab(htab, tr("History"), false, -1, false)) {
|
||||
for (i32 i = 0; i < history_steps->length; ++i) {
|
||||
i32 active = history_steps->length - 1 - history_redos;
|
||||
if (i == active) {
|
||||
ui_fill(0, 0, ui->_window_w, ui->ops->theme->ELEMENT_H, ui->ops->theme->HIGHLIGHT_COL);
|
||||
}
|
||||
ui_text(history_steps->buffer[i]->name, UI_ALIGN_LEFT, 0x00000000);
|
||||
if (ui->is_released) { // Jump to undo step
|
||||
i32 diff = i - active;
|
||||
while (diff > 0) {
|
||||
diff--;
|
||||
history_redo();
|
||||
}
|
||||
while (diff < 0) {
|
||||
diff++;
|
||||
history_undo();
|
||||
}
|
||||
}
|
||||
ui_fill(0, 0, (ui->_window_w / (float)UI_SCALE() - 2), 1 * UI_SCALE(), ui->ops->theme->SEPARATOR_COL);
|
||||
}
|
||||
|
||||
bool in_focus = ui->input_x > ui->_window_x && ui->input_x < ui->_window_x + ui->_window_w && ui->input_y > ui->_window_y &&
|
||||
ui->input_y < ui->_window_y + ui->_window_h;
|
||||
if (in_focus) {
|
||||
i32 active = history_steps->length - 1 - history_redos;
|
||||
if (ui->is_key_pressed && ui->key_code == KEY_CODE_UP) {
|
||||
if (active > 0) {
|
||||
history_undo();
|
||||
}
|
||||
}
|
||||
if (ui->is_key_pressed && ui->key_code == KEY_CODE_DOWN) {
|
||||
if (history_redos > 0) {
|
||||
history_redo();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
|
||||
#include "global.h"
|
||||
|
||||
typedef struct slot_stage {
|
||||
char *name;
|
||||
} slot_stage_t;
|
||||
|
||||
any_array_t *project_stages = NULL;
|
||||
int selected_stage = 0;
|
||||
bool tab_stages_show_context_menu = false;
|
||||
slot_stage_t *tab_stages_context_stage = NULL;
|
||||
|
||||
void tab_stages_context_menu_delete(void *_) {
|
||||
array_remove(project_stages, tab_stages_context_stage);
|
||||
if (selected_stage >= project_stages->length) {
|
||||
selected_stage = project_stages->length - 1;
|
||||
}
|
||||
}
|
||||
|
||||
void tab_stages_context_menu_draw() {
|
||||
ui->enabled = project_stages->length > 1;
|
||||
if (ui_menu_button(tr("Delete"), "delete", ICON_DELETE)) {
|
||||
sys_notify_on_next_frame(&tab_stages_context_menu_delete, NULL);
|
||||
}
|
||||
ui->enabled = true;
|
||||
}
|
||||
|
||||
void tab_stages_draw(ui_handle_t *htab) {
|
||||
if (ui_tab(htab, tr("Stages"), false, -1, false)) {
|
||||
|
||||
ui_begin_sticky();
|
||||
f32_array_t *row = f32_array_create_from_raw(
|
||||
(f32[]){
|
||||
-70,
|
||||
},
|
||||
1);
|
||||
ui_row(row);
|
||||
if (ui_icon_button("New", ICON_PLUS, UI_ALIGN_CENTER)) {
|
||||
slot_stage_t *s = GC_ALLOC_INIT(slot_stage_t, {.name = string("%s %s", tr("Stage"), i32_to_string(project_stages->length + 1))});
|
||||
any_array_push(project_stages, s);
|
||||
selected_stage = project_stages->length - 1;
|
||||
}
|
||||
// if (ui_button(tr("Nodes"), UI_ALIGN_CENTER, "")) {}
|
||||
ui_end_sticky();
|
||||
|
||||
if (project_stages == NULL) {
|
||||
project_stages = any_array_create(0);
|
||||
gc_root(project_stages);
|
||||
|
||||
slot_stage_t *s = GC_ALLOC_INIT(slot_stage_t, {.name = "Stage 1"});
|
||||
any_array_push(project_stages, s);
|
||||
}
|
||||
|
||||
for (i32 i = 0; i < project_stages->length; ++i) {
|
||||
slot_stage_t *s = project_stages->buffer[i];
|
||||
tab_stages_show_context_menu = false;
|
||||
if (i == selected_stage) {
|
||||
ui_fill(0, 0, ui->_window_w, ui->ops->theme->ELEMENT_H, ui->ops->theme->HIGHLIGHT_COL);
|
||||
}
|
||||
ui_text(s->name, UI_ALIGN_LEFT, 0x00000000);
|
||||
if (ui->is_released) {
|
||||
selected_stage = i;
|
||||
}
|
||||
if (ui->is_hovered && ui->input_released_r) {
|
||||
gc_unroot(tab_stages_context_stage);
|
||||
tab_stages_context_stage = s;
|
||||
gc_root(tab_stages_context_stage);
|
||||
tab_stages_show_context_menu = true;
|
||||
}
|
||||
ui_fill(0, 0, (ui->_window_w / (float)UI_SCALE() - 2), 1 * UI_SCALE(), ui->ops->theme->SEPARATOR_COL);
|
||||
if (tab_stages_show_context_menu) {
|
||||
ui_menu_draw(&tab_stages_context_menu_draw, -1, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user