file select screen displays user info logs

This commit is contained in:
Yousef Khadadeh 2026-05-17 10:02:18 +03:00
parent f214ba12f0
commit 3bc138e81f
3 changed files with 83 additions and 6 deletions

View file

@ -65,6 +65,17 @@ FileSelectScreen::FileSelectScreen(MainProgram& m): Screen(m) {
update_file_list(trashListTemp, trashPath, true);
}
void FileSelectScreen::update() {
std::erase_if(main.logMessages, [&](auto& logM) {
logM.time.update_time_since();
if(logM.time > UserLogMessage::FADE_START_TIME) {
main.g.gui.set_to_layout();
return logM.time >= UserLogMessage::DISPLAY_TIME;
}
return false;
});
}
void FileSelectScreen::gui_layout_run() {
main_display();
}
@ -136,6 +147,65 @@ void FileSelectScreen::update_file_list(std::vector<FileInfo>& fL, const std::fi
sort_file_list(fL);
}
void FileSelectScreen::global_log() {
auto& gui = main.g.gui;
auto& io = gui.io;
float notificationSize = std::min(300.0f, gui.io.safeWindowRect.width() - 20.0f);
gui.set_z_index(gui.get_z_index() + 100, [&] {
gui.new_id("Global log popup list file select screen", [&] {
CLAY_AUTO_ID({
.layout = {
.sizing = {.width = CLAY_SIZING_FIXED(notificationSize), .height = CLAY_SIZING_FIT(0) },
.childGap = io.theme->childGap1,
.childAlignment = { .x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_BOTTOM},
.layoutDirection = CLAY_TOP_TO_BOTTOM
},
.floating = {.offset = {10, -10}, .zIndex = gui.get_z_index(), .attachPoints = {.element = CLAY_ATTACH_POINT_LEFT_BOTTOM, .parent = CLAY_ATTACH_POINT_LEFT_BOTTOM}, .attachTo = CLAY_ATTACH_TO_PARENT}
}) {
for(size_t i = 0; i < main.logMessages.size(); i++) {
auto& logM = main.logMessages[i];
logM.time.update_time_since();
if(logM.time < UserLogMessage::DISPLAY_TIME) {
if(logM.whereToDisplay == UserLogMessage::DISPLAY_DESKTOP_ONLY)
continue;
float a = 1.0f - lerp_time<float>(logM.time, UserLogMessage::DISPLAY_TIME, UserLogMessage::FADE_START_TIME);
gui.new_id(i, [&] {
gui.element<LayoutElement>("Global log message", [&] (LayoutElement*, const Clay_ElementId& lId) {
CLAY(lId, {
.layout = {
.sizing = {.width = CLAY_SIZING_FIT(notificationSize), .height = CLAY_SIZING_FIT(0) },
.padding = CLAY_PADDING_ALL(io.theme->padding1),
.childGap = 0,
.childAlignment = { .x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_TOP},
.layoutDirection = CLAY_TOP_TO_BOTTOM
},
.backgroundColor = convert_vec4<Clay_Color>(color_mul_alpha(io.theme->backColor1, a)),
.cornerRadius = CLAY_CORNER_RADIUS(io.theme->windowCorners1)
}) {
SkColor4f c{0, 0, 0, 0};
switch(logM.color) {
case UserLogMessage::COLOR_NORMAL:
c = io.theme->frontColor1;
break;
case UserLogMessage::COLOR_ERROR:
c = io.theme->errorColor;
break;
}
text_label_color(gui, logM.text, color_mul_alpha(c, a));
}
});
});
}
else
break;
}
}
});
});
}
void FileSelectScreen::sort_file_list(std::vector<FileInfo>& fL) {
switch(saveInfo.fileSort) {
case SaveInfo::FileSort::ALPHABETICAL_ASCENDING:
@ -229,6 +299,7 @@ void FileSelectScreen::main_display() {
settings_view();
break;
}
global_log();
}
window_gap_side_bar(gui, WindowFillSideBarConfig::Direction::RIGHT);
}
@ -373,7 +444,7 @@ void FileSelectScreen::delete_selected_files_in_trash() {
void FileSelectScreen::edit_action_bar() {
auto& gui = main.g.gui;
if(actionBarOpenAnim->get_val()) {
gui.set_z_index(gui.get_z_index() + 3, [&] {
gui.set_z_index(gui.get_z_index() + 1000, [&] {
CLAY_AUTO_ID({
.layout = {
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0)},