From 61c6bab505c882055ff0cee423c187046ab4b3ae Mon Sep 17 00:00:00 2001 From: Annwan Date: Sun, 29 Sep 2024 00:05:08 +0200 Subject: [PATCH] More work --- CMakeLists.txt | 27 +++--- src/Application.cppm | 136 +++++++++++++++++++++------ src/Base.cppm | 45 +++++---- src/Node.cppm | 78 +++++++-------- src/Nodes/InputNode.cpp | 21 +++++ src/Nodes/OutputNode.cpp | 20 ++++ src/Nodes/StreamSpecConstantNode.cpp | 34 +++++++ src/Nodes/StringConstantNode.cpp | 13 +++ src/Port.cppm | 83 ++++++---------- src/Ports/InputPort.cpp | 21 +++++ src/Ports/OutputPort.cpp | 32 +++++++ src/Ports/StringUserInput.cpp | 15 +++ src/macros.hpp | 20 ++++ src/main.cpp | 2 +- 14 files changed, 386 insertions(+), 161 deletions(-) create mode 100644 src/Nodes/InputNode.cpp create mode 100644 src/Nodes/OutputNode.cpp create mode 100644 src/Nodes/StreamSpecConstantNode.cpp create mode 100644 src/Nodes/StringConstantNode.cpp create mode 100644 src/Ports/InputPort.cpp create mode 100644 src/Ports/OutputPort.cpp create mode 100644 src/Ports/StringUserInput.cpp create mode 100644 src/macros.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 93cec82..838c590 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,22 +31,18 @@ FetchContent_Declare(clopts ) FetchContent_MakeAvailable(clopts) -# Find all the modules +message(STATUS "Looking for files") file(GLOB_RECURSE modules src/*.cppm) -# Create the executable target -add_executable(ffmpegraph) -# Main file -target_sources(ffmpegraph - PUBLIC - src/main.cpp -) -# The modules -target_sources(ffmpegraph - PUBLIC - FILE_SET CXX_MODULES FILES - ${modules} +file(GLOB_RECURSE headers src/*.hpp) +file(GLOB_RECURSE impls src/*.cpp) + +message(STATUS "Create target") +add_executable(ffmpegraph ${impls}) +target_sources(ffmpegraph PUBLIC + FILE_SET CXX_MODULES FILES ${modules} + FILE_SET HEADERS FILES ${headers} ) -#Compile flags + target_compile_options(ffmpegraph PRIVATE -Wall -Wextra # Standard screaming -Wconversion -Wsign-conversion # Scream about accidentally converting stuff @@ -55,13 +51,12 @@ target_compile_options(ffmpegraph PRIVATE $<$:-O0 -g3 -glldb> $<$:-O3 -march=native> ) -# color shit out + if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") target_compile_options(ffmpegraph PRIVATE -fdiagnostics-color=always) elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") target_compile_options(ffmpegraph PRIVATE -fcolor-diagnostics) endif() -# Link against exernal libraries target_link_libraries(ffmpegraph PRIVATE raylib m) target_include_directories(ffmpegraph PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/libs/clopts/include") diff --git a/src/Application.cppm b/src/Application.cppm index b07a86d..6a7510c 100644 --- a/src/Application.cppm +++ b/src/Application.cppm @@ -1,6 +1,9 @@ module; +#include "macros.hpp" + #include #include +#include #include #include #include @@ -9,7 +12,6 @@ module; #include #include #include -#include export module Application; import Node; import Base; @@ -30,7 +32,7 @@ protected: void OnLeftClick(); void OnKeyPressed(i32 key); void Render(); - void ExecuteGraph(); + Result<> ExecuteGraph(); std::deque message_queue; std::string title; bool should_close; @@ -38,6 +40,14 @@ protected: Node *selected_node = nullptr; OutputPort *selected_port = nullptr; Button run_button; + enum class State { + DEFAULT, + CONNECTING, + EDITING, + ADDING, + } current_state = State::DEFAULT; + + std::vector