From c14bdd7c83615a23714f1348a113ce319736a168 Mon Sep 17 00:00:00 2001 From: Jules Fouchy Date: Tue, 27 Feb 2024 00:37:11 +0100 Subject: [PATCH 01/11] =?UTF-8?q?=F0=9F=9A=9A=20[open]=20Renamed=20open=5F?= =?UTF-8?q?link()=20as=20open()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitmodules | 6 +++--- CMakeLists.txt | 4 ++-- lib/open | 1 + lib/open_link | 1 - src/Cool/ImGui/ImGuiExtras.cpp | 1 - src/Cool/ImGui/markdown.cpp | 4 ++-- 6 files changed, 8 insertions(+), 9 deletions(-) create mode 160000 lib/open delete mode 160000 lib/open_link diff --git a/.gitmodules b/.gitmodules index 5a4568d64..a83ec6972 100644 --- a/.gitmodules +++ b/.gitmodules @@ -61,9 +61,6 @@ [submodule "lib/imgui_gradient"] path = lib/imgui_gradient url = https://github.com/CoolLibs/imgui_gradient.git -[submodule "lib/open_link"] - path = lib/open_link - url = https://github.com/CoolLibs/open_link [submodule "lib/expected"] path = lib/expected url = https://github.com/TartanLlama/expected @@ -112,3 +109,6 @@ [submodule "lib/oscpack"] path = lib/oscpack url = https://github.com/CoolLibs/oscpack +[submodule "lib/open"] + path = lib/open + url = https://github.com/CoolLibs/open diff --git a/CMakeLists.txt b/CMakeLists.txt index 7327b4388..a4060e98a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -232,8 +232,8 @@ add_subdirectory(lib/wafl) target_link_libraries(Cool-PublicProperties INTERFACE wafl::wafl) # open_link -add_subdirectory(lib/open_link) -target_link_libraries(Cool-PublicProperties INTERFACE open_link::open_link) +add_subdirectory(lib/open) +target_link_libraries(Cool-PublicProperties INTERFACE Cool::open) # os_name add_subdirectory(lib/os_name) diff --git a/lib/open b/lib/open new file mode 160000 index 000000000..27aeb46c4 --- /dev/null +++ b/lib/open @@ -0,0 +1 @@ +Subproject commit 27aeb46c409a0fcd376528a205452b69473ec987 diff --git a/lib/open_link b/lib/open_link deleted file mode 160000 index 881827fd2..000000000 --- a/lib/open_link +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 881827fd215131fb35623eaa680e0733553fa1c2 diff --git a/src/Cool/ImGui/ImGuiExtras.cpp b/src/Cool/ImGui/ImGuiExtras.cpp index fa440deb1..3d801de30 100644 --- a/src/Cool/ImGui/ImGuiExtras.cpp +++ b/src/Cool/ImGui/ImGuiExtras.cpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include "Cool/ImGui/Fonts.h" #include "Cool/ImGui/IcoMoonCodepoints.h" diff --git a/src/Cool/ImGui/markdown.cpp b/src/Cool/ImGui/markdown.cpp index c9dff01e3..a2c38ec9d 100644 --- a/src/Cool/ImGui/markdown.cpp +++ b/src/Cool/ImGui/markdown.cpp @@ -1,6 +1,6 @@ #include "markdown.h" #include -#include +#include #include "Cool/ImGui/Fonts.h" #include "Cool/ImGui/ImGuiExtrasStyle.h" #include "Fonts.h" @@ -12,7 +12,7 @@ static void link_clicked_callback(ImGui::MarkdownLinkCallbackData data) { if (data.isImage) return; - open_link(std::string{data.link, static_cast(data.linkLength)}.c_str()); // `link` is not a zero-terminated string, so we must construct a string from the pointer and the length. + open(std::string{data.link, static_cast(data.linkLength)}.c_str()); // `link` is not a zero-terminated string, so we must construct a string from the pointer and the length. } static void format_callback(ImGui::MarkdownFormatInfo const& info, bool is_beginning); From 20f2da418c450bc528e5d3fd2673f266d3c1a70b Mon Sep 17 00:00:00 2001 From: Jules Fouchy Date: Tue, 27 Feb 2024 01:38:18 +0100 Subject: [PATCH 02/11] =?UTF-8?q?=F0=9F=A4=8F=20[Shader]=20Replace=20=5FUS?= =?UTF-8?q?ER=5FDATA=5F=20with=20the=20path?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Cool/Gpu/OpenGL/preprocess_shader_source.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Cool/Gpu/OpenGL/preprocess_shader_source.cpp b/src/Cool/Gpu/OpenGL/preprocess_shader_source.cpp index f363e7c98..d9bc8e099 100644 --- a/src/Cool/Gpu/OpenGL/preprocess_shader_source.cpp +++ b/src/Cool/Gpu/OpenGL/preprocess_shader_source.cpp @@ -70,6 +70,7 @@ static auto preprocess_shader_source_impl(std::string_view source, std::vector Date: Tue, 27 Feb 2024 02:07:22 +0100 Subject: [PATCH 03/11] =?UTF-8?q?=F0=9F=90=9B=E2=9A=A1=20[NodesCategory]?= =?UTF-8?q?=20Only=20create=20a=20NodesCategory=20when=20necessary,=20and?= =?UTF-8?q?=20not=20on=20all=20parsed=20nodes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prevents getting a warning when nodes of a category come from two separate folders but only one of them has the _category_config.json + improves perfs in the general case because we don't create one config per node, but only once when the first node of the category is encountered --- src/Cool/Nodes/NodesDefinitionUpdater.cpp | 2 +- src/Cool/Nodes/NodesLibrary.cpp | 9 ++++----- src/Cool/Nodes/NodesLibrary.h | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Cool/Nodes/NodesDefinitionUpdater.cpp b/src/Cool/Nodes/NodesDefinitionUpdater.cpp index 96431acd9..3e1641517 100644 --- a/src/Cool/Nodes/NodesDefinitionUpdater.cpp +++ b/src/Cool/Nodes/NodesDefinitionUpdater.cpp @@ -55,7 +55,7 @@ void NodesDefinitionUpdater::add_definition( { auto const category_folder = File::without_file_name(path).string(); - _library.add_definition(*definition, category_name, make_category_config(category_folder), get_category_order(path, root)); + _library.add_definition(*definition, category_name, [&]() { return NodesCategory{category_name, make_category_config(category_folder), get_category_order(path, root)}; }); } { diff --git a/src/Cool/Nodes/NodesLibrary.cpp b/src/Cool/Nodes/NodesLibrary.cpp index 04889c2d4..5fa6f1d61 100644 --- a/src/Cool/Nodes/NodesLibrary.cpp +++ b/src/Cool/Nodes/NodesLibrary.cpp @@ -90,10 +90,9 @@ auto NodesLibrary::imgui_nodes_menu(std::string const& nodes_filter, MaybeDisabl } void NodesLibrary::add_definition( - NodeDefinition const& definition, - std::string category_name, - NodesCategoryConfig const& category_config, - int category_order + NodeDefinition const& definition, + std::string const& category_name, + std::function const& make_category // We take a function because we want to delay the creation of the category until we are sure we need to create one, which is rare (and otherwise would cause warning when two folders correspond to the same category, but only one of them contains the _category_config.json, which happens when reading nodes from both the app's root folder and the user-data folder) ) { // Add definition to the corresponding category if it exists @@ -108,7 +107,7 @@ void NodesLibrary::add_definition( } // Add new category if not found - _categories.push_back(NodesCategory{category_name, category_config, category_order}); + _categories.push_back(make_category()); _categories.back().definitions().push_back(definition); std::sort( _categories.begin(), _categories.end(), diff --git a/src/Cool/Nodes/NodesLibrary.h b/src/Cool/Nodes/NodesLibrary.h index 518f8c973..6467dbe8d 100644 --- a/src/Cool/Nodes/NodesLibrary.h +++ b/src/Cool/Nodes/NodesLibrary.h @@ -62,7 +62,7 @@ class NodesLibrary { auto imgui_nodes_menu(std::string const& nodes_filter, MaybeDisableNodeDefinition const&, bool select_first, bool open_all_categories, bool menu_just_opened) const -> std::optional; - void add_definition(NodeDefinition const&, std::string category_name, NodesCategoryConfig const&, int category_order); + void add_definition(NodeDefinition const& definition, std::string const& category_name, std::function const& make_category); void remove_definition(NodeDefinitionIdentifier const&); From d7b4f869c5d9881a8d28e3efbd273f67e22f0901 Mon Sep 17 00:00:00 2001 From: Jules Fouchy Date: Tue, 27 Feb 2024 02:25:14 +0100 Subject: [PATCH 04/11] =?UTF-8?q?=F0=9F=90=9B=20[Nodes]=20When=20adding=20?= =?UTF-8?q?a=20link,=20remove=20previous=20links=20going=20into=20the=20sa?= =?UTF-8?q?me=20input=20pin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Cool/Nodes/EditorImpl.cpp | 10 ++++++++++ src/Cool/Nodes/NodesGraph.cpp | 10 ++++++++++ src/Cool/Nodes/NodesGraph.h | 1 + 3 files changed, 21 insertions(+) diff --git a/src/Cool/Nodes/EditorImpl.cpp b/src/Cool/Nodes/EditorImpl.cpp index fdb64e6c9..14815e9b6 100644 --- a/src/Cool/Nodes/EditorImpl.cpp +++ b/src/Cool/Nodes/EditorImpl.cpp @@ -534,6 +534,16 @@ auto NodesEditorImpl::process_link_creation(NodesConfig& nodes_cfg) -> bool .from_pin_id = begin_pin->id(), .to_pin_id = end_pin->id(), }; + { + // Remove all links going into the same pin as the new link + // Must be done before adding the link, otherwise we would remove it too + auto links_to_remove = std::vector>{}; // Can't remove while iterating, so we delay it + _graph.for_each_link_connected_to_input_pin(link.to_pin_id, [&](LinkId const& link_id, Link const& link) { + links_to_remove.emplace_back(link_id, link); + }); + for (auto const& [link_id, link] : links_to_remove) + nodes_cfg.remove_link(link_id, link); + } auto const link_id = nodes_cfg.add_link(link); nodes_cfg.on_link_created_between_existing_nodes(link, link_id); return true; diff --git a/src/Cool/Nodes/NodesGraph.cpp b/src/Cool/Nodes/NodesGraph.cpp index 7dbc83b3b..bf373348e 100644 --- a/src/Cool/Nodes/NodesGraph.cpp +++ b/src/Cool/Nodes/NodesGraph.cpp @@ -186,4 +186,14 @@ void NodesGraph::for_each_link_connected_to_pin(PinId const& pin_id, std::functi } } +void NodesGraph::for_each_link_connected_to_input_pin(PinId const& pin_id, std::function const& callback) const +{ + std::shared_lock lock{_links.mutex()}; + for (auto const& [id, link] : _links) + { + if (link.to_pin_id == pin_id) + callback(id, link); + } +} + } // namespace Cool \ No newline at end of file diff --git a/src/Cool/Nodes/NodesGraph.h b/src/Cool/Nodes/NodesGraph.h index 9a3f61ada..1bc1b9778 100644 --- a/src/Cool/Nodes/NodesGraph.h +++ b/src/Cool/Nodes/NodesGraph.h @@ -68,6 +68,7 @@ class NodesGraph { } void for_each_link_connected_to_node(Node const&, std::function const&) const; void for_each_link_connected_to_pin(PinId const&, std::function const&) const; + void for_each_link_connected_to_input_pin(PinId const&, std::function const&) const; private: reg::RawRegistry _nodes; From 1fada7639a785c5b209e6c3f623de7f6da048898 Mon Sep 17 00:00:00 2001 From: Jules Fouchy Date: Tue, 27 Feb 2024 02:40:09 +0100 Subject: [PATCH 05/11] =?UTF-8?q?=F0=9F=9A=A8=20Fix=20warnings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/open | 2 +- src/Cool/Nodes/EditorImpl.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/open b/lib/open index 27aeb46c4..3cdf439f2 160000 --- a/lib/open +++ b/lib/open @@ -1 +1 @@ -Subproject commit 27aeb46c409a0fcd376528a205452b69473ec987 +Subproject commit 3cdf439f2297b16c76c74ed7b78553808199d124 diff --git a/src/Cool/Nodes/EditorImpl.cpp b/src/Cool/Nodes/EditorImpl.cpp index 14815e9b6..d6e868a60 100644 --- a/src/Cool/Nodes/EditorImpl.cpp +++ b/src/Cool/Nodes/EditorImpl.cpp @@ -538,11 +538,11 @@ auto NodesEditorImpl::process_link_creation(NodesConfig& nodes_cfg) -> bool // Remove all links going into the same pin as the new link // Must be done before adding the link, otherwise we would remove it too auto links_to_remove = std::vector>{}; // Can't remove while iterating, so we delay it - _graph.for_each_link_connected_to_input_pin(link.to_pin_id, [&](LinkId const& link_id, Link const& link) { - links_to_remove.emplace_back(link_id, link); + _graph.for_each_link_connected_to_input_pin(link.to_pin_id, [&](LinkId const& old_link_id, Link const& old_link) { + links_to_remove.emplace_back(old_link_id, old_link); }); - for (auto const& [link_id, link] : links_to_remove) - nodes_cfg.remove_link(link_id, link); + for (auto const& [old_link_id, old_link] : links_to_remove) + nodes_cfg.remove_link(old_link_id, old_link); } auto const link_id = nodes_cfg.add_link(link); nodes_cfg.on_link_created_between_existing_nodes(link, link_id); From ed89e4dda7b3e129742012fb52e3692b564bf010 Mon Sep 17 00:00:00 2001 From: Jules Fouchy Date: Thu, 29 Feb 2024 16:18:18 +0100 Subject: [PATCH 06/11] =?UTF-8?q?=F0=9F=A4=8F=20[Camera2D]=20Added=20view?= =?UTF-8?q?=5Fprojection=5Fmatrix()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Cool/StrongTypes/Camera2D.cpp | 5 +++++ src/Cool/StrongTypes/Camera2D.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/Cool/StrongTypes/Camera2D.cpp b/src/Cool/StrongTypes/Camera2D.cpp index d1256b69a..ea5d45fad 100644 --- a/src/Cool/StrongTypes/Camera2D.cpp +++ b/src/Cool/StrongTypes/Camera2D.cpp @@ -32,6 +32,11 @@ auto Camera2D::view_matrix() const -> glm::mat3 return res; } +auto Camera2D::view_projection_matrix(float inverse_aspect_ratio) const -> glm::mat3 +{ + return glm::scale(glm::mat3{1.f}, glm::vec2{inverse_aspect_ratio, 1.f}) * view_matrix(); +} + auto to_string(Camera2D const& cam) -> std::string { return fmt::format( diff --git a/src/Cool/StrongTypes/Camera2D.h b/src/Cool/StrongTypes/Camera2D.h index cd35dcf32..8c6a78961 100644 --- a/src/Cool/StrongTypes/Camera2D.h +++ b/src/Cool/StrongTypes/Camera2D.h @@ -12,6 +12,7 @@ struct Camera2D { auto transform_matrix() const -> glm::mat3; /// Inverse of transform_matrix(). auto view_matrix() const -> glm::mat3; + auto view_projection_matrix(float inverse_aspect_ratio) const -> glm::mat3; friend auto operator==(Camera2D const& a, Camera2D const& b) -> bool = default; From c3a39f2b731a68c7310008650c258e0743850f65 Mon Sep 17 00:00:00 2001 From: Jules Fouchy Date: Thu, 29 Feb 2024 17:03:38 +0100 Subject: [PATCH 07/11] =?UTF-8?q?=F0=9F=A4=8F=20[AppManager]=20In=20debug,?= =?UTF-8?q?=20don't=20catch=20unknown=20exceptions=20so=20that=20they=20ar?= =?UTF-8?q?e=20easier=20to=20debug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Cool/AppManager/AppManager.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Cool/AppManager/AppManager.cpp b/src/Cool/AppManager/AppManager.cpp index 79f353541..c14a13bd4 100644 --- a/src/Cool/AppManager/AppManager.cpp +++ b/src/Cool/AppManager/AppManager.cpp @@ -64,19 +64,19 @@ AppManager::AppManager(WindowManager& window_manager, ViewsManager& views, IApp& void AppManager::run(std::function on_update) { auto const do_update = [&]() { +#if !DEBUG try +#endif { update(); on_update(); } +#if !DEBUG catch (std::exception const& e) { Cool::Log::ToUser::error("UNKNOWN ERROR 1", e.what()); -#if DEBUG - std::cerr << e.what() << '\n'; - assert(false); // Please catch the error where appropriate, and handle it properly. -#endif } +#endif }; #if defined(COOL_UPDATE_APP_ON_SEPARATE_THREAD) auto should_stop = false; @@ -144,18 +144,18 @@ void AppManager::update() _app.request_rerender(); if (TextureLibrary_FromFile::instance().update()) // update() needs to be called because update has side effect _app.request_rerender(); +#if !DEBUG try +#endif { _app.update(); } +#if !DEBUG catch (std::exception const& e) { Cool::Log::ToUser::error("UNKNOWN ERROR 2", e.what()); -#if DEBUG - std::cerr << e.what() << '\n'; - assert(false); // Please catch the error where appropriate, and handle it properly. -#endif } +#endif restore_imgui_ini_state_ifn(); // Must be before `imgui_new_frame()` (this is a constraint from Dear ImGui (https://github.com/ocornut/imgui/issues/6263#issuecomment-1479727227)) imgui_new_frame(); check_for_imgui_item_picker_request(); From 33d257290d363705cfa09bfa9bdd1cc92dc7092e Mon Sep 17 00:00:00 2001 From: Jules Fouchy Date: Fri, 1 Mar 2024 18:34:09 +0100 Subject: [PATCH 08/11] =?UTF-8?q?=F0=9F=90=9B=20[Gizmos]=20When=20dragging?= =?UTF-8?q?=20gizmos,=20mouse=20can=20now=20wrap=20around=20the=20screen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Cool/View/GizmoManager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Cool/View/GizmoManager.cpp b/src/Cool/View/GizmoManager.cpp index 078188e6b..e51e67a7d 100644 --- a/src/Cool/View/GizmoManager.cpp +++ b/src/Cool/View/GizmoManager.cpp @@ -68,6 +68,7 @@ void GizmoManager::on_drag_update(MouseDragUpdateEvent const& e { with_dragged_gizmo([&](Gizmo_Point2D const& gizmo) { gizmo.set_position(ViewCoordinates{gizmo.get_position() + event.delta}); + ImGui::WrapMousePos(ImGuiAxesMask_All); }); } From a1237098d5cd00f9fb207f6ed06678cfe1a2b5f2 Mon Sep 17 00:00:00 2001 From: Jules Fouchy Date: Mon, 4 Mar 2024 14:42:39 +0100 Subject: [PATCH 09/11] =?UTF-8?q?=E2=9C=A8=20Added=20String::remove=5Fsubs?= =?UTF-8?q?tring()=20and=20RETURN=5FIF=5FERROR?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Cool/Expected/RETURN_IF_ERROR.h | 17 +++++++++++++++++ src/Cool/String/String.cpp | 5 +++++ src/Cool/String/String.h | 3 +++ 3 files changed, 25 insertions(+) create mode 100644 src/Cool/Expected/RETURN_IF_ERROR.h diff --git a/src/Cool/Expected/RETURN_IF_ERROR.h b/src/Cool/Expected/RETURN_IF_ERROR.h new file mode 100644 index 000000000..e145ed3fa --- /dev/null +++ b/src/Cool/Expected/RETURN_IF_ERROR.h @@ -0,0 +1,17 @@ +#pragma once + +/// x should be a std::optional representing an optional error message +#define RETURN_IF_ERROR(x) \ + { \ + auto maybe_error = x; \ + if (maybe_error) \ + return tl::make_unexpected(std::move(*maybe_error)); \ + } + +/// x should be a std::optional representing an optional error message +#define RETURN_IF_ERR(x) \ + { \ + auto maybe_error = x; \ + if (maybe_error) \ + return maybe_error; \ + } diff --git a/src/Cool/String/String.cpp b/src/Cool/String/String.cpp index 58bdc0723..7504cd413 100644 --- a/src/Cool/String/String.cpp +++ b/src/Cool/String/String.cpp @@ -290,6 +290,11 @@ auto substring( return substring_impl(text, begin, end); } +void remove_substring(std::string& string, size_t start, size_t end) +{ + string.erase(start, end - start); +} + auto find_next_word_position( std::string_view text, size_t starting_pos, diff --git a/src/Cool/String/String.h b/src/Cool/String/String.h index ebfecad4a..2a9cd48ca 100644 --- a/src/Cool/String/String.h +++ b/src/Cool/String/String.h @@ -154,6 +154,9 @@ auto substring( std::pair begin_end ) -> std::string_view; +/// Removes all characters in `string` between `start` (included) and `end` (excluded). +void remove_substring(std::string& string, size_t start, size_t end); + /// Returns the indices of the beginning and end of the next word in "text" after position "starting_pos". /// Words are considered to be separated by one or more characters of "delimiters". auto find_next_word_position( From 81b89eb027c11e66b1c8c9ea7dd645afadd1c616 Mon Sep 17 00:00:00 2001 From: Jules Fouchy Date: Tue, 5 Mar 2024 16:36:25 +0100 Subject: [PATCH 10/11] =?UTF-8?q?=F0=9F=94=A5=20[UserSettings]=20Remove=20?= =?UTF-8?q?"Nodes=20developper=20mode"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Cool/Nodes/NodesFolderWatcher.cpp | 7 ------- src/Cool/UserSettings/UserSettings.cpp | 10 ---------- src/Cool/UserSettings/UserSettings.h | 13 +------------ 3 files changed, 1 insertion(+), 29 deletions(-) diff --git a/src/Cool/Nodes/NodesFolderWatcher.cpp b/src/Cool/Nodes/NodesFolderWatcher.cpp index 6f94fd4e0..4496b5624 100644 --- a/src/Cool/Nodes/NodesFolderWatcher.cpp +++ b/src/Cool/Nodes/NodesFolderWatcher.cpp @@ -15,13 +15,6 @@ auto NodesFolderWatcher::update( std::function const& make_category_config ) -> bool { - // If not in nodes dev mode, we disable hot reloading. We only update the folder watcher once, when the library is empty, to fill it. - if (!Cool::user_settings().nodes_developer_mode - && !updater.library_is_empty()) - { - return false; - } - bool has_changed = false; auto const clear_errors_and_check_extension = [&](std::filesystem::path const& path) { Cool::Log::ToUser::console().remove(_error_message_id); diff --git a/src/Cool/UserSettings/UserSettings.cpp b/src/Cool/UserSettings/UserSettings.cpp index 38e3428b4..cdc45c00f 100644 --- a/src/Cool/UserSettings/UserSettings.cpp +++ b/src/Cool/UserSettings/UserSettings.cpp @@ -17,9 +17,6 @@ auto UserSettings::imgui() -> bool ImGuiExtras::separator_text("Miscellaneous"); b |= imgui_single_click_to_input_in_drag_widgets(); b |= imgui_enable_multi_viewport(); - ImGui::NewLine(); - ImGuiExtras::separator_text("Advanced"); - b |= imgui_nodes_developer_mode(); return b; } @@ -78,13 +75,6 @@ void UserSettings::apply_multi_viewport_setting() const ImGui::GetIO().ConfigFlags &= ~ImGuiConfigFlags_ViewportsEnable; } -auto UserSettings::imgui_nodes_developer_mode() -> bool -{ - bool const b = ImGuiExtras::toggle("Nodes developer mode", &nodes_developer_mode); - ImGuiExtras::help_marker("If you want to write your own nodes, enable this. It will enable hot reloading of the nodes files."); - return b; -} - auto should_enable_multi_viewport_by_default() -> bool { #if !defined(__linux__) diff --git a/src/Cool/UserSettings/UserSettings.h b/src/Cool/UserSettings/UserSettings.h index e6e11eb1a..e83d11b73 100644 --- a/src/Cool/UserSettings/UserSettings.h +++ b/src/Cool/UserSettings/UserSettings.h @@ -21,22 +21,12 @@ struct UserSettings { bool enable_multi_viewport{should_enable_multi_viewport_by_default()}; void apply_multi_viewport_setting() const; - bool nodes_developer_mode - { -#if DEBUG - true -#else - false -#endif - }; - auto imgui() -> bool; auto imgui_autosave() -> bool; auto imgui_extra_icons() -> bool; auto imgui_camera2D_zoom_sensitivity() -> bool; auto imgui_single_click_to_input_in_drag_widgets() -> bool; auto imgui_enable_multi_viewport() -> bool; - auto imgui_nodes_developer_mode() -> bool; private: // Serialization @@ -51,8 +41,7 @@ struct UserSettings { cereal::make_nvp("Camera 2D zoom sensitivity", camera2D_zoom_sensitivity), cereal::make_nvp("Use OS color theme", color_themes), cereal::make_nvp("Single click to input in drag widgets", single_click_to_input_in_drag_widgets), - cereal::make_nvp("Enable multi-viewport", enable_multi_viewport), - cereal::make_nvp("Nodes developer mode", nodes_developer_mode) + cereal::make_nvp("Enable multi-viewport", enable_multi_viewport) ); } }; From 18fedbb7433d8f52be98f4fd57bf6746e372f85b Mon Sep 17 00:00:00 2001 From: Jules Fouchy Date: Fri, 8 Mar 2024 16:13:34 +0100 Subject: [PATCH 11/11] =?UTF-8?q?=E2=9C=A8=20[String]=20Added=20find=5Fpre?= =?UTF-8?q?vious=5Fword()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Cool/String/String.cpp | 13 +++++++++++++ src/Cool/String/String.h | 8 ++++++++ 2 files changed, 21 insertions(+) diff --git a/src/Cool/String/String.cpp b/src/Cool/String/String.cpp index 7504cd413..e0202b1f4 100644 --- a/src/Cool/String/String.cpp +++ b/src/Cool/String/String.cpp @@ -333,6 +333,19 @@ auto find_previous_word_position( return std::make_pair(idx1, idx2 + 1); } +auto find_previous_word( + std::string_view text, + size_t ending_pos, + std::string_view delimiters +) -> std::optional +{ + auto const position = find_previous_word_position(text, ending_pos, delimiters); + if (!position) + return std::nullopt; + + return std::string{substring(text, *position)}; +} + auto next_word( std::string_view text, size_t starting_pos, diff --git a/src/Cool/String/String.h b/src/Cool/String/String.h index 2a9cd48ca..2d0a36992 100644 --- a/src/Cool/String/String.h +++ b/src/Cool/String/String.h @@ -173,6 +173,14 @@ auto find_previous_word_position( std::string_view delimiters = default_word_delimiters ) -> std::optional>; +/// Returns the word in "text" before the position "ending_pos". Or nullopt if there is no such word. +/// Words are considered to be separated by one or more characters of "delimiters". +auto find_previous_word( + std::string_view text, + size_t ending_pos, + std::string_view delimiters = default_word_delimiters +) -> std::optional; + /// /!\ The returned string_view is only valid as long as the input string_view is valid! /// Returns the next word after `startingPos`. A word is a block of characters that doesn't contain any of the `delimiters`. auto next_word(