Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/RunTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
branches:
- 'main'
- 'develop'
- 'linux'
env:
BUILD_TYPE: Release
BUILD_DIR: Builds
Expand Down Expand Up @@ -37,7 +38,10 @@ jobs:

- name: Set up Clang
if: runner.os == 'Linux'
uses: egor-tensin/setup-clang@v1
uses: egor-tensin/setup-clang@v2.1
with:
version: 18
platform: x64

- name: Install JUCE's Linux Deps
if: runner.os == 'Linux'
Expand Down
18 changes: 16 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
cmake_minimum_required(VERSION 3.24)

# TODO figure this out
# https://stackoverflow.com/questions/47087237/cmake-and-ninja-rebuild-unnecessary-files
option(LINUX_REBUILD_WORKAROUND "ignore system headers for detecting dirty files" OFF)
if(LINUX_REBUILD_WORKAROUND)
file(
WRITE "${CMAKE_BINARY_DIR}/GNUMakeRulesOverwrite.cmake"
"STRING(REPLACE \"-MD\" \"-MMD\" CMAKE_DEPFILE_FLAGS_C \"\${CMAKE_DEPFILE_FLAGS_C}\")\n"
"STRING(REPLACE \"-MD\" \"-MMD\" CMAKE_DEPFILE_FLAGS_CXX \"\${CMAKE_DEPFILE_FLAGS_CXX}\")\n"
)
set(CMAKE_USER_MAKE_RULES_OVERRIDE "${CMAKE_BINARY_DIR}/GNUMakeRulesOverwrite.cmake" CACHE INTERNAL "")
endif()

project(VainDirectoryModel VERSION 0.0.1)

set(CMAKE_CXX_STANDARD 20)

include(FetchContent)
FetchContent_Declare(
juce
GIT_REPOSITORY "https://github.com/juce-framework/JUCE.git"
GIT_TAG "8.0.10"
GIT_TAG "8.0.12"
SOURCE_DIR "${CMAKE_BINARY_DIR}/juce"
BINARY_DIR "${CMAKE_BINARY_DIR}/juce_build"
)
FetchContent_MakeAvailable(juce)

add_subdirectory(Modules)
add_subdirectory(Demo)
add_subdirectory(Tests)
add_subdirectory(Demo)
2 changes: 2 additions & 0 deletions Demo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ target_compile_definitions(
Demo
PUBLIC
-DPROJECT_ROOT_DIR="${CMAKE_SOURCE_DIR}/"
-DJUCE_USE_CURL=0
-DJUCE_WEB_BROWSER=0
)

target_sources(
Expand Down
5 changes: 3 additions & 2 deletions Modules/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ option(BUILD_SHARED_LIBS "Build efsw as a shared library" OFF)
FetchContent_Declare(
efsw
GIT_REPOSITORY "https://github.com/SpartanJ/efsw.git"
GIT_TAG "f94a661"
GIT_TAG "f94a661" # TODO update?
SOURCE_DIR "${CMAKE_BINARY_DIR}/efsw"
BINARY_DIR "${CMAKE_BINARY_DIR}/efsw_build"
)
FetchContent_MakeAvailable(efsw)

juce_add_modules(
ALIAS_NAMESPACE vdm

vdm
vdm_directory
vdm_ui
)
)

target_link_libraries(
vdm
Expand Down
15 changes: 12 additions & 3 deletions Modules/vdm_directory/Cursor/vdm_TreeViewCursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@ bool vdm::TreeViewCursor::keyUp()
{
while (DirectoryModel::IsDirOpen(m_cursor.getValueTree()))
{
m_cursor.child();
while (m_cursor.next()) {}
if (m_cursor.child())
{
while (m_cursor.next()) {}
}
else
{
m_cursor.previous();
}
}
return true;
}
Expand All @@ -37,7 +43,10 @@ bool vdm::TreeViewCursor::keyDown()
{
if (DirectoryModel::IsDirOpen(m_cursor.getValueTree()))
{
m_cursor.child();
if (!m_cursor.child())
{
m_cursor.next();
}
}
else if (m_cursor.next()) {}
else
Expand Down
1 change: 0 additions & 1 deletion Modules/vdm_directory/DirectoryModel/vdm_DirectoryModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//-----------------------------------------------------------------------------

#include <vdm/vdm.h>
#include <juce_core/juce_core.h>
#include <juce_data_structures/juce_data_structures.h>
#include "vdm_DirectoryTree.h"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
#include "vdm_DirectoryModelSync.h"
#include "vdm_DirectoryModel.h"
#include <ranges>

//-----------------------------------------------------------------------------

vdm::DirectoryModelSync::DirectoryModelSync() = default;
//-----------------------------------------------------------------------------

vdm::DirectoryModelSync::~DirectoryModelSync() = default;
vdm::DirectoryModelSync::~DirectoryModelSync()
{
for (const auto &[id, _] : m_models)
m_fileWatcher.removeWatch(id);
}

//-----------------------------------------------------------------------------

Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Vain Directory Model

[![Run Tests](https://github.com/carl-sr/ValueTreeLib/actions/workflows/RunTests.yml/badge.svg?branch=develop)](https://github.com/carl-sr/ValueTreeLib/actions/workflows/RunTests.yml)

[![Run Tests](https://github.com/VainAudio/DirectoryModel/actions/workflows/RunTests.yml/badge.svg)](https://github.com/VainAudio/DirectoryModel/actions/workflows/RunTests.yml)

A couple JUCE modules that are useful for representing and interacting with files and directories through `juce::ValueTree`.
It allows displaying a directory's contents in a tree view and allowing the user to make selections and open/close directories with their mouse or arrow keys.
Expand Down
3 changes: 2 additions & 1 deletion Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ set(TestSourceFiles
)

add_executable("Tests" "${TestSourceFiles}")
target_compile_features("Tests" PRIVATE cxx_std_20)

target_compile_definitions(
"Tests"
PRIVATE
-DTEST_TEMP_DIR="${CMAKE_CURRENT_SOURCE_DIR}/tmp/"
JUCE_USE_CURL=0
-DJUCE_WEB_BROWSER=0
)

target_link_libraries("Tests"
Expand All @@ -35,6 +35,7 @@ target_link_libraries("Tests"

juce::juce_core
juce::juce_gui_basics
juce::juce_data_structures
juce::juce_recommended_config_flags
juce::juce_recommended_lto_flags
juce::juce_recommended_warning_flags
Expand Down
5 changes: 4 additions & 1 deletion Tests/DirectoryModelTests.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ TEST(DirectoryModel, AddToTree)
dir.createFile("test3.txt");

DirTestHelper dir2 = dir.createDir("asdf");

mm.runMessageThread();

dir2.createFile("dir_test1.txt");
dir2.createFile("dir_test2.txt");

Expand Down Expand Up @@ -253,7 +256,7 @@ TEST(DirectoryModel, OnModifyUpdateHandler)
vdm::DirectoryModel model;

MockModifyHandler mock;
EXPECT_CALL(mock, onModify(_, _)).Times(1);
EXPECT_CALL(mock, onModify(_, _)).Times(testing::AnyNumber());
model.addUpdateHandler(mock);

model.initialize(dir.file());
Expand Down
3 changes: 2 additions & 1 deletion Tests/TestHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class DirTestHelper
juce::File file();

private:
DirTestHelper(const DirTestHelper &) = default;
DirTestHelper(const DirTestHelper &) = delete;
DirTestHelper(DirTestHelper &&) = default;
explicit DirTestHelper(juce::File child);

juce::File m_root{ TEST_TEMP_DIR };
Expand Down
Loading