Mercurial > hg > pub > prymula > com
comparison DPF-Prymula-audioplugins/dpf/dgl/src/ApplicationPrivateData.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-2021 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 #ifndef DGL_APP_PRIVATE_DATA_HPP_INCLUDED | |
18 #define DGL_APP_PRIVATE_DATA_HPP_INCLUDED | |
19 | |
20 #include "../Application.hpp" | |
21 | |
22 #include <list> | |
23 | |
24 #ifdef DISTRHO_OS_WINDOWS | |
25 # ifndef NOMINMAX | |
26 # define NOMINMAX | |
27 # endif | |
28 # include <winsock2.h> | |
29 # include <windows.h> | |
30 typedef HANDLE d_ThreadHandle; | |
31 #else | |
32 # include <pthread.h> | |
33 typedef pthread_t d_ThreadHandle; | |
34 #endif | |
35 | |
36 #ifdef DISTRHO_OS_MAC | |
37 typedef struct PuglWorldImpl PuglWorld; | |
38 #endif | |
39 | |
40 START_NAMESPACE_DGL | |
41 | |
42 class Window; | |
43 | |
44 #ifndef DISTRHO_OS_MAC | |
45 typedef struct PuglWorldImpl PuglWorld; | |
46 #endif | |
47 | |
48 // -------------------------------------------------------------------------------------------------------------------- | |
49 | |
50 struct Application::PrivateData { | |
51 /** Pugl world instance. */ | |
52 PuglWorld* const world; | |
53 | |
54 /** Whether the application is running as standalone, otherwise it is part of a plugin. */ | |
55 const bool isStandalone; | |
56 | |
57 /** Whether the applicating is about to quit, or already stopped. Defaults to false. */ | |
58 bool isQuitting; | |
59 | |
60 /** Helper for safely close everything from main thread. */ | |
61 bool isQuittingInNextCycle; | |
62 | |
63 /** Whether the applicating is starting up, that is, no windows have been made visible yet. Defaults to true. */ | |
64 bool isStarting; | |
65 | |
66 /** Counter of visible windows, only used in standalone mode. | |
67 If 0->1, application is starting. If 1->0, application is quitting/stopping. */ | |
68 uint visibleWindows; | |
69 | |
70 /** Handle that identifies the main thread. Used to check if calls belong to current thread or not. */ | |
71 d_ThreadHandle mainThreadHandle; | |
72 | |
73 /** List of windows for this application. Only used during `close`. */ | |
74 std::list<DGL_NAMESPACE::Window*> windows; | |
75 | |
76 /** List of idle callbacks for this application. */ | |
77 std::list<DGL_NAMESPACE::IdleCallback*> idleCallbacks; | |
78 | |
79 /** Constructor and destructor */ | |
80 explicit PrivateData(bool standalone); | |
81 ~PrivateData(); | |
82 | |
83 /** Flag one window as shown, which increments @a visibleWindows. | |
84 Sets @a isQuitting and @a isStarting as false if this is the first window. | |
85 For standalone mode only. */ | |
86 void oneWindowShown() noexcept; | |
87 | |
88 /** Flag one window as closed, which decrements @a visibleWindows. | |
89 Sets @a isQuitting as true if this is the last window. | |
90 For standalone mode only. */ | |
91 void oneWindowClosed() noexcept; | |
92 | |
93 /** Run Pugl world update for @a timeoutInMs, and then each idle callback in order of registration. */ | |
94 void idle(uint timeoutInMs); | |
95 | |
96 /** Run each idle callback without updating pugl world. */ | |
97 void triggerIdleCallbacks(); | |
98 | |
99 /** Set flag indicating application is quitting, and close all windows in reverse order of registration. | |
100 For standalone mode only. */ | |
101 void quit(); | |
102 | |
103 /** Get time via pugl */ | |
104 double getTime() const; | |
105 | |
106 /** Set pugl world class name. */ | |
107 void setClassName(const char* name); | |
108 | |
109 DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PrivateData) | |
110 }; | |
111 | |
112 // -------------------------------------------------------------------------------------------------------------------- | |
113 | |
114 END_NAMESPACE_DGL | |
115 | |
116 #endif // DGL_APP_PRIVATE_DATA_HPP_INCLUDED |