summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2024-10-06 16:40:23 -0400
committerDavid Robillard <d@drobilla.net>2024-10-11 19:58:27 -0400
commit387e4faee9548a21f71a678f9e2730f6d5a307df (patch)
tree3ed0e418e86eb6c1b1cb623d4e0de5653d1f9427 /src/gui
parent676651dea6c22895b0bc8de18d724d716089d798 (diff)
downloadingen-387e4faee9548a21f71a678f9e2730f6d5a307df.tar.gz
ingen-387e4faee9548a21f71a678f9e2730f6d5a307df.tar.bz2
ingen-387e4faee9548a21f71a678f9e2730f6d5a307df.zip
Use std::any_of()
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/GraphBox.cpp30
-rw-r--r--src/gui/NodeMenu.cpp15
2 files changed, 21 insertions, 24 deletions
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 <http://drobilla.net/>
+ Copyright 2007-2024 David Robillard <http://drobilla.net/>
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 <webkit/webkit.h>
#endif
+#include <algorithm>
#include <cassert>
#include <cstdint>
#include <cstdio>
@@ -100,7 +101,6 @@
#include <sstream>
#include <string>
#include <utility>
-#include <vector>
namespace ingen {
@@ -382,12 +382,12 @@ GraphBox::set_graph(const std::shared_ptr<const GraphModel>& 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<const PortModel>& 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 <http://drobilla.net/>
+ Copyright 2007-2024 David Robillard <http://drobilla.net/>
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 <sigc++/adaptors/bind.h>
#include <sigc++/functors/mem_fun.h>
+#include <algorithm>
#include <cstdint>
#include <map>
#include <memory>
@@ -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