From a0291df02429dcf24b7889ea3956474c73f58454 Mon Sep 17 00:00:00 2001 From: johannes hanika Date: Sat, 7 Sep 2024 12:27:34 +0200 Subject: [PATCH] lighttable: streamlined collection filters --- src/gui/render_lighttable.c | 151 ++++++++++++++++-------------------- 1 file changed, 66 insertions(+), 85 deletions(-) diff --git a/src/gui/render_lighttable.c b/src/gui/render_lighttable.c index 947f700f..07747b63 100644 --- a/src/gui/render_lighttable.c +++ b/src/gui/render_lighttable.c @@ -608,106 +608,87 @@ void render_lighttable_right_panel() nk_label(&vkdt.ctx, "sort", NK_TEXT_LEFT); nk_layout_row(ctx, NK_STATIC, row_height, 2, ratio); - int rating = (ft->active >> s_prop_rating)&1; - res = nk_combo_string(ctx, "any\0filter by\0\0", rating, 0xffff, row_height, size); - if(res != rating) + int resi = CLAMP(ft->rating, 0, 5); + nk_style_push_font(ctx, &dt_gui_get_font(3)->handle); + resi = nk_combo_string(ctx, "\ue836\0\ue838\0\ue838\ue838\0\ue838\ue838\ue838\0\ue838\ue838\ue838\ue838\0\ue838\ue838\ue838\ue838\ue838\0\0", resi, 0xffff, row_height, size); + + nk_style_pop_font(ctx); + if(resi != ft->rating) { - ft->active ^= 1<active &= ~(1<active |= 1<rating = resi; update_collection = 1; } + dt_tooltip("select the minimum star rating of images in the collection"); nk_label(ctx, "rating", NK_TEXT_LEFT); - if(ft->active & (1<active & (1<labels = 0; + for(int k=0;k<7;k++) { - nk_layout_row(ctx, NK_STATIC, row_height, 2, ratio); - int resi = ft->rating; - nk_property_int(ctx, "#", 0, &resi, 5, 1, 1); - if(resi != ft->rating) + nk_style_push_style_item(ctx, &ctx->style.button.normal, nk_style_item_color(col[k])); + nk_style_push_float(ctx, &ctx->style.button.border, 1); + + int sel = ft->labels & (1<style.button.border, vkdt.wstate.fontsize*0.2); + if(sel) nk_style_push_float(ctx, &ctx->style.button.rounding, row_height/2); + else nk_style_push_float(ctx, &ctx->style.button.rounding, 0); + dt_tooltip(k==0?"red":k==1?"green":k==2?"blue":k==3?"yellow":k==4?"purple":k==5?"video":"bracket"); + if(nk_button_label(ctx, k==5 ? "m" : k==6 ? "[ ]" : " ")) { - ft->rating = resi; + ft->labels ^= (1<labels) ft->active &= ~(1<active |= 1<active >> s_prop_labels)&1; - res = nk_combo_string(ctx, "any\0filter by\0\0", label, 0xffff, row_height, size); - if(res != label) - { - ft->active ^= 1<active & (1<style.button.normal, nk_style_item_color(col[k])); - nk_style_push_float(ctx, &ctx->style.button.border, 1); - - int sel = ft->labels & (1<style.button.border, vkdt.wstate.fontsize*0.2); - if(sel) nk_style_push_float(ctx, &ctx->style.button.rounding, row_height/2); - else nk_style_push_float(ctx, &ctx->style.button.rounding, 0); - dt_tooltip(k==0?"red":k==1?"green":k==2?"blue":k==3?"yellow":k==4?"purple":k==5?"video":"bracket"); - if(nk_button_label(ctx, k==5 ? "m" : k==6 ? "[ ]" : " ")) - { - ft->labels ^= (1<active >> s_prop_filetype)&1; - res = nk_combo_string(ctx, "any\0filter by\0\0", filetype, 0xffff, row_height, size); - if(res != filetype) + static int32_t filter_module_idx = 0; + static const char *input_modules_str = + "any\0" + "raw : raw files\0" + "jpg : jpg images\0" + "exr : high dynamic range scene linear exr\0" + "vid : compressed video\0" + "mlv : magic lantern raw video\0" + "mcraw: motioncam raw video\0\0"; + dt_token_t input_modules[] = { + 0, + dt_token("i-raw"), + dt_token("i-jpg"), + dt_token("i-exr"), + dt_token("i-vid"), + dt_token("i-mlv"), + dt_token("i-mcraw"), + }; + dt_token_t filter_val = ft->filetype; + for(int k=0;kactive ^= 1<filetype = input_modules[res]; update_collection = 1; } nk_label(ctx, "filetype", NK_TEXT_LEFT); - if(ft->active & (1<filetype; - for(int k=0;kfiletype = input_modules[res]; - update_collection = 1; - } - nk_label(ctx, "input module", NK_TEXT_LEFT); - } + if(!ft->filetype) ft->active &= ~(1<active |= 1<active >> s_prop_filename)&1;