From a79a662e8037532ec75394ab92a659ce7333d59c Mon Sep 17 00:00:00 2001 From: Raymond Namyst Date: Tue, 15 Feb 2022 09:52:30 +0100 Subject: [PATCH] New footprint mode: press 'f' to show the full tile coverage of all displayed tasks --- traces/img/footprint.png | Bin 0 -> 4518 bytes traces/include/trace_graphics.h | 1 + traces/src/main.c | 3 ++ traces/src/trace_graphics.c | 81 +++++++++++++++++++++++++------- 4 files changed, 69 insertions(+), 16 deletions(-) create mode 100644 traces/img/footprint.png diff --git a/traces/img/footprint.png b/traces/img/footprint.png new file mode 100644 index 0000000000000000000000000000000000000000..da5935a2f33167ae3061440453fe41af824366fd GIT binary patch literal 4518 zcmc&&2~-o;8jjLhKyjgNSj7;YiiIJWOahr`R3IpMfCU5<1a&f*z(6t+lMuqLAPB_; z7ob$7iq(n~DF|8-5TBrFp^A#yMy-nAQW0=NQL3G=MBAfJ&+B{VaY!<`_q+e{-S7YJ zJxTYOKhMH^f;o*wvk-X*{isg~^|Cb`LcNQR7O$i}%oHAhDjJPlV|Wd+lLTF&(ai7Q z{)^R%y}kG-DR)F9q!@G5$`urvMw>ZXt3c2QOidSKp*SI6bR0R#pyLt&V-eSz<*jhT z!f=lmCAJ`DzCRihfx;5T>{;}gT0Uh!j;Rs4RxTq{e64`dYnM+w8-|$-dM`vBAz-)| z9MTti`_SD;B}R941Ob%AV$q#pM@)jS#gG(19q4Qp8)SmizcT({}N1ys4)S3zw>MuzsMH97Vj`h{L8ah`;}Sj(W&5D4&ikQm@1 zEGHBJIUF|19at|U(MW^b4D0)fPeP)UjaObF7-pe7HV=?WrIbl7hXe3Xma^=c~cwJBFq+xGXUOvm~Gxsm90K<`!Ef5+cDRrh{v_W!U=OvA0DukA4Z+L8Lc3;Vd7YpBuQgPZ@x z-t(S1q)u`^b!xoh9Kld7#KAxaU?Cg?KqMR|0CD1q0f=WfUnI_mGmmP#ebJDA_Z%_w zl3p5KyQ~ciQ8z%tqw)4heKFo&F@maHC3QQ!Wd;}1XhTqu(8W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g(X`Cdd9?5>bk7dSnUlQ_zgW!8aEAd}$KT8(|q{R|}+Ei)pbU+Xf}HMKyJiV>R}=4Eaer Q!!Ic!_xZy8uFI4D0C%j{W&i*H literal 0 HcmV?d00001 diff --git a/traces/include/trace_graphics.h b/traces/include/trace_graphics.h index 70c4c46..44652d9 100644 --- a/traces/include/trace_graphics.h +++ b/traces/include/trace_graphics.h @@ -24,6 +24,7 @@ void trace_graphics_display_all (void); void trace_graphics_toggle_align_mode (void); void trace_graphics_toggle_vh_mode (void); void trace_graphics_toggle_tracking_mode (void); +void trace_graphics_toggle_footprint_mode (void); extern int use_thumbnails; extern unsigned char brightness; diff --git a/traces/src/main.c b/traces/src/main.c index 0b5daa8..00a595d 100644 --- a/traces/src/main.c +++ b/traces/src/main.c @@ -195,6 +195,9 @@ int main (int argc, char **argv) case SDLK_t: trace_graphics_toggle_tracking_mode (); break; + case SDLK_f: + trace_graphics_toggle_footprint_mode (); + break; case SDLK_z: trace_graphics_zoom_to_selection (); break; diff --git a/traces/src/trace_graphics.c b/traces/src/trace_graphics.c index e71fdd3..abaed98 100644 --- a/traces/src/trace_graphics.c +++ b/traces/src/trace_graphics.c @@ -82,9 +82,10 @@ static SDL_Texture *tab_low = NULL; static SDL_Texture *align_tex = NULL; static SDL_Texture *quick_nav_tex = NULL; static SDL_Texture *track_tex = NULL; +static SDL_Texture *footprint_tex = NULL; static SDL_Texture *digit_tex[10] = {NULL}; -static SDL_Rect align_rect, quick_nav_rect, track_rect; +static SDL_Rect align_rect, quick_nav_rect, track_rect, footprint_rect; static unsigned digit_tex_width[10]; static unsigned digit_tex_height; @@ -92,6 +93,7 @@ static unsigned digit_tex_height; static int quick_nav_mode = 0; static int horiz_mode = 0; static int tracking_mode = 0; +static int footprint_mode = 0; static long start_time = 0, end_time = 0, duration = 0; @@ -183,6 +185,9 @@ static void layout_place_buttons (void) track_rect.x = align_rect.x - Y_MARGIN - track_rect.w; track_rect.y = 2; + + footprint_rect.x = track_rect.x - Y_MARGIN - footprint_rect.w; + footprint_rect.y = 2; } static void layout_recompute (void) @@ -733,6 +738,17 @@ static void create_misc_tex (void) tracking_mode ? 0xFF : BUTTON_ALPHA); SDL_QueryTexture (track_tex, NULL, NULL, &track_rect.w, &track_rect.h); + + surf = IMG_Load ("./traces/img/footprint.png"); + if (surf == NULL) + exit_with_error ("IMG_Load failed: %s", SDL_GetError ()); + + footprint_tex = SDL_CreateTextureFromSurface (renderer, surf); + SDL_FreeSurface (surf); + SDL_SetTextureAlphaMod (footprint_tex, + footprint_mode ? 0xFF : BUTTON_ALPHA); + + SDL_QueryTexture (footprint_tex, NULL, NULL, &footprint_rect.w, &footprint_rect.h); } // Display functions @@ -956,18 +972,20 @@ static void display_mouse_selection (const selected_task_info_t *selected) SDL_Rect dst; if (horiz_mode) { - // horizontal bar - if (mouse_in_gantt_zone) { - dst.x = trace_display_info[0].gantt.x; - dst.y = mouse.y; - dst.w = GANTT_WIDTH; - dst.h = 1; - - SDL_RenderCopy (renderer, horizontal_line, NULL, &dst); - - dst.y = get_y_mouse_sibbling (); - if (dst.y != mouse.y) - SDL_RenderCopy (renderer, horizontal_bis, NULL, &dst); + if (!footprint_mode) { + // horizontal bar + if (mouse_in_gantt_zone) { + dst.x = trace_display_info[0].gantt.x; + dst.y = mouse.y; + dst.w = GANTT_WIDTH; + dst.h = 1; + + SDL_RenderCopy (renderer, horizontal_line, NULL, &dst); + + dst.y = get_y_mouse_sibbling (); + if (dst.y != mouse.y) + SDL_RenderCopy (renderer, horizontal_bis, NULL, &dst); + } } } else { trace_t *tr = selected->trace; @@ -1023,6 +1041,7 @@ static void display_mouse_selection (const selected_task_info_t *selected) static void display_misc_status (void) { SDL_RenderCopy (renderer, quick_nav_tex, NULL, &quick_nav_rect); + SDL_RenderCopy (renderer, footprint_tex, NULL, &footprint_rect); if (nb_traces > 1) { SDL_RenderCopy (renderer, align_tex, NULL, &align_rect); @@ -1233,7 +1252,7 @@ static void trace_graphics_display_trace (unsigned _t, // Check if mouse is within the bounds of the gantt zone if (mouse_in_gantt_zone) { - if (horiz_mode && point_in_yrange (&dst, virt_mouse.y)) { + if (horiz_mode && (footprint_mode | point_in_yrange (&dst, virt_mouse.y))) { if (to_be_emphasized[c] == NULL) to_be_emphasized[c] = first; // store a ref to the first task on this lane @@ -1441,8 +1460,34 @@ void trace_graphics_toggle_vh_mode (void) { horiz_mode ^= 1; - if (tracking_mode) + if (tracking_mode) { tracking_mode = 0; + SDL_SetTextureAlphaMod (track_tex, BUTTON_ALPHA); + } + if (footprint_mode) { + footprint_mode = 0; + SDL_SetTextureAlphaMod (footprint_tex, BUTTON_ALPHA); + } + trace_graphics_display (); +} + +void trace_graphics_toggle_footprint_mode (void) +{ + static unsigned old_horiz, old_track; + + footprint_mode ^= 1; + SDL_SetTextureAlphaMod (footprint_tex, footprint_mode ? 0xFF : BUTTON_ALPHA); + + if (footprint_mode) { + old_horiz = horiz_mode; + old_track = tracking_mode; + horiz_mode = 1; + tracking_mode = 0; + } else { + horiz_mode = old_horiz; + tracking_mode = old_track; + } + SDL_SetTextureAlphaMod (track_tex, tracking_mode ? 0xFF : BUTTON_ALPHA); trace_graphics_display (); } @@ -1451,10 +1496,14 @@ void trace_graphics_toggle_tracking_mode (void) { if (nb_traces > 1) { tracking_mode ^= 1; + SDL_SetTextureAlphaMod (track_tex, tracking_mode ? 0xFF : BUTTON_ALPHA); horiz_mode = 0; - SDL_SetTextureAlphaMod (track_tex, tracking_mode ? 0xFF : BUTTON_ALPHA); + if (footprint_mode) { + footprint_mode = 0; + SDL_SetTextureAlphaMod (footprint_tex, BUTTON_ALPHA); + } trace_graphics_display (); } else