FFmpeg
Loading...
Searching...
No Matches
ffplay_list.h
Go to the documentation of this file.
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19/**
20 * @file
21 * A list overlay for ffplay: entries with title, artist, length and metadata that the user can sort, filter by typing,
22 * browse with keys, wheel and mouse, and pick one of.
23 *
24 * A ListView is used from the thread handling the SDL events and rendering; separate ListViews are independent.
25 */
26
27#ifndef FFTOOLS_FFPLAY_LIST_H
28#define FFTOOLS_FFPLAY_LIST_H
29
30#include <stdint.h>
31
32#include <SDL.h>
33
34#include "libavutil/dict.h"
35
36typedef struct ListEntry {
37 const char *title;
38 const char *artist;
39 int64_t length; ///< in AV_TIME_BASE units, negative when unknown
40 AVDictionary *metadata; ///< shown when the mouse is over the entry's symbol, may be NULL
41} ListEntry;
42
43typedef struct ListView ListView;
44
45/**
46 * @param renderer NULL when there is none, which leaves the list unable to show
47 * @return the list, hidden, or NULL on allocation failure
48 */
49ListView *list_view_alloc(SDL_Renderer *renderer);
50
51void list_view_free(ListView **lv);
52
53/**
54 * Replaces the entries and shows the list, fading it in.
55 *
56 * @param entries numbered from 1 in the list; their strings and dictionaries must stay valid until the next call or
57 * list_view_free()
58 * @param selected entry to select, the selection is kept when it is -1 or not listed
59 * @return 0 or a negative error code
60 */
62
63/**
64 * Removes the entries, which may be freed after this, and resets the sort and the search.
65 */
67
68/**
69 * Keeps the list on screen and lets it take the keyboard and text input, or lets it fade out again.
70 */
71void list_view_pin(ListView *lv, int pinned);
72
73int list_view_pinned(const ListView *lv);
74
75/**
76 * @return whether the list is on screen or about to be
77 */
78int list_view_visible(const ListView *lv);
79
80/**
81 * @return the selected entry, -1 when none is listed
82 */
83int list_view_selected(const ListView *lv);
84
85/**
86 * Moves the selection by delta rows.
87 */
88void list_view_move(ListView *lv, int delta);
89
90/**
91 * Handles a key while the list is pinned: escape unpins it, up/down move the selection, backspace erases from the search.
92 *
93 * @return the entry chosen by enter, -1 otherwise
94 */
95int list_view_key(ListView *lv, SDL_Keycode key);
96
97/**
98 * Appends text typed while the list is pinned to the search, or erases its last character when text is NULL.
99 */
100void list_view_text(ListView *lv, const char *text);
101
102/**
103 * Clears the search, listing all entries.
104 */
106
107/**
108 * Keeps the mouse position, in window coordinates, -1 when the mouse left the window.
109 */
110void list_view_hover(ListView *lv, int x, int y);
111
112/**
113 * Handles a left click at window coordinates: a click on an entry chooses it, a click on a column button sorts by it.
114 *
115 * @param chosen set to the entry clicked, -1 when none was
116 * @return whether the click hit the list
117 */
118int list_view_click(ListView *lv, int x, int y, int *chosen);
119
120/**
121 * Sets the size of the window the list is drawn into.
122 */
123void list_view_set_size(ListView *lv, int width, int height);
124
125/**
126 * Marks the entry as playing, -1 for none.
127 */
129
130/**
131 * Brings the list up to date for the next frame, once the pending input is handled.
132 *
133 * @return whether the window needs to be drawn again
134 */
136
137/**
138 * Draws the list onto the window, between its other content and the present.
139 */
140void list_view_draw(ListView *lv);
141
142#endif /* FFTOOLS_FFPLAY_LIST_H */
#define entry
long long int64_t
Definition coverity.c:34
Public dictionary API.
const char * key
static SDL_Renderer * renderer
Definition ffplay.c:422
int list_view_selected(const ListView *lv)
void list_view_set_size(ListView *lv, int width, int height)
Sets the size of the window the list is drawn into.
ListView * list_view_alloc(SDL_Renderer *renderer)
void list_view_set_playing(ListView *lv, int entry)
Marks the entry as playing, -1 for none.
void list_view_free(ListView **lv)
int list_view_show(ListView *lv, const ListEntry *entries, int nb_entries, int selected)
Replaces the entries and shows the list, fading it in.
int list_view_pinned(const ListView *lv)
int list_view_click(ListView *lv, int x, int y, int *chosen)
Handles a left click at window coordinates: a click on an entry chooses it, a click on a column butto...
void list_view_move(ListView *lv, int delta)
Moves the selection by delta rows.
void list_view_clear_search(ListView *lv)
Clears the search, listing all entries.
void list_view_hover(ListView *lv, int x, int y)
Keeps the mouse position, in window coordinates, -1 when the mouse left the window.
int list_view_visible(const ListView *lv)
void list_view_pin(ListView *lv, int pinned)
Keeps the list on screen and lets it take the keyboard and text input, or lets it fade out again.
int list_view_update(ListView *lv)
Brings the list up to date for the next frame, once the pending input is handled.
void list_view_text(ListView *lv, const char *text)
Appends text typed while the list is pinned to the search, or erases its last character when text is ...
void list_view_draw(ListView *lv)
Draws the list onto the window, between its other content and the present.
int list_view_key(ListView *lv, SDL_Keycode key)
Handles a key while the list is pinned: escape unpins it, up/down move the selection,...
void list_view_clear(ListView *lv)
Removes the entries, which may be freed after this, and resets the sort and the search.
const char * title
Definition ffplay_list.h:37
AVDictionary * metadata
shown when the mouse is over the entry's symbol, may be NULL
Definition ffplay_list.h:40
const char * artist
Definition ffplay_list.h:38
int64_t length
in AV_TIME_BASE units, negative when unknown
Definition ffplay_list.h:39
int nb_entries
ListEntry * entries
Definition ffplay_list.c:99
#define height
Definition dsp.h:99
#define width
Definition dsp.h:99
float delta