Skip to content

Commit 9901c04

Browse files
committed
Switch to nativefiledialog from frogtoss. Better handling of SampledAudioNode in UI
1 parent 218f3a3 commit 9901c04

20 files changed

+5695
-303
lines changed

CMakeLists.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,18 @@ endforeach()
159159
add_custom_target(ProcessPlaygroundShaderFiles ALL DEPENDS ${PLAYGROUND_SHADERS_SRC})
160160

161161
if(APPLE)
162-
set(NFD src/nfd.h src/nfd.mm)
162+
set(NFD third/nativefiledialog/include/nfd.h
163+
third/nativefiledialog/nfd_cocoa_arc.m third/nativefiledialog/nfd_common.c
164+
third/nativefiledialog/nfd_common.h)
165+
elseif(WIN32)
166+
set(NFD third/nativefiledialog/include/nfd.h
167+
third/nativefiledialog/nfd_win.cpp third/nativefiledialog/nfd_common.c
168+
third/nativefiledialog/nfd_common.h)
163169
else()
164-
set(NFD src/nfd.h src/nfd.cc)
170+
# nb: there is a zenity variant, but haven't had a call for it yet
171+
set(NFD third/nativefiledialog/include/nfd.h
172+
third/nativefiledialog/nfd_gtk.cpp third/nativefiledialog/nfd_common.c
173+
third/nativefiledialog/nfd_common.h)
165174
endif()
166175

167176
add_executable(LabSoundGraphToy
@@ -191,6 +200,7 @@ target_include_directories(LabSoundGraphToy SYSTEM
191200
target_include_directories(LabSoundGraphToy
192201
PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/generated_src"
193202
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src"
203+
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/third/nativefiledialog/include"
194204
PRIVATE third/imgui/examples)
195205

196206
set_property(TARGET LabSoundGraphToy PROPERTY CXX_STANDARD 17)

src/LabSoundInterface.cpp

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -424,17 +424,25 @@ void LabSoundProvider::node_start_stop(ln_Node node_id, float when)
424424
if (!in_node)
425425
return;
426426

427-
lab::AudioScheduledSourceNode* n = dynamic_cast<lab::AudioScheduledSourceNode*>(in_node.get());
428-
if (n)
429-
{
430-
if (n->isPlayingOrScheduled()) {
431-
printf("Stop %lld\n", node_id.id);
432-
n->stop(when);
433-
}
434-
else {
435-
printf("Start %lld\n", node_id.id);
436-
n->start(when);
437-
}
427+
lab::SampledAudioNode* san =
428+
dynamic_cast<lab::SampledAudioNode*>(in_node.get());
429+
if (san) {
430+
san->schedule(0);
431+
return;
432+
}
433+
434+
lab::AudioScheduledSourceNode* n =
435+
dynamic_cast<lab::AudioScheduledSourceNode*>(in_node.get());
436+
if (!n)
437+
return;
438+
439+
if (n->isPlayingOrScheduled()) {
440+
printf("Stop %lld\n", node_id.id);
441+
n->stop(when);
442+
}
443+
else {
444+
printf("Start %lld\n", node_id.id);
445+
n->start(when);
438446
}
439447
}
440448

src/lab_noodle.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,8 @@ namespace noodle {
817817
{
818818
if (ImGui::Button("Load Audio File..."))
819819
{
820-
const char* file = noc_file_dialog_open(NOC_FILE_DIALOG_OPEN, "*.*", ".", "*.*");
820+
char* file = nullptr;
821+
nfdresult_t open_result = NFD_OpenDialog("", "", &file);
821822
if (file)
822823
{
823824
{

src/main.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ void frame()
307307
{
308308
if (ImGui::Button("Save and Quit"))
309309
{
310-
const char* file = noc_file_dialog_open(NOC_FILE_DIALOG_SAVE, "*.ls", ".", "*.*");
310+
char* file = nullptr;
311+
nfdresult_t result = NFD_SaveDialog("*.ls", "", &file);
311312
if (file)
312313
{
313314
config.save(file);
@@ -345,7 +346,8 @@ void frame()
345346
{
346347
if (ImGui::Button("Save work in progress"))
347348
{
348-
const char* file = noc_file_dialog_open(NOC_FILE_DIALOG_SAVE, "*.ls", ".", "*.*");
349+
char* file = nullptr;
350+
nfdresult_t result = NFD_SaveDialog("*.ls", "", &file);
349351
if (file)
350352
{
351353
config.save(file);
@@ -377,7 +379,8 @@ void frame()
377379

378380
case Command::Save:
379381
{
380-
const char* file = noc_file_dialog_open(NOC_FILE_DIALOG_SAVE, "*.ls\0", ".", "*.*");
382+
char* file = nullptr;
383+
nfdresult_t result = NFD_SaveDialog("*.ls", "", &file);
381384
if (file)
382385
{
383386
config.save(file);
@@ -388,7 +391,8 @@ void frame()
388391

389392
case Command::ExportCpp:
390393
{
391-
const char* file = noc_file_dialog_open(NOC_FILE_DIALOG_SAVE, "*.cpp\0", ".", "*.*");
394+
char* file = nullptr;
395+
nfdresult_t result = NFD_SaveDialog("*.cpp", "", &file);
392396
if (file)
393397
{
394398
config.export_cpp(file);
@@ -405,7 +409,8 @@ void frame()
405409
{
406410
if (ImGui::Button("Save work in progress?"))
407411
{
408-
const char* file = noc_file_dialog_open(NOC_FILE_DIALOG_SAVE, "*.ls", ".", "*.*");
412+
char* file = nullptr;
413+
nfdresult_t result = NFD_SaveDialog("*.ls", "", &file);
409414
if (file)
410415
{
411416
config.save(file);
@@ -431,7 +436,8 @@ void frame()
431436
{
432437
command = Command::None;
433438
}
434-
const char* file = noc_file_dialog_open(NOC_FILE_DIALOG_OPEN, "*.ls", ".", "*.*");
439+
char* file = nullptr;
440+
nfdresult_t result = NFD_OpenDialog("*.ls", "", &file);
435441
if (file)
436442
{
437443
config.clear_all();

src/nfd.cc

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)