summaryrefslogtreecommitdiffstats
path: root/src/gui/NodeMenu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/NodeMenu.cpp')
-rw-r--r--src/gui/NodeMenu.cpp52
1 files changed, 29 insertions, 23 deletions
diff --git a/src/gui/NodeMenu.cpp b/src/gui/NodeMenu.cpp
index 2ebc223d..2815194c 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
@@ -19,22 +19,22 @@
#include "App.hpp"
#include "ObjectMenu.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Properties.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/client/BlockModel.hpp"
-#include "ingen/client/ObjectModel.hpp"
-#include "ingen/client/PluginModel.hpp"
-#include "ingen/client/PortModel.hpp"
-#include "raul/Symbol.hpp"
+#include <ingen/Atom.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/client/BlockModel.hpp>
+#include <ingen/client/ObjectModel.hpp>
+#include <ingen/client/PluginModel.hpp>
+#include <ingen/client/PortModel.hpp>
+#include <raul/Symbol.hpp>
#include <glib.h>
#include <glibmm/convert.h>
#include <glibmm/miscutils.h>
#include <glibmm/refptr.h>
-#include <glibmm/signalproxy.h>
#include <glibmm/ustring.h>
#include <gtkmm/box.h>
#include <gtkmm/builder.h>
@@ -46,15 +46,17 @@
#include <gtkmm/filechooserdialog.h>
#include <gtkmm/image.h>
#include <gtkmm/label.h>
+#include <gtkmm/menu.h>
#include <gtkmm/menu_elems.h>
#include <gtkmm/menuitem.h>
-#include <gtkmm/menushell.h>
#include <gtkmm/object.h>
#include <gtkmm/separatormenuitem.h>
#include <gtkmm/stock.h>
+#include <gtkmm/stockid.h>
#include <sigc++/adaptors/bind.h>
#include <sigc++/functors/mem_fun.h>
+#include <algorithm>
#include <cstdint>
#include <map>
#include <memory>
@@ -160,6 +162,12 @@ NodeMenu::init(App& app, const std::shared_ptr<const client::BlockModel>& block)
_enable_signal = true;
}
+std::shared_ptr<const client::BlockModel>
+NodeMenu::block() const
+{
+ return std::dynamic_pointer_cast<const client::BlockModel>(_object);
+}
+
void
NodeMenu::add_preset(const URI& uri, const std::string& label)
{
@@ -183,7 +191,7 @@ NodeMenu::on_menu_enabled()
{
_app->set_property(_object->uri(),
_app->uris().ingen_enabled,
- _app->forge().make(bool(_enabled_menuitem->get_active())));
+ _app->forge().make(_enabled_menuitem->get_active()));
}
void
@@ -199,7 +207,7 @@ NodeMenu::on_menu_randomize()
bm->port_value_range(p, min, max, _app->sample_rate());
const auto r = static_cast<float>(g_random_double_range(0.0, 1.0));
- const float val = r * (max - min) + min;
+ const float val = (r * (max - min)) + min;
_app->set_property(p->uri(),
_app->uris().ingen_value,
_app->forge().make(val));
@@ -245,7 +253,7 @@ NodeMenu::on_save_preset_activated()
const std::string real_path = Glib::build_filename(dirname, bundle, file);
const std::string real_uri = Glib::filename_to_uri(real_path);
- Properties props{
+ const Properties props{
{ _app->uris().rdf_type,
_app->uris().pset_Preset },
{ _app->uris().rdfs_label,
@@ -267,13 +275,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