plugins: text viewer: use SBS title

Take advantage of skinned status bar title, instead of
displaying a custom header that reduces space for content.

A custom header will still be displayed if the SBS
doesn't come with its own title, such as on the default
theme, or if the status bar has been turned off in Text
Viewer's settings.

Change-Id: I14c8d9a61acf338d09d7f54947399e8692987a7b
This commit is contained in:
Christian Soffke 2025-12-16 13:39:03 +01:00
parent 1fd45d23a0
commit 8c9f70de82
7 changed files with 51 additions and 3 deletions

View file

@ -870,6 +870,7 @@ static const struct plugin_api rockbox_api = {
gesture_vel_get,
#endif
strstr,
sb_set_title_text,
};
static int plugin_buffer_handle;
@ -889,6 +890,7 @@ int plugin_load(const char* plugin, const void* parameter)
bool theme_enabled = sepch && (!strcmp("properties.rock", sepch + 1) ||
!strcmp("playing_time.rock", sepch + 1) ||
!strcmp("main_menu_config.rock", sepch + 1) ||
!strcmp("text_viewer.rock", sepch + 1) ||
!strcmp("disktidy.rock", sepch + 1));
if (current_plugin_handle)

View file

@ -112,6 +112,7 @@ int plugin_open(const char *plugin, const char *parameter);
#include "menu.h"
#include "rbunicode.h"
#include "list.h"
#include "statusbar-skinned.h"
#include "tree.h"
#include "color_picker.h"
#include "buflib.h"
@ -1020,6 +1021,7 @@ struct plugin_api {
bool (*gesture_vel_get)(struct gesture_vel *gv, int *xvel, int *yvel);
#endif
char* (*strstr)(const char *s1, const char *s2);
bool (*sb_set_title_text)(const char* title, enum themable_icons icon, enum screen_type screen);
};
/* plugin header */

View file

@ -76,6 +76,8 @@ bool tv_load_file(const unsigned char *file)
/* select to read the page */
tv_select_bookmark();
tv_update_sbs_title();
return true;
}
@ -189,6 +191,8 @@ unsigned tv_menu(void)
res = tv_display_menu();
tv_update_sbs_title();
if (res == TV_MENU_RESULT_EXIT_MENU)
{
#ifdef HAVE_ADJUSTABLE_CPU_FREQ

View file

@ -69,7 +69,11 @@ struct tv_rect {
static struct viewport vp_info;
static struct viewport vp_text;
static bool is_initialized_vp = false;
static bool is_initialized_vp;
static bool sbs_has_title;
#if LCD_DEPTH > 1
static fb_data* backdrop;
#endif
static struct screen* display;
@ -90,9 +94,15 @@ static int row_height = 1;
static int totalsize;
static bool tv_has_sbs_title(void)
{
return preferences->statusbar && sbs_has_title;
}
static void tv_show_header(void)
{
if (preferences->header_mode)
/* Ignore header mode if we have an SBS title */
if (preferences->header_mode && !tv_has_sbs_title())
display->putsxy(header.x, header.y, preferences->file_name);
}
@ -189,6 +199,12 @@ void tv_draw_text(int row, const unsigned char *text, int offset)
display->set_viewport(&vp_info);
}
bool tv_set_sbs_title(void)
{
sbs_has_title = rb->sb_set_title_text(preferences->file_name, Icon_NOICON, SCREEN_MAIN);
return preferences->statusbar && sbs_has_title;
}
void tv_start_display(void)
{
display->set_viewport(&vp_info);
@ -197,7 +213,10 @@ void tv_start_display(void)
#if LCD_DEPTH > 1
if (preferences->night_mode)
{
backdrop = rb->lcd_get_backdrop();
rb->lcd_set_backdrop(NULL);
}
#endif
display->clear_viewport();
@ -207,6 +226,10 @@ void tv_end_display(void)
{
display->update_viewport();
display->set_viewport(NULL);
#if LCD_DEPTH > 1
if (preferences->night_mode)
rb->lcd_set_backdrop(backdrop);
#endif
}
void tv_set_layout(bool show_scrollbar)
@ -221,7 +244,7 @@ void tv_set_layout(bool show_scrollbar)
header.x = 0;
header.y = 0;
header.w = vp_info.width;
header.h = (preferences->header_mode)? row_height + 1 : 0;
header.h = (preferences->header_mode && !tv_set_sbs_title()) ? row_height + 1 : 0;
footer.x = 0;
footer.w = vp_info.width;

View file

@ -97,6 +97,14 @@ void tv_update_extra(int window, int col, const struct tv_screen_pos *pos, int s
*/
void tv_init_scrollbar(off_t total, bool show_scrollbar);
/* set the SBS title
*
* return
* true, if title is displayed in SBS
* false, if SBS is hidden or has no title
*/
bool tv_set_sbs_title(void);
/* start the display processing */
void tv_start_display(void);

View file

@ -54,6 +54,12 @@ static void tv_draw_bookmarks(const struct tv_screen_pos *top_pos)
tv_show_bookmarks(disp_bookmarks, disp_count);
}
void tv_update_sbs_title(void)
{
if (tv_set_sbs_title())
rb->send_event(GUI_EVENT_ACTIONUPDATE, (void*)1);
}
void tv_draw_window(void)
{
struct tv_screen_pos pos;

View file

@ -41,6 +41,9 @@ bool tv_init_window(unsigned char **buf, size_t *bufsize);
/* finalize the window module */
void tv_finalize_window(void);
/* update the skinned status bar title, if one is present */
void tv_update_sbs_title(void);
/* draw the display */
void tv_draw_window(void);