diff --git a/src/app.c b/src/app.c index 5644175..fcc9acc 100644 --- a/src/app.c +++ b/src/app.c @@ -328,7 +328,19 @@ static void handle_event(App *app, const SDL_Event *event) { } break; case SDLK_TAB: - app->mode = app->mode == MODE_FULLSCREEN ? MODE_GUIDE : MODE_FULLSCREEN; + if (app->mode == MODE_FULLSCREEN) { + app->mode = MODE_GUIDE; + app->guide_selected_index = app->player.current_index; + } else { + app->mode = MODE_FULLSCREEN; + } + break; + case SDLK_RETURN: + case SDLK_KP_ENTER: + if (app->mode == MODE_GUIDE) { + tune_to_channel(app, app->guide_selected_index); + app->mode = MODE_FULLSCREEN; + } break; case SDLK_f: toggle_fullscreen(app); @@ -349,10 +361,18 @@ static void handle_event(App *app, const SDL_Event *event) { app->about_modal_open = !app->about_modal_open; break; case SDLK_UP: - tune_relative(app, app->mode == MODE_GUIDE ? -1 : 1); + if (app->mode == MODE_GUIDE && app->channels.count > 0) { + app->guide_selected_index = (app->guide_selected_index - 1 + app->channels.count) % app->channels.count; + } else if (app->mode != MODE_GUIDE) { + tune_relative(app, 1); + } break; case SDLK_DOWN: - tune_relative(app, app->mode == MODE_GUIDE ? 1 : -1); + if (app->mode == MODE_GUIDE && app->channels.count > 0) { + app->guide_selected_index = (app->guide_selected_index + 1) % app->channels.count; + } else if (app->mode != MODE_GUIDE) { + tune_relative(app, -1); + } break; case SDLK_LEFT: browse_guide_time(app, -GUIDE_BROWSE_STEP_MINUTES); @@ -509,6 +529,7 @@ void app_run(App *app) { &app->ui_cache, &app->channels, app->player.current_index, + app->guide_selected_index, app->app_start_time, now_wall, app->guide_time_offset_minutes); diff --git a/src/app.h b/src/app.h index 8660600..f8d6912 100644 --- a/src/app.h +++ b/src/app.h @@ -29,6 +29,7 @@ typedef struct App { time_t app_start_time; Uint64 app_start_ticks; int guide_time_offset_minutes; + int guide_selected_index; char numeric_input_buffer[4]; int numeric_input_length; Uint32 numeric_input_timeout; diff --git a/src/app.o b/src/app.o index 0da551d..63e8672 100644 Binary files a/src/app.o and b/src/app.o differ diff --git a/src/main.o b/src/main.o index 2e54a5d..83378a8 100644 Binary files a/src/main.o and b/src/main.o differ diff --git a/src/ui.c b/src/ui.c index aed51aa..fe1b6cf 100644 --- a/src/ui.c +++ b/src/ui.c @@ -875,6 +875,7 @@ void ui_render_guide(SDL_Renderer *renderer, UiCache *cache, const ChannelList *channels, int active_channel, + int selected_channel, time_t app_start_time, time_t now_wall, int guide_time_offset_minutes) { @@ -894,8 +895,8 @@ void ui_render_guide(SDL_Renderer *renderer, SDL_Rect grid = {0, grid_y, window_width, window_height - grid_y - (int) (GUIDE_FOOTER_HEIGHT * scale_y)}; int row_height = grid.h / GUIDE_VISIBLE_ROWS; int timeline_w = window_width - guide_x_start - (int) (20 * scale_x); - int start_index = active_channel - 2; - const Channel *selected_channel = NULL; + int start_index = selected_channel - 2; + const Channel *selected_channel_ptr = NULL; double pixels_per_minute = timeline_w / 90.0; time_t guide_view_start_time = now_wall - (30 * 60) + (guide_time_offset_minutes * 60); time_t guide_focus_time = guide_view_start_time + (30 * 60); @@ -903,8 +904,8 @@ void ui_render_guide(SDL_Renderer *renderer, double guide_view_end_seconds = guide_view_start_seconds + TIMELINE_VISIBLE_SECONDS; double guide_focus_seconds = channel_schedule_elapsed_seconds(app_start_time, guide_focus_time); - if (channels && channels->count > 0 && active_channel >= 0 && active_channel < channels->count) { - selected_channel = &channels->items[active_channel]; + if (channels && channels->count > 0 && selected_channel >= 0 && selected_channel < channels->count) { + selected_channel_ptr = &channels->items[selected_channel]; } fill_three_stop_gradient(renderer, @@ -912,11 +913,11 @@ void ui_render_guide(SDL_Renderer *renderer, theme->background_top, theme->background_mid, theme->background_bottom); - draw_info_panel(renderer, fonts, theme, selected_channel, &info_panel, app_start_time, guide_focus_time); + draw_info_panel(renderer, fonts, theme, selected_channel_ptr, &info_panel, app_start_time, guide_focus_time); draw_panel_shadow(renderer, &preview); fill_rect(renderer, &preview, COLOR_BLACK); draw_video(renderer, video_texture, texture_width, texture_height, preview); - draw_mini_status_bar(renderer, fonts->small, theme, selected_channel, &mini_status_bar, now_wall); + draw_mini_status_bar(renderer, fonts->small, theme, selected_channel_ptr, &mini_status_bar, now_wall); if (cache->timeline_label_slot != guide_view_start_time / 60 || cache->timeline_theme != theme) { char label[32]; @@ -951,7 +952,7 @@ void ui_render_guide(SDL_Renderer *renderer, SDL_Rect sidebar = {0, row_rect.y, sidebar_width, row_height}; SDL_Rect timeline_rect = {guide_x_start, row_rect.y + (int) (6 * scale_y), timeline_w, row_height - (int) (12 * scale_y)}; SDL_Rect clip = timeline_rect; - int is_selected = channel_index == active_channel; + int is_selected = channel_index == selected_channel; SDL_Rect inset = {row_rect.x + 4, row_rect.y + 3, row_rect.w - 8, row_rect.h - 6}; draw_beveled_bar(renderer, @@ -1095,8 +1096,8 @@ void ui_render_guide(SDL_Renderer *renderer, } } - if (selected_channel && active_channel >= 0 && start_index <= active_channel && active_channel < start_index + GUIDE_VISIBLE_ROWS) { - SDL_Rect highlight = {0, grid.y + (active_channel - start_index) * row_height, window_width, row_height}; + if (selected_channel_ptr && selected_channel >= 0 && start_index <= selected_channel && selected_channel < start_index + GUIDE_VISIBLE_ROWS) { + SDL_Rect highlight = {0, grid.y + (selected_channel - start_index) * row_height, window_width, row_height}; draw_selection_glow(renderer, &highlight, theme->selection_edge); draw_selection_glow(renderer, &(SDL_Rect){guide_x_start, highlight.y + (int) (6 * scale_y), timeline_w, row_height - (int) (12 * scale_y)}, theme->selection_edge); } diff --git a/src/ui.h b/src/ui.h index e54039c..fd765c1 100644 --- a/src/ui.h +++ b/src/ui.h @@ -74,6 +74,7 @@ void ui_render_guide(SDL_Renderer *renderer, UiCache *cache, const ChannelList *channels, int active_channel, + int selected_channel, time_t app_start_time, time_t now_wall, int guide_time_offset_minutes); diff --git a/src/ui.o b/src/ui.o index ddb19a9..688ca61 100644 Binary files a/src/ui.o and b/src/ui.o differ