Mercurial > hg > pub > prymula > com
comparison DPF-Prymula-audioplugins/dpf/distrho/extra/FileBrowserDialogImpl.hpp @ 3:84e66ea83026
DPF-Prymula-audioplugins-0.231015-2
author | prymula <prymula76@outlook.com> |
---|---|
date | Mon, 16 Oct 2023 21:53:34 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2:cf2cb71d31dd | 3:84e66ea83026 |
---|---|
1 /* | |
2 * DISTRHO Plugin Framework (DPF) | |
3 * Copyright (C) 2012-2022 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(DISTRHO_FILE_BROWSER_DIALOG_HPP_INCLUDED) && !defined(DGL_FILE_BROWSER_DIALOG_HPP_INCLUDED) | |
18 # error bad include | |
19 #endif | |
20 | |
21 // -------------------------------------------------------------------------------------------------------------------- | |
22 // File Browser Dialog stuff | |
23 | |
24 struct FileBrowserData; | |
25 typedef FileBrowserData* FileBrowserHandle; | |
26 | |
27 // -------------------------------------------------------------------------------------------------------------------- | |
28 | |
29 /** | |
30 File browser options, for customizing the file browser dialog.@n | |
31 By default the file browser dialog will be work as "open file" in the current working directory. | |
32 */ | |
33 struct FileBrowserOptions { | |
34 /** Whether we are saving, opening files otherwise (default) */ | |
35 bool saving; | |
36 | |
37 /** Default filename when saving, required in some platforms (basename without path separators) */ | |
38 const char* defaultName; | |
39 | |
40 /** Start directory, uses current working directory if null */ | |
41 const char* startDir; | |
42 | |
43 /** File browser dialog window title, uses "FileBrowser" if null */ | |
44 const char* title; | |
45 | |
46 // TODO file filter | |
47 | |
48 /** | |
49 File browser button state. | |
50 This allows to customize the behaviour of the file browse dialog buttons. | |
51 Note these are merely hints, not all systems support them. | |
52 */ | |
53 enum ButtonState { | |
54 kButtonInvisible, | |
55 kButtonVisibleUnchecked, | |
56 kButtonVisibleChecked, | |
57 }; | |
58 | |
59 /** | |
60 File browser buttons. | |
61 */ | |
62 struct Buttons { | |
63 /** Whether to list all files vs only those with matching file extension */ | |
64 ButtonState listAllFiles; | |
65 /** Whether to show hidden files */ | |
66 ButtonState showHidden; | |
67 /** Whether to show list of places (bookmarks) */ | |
68 ButtonState showPlaces; | |
69 | |
70 /** Constructor for default values */ | |
71 Buttons() | |
72 : listAllFiles(kButtonVisibleChecked), | |
73 showHidden(kButtonVisibleUnchecked), | |
74 showPlaces(kButtonVisibleChecked) {} | |
75 } buttons; | |
76 | |
77 /** Constructor for default values */ | |
78 FileBrowserOptions() | |
79 : saving(false), | |
80 defaultName(nullptr), | |
81 startDir(nullptr), | |
82 title(nullptr), | |
83 buttons() {} | |
84 }; | |
85 | |
86 // -------------------------------------------------------------------------------------------------------------------- | |
87 | |
88 /** | |
89 Create a new file browser dialog. | |
90 | |
91 @p isEmbed: Whether the window this dialog belongs to is an embed/child window (needed to close dialog on Windows) | |
92 @p windowId: The native window id to attach this dialog to as transient parent (X11 Window, HWND or NSView*) | |
93 @p scaleFactor: Scale factor to use (only used on X11) | |
94 @p options: Extra options, optional | |
95 By default the file browser dialog will work as "open file" in the current working directory. | |
96 */ | |
97 FileBrowserHandle fileBrowserCreate(bool isEmbed, | |
98 uintptr_t windowId, | |
99 double scaleFactor, | |
100 const FileBrowserOptions& options = FileBrowserOptions()); | |
101 | |
102 /** | |
103 Idle the file browser dialog handle.@n | |
104 Returns true if dialog was closed (with or without a file selection), | |
105 in which case this idle function must not be called anymore for this handle. | |
106 You can then call fileBrowserGetPath to know the selected file (or null if cancelled). | |
107 */ | |
108 bool fileBrowserIdle(const FileBrowserHandle handle); | |
109 | |
110 /** | |
111 Close and free the file browser dialog, handle must not be used afterwards. | |
112 */ | |
113 void fileBrowserClose(const FileBrowserHandle handle); | |
114 | |
115 /** | |
116 Get the path chosen by the user or null.@n | |
117 Should only be called after fileBrowserIdle returns true. | |
118 */ | |
119 const char* fileBrowserGetPath(const FileBrowserHandle handle); | |
120 | |
121 // -------------------------------------------------------------------------------------------------------------------- |