A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd
at master 148 lines 5.6 kB view raw
1/*************************************************************************** 2* __________ __ ___. 3* Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7* \/ \/ \/ \/ \/ 8* $Id$ 9* 10* Floating on-screen display 11* 12* Copyright (C) 2012 Michael Sevakis 13* 14* This program is free software; you can redistribute it and/or 15* modify it under the terms of the GNU General Public License 16* as published by the Free Software Foundation; either version 2 17* of the License, or (at your option) any later version. 18* 19* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 20* KIND, either express or implied. 21* 22****************************************************************************/ 23#ifndef OSD_H 24#define OSD_H 25 26/* At this time: assumes use of the default viewport for normal drawing */ 27 28/* Callback implemented by user. Paramters are OSD vp-relative coordinates */ 29typedef void (* osd_draw_cb_fn_t)(int x, int y, int width, int height); 30 31/* Initialize the OSD, set its backbuffer, update callback and enable it if 32 * the call succeeded. */ 33enum osd_init_flags 34{ 35 OSD_INIT_MAJOR_WIDTH = 0x0, /* Width guides buffer dims (default) */ 36 OSD_INIT_MAJOR_HEIGHT = 0x1, /* Height guides buffer dims */ 37 OSD_INIT_MINOR_MIN = 0x2, /* Treat minor axis dim as a minimum */ 38 OSD_INIT_MINOR_MAX = 0x4, /* Treat minor axis dim as a maximum */ 39 /* To get exact minor size, combine min/max flags */ 40}; 41bool osd_init(unsigned flags, void *backbuf, size_t backbuf_size, 42 osd_draw_cb_fn_t draw_cb, int *width, 43 int *height, size_t *bufused); 44 45/* Destroy the OSD, rendering it disabled */ 46void osd_destroy(void); 47 48enum 49{ 50 OSD_HIDE = 0x0, /* Hide from view */ 51 OSD_SHOW = 0x1, /* Bring into view, updating if needed */ 52 OSD_UPDATENOW = 0x2, /* Force update even if nothing changed */ 53}; 54 55/* Show/Hide the OSD on screen returning previous status */ 56bool osd_show(unsigned flags); 57 58/* Redraw the entire OSD returning true if screen update occurred */ 59bool osd_update(void); 60 61/* Redraw part of the OSD (OSD viewport-relative coordinates) returning true 62 if any screen update occurred */ 63bool osd_update_rect(int x, int y, int width, int height); 64 65/* Set a new screen location and size (screen coordinates) */ 66bool osd_update_pos(int x, int y, int width, int height); 67 68/* Call periodically to have the OSD timeout and hide itself */ 69void osd_monitor_timeout(void); 70 71/* Set the OSD timeout value. 'timeout' <= 0 == never timeout */ 72void osd_set_timeout(long timeout); 73 74/* Use the OSD viewport context */ 75struct viewport * osd_get_viewport(void); 76 77/* Get the maximum buffer dimensions calculated by osd_init() */ 78void osd_get_max_dims(int *maxwidth, int *maxheight); 79 80/* Is the OSD enabled? */ 81bool osd_enabled(void); 82 83/** Functions that must be used in lieu of regular LCD functions for this 84 ** to work. 85 ** 86 ** To be efficient, as much drawing as possible should be combined between 87 ** *prepare and *update. 88 ** 89 ** osd_lcd_update_prepare(); 90 ** <draw stuff using lcd_* routines> 91 ** osd_lcd_update[_rect](); 92 ** 93 ** TODO: Make it work seamlessly with greylib and regular LCD functions. 94 **/ 95 96/* Prepare LCD frambuffer for regular drawing - call before any other LCD 97 function */ 98void osd_lcd_update_prepare(void); 99 100/* Update the whole screen and restore OSD if it is visible */ 101void osd_lcd_update(void); 102 103/* Update a part of the screen and restore OSD if it is visible */ 104void osd_lcd_update_rect(int x, int y, int width, int height); 105 106#if LCD_DEPTH < 4 107/* Like other functions but for greylib surface (requires GREY_BUFFERED) */ 108bool osd_grey_init(unsigned flags, void *backbuf, size_t backbuf_size, 109 osd_draw_cb_fn_t draw_cb, int *width, 110 int *height, size_t *bufused); 111void osd_grey_destroy(void); 112bool osd_grey_show(unsigned flags); 113bool osd_grey_update(void); 114bool osd_grey_update_rect(int x, int y, int width, int height); 115bool osd_grey_update_pos(int x, int y, int width, int height); 116void osd_grey_monitor_timeout(void); 117void osd_grey_set_timeout(long timeout); 118struct viewport * osd_grey_get_viewport(void); 119void osd_grey_get_max_dims(int *maxwidth, int *maxheight); 120bool osd_grey_enabled(void); 121void osd_grey_lcd_update_prepare(void); 122void osd_grey_lcd_update(void); 123void osd_grey_lcd_update_rect(int x, int y, int width, int height); 124#endif /* LCD_DEPTH < 4 */ 125 126/* MYLCD-style helper defines to compile with different graphics libs */ 127#ifdef __GREY_H__ 128#define myosd_(fn) osd_grey_##fn 129#else 130#define myosd_(fn) osd_##fn 131#endif 132 133#define myosd_init myosd_(init) 134#define myosd_destroy myosd_(destroy) 135#define myosd_show myosd_(show) 136#define myosd_update myosd_(update) 137#define myosd_update_rect myosd_(update_rect) 138#define myosd_update_pos myosd_(update_pos) 139#define myosd_monitor_timeout myosd_(monitor_timeout) 140#define myosd_set_timeout myosd_(set_timeout) 141#define myosd_get_viewport myosd_(get_viewport) 142#define myosd_get_max_dims myosd_(get_max_dims) 143#define myosd_enabled myosd_(enabled) 144#define myosd_lcd_update_prepare myosd_(lcd_update_prepare) 145#define myosd_lcd_update myosd_(lcd_update) 146#define myosd_lcd_update_rect myosd_(lcd_update_rect) 147 148#endif /* OSD_H */