Files
armorpaint/paint/sources/tab_history.c
T

43 lines
1.2 KiB
C
Raw Normal View History

2026-03-09 13:17:15 +01:00
#include "global.h"
2026-03-06 12:56:38 +01:00
void tab_history_draw(ui_handle_t *htab) {
2026-03-15 11:37:45 +01:00
if (ui_tab(htab, tr("History"), false, -1, false)) {
2026-03-06 12:56:38 +01:00
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);
}
2026-04-15 22:34:47 +02:00
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();
}
}
}
2026-03-06 12:56:38 +01:00
}
}