summaryrefslogtreecommitdiff
path: root/apps/gui/line.h
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2013-12-20 23:34:28 +0100
committerThomas Martitz <kugel@rockbox.org>2014-01-07 14:13:17 +0100
commit5d6974641b14ef81396e8deebcc65a87c07334e5 (patch)
treea3c12feecc5ae2007d71be2fb383ea7047c87f11 /apps/gui/line.h
parent5752d029fd80e87fe522d7d5e952a56dc371d65e (diff)
downloadrockbox-5d6974641b14ef81396e8deebcc65a87c07334e5.tar.gz
rockbox-5d6974641b14ef81396e8deebcc65a87c07334e5.zip
Introduce put_line().
This function is a fully-fletched, high-level pixel-based line printer, that combines functionality of several firmware and list functions. It can draw spacing, icons and text in a single call, in any order and each multiple times. It can also apply line decorations at the same time. It features printf-like semantics by accepting a format string that contain format tags as well as inline text. It's accessible directly, but also through the multi-screen api for plugins. Change-Id: I70f5a77bbf4b0252521f2e47ead377b9d6d29b54
Diffstat (limited to 'apps/gui/line.h')
-rw-r--r--apps/gui/line.h117
1 files changed, 117 insertions, 0 deletions
diff --git a/apps/gui/line.h b/apps/gui/line.h
new file mode 100644
index 0000000000..d5350eb410
--- /dev/null
+++ b/apps/gui/line.h
@@ -0,0 +1,117 @@
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
32struct line_desc {
33 /* height of the line (in pixels). -1 to inherit the height
34 * from the font. The text will be centered if the height is larger,
35 * but the decorations will span the entire height */
36 int height;
37 /* multiline support: For some decorations (e.g. gradient) to work
38 * across multiple lines (e.g. to draw a line selector across 2 lines)
39 * the line index and line count must be known. For normal, single
40 * lines specify nlines=1 and line=0 */
41 /* line count of a group */
42 int16_t nlines;
43 /* index of the line in the group */
44 int16_t line;
45 /* line text color if STYLE_COLORED is specified, in native
46 * lcd format (convert with LCD_RGBPACK() if necessary) */
47 fb_data text_color;
48 /* line color if STYLE_COLORBAR or STYLE_GRADIENT is specified, in native
49 * lcd format (convert with LCD_RGBPACK() if necessary) */
50 fb_data line_color, line_end_color;
51 /* line decorations, see STYLE_DEFAULT etc. */
52 int style;
53 /* whether the line can scroll */
54 bool scroll;
55};
56
57/* default initializer, can be used for static initialitation also.
58 * This initializer will result in single lines without style that don't scroll */
59#define LINE_DESC_DEFINIT { .style = STYLE_DEFAULT, .height = -1, .line = 0, .nlines = 1, .scroll = false }
60
61/**
62 * Print a line at a given pixel postion, using decoration information from
63 * line and content information from the format specifier. The format specifier
64 * can include tags that depend on further parameters given to the function
65 * (similar to the well-known printf()).
66 *
67 * Tags start with the $ sign. Below is a list of the currently supported tags:
68 * $s - insert a column (1px wide) of empty space.
69 * $S - insert a column (1 char wide) of empty space.
70 * $i - insert an icon. put_line() expects a corresponding parameter of the
71 * type 'enum themable_icons'. If Icon_NOICON is passed, then empty
72 * space (icon-wide) will be inserted.
73 * $I - insert an icon with padding. Works like $i but additionally
74 * adds a column (1px wide) of empty space on either side of the icon.
75 * $t - insert text. put_line() expects a corresponding parameter of the type
76 * 'const char *'
77 * $$ - insert a '$' char, use it to escape $.
78 *
79 * $I, $s and $S support the following two forms:
80 * $n[IsS] - inserts n columns (pixels/chars respectively) of empty space
81 * $*[IsS] - inserts n columns (pixels/chars respectively) of empty space. put_line()
82 * expects a correspinding paramter of the type 'int' that specifies n.
83 *
84 * $t supports the following two forms:
85 * $nt - skips the first n pixels when displaying the string
86 * $*t - skips the first n pixels when displaying the string. put_line()
87 * expects a correspinding paramter of the type 'int' that specifies n.
88 *
89 * Inline text will be printed as is and can be freely intermixed with tags,
90 * except when the line can scroll. Due to limitations of the scroll engine
91 * only the last piece of text (whether inline or via $t) can scroll.
92 *
93 * x, y - pixel postion of the line.
94 * line - holds information for the line decorations
95 * fmt - holds the text and optionally format tags
96 * ... - additional paramters for the format tags
97 *
98 */
99void put_line(struct screen *display,
100 int x, int y, struct line_desc *line,
101 const char *fmt, ...);
102
103
104/**
105 * Print a line at a given pixel postion, using decoration information from
106 * line and content information from the format specifier. The format specifier
107 * can include tags that depend on further parameters given to the function
108 * (similar to the well-known vprintf()).
109 *
110 * For details, see put_line(). This function is equivalent, except for
111 * accepting a va_list instead of a variable paramter list.
112 */
113void vput_line(struct screen *display,
114 int x, int y, struct line_desc *line,
115 const char *fmt, va_list ap);
116
117#endif /* __LINE_H__*/