Skip to content

Commit

Permalink
New footprint mode: press 'f' to show the full tile coverage of all d…
Browse files Browse the repository at this point in the history
…isplayed tasks
  • Loading branch information
gforgeron committed Feb 15, 2022
1 parent 1ce49b2 commit a79a662
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 16 deletions.
Binary file added traces/img/footprint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions traces/include/trace_graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions traces/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
81 changes: 65 additions & 16 deletions traces/src/trace_graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,18 @@ 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;

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;

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ();
}
Expand All @@ -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
Expand Down

0 comments on commit a79a662

Please sign in to comment.