summaryrefslogtreecommitdiff
path: root/src/modules/rtv
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/rtv')
-rw-r--r--src/modules/rtv/Makefile.am2
-rw-r--r--src/modules/rtv/rtv.c42
2 files changed, 38 insertions, 6 deletions
diff --git a/src/modules/rtv/Makefile.am b/src/modules/rtv/Makefile.am
index c301257..4d5cb6e 100644
--- a/src/modules/rtv/Makefile.am
+++ b/src/modules/rtv/Makefile.am
@@ -1,3 +1,3 @@
noinst_LIBRARIES = librtv.a
librtv_a_SOURCES = rtv.c
-librtv_a_CPPFLAGS = -I@top_srcdir@/src
+librtv_a_CPPFLAGS = -I@top_srcdir@/src -I@top_srcdir@/src/libs
diff --git a/src/modules/rtv/rtv.c b/src/modules/rtv/rtv.c
index 8848e82..215f5d2 100644
--- a/src/modules/rtv/rtv.c
+++ b/src/modules/rtv/rtv.c
@@ -3,6 +3,7 @@
#include "fb.h"
#include "rototiller.h"
+#include "txt/txt.h"
#include "util.h"
/* Copyright (C) 2019 - Vito Caputo <vcaputo@pengaru.com> */
@@ -24,16 +25,18 @@
* same thing over and over.
*/
-#define RTV_SNOW_DURATION_SECS 1
-#define RTV_DURATION_SECS 15
+#define RTV_SNOW_DURATION_SECS 1
+#define RTV_DURATION_SECS 15
+#define RTV_CAPTION_DURATION_SECS 5
typedef struct rtv_context_t {
const rototiller_module_t **modules;
size_t n_modules;
- time_t next_switch;
+ time_t next_switch, next_hide_caption;
const rototiller_module_t *module;
void *module_ctxt;
+ txt_t *caption;
const rototiller_module_t *snow_module;
} rtv_context_t;
@@ -69,6 +72,7 @@ static void setup_next_module(rtv_context_t *ctxt)
ctxt->module->destroy_context(ctxt->module_ctxt);
ctxt->module_ctxt = NULL;
+ ctxt->caption = txt_free(ctxt->caption);
}
if (ctxt->module != ctxt->snow_module) {
@@ -82,7 +86,15 @@ static void setup_next_module(rtv_context_t *ctxt)
ctxt->modules[i] == ctxt->snow_module);
ctxt->module = ctxt->modules[i];
+
+ ctxt->caption = txt_newf("Title: %s\nAuthor: %s\nDescription: %s\nLicense: %s",
+ ctxt->module->name,
+ ctxt->module->author,
+ ctxt->module->description,
+ ctxt->module->license);
+
ctxt->next_switch = time(NULL) + RTV_DURATION_SECS;
+ ctxt->next_hide_caption = time(NULL) + RTV_CAPTION_DURATION_SECS;
}
if (ctxt->module->create_context)
@@ -111,15 +123,35 @@ static void rtv_destroy_context(void *context)
static void rtv_prepare_frame(void *context, unsigned n_cpus, fb_fragment_t *fragment, rototiller_fragmenter_t *res_fragmenter)
{
rtv_context_t *ctxt = context;
+ time_t now = time(NULL);
- if (time(NULL) >= ctxt->next_switch)
+ if (now >= ctxt->next_switch)
setup_next_module(ctxt);
+ if (now >= ctxt->next_hide_caption)
+ ctxt->caption = txt_free(ctxt->caption);
+
rototiller_module_render(ctxt->module, ctxt->module_ctxt, fragment);
}
static void rtv_finish_frame(void *context, fb_fragment_t *fragment)
{
- /* TODO: this is stubbed here for drawing the caption overlay */
+ rtv_context_t *ctxt = context;
+
+ if (!ctxt->caption)
+ return;
+
+ txt_render_fragment(ctxt->caption, fragment, 0x00000000,
+ 1, fragment->frame_height + 1,
+ (txt_align_t){
+ .horiz = TXT_HALIGN_LEFT,
+ .vert = TXT_VALIGN_BOTTOM
+ });
+ txt_render_fragment(ctxt->caption, fragment, 0xffffffff,
+ 0, fragment->frame_height,
+ (txt_align_t){
+ .horiz = TXT_HALIGN_LEFT,
+ .vert = TXT_VALIGN_BOTTOM
+ });
}
© All Rights Reserved