From 387e4faee9548a21f71a678f9e2730f6d5a307df Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 6 Oct 2024 16:40:23 -0400 Subject: Use std::any_of() --- src/gui/GraphBox.cpp | 30 ++++++++++++++---------------- src/gui/NodeMenu.cpp | 15 +++++++-------- 2 files changed, 21 insertions(+), 24 deletions(-) (limited to 'src/gui') diff --git a/src/gui/GraphBox.cpp b/src/gui/GraphBox.cpp index 4c3ff50d..0cbd7303 100644 --- a/src/gui/GraphBox.cpp +++ b/src/gui/GraphBox.cpp @@ -1,6 +1,6 @@ /* This file is part of Ingen. - Copyright 2007-2017 David Robillard + Copyright 2007-2024 David Robillard Ingen is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free @@ -91,6 +91,7 @@ # include #endif +#include #include #include #include @@ -100,7 +101,6 @@ #include #include #include -#include namespace ingen { @@ -382,12 +382,12 @@ GraphBox::set_graph(const std::shared_ptr& graph, _menu_view_control_window->property_sensitive() = false; - for (const auto& p : graph->ports()) { - if (_app->can_control(p.get())) { - _menu_view_control_window->property_sensitive() = true; - break; - } - } + _menu_view_control_window->property_sensitive() = + std::any_of(graph->ports().begin(), + graph->ports().end(), + [this](const auto& p) { + return _app->can_control(p.get()); + }); _menu_parent->property_sensitive() = !!graph->parent(); @@ -425,14 +425,12 @@ GraphBox::graph_port_removed(const std::shared_ptr& port) return; } - for (const auto& p : _graph->ports()) { - if (p->is_input() && _app->can_control(p.get())) { - _menu_view_control_window->property_sensitive() = true; - return; - } - } - - _menu_view_control_window->property_sensitive() = false; + _menu_view_control_window->property_sensitive() = + std::any_of(_graph->ports().begin(), + _graph->ports().end(), + [this](const auto& p) { + return p->is_input() && _app->can_control(p.get()); + }); } void diff --git a/src/gui/NodeMenu.cpp b/src/gui/NodeMenu.cpp index ced303fb..e18ff6b9 100644 --- a/src/gui/NodeMenu.cpp +++ b/src/gui/NodeMenu.cpp @@ -1,6 +1,6 @@ /* This file is part of Ingen. - Copyright 2007-2015 David Robillard + Copyright 2007-2024 David Robillard Ingen is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free @@ -55,6 +55,7 @@ #include #include +#include #include #include #include @@ -273,13 +274,11 @@ NodeMenu::on_preset_activated(const std::string& uri) bool NodeMenu::has_control_inputs() { - for (const auto& p : block()->ports()) { - if (p->is_input() && p->is_numeric()) { - return true; - } - } - - return false; + return std::any_of(block()->ports().begin(), + block()->ports().end(), + [](const auto& p) { + return p->is_input() && p->is_numeric(); + }); } } // namespace ingen::gui -- cgit v1.2.1