A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd
at master 147 lines 6.5 kB view raw
1/*************************************************************************** 2 * __________ __ ___. 3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 * \/ \/ \/ \/ \/ 8 * $Id$ 9 * 10 * Copyright (C) 2013 Thomas Martitz 11 * 12 * This program is free software; you can redistribute it and/or 13 * modify it under the terms of the GNU General Public License 14 * as published by the Free Software Foundation; either version 2 15 * of the License, or (at your option) any later version. 16 * 17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 18 * KIND, either express or implied. 19 * 20 ****************************************************************************/ 21 22#ifndef __LINE_H__ 23#define __LINE_H__ 24 25#include <stdint.h> 26#include <stdbool.h> 27#include <stdarg.h> 28 29#include "lcd.h" 30#include "screens.h" 31 32/* Possible line decoration styles. Specify one of 33 * STYLE_NONE, _DEFAULT, _INVERT, _COLORBAR or _GRADIENT, and optionally 34 * or with STYLE_COLORED specifying line_desc.text_color */ 35enum line_styles { 36 /* Just print the text. Do not clear or draw line decorations */ 37 STYLE_NONE = 0x00, 38 /* Line background filled with the bg color (or backdrop if present) */ 39 STYLE_DEFAULT = 0x01, 40 /* Like STYLE_DFEAULT except that text and background color will be swapped */ 41 STYLE_INVERT = 0x02, 42 /* Line background filled with line color line_desc.line_color */ 43 STYLE_COLORBAR = 0x04, 44 /* Line background filled with gradient, colors taken from 45 * line_desc.line_color and line_desc.line_end_color */ 46 STYLE_GRADIENT = 0x08, 47 /* Modifier for the text color, which will be taken from line_desc.text_color */ 48 STYLE_COLORED = 0x10, 49 /* These are used internally */ 50 _STYLE_DECO_MASK = 0x0f, 51 _STYLE_MODE_MASK = 0x7F, 52}; 53 54struct line_desc { 55 /* height of the line (in pixels). -1 to inherit the height 56 * from the font. The text will be centered if the height is larger, 57 * but the decorations will span the entire height */ 58 int height; 59 /* multiline support: For some decorations (e.g. gradient) to work 60 * across multiple lines (e.g. to draw a line selector across 2 lines) 61 * the line index and line count must be known. For normal, single 62 * lines specify nlines=1 and line=0 */ 63 /* line count of a group */ 64 int16_t nlines; 65 /* index of the line in the group */ 66 int16_t line; 67 /* line text color if STYLE_COLORED is specified, in native 68 * lcd format (convert with LCD_RGBPACK() if necessary) */ 69 unsigned text_color; 70 /* line color if STYLE_COLORBAR or STYLE_GRADIENT is specified, in native 71 * lcd format (convert with LCD_RGBPACK() if necessary) */ 72 unsigned line_color, line_end_color; 73 /* line decorations, see STYLE_DEFAULT etc. */ 74 enum line_styles style; 75 /* whether the line can scroll */ 76 bool scroll; 77 /* height of the line separator (in pixels). 0 to disable drawing 78 * of the separator */ 79 int8_t separator_height; 80}; 81 82/* default initializer, can be used for static initialitation also. 83 * This initializer will result in single lines without style that don't scroll */ 84#define LINE_DESC_DEFINIT { .style = STYLE_DEFAULT, .height = -1, .separator_height = 0, .line = 0, .nlines = 1, .scroll = false } 85 86/** 87 * Print a line at a given pixel postion, using decoration information from 88 * line and content information from the format specifier. The format specifier 89 * can include tags that depend on further parameters given to the function 90 * (similar to the well-known printf()). 91 * 92 * Tags start with the $ sign. Below is a list of the currently supported tags: 93 * $s - insert a column (1px wide) of empty space. 94 * $S - insert a column (1 char wide) of empty space. 95 * $i - insert an icon. put_line() expects a corresponding parameter of the 96 * type 'enum themable_icons'. If Icon_NOICON is passed, then empty 97 * space (icon-wide) will be inserted. 98 * $I - insert an icon with padding. Works like $i but additionally 99 * adds a column (1px wide) of empty space on either side of the icon. 100 * $t - insert text. put_line() expects a corresponding parameter of the type 101 * 'const char *' 102 * $$ - insert a '$' char, use it to escape $. 103 * 104 * $I, $s and $S support the following two forms: 105 * $n[IsS] - inserts n columns (pixels/chars respectively) of empty space 106 * $*[IsS] - inserts n columns (pixels/chars respectively) of empty space. put_line() 107 * expects a correspinding paramter of the type 'int' that specifies n. 108 * 109 * $t supports the following two forms: 110 * $nt - skips the first n pixels when displaying the string 111 * $*t - skips the first n pixels when displaying the string. put_line() 112 * expects a correspinding paramter of the type 'int' that specifies n. 113 * 114 * Inline text will be printed as is (be sure to escape '$') and can be freely 115 * intermixed with tags. Inline text will be truncated after MAX_PATH+31 bytes. 116 * If you have a longer inline string use a separate buffer and pass that via $t, 117 * which does not suffer from this truncation. 118 * 119 * Text can appear anywhere, before or after (or both) tags. However, when the 120 * line can scroll, only the last piece of text (whether inline or via $t) can 121 * scroll. This is due to a scroll_engine limitation. 122 * 123 * x, y - pixel postion of the line. 124 * line - holds information for the line decorations 125 * fmt - holds the text and optionally format tags 126 * ... - additional paramters for the format tags 127 * 128 */ 129void put_line(struct screen *display, 130 int x, int y, struct line_desc *line, 131 const char *fmt, ...); 132 133 134/** 135 * Print a line at a given pixel postion, using decoration information from 136 * line and content information from the format specifier. The format specifier 137 * can include tags that depend on further parameters given to the function 138 * (similar to the well-known vprintf()). 139 * 140 * For details, see put_line(). This function is equivalent, except for 141 * accepting a va_list instead of a variable paramter list. 142 */ 143void vput_line(struct screen *display, 144 int x, int y, struct line_desc *line, 145 const char *fmt, va_list ap); 146 147#endif /* __LINE_H__*/