Dusk Audio Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
daf
extra
FileBrowserDialogImpl.hpp
1
/*
2
* DISTRHO Plugin Framework (DPF)
3
* Copyright (C) 2012-2024 Filipe Coelho <falktx@falktx.com>
4
*
5
* Permission to use, copy, modify, and/or distribute this software for any purpose with
6
* or without fee is hereby granted, provided that the above copyright notice and this
7
* permission notice appear in all copies.
8
*
9
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
10
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
11
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
12
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
13
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15
*/
16
17
#if !defined(DAF_FILE_BROWSER_DIALOG_HPP_INCLUDED) && !defined(DGL_FILE_BROWSER_DIALOG_HPP_INCLUDED)
18
# error bad include
19
#endif
20
21
#if !defined(DGL_USE_FILE_BROWSER) && defined(DAF_UI_FILE_BROWSER) && DAF_UI_FILE_BROWSER == 0
22
# error To use File Browser in DAF plugins please set DAF_UI_FILE_BROWSER to 1
23
#endif
24
25
// --------------------------------------------------------------------------------------------------------------------
26
// File Browser Dialog stuff
27
28
struct
FileBrowserData
;
29
typedef
FileBrowserData
* FileBrowserHandle;
30
31
// --------------------------------------------------------------------------------------------------------------------
32
33
/**
34
File browser options, for customizing the file browser dialog.@n
35
By default the file browser dialog will be work as "open file" in the current working directory.
36
*/
37
struct
FileBrowserOptions
{
38
/** Whether we are saving, opening files otherwise (default) */
39
bool
saving
;
40
41
/** Default filename when saving, required in some platforms (basename without path separators) */
42
const
char
*
defaultName
;
43
44
/** Start directory, uses current working directory if null */
45
const
char
*
startDir
;
46
47
/** File browser dialog window title, uses "FileBrowser" if null */
48
const
char
*
title
;
49
50
/** Class name of the matching Application instance that controls this dialog */
51
const
char
*
className
;
52
53
// TODO file filter
54
55
/**
56
File browser button state.
57
This allows to customize the behaviour of the file browse dialog buttons.
58
Note these are merely hints, not all systems support them.
59
*/
60
enum
ButtonState
{
61
kButtonInvisible,
62
kButtonVisibleUnchecked,
63
kButtonVisibleChecked,
64
};
65
66
/**
67
File browser buttons.
68
*/
69
struct
Buttons
{
70
/** Whether to list all files vs only those with matching file extension */
71
ButtonState
listAllFiles
;
72
/** Whether to show hidden files */
73
ButtonState
showHidden
;
74
/** Whether to show list of places (bookmarks) */
75
ButtonState
showPlaces
;
76
77
/** Constructor for default values */
78
Buttons
()
79
:
listAllFiles
(kButtonVisibleChecked),
80
showHidden
(kButtonVisibleUnchecked),
81
showPlaces
(kButtonVisibleChecked) {}
82
} buttons;
83
84
/** Constructor for default values */
85
FileBrowserOptions
()
86
:
saving
(false),
87
defaultName
(nullptr),
88
startDir
(nullptr),
89
title
(nullptr),
90
className
(nullptr),
91
buttons() {}
92
};
93
94
// --------------------------------------------------------------------------------------------------------------------
95
96
/**
97
Create a new file browser dialog.
98
99
@p isEmbed: Whether the window this dialog belongs to is an embed/child window (needed to close dialog on Windows)
100
@p windowId: The native window id to attach this dialog to as transient parent (X11 Window, HWND or NSView*)
101
@p scaleFactor: Scale factor to use (only used on X11)
102
@p options: Extra options, optional
103
By default the file browser dialog will work as "open file" in the current working directory.
104
*/
105
FileBrowserHandle fileBrowserCreate(
bool
isEmbed,
106
uintptr_t windowId,
107
double
scaleFactor,
108
const
FileBrowserOptions
& options =
FileBrowserOptions
());
109
110
#ifdef DGL_RUNTIME_BACKEND
111
/**
112
Create a new file browser dialog, for a window of a DGL_BACKEND=both build.
113
114
@p isX11 says whether @p windowId is an X11 window rather than a Wayland one; the call above assumes X11.
115
A Wayland window gets the xdg-desktop-portal dialog or none, as in a Wayland-only build, and no X11
116
connection is opened for it.
117
*/
118
FileBrowserHandle fileBrowserCreate(
bool
isEmbed,
119
uintptr_t windowId,
120
double
scaleFactor,
121
const
FileBrowserOptions
& options,
122
bool
isX11);
123
#endif
124
125
/**
126
Idle the file browser dialog handle.@n
127
Returns true if dialog was closed (with or without a file selection),
128
in which case this idle function must not be called anymore for this handle.
129
You can then call fileBrowserGetPath to know the selected file (or null if cancelled).
130
*/
131
bool
fileBrowserIdle(FileBrowserHandle handle);
132
133
/**
134
Close and free the file browser dialog, handle must not be used afterwards.
135
*/
136
void
fileBrowserClose(FileBrowserHandle handle);
137
138
/**
139
Get the path chosen by the user or null.@n
140
Should only be called after fileBrowserIdle returns true.
141
*/
142
const
char
* fileBrowserGetPath(FileBrowserHandle handle);
143
144
// --------------------------------------------------------------------------------------------------------------------
FileBrowserData
Definition
FileBrowserDialogImpl.cpp:296
FileBrowserOptions::Buttons::showHidden
ButtonState showHidden
Definition
FileBrowserDialogImpl.hpp:73
FileBrowserOptions::Buttons::showPlaces
ButtonState showPlaces
Definition
FileBrowserDialogImpl.hpp:75
FileBrowserOptions::Buttons::Buttons
Buttons()
Definition
FileBrowserDialogImpl.hpp:78
FileBrowserOptions::Buttons::listAllFiles
ButtonState listAllFiles
Definition
FileBrowserDialogImpl.hpp:71
FileBrowserOptions
Definition
FileBrowserDialogImpl.hpp:37
FileBrowserOptions::title
const char * title
Definition
FileBrowserDialogImpl.hpp:48
FileBrowserOptions::className
const char * className
Definition
FileBrowserDialogImpl.hpp:51
FileBrowserOptions::startDir
const char * startDir
Definition
FileBrowserDialogImpl.hpp:45
FileBrowserOptions::saving
bool saving
Definition
FileBrowserDialogImpl.hpp:39
FileBrowserOptions::ButtonState
ButtonState
Definition
FileBrowserDialogImpl.hpp:60
FileBrowserOptions::defaultName
const char * defaultName
Definition
FileBrowserDialogImpl.hpp:42
FileBrowserOptions::FileBrowserOptions
FileBrowserOptions()
Definition
FileBrowserDialogImpl.hpp:85
Generated by
1.18.0