diff options
Diffstat (limited to 'src/gui')
62 files changed, 757 insertions, 808 deletions
diff --git a/src/gui/.clang-tidy b/src/gui/.clang-tidy index 7f216d2c..4dc4facc 100644 --- a/src/gui/.clang-tidy +++ b/src/gui/.clang-tidy @@ -1,74 +1,30 @@ Checks: > - *, - -*-avoid-c-arrays, - -*-else-after-return, - -*-magic-numbers, - -*-member-init, - -*-named-parameter, -*-narrowing-conversions, - -*-non-private-member-variables-in-classes, - -*-special-member-functions, - -*-uppercase-literal-suffix, - -abseil-string-find-str-contains, -android-cloexec-*, -bugprone-branch-clone, -bugprone-exception-escape, -bugprone-macro-parentheses, -bugprone-parent-virtual-call, -bugprone-reserved-identifier, - -bugprone-signed-char-misuse, -bugprone-suspicious-string-compare, -cert-dcl21-cpp, -cert-dcl37-c, - -cert-dcl50-cpp, -cert-dcl51-cpp, - -cert-err34-c, -cert-err58-cpp, -cert-str34-c, - -clang-analyzer-alpha.*, -clang-analyzer-core.CallAndMessage, - -clang-analyzer-optin.cplusplus.VirtualCall, - -clang-analyzer-valist.Uninitialized, - -cppcoreguidelines-avoid-non-const-global-variables, -cppcoreguidelines-macro-usage, - -cppcoreguidelines-no-malloc, - -cppcoreguidelines-owning-memory, - -cppcoreguidelines-pro-bounds-array-to-pointer-decay, -cppcoreguidelines-pro-bounds-constant-array-index, - -cppcoreguidelines-pro-bounds-pointer-arithmetic, - -cppcoreguidelines-pro-type-const-cast, -cppcoreguidelines-pro-type-cstyle-cast, - -cppcoreguidelines-pro-type-reinterpret-cast, -cppcoreguidelines-pro-type-static-cast-downcast, - -cppcoreguidelines-pro-type-union-access, -cppcoreguidelines-pro-type-vararg, -cppcoreguidelines-slicing, - -fuchsia-*, -google-default-arguments, - -google-explicit-constructor, -google-readability-todo, -google-runtime-int, -google-runtime-references, - -hicpp-explicit-conversions, -hicpp-multiway-paths-covered, - -hicpp-no-array-decay, - -hicpp-no-malloc, - -hicpp-signed-bitwise, -hicpp-vararg, -llvm-header-guard, - -llvmlibc-*, - -misc-no-recursion, - -misc-unused-parameters, - -modernize-use-trailing-return-type, -readability-convert-member-functions-to-static, - -readability-implicit-bool-conversion, - -readability-use-anyofallof, -CheckOptions: - - key: modernize-use-override.AllowOverrideAndFinal - value: 'true' -CheckOptions: - - key: cppcoreguidelines-explicit-virtual-functions.AllowOverrideAndFinal - value: 'true' -WarningsAsErrors: '*' -HeaderFilterRegex: 'include/ingen/.*|tests/.*|src/.*' -FormatStyle: file +InheritParentConfig: true diff --git a/src/gui/App.cpp b/src/gui/App.cpp index dc51df1d..5ae1c8d9 100644 --- a/src/gui/App.cpp +++ b/src/gui/App.cpp @@ -31,11 +31,11 @@ #include "ingen/ColorContext.hpp" #include "ingen/Configuration.hpp" #include "ingen/EngineBase.hpp" -#include "ingen/FilePath.hpp" #include "ingen/Forge.hpp" #include "ingen/Interface.hpp" #include "ingen/Log.hpp" #include "ingen/QueuedInterface.hpp" +#include "ingen/Status.hpp" #include "ingen/StreamWriter.hpp" #include "ingen/URIs.hpp" #include "ingen/World.hpp" @@ -45,9 +45,9 @@ #include "ingen/client/SigClientInterface.hpp" #include "ingen/runtime_paths.hpp" #include "lilv/lilv.h" +#include "lv2/urid/urid.h" #include "suil/suil.h" -#include <boost/variant/get.hpp> #include <glib.h> #include <glibmm/main.h> #include <glibmm/miscutils.h> @@ -67,15 +67,14 @@ #include <cassert> #include <cstdio> #include <exception> -#include <functional> #include <iostream> #include <map> #include <memory> #include <string> #include <utility> +#include <variant> -namespace ingen { -namespace gui { +namespace ingen::gui { Gtk::Main* App::_main = nullptr; @@ -83,15 +82,6 @@ App::App(ingen::World& world) : _style(new Style(*this)) , _window_factory(new WindowFactory(*this)) , _world(world) - , _sample_rate(48000) - , _block_length(1024) - , _n_threads(1) - , _mean_run_load(0.0f) - , _min_run_load(0.0f) - , _max_run_load(0.0f) - , _enable_signal(true) - , _requested_plugins(false) - , _is_plugin(false) { _world.conf().load_default("ingen", "gui.ttl"); @@ -108,11 +98,10 @@ App::App(ingen::World& world) client::PluginModel::set_rdf_world(*world.rdf_world()); client::PluginModel::set_lilv_world(world.lilv_world()); - world.log().set_sink(std::bind(&MessagesWindow::log, - _messages_window, - std::placeholders::_1, - std::placeholders::_2, - std::placeholders::_3)); + world.log().set_sink( + [this](const LV2_URID type, const char* fmt, va_list args) { + return _messages_window->log(type, fmt, args); + }); } App::~App() @@ -248,13 +237,13 @@ App::serialiser() void App::message(const Message& msg) { - if (const Response* const r = boost::get<Response>(&msg)) { + if (const Response* const r = std::get_if<Response>(&msg)) { response(r->id, r->status, r->subject); - } else if (const Error* const e = boost::get<Error>(&msg)) { + } else if (const Error* const e = std::get_if<Error>(&msg)) { error_message(e->message); - } else if (const Put* const p = boost::get<Put>(&msg)) { + } else if (const Put* const p = std::get_if<Put>(&msg)) { put(p->uri, p->properties, p->ctx); - } else if (const SetProperty* const s = boost::get<SetProperty>(&msg)) { + } else if (const SetProperty* const s = std::get_if<SetProperty>(&msg)) { property_change(s->subject, s->predicate, s->value, s->ctx); } } @@ -326,7 +315,9 @@ App::property_change(const URI& subject, { if (subject != URI("ingen:/engine")) { return; - } else if (key == uris().param_sampleRate && value.type() == forge().Int) { + } + + if (key == uris().param_sampleRate && value.type() == forge().Int) { _sample_rate = value.get<int32_t>(); } else if (key == uris().bufsz_maxBlockLength && value.type() == forge().Int) { _block_length = value.get<int32_t>(); @@ -376,7 +367,7 @@ App::status_text() const void App::port_activity(Port* port) { - std::pair<ActivityPorts::iterator, bool> inserted = _activity_ports.emplace(port, false); + const auto inserted = _activity_ports.emplace(port, false); if (inserted.second) { inserted.first->second = false; } @@ -509,5 +500,4 @@ App::sample_rate() const return _sample_rate; } -} // namespace gui -} // namespace ingen +} // namespace ingen::gui diff --git a/src/gui/App.hpp b/src/gui/App.hpp index c09d1cd5..d7776896 100644 --- a/src/gui/App.hpp +++ b/src/gui/App.hpp @@ -20,7 +20,6 @@ #include "ingen/Message.hpp" #include "ingen/Properties.hpp" #include "ingen/Resource.hpp" -#include "ingen/Status.hpp" #include "ingen/URI.hpp" #include "ingen/World.hpp" #include "ingen/ingen.h" @@ -42,6 +41,8 @@ class Window; namespace ingen { +enum class Status; + class Atom; class Forge; class Interface; @@ -97,7 +98,7 @@ public: bool signal() const { return _enable_signal; } void enable_signals(bool b) { _enable_signal = b; } bool disable_signals() { - bool old = _enable_signal; + const bool old = _enable_signal; _enable_signal = false; return old; } @@ -139,9 +140,9 @@ public: sigc::signal<void, const std::string&> signal_status_text_changed; - inline ingen::World& world() const { return _world; } - inline ingen::URIs& uris() const { return _world.uris(); } - inline ingen::Log& log() const { return _world.log(); } + ingen::World& world() const { return _world; } + ingen::URIs& uris() const { return _world.uris(); } + ingen::Log& log() const { return _world.log(); } protected: explicit App(ingen::World& world); @@ -177,20 +178,20 @@ protected: ingen::World& _world; - int32_t _sample_rate; - int32_t _block_length; - int32_t _n_threads; - float _mean_run_load; - float _min_run_load; - float _max_run_load; + int32_t _sample_rate{48000}; + int32_t _block_length{1024}; + int32_t _n_threads{1}; + float _mean_run_load{0.0f}; + float _min_run_load{0.0f}; + float _max_run_load{0.0f}; std::string _status_text; using ActivityPorts = std::unordered_map<Port*, bool>; ActivityPorts _activity_ports; - bool _enable_signal; - bool _requested_plugins; - bool _is_plugin; + bool _enable_signal{true}; + bool _requested_plugins{false}; + bool _is_plugin{false}; }; } // namespace gui diff --git a/src/gui/Arc.cpp b/src/gui/Arc.cpp index c9260d12..17cd57df 100644 --- a/src/gui/Arc.cpp +++ b/src/gui/Arc.cpp @@ -19,6 +19,7 @@ #include "ingen/URI.hpp" #include "ingen/client/ArcModel.hpp" #include "ingen/client/BlockModel.hpp" +#include "ingen/client/ObjectModel.hpp" #include "ingen/client/PortModel.hpp" #include <glib-object.h> @@ -27,13 +28,7 @@ #define NS_INTERNALS "http://drobilla.net/ns/ingen-internals#" -namespace ingen { - -namespace client { -class ObjectModel; -} // namespace client - -namespace gui { +namespace ingen::gui { Arc::Arc(Ganv::Canvas& canvas, const std::shared_ptr<const client::ArcModel>& model, @@ -41,8 +36,8 @@ Arc::Arc(Ganv::Canvas& canvas, Ganv::Node* dst) : Ganv::Edge(canvas, src, dst), _arc_model(model) { - std::shared_ptr<const client::ObjectModel> tparent = model->tail()->parent(); - std::shared_ptr<const client::BlockModel> tparent_block; + const std::shared_ptr<const client::ObjectModel> tparent = model->tail()->parent(); + std::shared_ptr<const client::BlockModel> tparent_block; if ((tparent_block = std::dynamic_pointer_cast<const client::BlockModel>(tparent))) { if (tparent_block->plugin_uri() == NS_INTERNALS "BlockDelay") { g_object_set(_gobj, "dash-length", 4.0, nullptr); @@ -51,5 +46,4 @@ Arc::Arc(Ganv::Canvas& canvas, } } -} // namespace gui -} // namespace ingen +} // namespace ingen::gui diff --git a/src/gui/Arc.hpp b/src/gui/Arc.hpp index 746f6d61..82467a5a 100644 --- a/src/gui/Arc.hpp +++ b/src/gui/Arc.hpp @@ -28,7 +28,9 @@ class Node; namespace ingen { -namespace client { class ArcModel; } +namespace client { +class ArcModel; +} // namespace client namespace gui { diff --git a/src/gui/BreadCrumbs.cpp b/src/gui/BreadCrumbs.cpp index 4e257d88..076a259f 100644 --- a/src/gui/BreadCrumbs.cpp +++ b/src/gui/BreadCrumbs.cpp @@ -20,24 +20,23 @@ #include "GraphView.hpp" #include "ingen/client/SigClientInterface.hpp" +#include "raul/Path.hpp" #include "raul/Symbol.hpp" -#include <boost/variant/get.hpp> #include <glibmm/signalproxy.h> #include <sigc++/adaptors/bind.h> #include <sigc++/functors/mem_fun.h> #include <string> +#include <variant> -namespace ingen { -namespace gui { +namespace ingen::gui { using std::string; BreadCrumbs::BreadCrumbs(App& app) : _active_path("/") , _full_path("/") - , _enable_signal(true) { app.sig_client()->signal_message().connect( sigc::mem_fun(this, &BreadCrumbs::message)); @@ -66,7 +65,7 @@ void BreadCrumbs::build(const raul::Path& path, const std::shared_ptr<GraphView>& view) { - bool old_enable_signal = _enable_signal; + const bool old_enable_signal = _enable_signal; _enable_signal = false; if (!_breadcrumbs.empty() && (path.is_parent_of(_full_path) || path == _full_path)) { @@ -78,7 +77,7 @@ BreadCrumbs::build(const raul::Path& path, b->set_view(view); } - // views are expensive, having two around for the same graph is a bug + // Views are expensive, having two around is a bug assert(b->view() == view); } else { @@ -90,7 +89,7 @@ BreadCrumbs::build(const raul::Path& path, _enable_signal = old_enable_signal; } else if (!_breadcrumbs.empty() && path.is_child_of(_full_path)) { - // Moving to a child of the full path, just append crumbs (preserve view cache) + // Moving to a child of the full path, append crumbs (preserve cache) string suffix = path.substr(_full_path.length()); while (suffix.length() > 0) { @@ -105,9 +104,9 @@ BreadCrumbs::build(const raul::Path& path, but->show(); if (suffix.find('/') == string::npos) { break; - } else { - suffix = suffix.substr(suffix.find('/') + 1); } + + suffix = suffix.substr(suffix.find('/') + 1); } for (const auto& b : _breadcrumbs) { @@ -116,8 +115,8 @@ BreadCrumbs::build(const raul::Path& path, _breadcrumbs.back()->set_active(true); } else { - // Rebuild from scratch - // Getting here is bad unless absolutely necessary, since the GraphView cache is lost + /* Rebuild from scratch. Getting here is bad unless absolutely + necessary, since the GraphView cache is lost. */ _full_path = path; _active_path = path; @@ -149,9 +148,9 @@ BreadCrumbs::build(const raul::Path& path, but->show(); if (suffix.find('/') == string::npos) { break; - } else { - suffix = suffix.substr(suffix.find('/')+1); } + + suffix = suffix.substr(suffix.find('/')+1); } } @@ -197,7 +196,7 @@ BreadCrumbs::breadcrumb_clicked(BreadCrumb* crumb) void BreadCrumbs::message(const Message& msg) { - if (const Del* const del = boost::get<Del>(&msg)) { + if (const Del* const del = std::get_if<Del>(&msg)) { object_destroyed(del->uri); } } @@ -228,5 +227,4 @@ BreadCrumbs::object_moved(const raul::Path& old_path, const raul::Path& new_path } } -} // namespace gui -} // namespace ingen +} // namespace ingen::gui diff --git a/src/gui/BreadCrumbs.hpp b/src/gui/BreadCrumbs.hpp index d877d0c5..e7fffc18 100644 --- a/src/gui/BreadCrumbs.hpp +++ b/src/gui/BreadCrumbs.hpp @@ -35,8 +35,7 @@ #include <memory> #include <string> -namespace ingen { -namespace gui { +namespace ingen::gui { class App; @@ -118,11 +117,10 @@ private: raul::Path _active_path; raul::Path _full_path; - bool _enable_signal; + bool _enable_signal{true}; std::list<BreadCrumb*> _breadcrumbs; }; -} // namespace gui -} // namespace ingen +} // namespace ingen::gui #endif // INGEN_GUI_BREADCRUMBS_HPP diff --git a/src/gui/ConnectWindow.cpp b/src/gui/ConnectWindow.cpp index ea1a6e27..f49b8788 100644 --- a/src/gui/ConnectWindow.cpp +++ b/src/gui/ConnectWindow.cpp @@ -27,6 +27,7 @@ #include "ingen/Interface.hpp" #include "ingen/Log.hpp" #include "ingen/QueuedInterface.hpp" +#include "ingen/Status.hpp" #include "ingen/URIs.hpp" #include "ingen/World.hpp" #include "ingen/client/ClientStore.hpp" @@ -37,13 +38,13 @@ #include "raul/Path.hpp" #include "raul/Process.hpp" -#include <boost/variant/get.hpp> #include <glib.h> #include <glibmm/main.h> #include <glibmm/signalproxy.h> #include <glibmm/ustring.h> #include <gtkmm/builder.h> #include <gtkmm/button.h> +#include <gtkmm/dialog.h> #include <gtkmm/entry.h> #include <gtkmm/enums.h> #include <gtkmm/image.h> @@ -62,44 +63,22 @@ #include <string> #include <sys/time.h> #include <utility> +#include <variant> -namespace ingen { -namespace gui { +namespace ingen::gui { ConnectWindow::ConnectWindow(BaseObjectType* cobject, Glib::RefPtr<Gtk::Builder> xml) : Dialog(cobject) , _xml(std::move(xml)) - , _icon(nullptr) - , _progress_bar(nullptr) - , _progress_label(nullptr) - , _url_entry(nullptr) - , _server_radio(nullptr) - , _port_spinbutton(nullptr) - , _launch_radio(nullptr) - , _internal_radio(nullptr) - , _activate_button(nullptr) - , _deactivate_button(nullptr) - , _disconnect_button(nullptr) - , _connect_button(nullptr) - , _quit_button(nullptr) - , _mode(Mode::CONNECT_REMOTE) - , _connect_uri("unix:///tmp/ingen.sock") - , _ping_id(-1) - , _attached(false) - , _finished_connecting(false) - , _widgets_loaded(false) - , _connect_stage(0) - , _quit_flag(false) -{ -} +{} void ConnectWindow::message(const Message& msg) { - if (const Response* const r = boost::get<Response>(&msg)) { + if (const Response* const r = std::get_if<Response>(&msg)) { ingen_response(r->id, r->status, r->subject); - } else if (const Error* const e = boost::get<Error>(&msg)) { + } else if (const Error* const e = std::get_if<Error>(&msg)) { error(e->message); } } @@ -218,7 +197,7 @@ ConnectWindow::connect_remote(const URI& uri) auto sci = std::make_shared<client::SigClientInterface>(); auto qi = std::make_shared<QueuedInterface>(sci); - std::shared_ptr<ingen::Interface> iface(world.new_interface(uri, qi)); + const std::shared_ptr<ingen::Interface> iface{world.new_interface(uri, qi)}; if (iface) { world.set_interface(iface); _app->attach(qi); @@ -236,10 +215,10 @@ ConnectWindow::connect(bool existing) if (_app->client()) { error("Already connected"); return; - } else if (_attached) { - _attached = false; } + _attached = false; + set_connecting_widget_states(); _connect_stage = 0; @@ -286,10 +265,14 @@ ConnectWindow::connect(bool existing) if (!world.load_module("server")) { error("Failed to load server module"); return; - } else if (!world.load_module("jack")) { + } + + if (!world.load_module("jack")) { error("Failed to load jack module"); return; - } else if (!world.engine()->activate()) { + } + + if (!world.engine()->activate()) { error("Failed to activate engine"); return; } @@ -577,9 +560,9 @@ ConnectWindow::gtk_callback() _progress_label->set_text(std::string("Disconnected")); } return false; - } else { - return true; } + + return true; } void @@ -589,5 +572,4 @@ ConnectWindow::quit() Gtk::Main::quit(); } -} // namespace gui -} // namespace ingen +} // namespace ingen::gui diff --git a/src/gui/ConnectWindow.hpp b/src/gui/ConnectWindow.hpp index 6fc4dbfb..269a4d76 100644 --- a/src/gui/ConnectWindow.hpp +++ b/src/gui/ConnectWindow.hpp @@ -20,12 +20,10 @@ #include "Window.hpp" #include "ingen/Message.hpp" -#include "ingen/Status.hpp" #include "ingen/URI.hpp" #include <glibmm/refptr.h> #include <gtkmm/builder.h> -#include <gtkmm/dialog.h> #include <cstdint> #include <memory> @@ -43,6 +41,8 @@ class SpinButton; namespace ingen { +enum class Status; + class Interface; class World; @@ -100,28 +100,28 @@ private: const Glib::RefPtr<Gtk::Builder> _xml; - Gtk::Image* _icon; - Gtk::ProgressBar* _progress_bar; - Gtk::Label* _progress_label; - Gtk::Entry* _url_entry; - Gtk::RadioButton* _server_radio; - Gtk::SpinButton* _port_spinbutton; - Gtk::RadioButton* _launch_radio; - Gtk::RadioButton* _internal_radio; - Gtk::Button* _activate_button; - Gtk::Button* _deactivate_button; - Gtk::Button* _disconnect_button; - Gtk::Button* _connect_button; - Gtk::Button* _quit_button; - - Mode _mode; - URI _connect_uri; - int32_t _ping_id; - bool _attached; - bool _finished_connecting; - bool _widgets_loaded; - int _connect_stage; - bool _quit_flag; + Gtk::Image* _icon{nullptr}; + Gtk::ProgressBar* _progress_bar{nullptr}; + Gtk::Label* _progress_label{nullptr}; + Gtk::Entry* _url_entry{nullptr}; + Gtk::RadioButton* _server_radio{nullptr}; + Gtk::SpinButton* _port_spinbutton{nullptr}; + Gtk::RadioButton* _launch_radio{nullptr}; + Gtk::RadioButton* _internal_radio{nullptr}; + Gtk::Button* _activate_button{nullptr}; + Gtk::Button* _deactivate_button{nullptr}; + Gtk::Button* _disconnect_button{nullptr}; + Gtk::Button* _connect_button{nullptr}; + Gtk::Button* _quit_button{nullptr}; + + Mode _mode{Mode::CONNECT_REMOTE}; + URI _connect_uri{"unix:///tmp/ingen.sock"}; + int32_t _ping_id{-1}; + bool _attached{false}; + bool _finished_connecting{false}; + bool _widgets_loaded{false}; + int _connect_stage{0}; + bool _quit_flag{false}; }; } // namespace gui diff --git a/src/gui/GraphBox.cpp b/src/gui/GraphBox.cpp index f994d47c..9efba2ee 100644 --- a/src/gui/GraphBox.cpp +++ b/src/gui/GraphBox.cpp @@ -27,6 +27,7 @@ #include "ThreadedLoader.hpp" #include "WidgetFactory.hpp" #include "WindowFactory.hpp" +#include "ingen_config.h" #include "ganv/canvas.h" #include "ingen/Atom.hpp" @@ -87,8 +88,8 @@ #include <sigc++/functors/mem_fun.h> #include <sigc++/signal.h> -#ifdef HAVE_WEBKIT -#include <webkit/webkit.h> +#if USE_WEBKIT +# include <webkit/webkit.h> #endif #include <cassert> @@ -227,7 +228,7 @@ GraphBox::GraphBox(BaseObjectType* cobject, _menu_view_graph_properties->signal_activate().connect( sigc::mem_fun(this, &GraphBox::event_show_properties)); - Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); + const Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); clipboard->signal_owner_change().connect( sigc::mem_fun(this, &GraphBox::event_clipboard_changed)); @@ -249,8 +250,12 @@ std::shared_ptr<GraphBox> GraphBox::create(App& app, const std::shared_ptr<const GraphModel>& graph) { GraphBox* result = nullptr; - Glib::RefPtr<Gtk::Builder> xml = WidgetFactory::create("graph_win"); + const Glib::RefPtr<Gtk::Builder> xml = WidgetFactory::create("graph_win"); xml->get_widget_derived("graph_win_vbox", result); + if (!result) { + return {}; + } + result->init_box(app); result->set_graph(graph, nullptr); @@ -449,7 +454,7 @@ GraphBox::set_documentation(const std::string& doc, bool html) _doc_scrolledwindow->hide(); return; } -#ifdef HAVE_WEBKIT +#if USE_WEBKIT WebKitWebView* view = WEBKIT_WEB_VIEW(webkit_web_view_new()); webkit_web_view_load_html_string(view, doc.c_str(), ""); Gtk::Widget* widget = Gtk::manage(Glib::wrap(GTK_WIDGET(view))); @@ -534,7 +539,7 @@ GraphBox::event_show_engine() void GraphBox::event_clipboard_changed(GdkEventOwnerChange* ev) { - Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); + const Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); _menu_paste->set_sensitive(clipboard->wait_is_text_available()); } @@ -716,18 +721,17 @@ GraphBox::event_export_image() dialog.set_transient_for(*_window); } - using Types = std::map<std::string, std::string>; - Types types; + std::map<std::string, std::string> types; types["*.dot"] = "Graphviz DOT"; types["*.pdf"] = "Portable Document Format"; types["*.ps"] = "PostScript"; types["*.svg"] = "Scalable Vector Graphics"; - for (Types::const_iterator t = types.begin(); t != types.end(); ++t) { + for (const auto& t : types) { Gtk::FileFilter filt; - filt.add_pattern(t->first); - filt.set_name(t->second); + filt.add_pattern(t.first); + filt.set_name(t.second); dialog.add_filter(filt); - if (t->first == "*.pdf") { + if (t.first == "*.pdf") { dialog.set_filter(filt); } } diff --git a/src/gui/GraphCanvas.cpp b/src/gui/GraphCanvas.cpp index 77c33052..896cbf1f 100644 --- a/src/gui/GraphCanvas.cpp +++ b/src/gui/GraphCanvas.cpp @@ -14,9 +14,10 @@ along with Ingen. If not, see <http://www.gnu.org/licenses/>. */ +#include "GraphCanvas.hpp" + #include "App.hpp" #include "Arc.hpp" -#include "GraphCanvas.hpp" #include "GraphPortModule.hpp" #include "GraphWindow.hpp" #include "NodeModule.hpp" @@ -57,10 +58,10 @@ #include "ingen/client/PluginModel.hpp" #include "ingen/client/PortModel.hpp" #include "ingen/paths.hpp" +#include "raul/Path.hpp" #include "raul/Symbol.hpp" #include "sord/sordmm.hpp" -#include <boost/optional/optional.hpp> #include <gdk/gdk.h> #include <gdk/gdkkeysyms-compat.h> #include <gdkmm/window.h> @@ -77,7 +78,6 @@ #include <gtkmm/menu.h> #include <gtkmm/menu_elems.h> #include <gtkmm/menuitem.h> -#include <gtkmm/menushell.h> #include <gtkmm/object.h> #include <gtkmm/stock.h> #include <sigc++/adaptors/bind.h> @@ -93,6 +93,7 @@ #include <map> #include <memory> #include <mutex> +#include <optional> #include <set> #include <sstream> #include <string> @@ -129,12 +130,8 @@ GraphCanvas::GraphCanvas(App& app, : Canvas(width, height) , _app(app) , _graph(std::move(graph)) - , _auto_position_count(0) - , _menu_x(0) - , _menu_y(0) - , _paste_count(0) { - Glib::RefPtr<Gtk::Builder> xml = WidgetFactory::create("canvas_menu"); + const Glib::RefPtr<Gtk::Builder> xml = WidgetFactory::create("canvas_menu"); xml->get_widget("canvas_menu", _menu); xml->get_widget("canvas_menu_add_audio_input", _menu_add_audio_input); @@ -284,7 +281,7 @@ GraphCanvas::build() const Store::const_range kids = _app.store()->children_range(_graph); // Create modules for blocks - for (Store::const_iterator i = kids.first; i != kids.second; ++i) { + for (auto i = kids.first; i != kids.second; ++i) { auto block = std::dynamic_pointer_cast<BlockModel>(i->second); if (block && block->parent() == _graph) { add_block(block); @@ -305,7 +302,7 @@ GraphCanvas::build() static void show_module_human_names(GanvNode* node, void* data) { - bool b = *static_cast<bool*>(data); + const bool b = *static_cast<bool*>(data); if (GANV_IS_MODULE(node)) { Ganv::Module* module = Glib::wrap(GANV_MODULE(node)); auto* nmod = dynamic_cast<NodeModule*>(module); @@ -440,14 +437,14 @@ GraphCanvas::get_port_view(const std::shared_ptr<PortModel>& port) return ppm ? *ppm->begin() : dynamic_cast<Ganv::Port*>(module); - } else { - module = dynamic_cast<NodeModule*>(_views[port->parent()]); - if (module) { - for (auto* p : *module) { - auto* pv = dynamic_cast<gui::Port*>(p); - if (pv && pv->model() == port) { - return pv; - } + } + + module = dynamic_cast<NodeModule*>(_views[port->parent()]); + if (module) { + for (auto* p : *module) { + auto* pv = dynamic_cast<gui::Port*>(p); + if (pv && pv->model() == port) { + return pv; } } } @@ -482,7 +479,7 @@ GraphCanvas::disconnection(const std::shared_ptr<const ArcModel>& arc) if (arc->head()->is_a(_app.uris().lv2_AudioPort)) { auto* const h = dynamic_cast<gui::Port*>(head); if (h) { - h->activity(_app.forge().make(0.0f)); // Reset peaks + h->activity(_app.forge().make(0.0f)); // Reset peaks } } } else { @@ -691,7 +688,7 @@ serialise_arc(GanvEdge* arc, void* data) void GraphCanvas::copy_selection() { - std::lock_guard<std::mutex> lock(_app.world().rdf_mutex()); + const std::lock_guard<std::mutex> lock{_app.world().rdf_mutex()}; Serialiser serialiser(_app.world()); serialiser.start_to_string(_graph->path(), _graph->base_uri()); @@ -699,7 +696,7 @@ GraphCanvas::copy_selection() for_each_selected_node(serialise_node, &serialiser); for_each_selected_edge(serialise_arc, &serialiser); - Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); + const Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); clipboard->set_text(serialiser.finish()); _paste_count = 0; } @@ -707,9 +704,7 @@ GraphCanvas::copy_selection() void GraphCanvas::paste() { - using PropIter = Properties::const_iterator; - - std::lock_guard<std::mutex> lock(_app.world().rdf_mutex()); + const std::lock_guard<std::mutex> lock{_app.world().rdf_mutex()}; const Glib::ustring str = Gtk::Clipboard::get()->wait_for_text(); auto parser = _app.loader()->parser(); @@ -732,7 +727,7 @@ GraphCanvas::paste() {{uris.rdf_type, Property(uris.ingen_Graph)}}); // Parse clipboard text into clipboard store - boost::optional<URI> base_uri = parser->parse_string( + std::optional<URI> base_uri = parser->parse_string( _app.world(), clipboard, str, main_uri()); // Figure out the copy graph base path @@ -807,8 +802,8 @@ GraphCanvas::paste() } // Set coordinates so paste origin is at the mouse pointer - PropIter xi = node->properties().find(uris.ingen_canvasX); - PropIter yi = node->properties().find(uris.ingen_canvasY); + const auto xi = node->properties().find(uris.ingen_canvasX); + const auto yi = node->properties().find(uris.ingen_canvasY); if (xi != node->properties().end()) { const float x = xi->second.get<float>() - min_x + paste_x; props.insert({xi->first, Property(_app.forge().make(x), @@ -893,8 +888,8 @@ GraphCanvas::load_plugin(const std::weak_ptr<PluginModel>& weak_plugin) return; } - raul::Symbol symbol = plugin->default_block_symbol(); - unsigned offset = _app.store()->child_name_offset(_graph->path(), symbol); + raul::Symbol symbol = plugin->default_block_symbol(); + const unsigned offset = _app.store()->child_name_offset(_graph->path(), symbol); if (offset != 0) { std::stringstream ss; ss << symbol << "_" << offset; diff --git a/src/gui/GraphCanvas.hpp b/src/gui/GraphCanvas.hpp index b1e60aa3..3ebd61df 100644 --- a/src/gui/GraphCanvas.hpp +++ b/src/gui/GraphCanvas.hpp @@ -141,12 +141,12 @@ private: using Views = std::map<std::shared_ptr<const client::ObjectModel>, Ganv::Module*>; Views _views; - int _auto_position_count; + int _auto_position_count{0}; std::pair<int, int> _auto_position_scroll_offsets; - int _menu_x; - int _menu_y; - int _paste_count; + int _menu_x{0}; + int _menu_y{0}; + int _paste_count{0}; // Track pasted objects so they can be selected when they arrive std::set<raul::Path> _pastees; diff --git a/src/gui/GraphPortModule.cpp b/src/gui/GraphPortModule.cpp index 3206f80b..ccbfbebf 100644 --- a/src/gui/GraphPortModule.cpp +++ b/src/gui/GraphPortModule.cpp @@ -14,9 +14,10 @@ along with Ingen. If not, see <http://www.gnu.org/licenses/>. */ +#include "GraphPortModule.hpp" + #include "App.hpp" #include "GraphCanvas.hpp" -#include "GraphPortModule.hpp" #include "Port.hpp" #include "ingen/Atom.hpp" @@ -41,16 +42,13 @@ #include <string> #include <utility> -namespace ingen { - -namespace gui { +namespace ingen::gui { GraphPortModule::GraphPortModule( GraphCanvas& canvas, const std::shared_ptr<const client::PortModel>& model) : Ganv::Module(canvas, "", 0, 0, false) // FIXME: coords? , _model(model) - , _port(nullptr) { assert(model); @@ -169,5 +167,4 @@ GraphPortModule::set_selected(gboolean b) } } -} // namespace gui -} // namespace ingen +} // namespace ingen::gui diff --git a/src/gui/GraphPortModule.hpp b/src/gui/GraphPortModule.hpp index 5ce7ea57..56b4521a 100644 --- a/src/gui/GraphPortModule.hpp +++ b/src/gui/GraphPortModule.hpp @@ -33,9 +33,7 @@ class Atom; namespace client { class PortModel; } // namespace client -} // namespace ingen -namespace ingen { namespace gui { class App; @@ -76,7 +74,7 @@ protected: void property_changed(const URI& key, const Atom& value); std::shared_ptr<const client::PortModel> _model; - Port* _port; + Port* _port{nullptr}; }; } // namespace gui diff --git a/src/gui/GraphTreeWindow.cpp b/src/gui/GraphTreeWindow.cpp index e1ef158f..b6c55b24 100644 --- a/src/gui/GraphTreeWindow.cpp +++ b/src/gui/GraphTreeWindow.cpp @@ -14,8 +14,9 @@ along with Ingen. If not, see <http://www.gnu.org/licenses/>. */ -#include "App.hpp" #include "GraphTreeWindow.hpp" + +#include "App.hpp" #include "Window.hpp" #include "WindowFactory.hpp" @@ -26,6 +27,7 @@ #include "ingen/URIs.hpp" #include "ingen/client/ClientStore.hpp" #include "ingen/client/GraphModel.hpp" +#include "ingen/client/ObjectModel.hpp" #include "raul/Path.hpp" #include "raul/Symbol.hpp" @@ -56,8 +58,6 @@ namespace gui { GraphTreeWindow::GraphTreeWindow(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& xml) : Window(cobject) - , _graphs_treeview(nullptr) - , _enable_signal(true) { xml->get_widget_derived("graphs_treeview", _graphs_treeview); @@ -108,8 +108,8 @@ void GraphTreeWindow::add_graph(const std::shared_ptr<GraphModel>& pm) { if (!pm->parent()) { - Gtk::TreeModel::iterator iter = _graph_treestore->append(); - Gtk::TreeModel::Row row = *iter; + const auto iter = _graph_treestore->append(); + auto row = *iter; if (pm->path().is_root()) { row[_graph_tree_columns.name_col] = _app->interface()->uri().string(); } else { @@ -119,12 +119,13 @@ GraphTreeWindow::add_graph(const std::shared_ptr<GraphModel>& pm) row[_graph_tree_columns.graph_model_col] = pm; _graphs_treeview->expand_row(_graph_treestore->get_path(iter), true); } else { - Gtk::TreeModel::Children children = _graph_treestore->children(); - Gtk::TreeModel::iterator c = find_graph(children, pm->parent()); + const auto& children = _graph_treestore->children(); + auto c = find_graph(children, pm->parent()); if (c != children.end()) { - Gtk::TreeModel::iterator iter = _graph_treestore->append(c->children()); - Gtk::TreeModel::Row row = *iter; + const auto iter = _graph_treestore->append(c->children()); + auto row = *iter; + row[_graph_tree_columns.name_col] = pm->symbol().c_str(); row[_graph_tree_columns.enabled_col] = pm->enabled(); row[_graph_tree_columns.graph_model_col] = pm; @@ -148,7 +149,7 @@ GraphTreeWindow::add_graph(const std::shared_ptr<GraphModel>& pm) void GraphTreeWindow::remove_graph(const std::shared_ptr<GraphModel>& pm) { - Gtk::TreeModel::iterator i = find_graph(_graph_treestore->children(), pm); + const auto i = find_graph(_graph_treestore->children(), pm); if (i != _graph_treestore->children().end()) { _graph_treestore->erase(i); } @@ -158,12 +159,14 @@ Gtk::TreeModel::iterator GraphTreeWindow::find_graph(Gtk::TreeModel::Children root, const std::shared_ptr<client::ObjectModel>& graph) { - for (Gtk::TreeModel::iterator c = root.begin(); c != root.end(); ++c) { - std::shared_ptr<GraphModel> pm = (*c)[_graph_tree_columns.graph_model_col]; + for (auto c = root.begin(); c != root.end(); ++c) { + const std::shared_ptr<GraphModel> pm = (*c)[_graph_tree_columns.graph_model_col]; if (graph == pm) { return c; - } else if (!(*c)->children().empty()) { - Gtk::TreeModel::iterator ret = find_graph(c->children(), graph); + } + + if (!(*c)->children().empty()) { + auto ret = find_graph(c->children(), graph); if (ret != c->children().end()) { return ret; } @@ -177,10 +180,12 @@ GraphTreeWindow::find_graph(Gtk::TreeModel::Children root, void GraphTreeWindow::show_graph_menu(GdkEventButton* ev) { - Gtk::TreeModel::iterator active = _graph_tree_selection->get_selected(); + const auto active = _graph_tree_selection->get_selected(); if (active) { - Gtk::TreeModel::Row row = *active; - std::shared_ptr<GraphModel> pm = row[_graph_tree_columns.graph_model_col]; + auto row = *active; + auto col = _graph_tree_columns.graph_model_col; + + const std::shared_ptr<GraphModel>& pm = row[col]; if (pm) { _app->log().warn("TODO: graph menu from tree window"); } @@ -191,9 +196,10 @@ void GraphTreeWindow::event_graph_activated(const Gtk::TreeModel::Path& path, Gtk::TreeView::Column* col) { - Gtk::TreeModel::iterator active = _graph_treestore->get_iter(path); - Gtk::TreeModel::Row row = *active; - std::shared_ptr<GraphModel> pm = row[_graph_tree_columns.graph_model_col]; + const auto active = _graph_treestore->get_iter(path); + auto row = *active; + + const std::shared_ptr<GraphModel> pm = row[_graph_tree_columns.graph_model_col]; _app->window_factory()->present_graph(pm); } @@ -201,11 +207,11 @@ GraphTreeWindow::event_graph_activated(const Gtk::TreeModel::Path& path, void GraphTreeWindow::event_graph_enabled_toggled(const Glib::ustring& path_str) { - Gtk::TreeModel::Path path(path_str); - Gtk::TreeModel::iterator active = _graph_treestore->get_iter(path); - Gtk::TreeModel::Row row = *active; + const Gtk::TreeModel::Path path{path_str}; + auto active = _graph_treestore->get_iter(path); + auto row = *active; - std::shared_ptr<GraphModel> pm = row[_graph_tree_columns.graph_model_col]; + const std::shared_ptr<GraphModel> pm = row[_graph_tree_columns.graph_model_col]; assert(pm); if (_enable_signal) { @@ -224,9 +230,9 @@ GraphTreeWindow::graph_property_changed( const URIs& uris = _app->uris(); _enable_signal = false; if (key == uris.ingen_enabled && value.type() == uris.forge.Bool) { - Gtk::TreeModel::iterator i = find_graph(_graph_treestore->children(), graph); + const auto i = find_graph(_graph_treestore->children(), graph); if (i != _graph_treestore->children().end()) { - Gtk::TreeModel::Row row = *i; + auto row = *i; row[_graph_tree_columns.enabled_col] = value.get<int32_t>(); } else { _app->log().error("Unable to find graph %1%\n", graph->path()); @@ -240,11 +246,9 @@ GraphTreeWindow::graph_moved(const std::shared_ptr<GraphModel>& graph) { _enable_signal = false; - Gtk::TreeModel::iterator i - = find_graph(_graph_treestore->children(), graph); - + auto i = find_graph(_graph_treestore->children(), graph); if (i != _graph_treestore->children().end()) { - Gtk::TreeModel::Row row = *i; + auto row = *i; row[_graph_tree_columns.name_col] = graph->symbol().c_str(); } else { _app->log().error("Unable to find graph %1%\n", graph->path()); diff --git a/src/gui/GraphTreeWindow.hpp b/src/gui/GraphTreeWindow.hpp index 1a719a81..16eb4647 100644 --- a/src/gui/GraphTreeWindow.hpp +++ b/src/gui/GraphTreeWindow.hpp @@ -29,7 +29,6 @@ #include <gtkmm/treeselection.h> #include <gtkmm/treestore.h> #include <gtkmm/treeview.h> -#include <gtkmm/window.h> #include <memory> @@ -87,10 +86,9 @@ protected: find_graph(Gtk::TreeModel::Children root, const std::shared_ptr<client::ObjectModel>& graph); - GraphTreeView* _graphs_treeview; + GraphTreeView* _graphs_treeview{nullptr}; - struct GraphTreeModelColumns : public Gtk::TreeModel::ColumnRecord - { + struct GraphTreeModelColumns : public Gtk::TreeModel::ColumnRecord { GraphTreeModelColumns() { add(name_col); add(enabled_col); @@ -105,7 +103,7 @@ protected: GraphTreeModelColumns _graph_tree_columns; Glib::RefPtr<Gtk::TreeStore> _graph_treestore; Glib::RefPtr<Gtk::TreeSelection> _graph_tree_selection; - bool _enable_signal; + bool _enable_signal{true}; }; /** Derived TreeView class to support context menus for graphs */ @@ -115,13 +113,12 @@ public: GraphTreeView(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& xml) : Gtk::TreeView(cobject) - , _window(nullptr) {} void set_window(GraphTreeWindow* win) { _window = win; } bool on_button_press_event(GdkEventButton* ev) override { - bool ret = Gtk::TreeView::on_button_press_event(ev); + const bool ret = Gtk::TreeView::on_button_press_event(ev); if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 3)) { _window->show_graph_menu(ev); @@ -131,7 +128,7 @@ public: } private: - GraphTreeWindow* _window; + GraphTreeWindow* _window{nullptr}; }; } // namespace gui diff --git a/src/gui/GraphView.cpp b/src/gui/GraphView.cpp index bd493499..969e0add 100644 --- a/src/gui/GraphView.cpp +++ b/src/gui/GraphView.cpp @@ -14,9 +14,10 @@ along with Ingen. If not, see <http://www.gnu.org/licenses/>. */ +#include "GraphView.hpp" + #include "App.hpp" #include "GraphCanvas.hpp" -#include "GraphView.hpp" #include "WidgetFactory.hpp" #include "ingen/Atom.hpp" @@ -119,8 +120,9 @@ GraphView::set_graph(const std::shared_ptr<const GraphModel>& graph) std::shared_ptr<GraphView> GraphView::create(App& app, const std::shared_ptr<const GraphModel>& graph) { - GraphView* result = nullptr; - Glib::RefPtr<Gtk::Builder> xml = WidgetFactory::create("warehouse_win"); + GraphView* result = nullptr; + const Glib::RefPtr<Gtk::Builder> xml = + WidgetFactory::create("warehouse_win"); xml->get_widget_derived("graph_view_box", result); if (!result) { diff --git a/src/gui/GraphWindow.cpp b/src/gui/GraphWindow.cpp index 38273a8e..a6978e46 100644 --- a/src/gui/GraphWindow.cpp +++ b/src/gui/GraphWindow.cpp @@ -25,17 +25,13 @@ #include <glibmm/refptr.h> #include <gtkmm/builder.h> #include <gtkmm/layout.h> +#include <gtkmm/window.h> -namespace ingen { -namespace gui { +namespace ingen::gui { GraphWindow::GraphWindow(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& xml) : Window(cobject) - , _box(nullptr) - , _position_stored(false) - , _x(0) - , _y(0) { property_visible() = false; @@ -84,5 +80,4 @@ GraphWindow::on_key_press_event(GdkEventKey* event) return Gtk::Window::on_key_press_event(event); } -} // namespace gui -} // namespace ingen +} // namespace ingen::gui diff --git a/src/gui/GraphWindow.hpp b/src/gui/GraphWindow.hpp index 290e0e00..05c555a5 100644 --- a/src/gui/GraphWindow.hpp +++ b/src/gui/GraphWindow.hpp @@ -21,7 +21,6 @@ #include "Window.hpp" #include <gdk/gdk.h> -#include <gtkmm/window.h> #include <memory> #include <string> @@ -85,10 +84,10 @@ protected: bool on_key_press_event(GdkEventKey* event) override; private: - GraphBox* _box; - bool _position_stored; - int _x; - int _y; + GraphBox* _box{nullptr}; + bool _position_stored{false}; + int _x{0}; + int _y{0}; }; } // namespace gui diff --git a/src/gui/LoadGraphWindow.cpp b/src/gui/LoadGraphWindow.cpp index 7a80a2bf..c9c18ae9 100644 --- a/src/gui/LoadGraphWindow.cpp +++ b/src/gui/LoadGraphWindow.cpp @@ -30,8 +30,8 @@ #include "ingen/client/GraphModel.hpp" #include "ingen/runtime_paths.hpp" #include "raul/Path.hpp" +#include "raul/Symbol.hpp" -#include <boost/optional/optional.hpp> #include <glibmm/fileutils.h> #include <glibmm/miscutils.h> #include <glibmm/propertyproxy.h> @@ -52,6 +52,7 @@ #include <list> #include <map> #include <memory> +#include <optional> #include <sstream> #include <string> #include <utility> @@ -187,8 +188,8 @@ LoadGraphWindow::ok_clicked() if (_import) { // If unset load_graph will load value - boost::optional<raul::Path> parent; - boost::optional<raul::Symbol> symbol; + std::optional<raul::Path> parent; + std::optional<raul::Symbol> symbol; if (!_graph->path().is_root()) { parent = _graph->path().parent(); symbol = _graph->symbol(); @@ -198,7 +199,7 @@ LoadGraphWindow::ok_clicked() true, FilePath(get_filename()), parent, symbol, _initial_data); } else { - std::list<Glib::ustring> uri_list = get_filenames(); + const std::list<Glib::ustring> uri_list = get_filenames(); for (const auto& u : uri_list) { // Cascade Atom& x = _initial_data.find(uris.ingen_canvasX)->second; @@ -244,16 +245,16 @@ LoadGraphWindow::symbol_from_filename(const Glib::ustring& filename) raul::Symbol LoadGraphWindow::avoid_symbol_clash(const raul::Symbol& symbol) { - unsigned offset = _app->store()->child_name_offset( + const unsigned offset = _app->store()->child_name_offset( _graph->path(), symbol); if (offset != 0) { std::stringstream ss; ss << symbol << "_" << offset; return raul::Symbol(ss.str()); - } else { - return symbol; } + + return symbol; } void diff --git a/src/gui/LoadGraphWindow.hpp b/src/gui/LoadGraphWindow.hpp index b2063d75..adb6bce1 100644 --- a/src/gui/LoadGraphWindow.hpp +++ b/src/gui/LoadGraphWindow.hpp @@ -40,7 +40,9 @@ class SpinButton; namespace ingen { -namespace client { class GraphModel; } +namespace client { +class GraphModel; +} // namespace client namespace gui { diff --git a/src/gui/LoadPluginWindow.cpp b/src/gui/LoadPluginWindow.cpp index 5a9536a2..6a4d998c 100644 --- a/src/gui/LoadPluginWindow.cpp +++ b/src/gui/LoadPluginWindow.cpp @@ -14,8 +14,9 @@ along with Ingen. If not, see <http://www.gnu.org/licenses/>. */ -#include "App.hpp" #include "LoadPluginWindow.hpp" + +#include "App.hpp" #include "Window.hpp" #include "ingen/Atom.hpp" @@ -44,6 +45,7 @@ #include <gtkmm/treeiter.h> #include <gtkmm/treeview.h> #include <gtkmm/treeviewcolumn.h> +#include <gtkmm/window.h> #include <sigc++/adaptors/bind.h> #include <sigc++/functors/mem_fun.h> #include <sigc++/signal.h> @@ -102,8 +104,9 @@ LoadPluginWindow::LoadPluginWindow(BaseObjectType* cobject, _criteria_liststore = Gtk::ListStore::create(_criteria_columns); _filter_combo->set_model(_criteria_liststore); - Gtk::TreeModel::iterator iter = _criteria_liststore->append(); - Gtk::TreeModel::Row row = *iter; + auto iter = _criteria_liststore->append(); + auto row = *iter; + row[_criteria_columns._col_label] = "Name contains"; row[_criteria_columns._col_criteria] = CriteriaColumns::Criteria::NAME; _filter_combo->set_active(iter); @@ -326,8 +329,8 @@ LoadPluginWindow::add_plugin(const std::shared_ptr<const PluginModel>& plugin) return; } - Gtk::TreeModel::iterator iter = _plugins_liststore->append(); - Gtk::TreeModel::Row row = *iter; + auto iter = _plugins_liststore->append(); + auto row = *iter; _rows.emplace(plugin->uri(), iter); set_row(row, plugin); @@ -349,19 +352,22 @@ LoadPluginWindow::plugin_activated(const Gtk::TreeModel::Path& path, void LoadPluginWindow::plugin_selection_changed() { - size_t n_selected = _selection->get_selected_rows().size(); + const size_t n_selected = _selection->get_selected_rows().size(); if (n_selected == 0) { _name_offset = 0; _name_entry->set_text(""); _name_entry->set_sensitive(false); } else if (n_selected == 1) { - Gtk::TreeModel::iterator iter = _plugins_liststore->get_iter( - *_selection->get_selected_rows().begin()); + auto iter = _plugins_liststore->get_iter( + *_selection->get_selected_rows().begin()); if (iter) { - Gtk::TreeModel::Row row = *iter; - auto p = row.get_value(_plugins_columns._col_plugin); - _name_offset = _app->store()->child_name_offset( - _graph->path(), p->default_block_symbol()); + auto row = *iter; + auto p = row.get_value(_plugins_columns._col_plugin); + + _name_offset = + _app->store()->child_name_offset(_graph->path(), + p->default_block_symbol()); + _name_entry->set_text(generate_module_name(p, _name_offset)); _name_entry->set_sensitive(true); } else { @@ -397,11 +403,11 @@ LoadPluginWindow::generate_module_name( void LoadPluginWindow::load_plugin(const Gtk::TreeModel::iterator& iter) { - const URIs& uris = _app->uris(); - Gtk::TreeModel::Row row = *iter; - auto plugin = row.get_value(_plugins_columns._col_plugin); - bool polyphonic = _polyphonic_checkbutton->get_active(); - string name = _name_entry->get_text(); + const URIs& uris = _app->uris(); + auto row = *iter; + auto plugin = row.get_value(_plugins_columns._col_plugin); + const bool polyphonic = _polyphonic_checkbutton->get_active(); + string name = _name_entry->get_text(); if (name.empty()) { name = generate_module_name(plugin, _name_offset); @@ -415,8 +421,8 @@ LoadPluginWindow::load_plugin(const Gtk::TreeModel::iterator& iter) dialog.run(); } else { - raul::Path path = _graph->path().child(raul::Symbol::symbolify(name)); - Properties props = _initial_data; + const raul::Path path = _graph->path().child(raul::Symbol::symbolify(name)); + Properties props = _initial_data; props.emplace(uris.rdf_type, Property(uris.ingen_Block)); props.emplace(uris.lv2_prototype, _app->forge().make_urid(plugin->uri())); props.emplace(uris.ingen_polyphonic, _app->forge().make(polyphonic)); @@ -451,8 +457,8 @@ LoadPluginWindow::filter_changed() transform(search.begin(), search.end(), search.begin(), ::toupper); // Get selected criteria - const Gtk::TreeModel::Row row = *(_filter_combo->get_active()); - CriteriaColumns::Criteria criteria = row[_criteria_columns._col_criteria]; + const auto row = *(_filter_combo->get_active()); + const CriteriaColumns::Criteria criteria = row[_criteria_columns._col_criteria]; string field; @@ -511,9 +517,9 @@ LoadPluginWindow::on_key_press_event(GdkEventKey* event) if (event->keyval == GDK_w && event->state & GDK_CONTROL_MASK) { hide(); return true; - } else { - return Gtk::Window::on_key_press_event(event); } + + return Gtk::Window::on_key_press_event(event); } void @@ -523,7 +529,7 @@ LoadPluginWindow::plugin_property_changed(const URI& plugin, { const URIs& uris = _app->uris(); if (predicate == uris.doap_name) { - Rows::const_iterator i = _rows.find(plugin); + const auto i = _rows.find(plugin); if (i != _rows.end() && value.type() == uris.forge.String) { (*i->second)[_plugins_columns._col_name] = value.ptr<char>(); } diff --git a/src/gui/LoadPluginWindow.hpp b/src/gui/LoadPluginWindow.hpp index 46c5e816..2f98b3ae 100644 --- a/src/gui/LoadPluginWindow.hpp +++ b/src/gui/LoadPluginWindow.hpp @@ -30,7 +30,6 @@ #include <gtkmm/treemodel.h> #include <gtkmm/treemodelcolumn.h> #include <gtkmm/treeselection.h> -#include <gtkmm/window.h> #include <map> #include <memory> @@ -88,7 +87,8 @@ protected: private: /** Columns for the plugin list */ - class ModelColumns : public Gtk::TreeModel::ColumnRecord { + class ModelColumns : public Gtk::TreeModel::ColumnRecord + { public: ModelColumns() { add(_col_name); @@ -110,7 +110,8 @@ private: }; /** Column for the filter criteria combo box. */ - class CriteriaColumns : public Gtk::TreeModel::ColumnRecord { + class CriteriaColumns : public Gtk::TreeModel::ColumnRecord + { public: enum class Criteria { NAME, TYPE, PROJECT, AUTHOR, URI, }; diff --git a/src/gui/MessagesWindow.cpp b/src/gui/MessagesWindow.cpp index 2e0fdb61..db32af91 100644 --- a/src/gui/MessagesWindow.cpp +++ b/src/gui/MessagesWindow.cpp @@ -18,6 +18,7 @@ #include "App.hpp" #include "Window.hpp" +#include "ingen_config.h" #include "ingen/URIs.hpp" #include "lv2/urid/urid.h" @@ -38,8 +39,8 @@ #include <string> #include <utility> -namespace ingen { -namespace gui { +namespace ingen::gui { + using std::string; MessagesWindow::MessagesWindow(BaseObjectType* cobject, @@ -83,7 +84,7 @@ MessagesWindow::init_window(App& app) void MessagesWindow::post_error(const string& msg) { - Glib::RefPtr<Gtk::TextBuffer> text_buf = _textview->get_buffer(); + const Glib::RefPtr<Gtk::TextBuffer> text_buf = _textview->get_buffer(); text_buf->insert_with_tag(text_buf->end(), msg, _error_tag); text_buf->insert(text_buf->end(), "\n"); @@ -100,9 +101,9 @@ MessagesWindow::post_error(const string& msg) int MessagesWindow::log(LV2_URID type, const char* fmt, va_list args) { - std::lock_guard<std::mutex> lock(_mutex); + const std::lock_guard<std::mutex> lock{_mutex}; -#ifdef HAVE_VASPRINTF +#if USE_VASPRINTF char* buf = nullptr; const int len = vasprintf(&buf, fmt, args); #else @@ -124,7 +125,7 @@ MessagesWindow::flush() std::string line; { - std::lock_guard<std::mutex> lock(_mutex); + const std::lock_guard<std::mutex> lock{_mutex}; if (!_stream.rdbuf()->in_avail()) { return; } @@ -132,7 +133,7 @@ MessagesWindow::flush() std::getline(_stream, line, '\0'); } - Glib::RefPtr<Gtk::TextBuffer> text_buf = _textview->get_buffer(); + const Glib::RefPtr<Gtk::TextBuffer> text_buf = _textview->get_buffer(); auto t = _tags.find(type); if (t != _tags.end()) { @@ -150,10 +151,9 @@ MessagesWindow::flush() void MessagesWindow::clear_clicked() { - Glib::RefPtr<Gtk::TextBuffer> text_buf = _textview->get_buffer(); + const Glib::RefPtr<Gtk::TextBuffer> text_buf = _textview->get_buffer(); text_buf->erase(text_buf->begin(), text_buf->end()); _clear_button->set_sensitive(false); } -} // namespace gui -} // namespace ingen +} // namespace ingen::gui diff --git a/src/gui/MessagesWindow.hpp b/src/gui/MessagesWindow.hpp index ab82193d..27b6a417 100644 --- a/src/gui/MessagesWindow.hpp +++ b/src/gui/MessagesWindow.hpp @@ -23,7 +23,6 @@ #include <glibmm/refptr.h> #include <gtkmm/texttag.h> -#include <gtkmm/window.h> #include <cstdarg> #include <map> @@ -37,8 +36,7 @@ class Button; class TextView; } // namespace Gtk -namespace ingen { -namespace gui { +namespace ingen::gui { class App; @@ -67,15 +65,14 @@ private: std::mutex _mutex; std::stringstream _stream; - Gtk::TextView* _textview; - Gtk::Button* _clear_button; - Gtk::Button* _close_button; + Gtk::TextView* _textview{nullptr}; + Gtk::Button* _clear_button{nullptr}; + Gtk::Button* _close_button{nullptr}; Glib::RefPtr<Gtk::TextTag> _error_tag; std::map< LV2_URID, Glib::RefPtr<Gtk::TextTag> > _tags; }; -} // namespace gui -} // namespace ingen +} // namespace ingen::gui #endif // INGEN_GUI_MESSAGESWINDOW_HPP diff --git a/src/gui/NewSubgraphWindow.cpp b/src/gui/NewSubgraphWindow.cpp index 9b6c4a1a..f10f8049 100644 --- a/src/gui/NewSubgraphWindow.cpp +++ b/src/gui/NewSubgraphWindow.cpp @@ -40,6 +40,7 @@ #include <gtkmm/entry.h> #include <gtkmm/label.h> #include <gtkmm/spinbutton.h> +#include <gtkmm/window.h> #include <sigc++/functors/mem_fun.h> #include <cstdint> @@ -47,8 +48,7 @@ #include <string> #include <utility> -namespace ingen { -namespace gui { +namespace ingen::gui { NewSubgraphWindow::NewSubgraphWindow(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& xml) @@ -94,7 +94,7 @@ NewSubgraphWindow::set_graph(std::shared_ptr<const client::GraphModel> graph) void NewSubgraphWindow::name_changed() { - std::string name = _name_entry->get_text(); + const std::string name = _name_entry->get_text(); if (!raul::Symbol::is_valid(name)) { _message_label->set_text("Name contains invalid characters."); _ok_button->property_sensitive() = false; @@ -138,5 +138,4 @@ NewSubgraphWindow::cancel_clicked() hide(); } -} // namespace gui -} // namespace ingen +} // namespace ingen::gui diff --git a/src/gui/NewSubgraphWindow.hpp b/src/gui/NewSubgraphWindow.hpp index 9897e6c2..acb6c977 100644 --- a/src/gui/NewSubgraphWindow.hpp +++ b/src/gui/NewSubgraphWindow.hpp @@ -21,8 +21,6 @@ #include "ingen/Properties.hpp" -#include <gtkmm/window.h> - #include <memory> namespace Glib { @@ -39,7 +37,9 @@ class SpinButton; namespace ingen { -namespace client { class GraphModel; } +namespace client { +class GraphModel; +} // namespace client namespace gui { @@ -68,11 +68,11 @@ private: Properties _initial_data; std::shared_ptr<const client::GraphModel> _graph; - Gtk::Entry* _name_entry; - Gtk::Label* _message_label; - Gtk::SpinButton* _poly_spinbutton; - Gtk::Button* _ok_button; - Gtk::Button* _cancel_button; + Gtk::Entry* _name_entry{nullptr}; + Gtk::Label* _message_label{nullptr}; + Gtk::SpinButton* _poly_spinbutton{nullptr}; + Gtk::Button* _ok_button{nullptr}; + Gtk::Button* _cancel_button{nullptr}; }; } // namespace gui diff --git a/src/gui/NodeMenu.cpp b/src/gui/NodeMenu.cpp index 517d0018..0b511fc1 100644 --- a/src/gui/NodeMenu.cpp +++ b/src/gui/NodeMenu.cpp @@ -46,9 +46,9 @@ #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> @@ -62,13 +62,11 @@ #include <utility> #include <vector> -namespace ingen { -namespace gui { +namespace ingen::gui { NodeMenu::NodeMenu(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& xml) : ObjectMenu(cobject, xml) - , _presets_menu(nullptr) { xml->get_widget("node_popup_gui_menuitem", _popup_gui_menuitem); xml->get_widget("node_embed_gui_menuitem", _embed_gui_menuitem); @@ -162,6 +160,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) { @@ -247,7 +251,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, @@ -278,5 +282,4 @@ NodeMenu::has_control_inputs() return false; } -} // namespace gui -} // namespace ingen +} // namespace ingen::gui diff --git a/src/gui/NodeMenu.hpp b/src/gui/NodeMenu.hpp index 8a1e5f06..7168bc7a 100644 --- a/src/gui/NodeMenu.hpp +++ b/src/gui/NodeMenu.hpp @@ -21,7 +21,6 @@ #include "ingen/URI.hpp" -#include <gtkmm/menu.h> #include <sigc++/connection.h> #include <sigc++/signal.h> @@ -35,6 +34,7 @@ template <class T> class RefPtr; namespace Gtk { class Builder; class CheckMenuItem; +class Menu; class MenuItem; } // namespace Gtk @@ -66,9 +66,7 @@ public: sigc::signal<void, bool> signal_embed_gui; protected: - std::shared_ptr<const client::BlockModel> block() const { - return std::dynamic_pointer_cast<const client::BlockModel>(_object); - } + std::shared_ptr<const client::BlockModel> block() const; void add_preset(const URI& uri, const std::string& label); @@ -79,11 +77,11 @@ protected: void on_save_preset_activated(); void on_preset_activated(const std::string& uri); - Gtk::MenuItem* _popup_gui_menuitem; - Gtk::CheckMenuItem* _embed_gui_menuitem; - Gtk::CheckMenuItem* _enabled_menuitem; - Gtk::MenuItem* _randomize_menuitem; - Gtk::Menu* _presets_menu; + Gtk::MenuItem* _popup_gui_menuitem{nullptr}; + Gtk::CheckMenuItem* _embed_gui_menuitem{nullptr}; + Gtk::CheckMenuItem* _enabled_menuitem{nullptr}; + Gtk::MenuItem* _randomize_menuitem{nullptr}; + Gtk::Menu* _presets_menu{nullptr}; sigc::connection _preset_connection; }; diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp index fe111572..223c0832 100644 --- a/src/gui/NodeModule.cpp +++ b/src/gui/NodeModule.cpp @@ -25,6 +25,7 @@ #include "SubgraphModule.hpp" #include "WidgetFactory.hpp" #include "WindowFactory.hpp" +#include "ingen_config.h" #include "ganv/Port.hpp" #include "ingen/Atom.hpp" @@ -77,9 +78,6 @@ NodeModule::NodeModule(GraphCanvas& canvas, const std::shared_ptr<const BlockModel>& block) : Ganv::Module(canvas, block->path().symbol(), 0, 0, true) , _block(block) - , _gui_widget(nullptr) - , _gui_window(nullptr) - , _initialised(false) { block->signal_new_port().connect( sigc::mem_fun(this, &NodeModule::new_port_view)); @@ -129,7 +127,7 @@ bool NodeModule::idle_init() { if (_block->ports().empty()) { - return true; // Need to embed GUI, but ports haven't shown up yet + return true; // Need to embed GUI, but ports haven't shown up yet } // Ports have arrived, embed GUI and deregister this callback @@ -209,7 +207,7 @@ NodeModule::show_human_names(bool b) if (name_property.type() == uris.forge.String) { label = name_property.ptr<char>(); } else { - Glib::ustring hn = block()->plugin_model()->port_human_name( + const Glib::ustring hn = block()->plugin_model()->port_human_name( port->model()->index()); if (!hn.empty()) { label = hn; @@ -410,9 +408,9 @@ NodeModule::popup_gui() _gui_window->present(); return true; - } else { - app().log().warn("No LV2 GUI for %1%\n", _block->path()); } + + app().log().warn("No LV2 GUI for %1%\n", _block->path()); } return false; @@ -451,9 +449,13 @@ NodeModule::on_event(GdkEvent* ev) { if (ev->type == GDK_BUTTON_PRESS && ev->button.button == 3) { return show_menu(&ev->button); - } else if (ev->type == GDK_2BUTTON_PRESS) { + } + + if (ev->type == GDK_2BUTTON_PRESS) { return on_double_click(&ev->button); - } else if (ev->type == GDK_ENTER_NOTIFY) { + } + + if (ev->type == GDK_ENTER_NOTIFY) { GraphBox* const box = app().window_factory()->graph_box( std::dynamic_pointer_cast<const GraphModel>(_block->parent())); if (box) { @@ -530,9 +532,10 @@ NodeModule::on_selected(gboolean selected) if (selected && win->documentation_is_visible()) { std::string doc; - bool html = false; -#ifdef HAVE_WEBKIT - html = true; +#if USE_WEBKIT + const bool html = true; +#else + const bool html = false; #endif if (block()->plugin_model()) { doc = block()->plugin_model()->documentation(html); diff --git a/src/gui/NodeModule.hpp b/src/gui/NodeModule.hpp index 1ca7955c..226dccd1 100644 --- a/src/gui/NodeModule.hpp +++ b/src/gui/NodeModule.hpp @@ -42,8 +42,7 @@ class PortModel; } // namespace client } // namespace ingen -namespace ingen { -namespace gui { +namespace ingen::gui { class App; class GraphCanvas; @@ -106,14 +105,13 @@ protected: bool show_menu(GdkEventButton* ev); std::shared_ptr<const client::BlockModel> _block; - NodeMenu* _menu; + NodeMenu* _menu{nullptr}; std::shared_ptr<client::PluginUI> _plugin_ui; - Gtk::Widget* _gui_widget; - Gtk::Window* _gui_window; ///< iff popped up - bool _initialised; + Gtk::Widget* _gui_widget{nullptr}; + Gtk::Window* _gui_window{nullptr}; ///< iff popped up + bool _initialised{false}; }; -} // namespace gui -} // namespace ingen +} // namespace ingen::gui #endif // INGEN_GUI_NODEMODULE_HPP diff --git a/src/gui/ObjectMenu.cpp b/src/gui/ObjectMenu.cpp index 5f78144f..56055d1c 100644 --- a/src/gui/ObjectMenu.cpp +++ b/src/gui/ObjectMenu.cpp @@ -39,19 +39,11 @@ #include <cstdint> #include <memory> -namespace ingen { -namespace gui { +namespace ingen::gui { ObjectMenu::ObjectMenu(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& xml) : Gtk::Menu(cobject) - , _app(nullptr) - , _polyphonic_menuitem(nullptr) - , _disconnect_menuitem(nullptr) - , _rename_menuitem(nullptr) - , _destroy_menuitem(nullptr) - , _properties_menuitem(nullptr) - , _enable_signal(false) { xml->get_widget("object_learn_menuitem", _learn_menuitem); xml->get_widget("object_unlearn_menuitem", _unlearn_menuitem); @@ -153,5 +145,4 @@ ObjectMenu::on_menu_properties() _app->window_factory()->present_properties(_object); } -} // namespace gui -} // namespace ingen +} // namespace ingen::gui diff --git a/src/gui/ObjectMenu.hpp b/src/gui/ObjectMenu.hpp index 214c8307..de105364 100644 --- a/src/gui/ObjectMenu.hpp +++ b/src/gui/ObjectMenu.hpp @@ -76,18 +76,18 @@ protected: void property_changed(const URI& predicate, const Atom& value); - App* _app; + App* _app{nullptr}; std::shared_ptr<const client::ObjectModel> _object; - Gtk::MenuItem* _learn_menuitem; - Gtk::MenuItem* _unlearn_menuitem; - Gtk::CheckMenuItem* _polyphonic_menuitem; - Gtk::MenuItem* _disconnect_menuitem; - Gtk::MenuItem* _rename_menuitem; - Gtk::MenuItem* _destroy_menuitem; - Gtk::MenuItem* _properties_menuitem; - Gtk::SeparatorMenuItem* _separator_menuitem; - - bool _enable_signal; + Gtk::MenuItem* _learn_menuitem{nullptr}; + Gtk::MenuItem* _unlearn_menuitem{nullptr}; + Gtk::CheckMenuItem* _polyphonic_menuitem{nullptr}; + Gtk::MenuItem* _disconnect_menuitem{nullptr}; + Gtk::MenuItem* _rename_menuitem{nullptr}; + Gtk::MenuItem* _destroy_menuitem{nullptr}; + Gtk::MenuItem* _properties_menuitem{nullptr}; + Gtk::SeparatorMenuItem* _separator_menuitem{nullptr}; + + bool _enable_signal{false}; }; } // namespace gui diff --git a/src/gui/PluginMenu.cpp b/src/gui/PluginMenu.cpp index 7ddfd075..53917b1e 100644 --- a/src/gui/PluginMenu.cpp +++ b/src/gui/PluginMenu.cpp @@ -20,11 +20,11 @@ #include "ingen/URIs.hpp" #include "ingen/World.hpp" #include "ingen/client/PluginModel.hpp" +#include "lilv/lilv.h" #include <glibmm/ustring.h> #include <gtkmm/menu_elems.h> #include <gtkmm/menuitem.h> -#include <gtkmm/menushell.h> #include <gtkmm/object.h> #include <sigc++/adaptors/bind.h> #include <sigc++/functors/mem_fun.h> @@ -32,8 +32,7 @@ #include <memory> #include <utility> -namespace ingen { -namespace gui { +namespace ingen::gui { PluginMenu::PluginMenu(ingen::World& world) : _world(world) @@ -56,7 +55,7 @@ PluginMenu::clear() // Build skeleton LV2Children children; - LILV_FOREACH(plugin_classes, i, classes) { + LILV_FOREACH (plugin_classes, i, classes) { const LilvPluginClass* c = lilv_plugin_classes_get(classes, i); const LilvNode* p = lilv_plugin_class_get_parent_uri(c); if (!p) { @@ -78,8 +77,6 @@ PluginMenu::clear() void PluginMenu::add_plugin(const std::shared_ptr<client::PluginModel>& p) { - using iterator = ClassMenus::iterator; - if (!p->lilv_plugin() || lilv_plugin_is_replaced(p->lilv_plugin())) { return; } @@ -88,7 +85,7 @@ PluginMenu::add_plugin(const std::shared_ptr<client::PluginModel>& p) const LilvNode* class_uri = lilv_plugin_class_get_uri(pc); const char* class_uri_str = lilv_node_as_string(class_uri); - std::pair<iterator, iterator> range = _class_menus.equal_range(class_uri_str); + const auto range = _class_menus.equal_range(class_uri_str); if (range.first == _class_menus.end() || range.first == range.second || range.first->second.menu == this) { // Add to uncategorized plugin menu @@ -112,16 +109,14 @@ PluginMenu::build_plugin_class_menu(Gtk::Menu* menu, const LilvNode* class_uri = lilv_plugin_class_get_uri(plugin_class); const char* class_uri_str = lilv_node_as_string(class_uri); - const std::pair<LV2Children::const_iterator, LV2Children::const_iterator> kids - = children.equal_range(class_uri_str); - + const auto kids = children.equal_range(class_uri_str); if (kids.first == children.end()) { return 0; } // Add submenus ancestors.insert(class_uri_str); - for (LV2Children::const_iterator i = kids.first; i != kids.second; ++i) { + for (auto i = kids.first; i != kids.second; ++i) { const LilvPluginClass* c = i->second; const char* sub_label_str = lilv_node_as_string(lilv_plugin_class_get_label(c)); const char* sub_uri_str = lilv_node_as_string(lilv_plugin_class_get_uri(c)); @@ -131,7 +126,7 @@ PluginMenu::build_plugin_class_menu(Gtk::Menu* menu, return 0; } - Gtk::Menu_Helpers::MenuElem menu_elem = Gtk::Menu_Helpers::MenuElem( + const Gtk::Menu_Helpers::MenuElem menu_elem = Gtk::Menu_Helpers::MenuElem( std::string("_") + sub_label_str); menu->items().push_back(menu_elem); Gtk::MenuItem* menu_item = &(menu->items().back()); @@ -139,7 +134,7 @@ PluginMenu::build_plugin_class_menu(Gtk::Menu* menu, Gtk::Menu* submenu = Gtk::manage(new Gtk::Menu()); menu_item->set_submenu(*submenu); - size_t num_child_items = build_plugin_class_menu( + const size_t num_child_items = build_plugin_class_menu( submenu, c, classes, children, ancestors); _class_menus.emplace(sub_uri_str, MenuRecord(menu_item, submenu)); @@ -163,10 +158,10 @@ PluginMenu::add_plugin_to_menu(MenuRecord& menu, LilvNode* ingen_Graph = lilv_new_uri(lworld, uris.ingen_Graph.c_str()); LilvNode* rdf_type = lilv_new_uri(lworld, uris.rdf_type.c_str()); - bool is_graph = lilv_world_ask(lworld, - lilv_plugin_get_uri(p->lilv_plugin()), - rdf_type, - ingen_Graph); + const bool is_graph = lilv_world_ask(lworld, + lilv_plugin_get_uri(p->lilv_plugin()), + rdf_type, + ingen_Graph); menu.menu->items().push_back( Gtk::Menu_Helpers::MenuElem( @@ -187,5 +182,4 @@ PluginMenu::load_plugin(const std::weak_ptr<client::PluginModel>& weak_plugin) signal_load_plugin.emit(weak_plugin); } -} // namespace gui -} // namespace ingen +} // namespace ingen::gui diff --git a/src/gui/PluginMenu.hpp b/src/gui/PluginMenu.hpp index 2cf130bb..b2c75ffe 100644 --- a/src/gui/PluginMenu.hpp +++ b/src/gui/PluginMenu.hpp @@ -36,7 +36,9 @@ namespace ingen { class World; -namespace client { class PluginModel; } +namespace client { +class PluginModel; +} // namespace client namespace gui { @@ -57,7 +59,9 @@ public: private: struct MenuRecord { - MenuRecord(Gtk::MenuItem* i, Gtk::Menu* m) : item(i), menu(m) {} + MenuRecord(Gtk::MenuItem* i, Gtk::Menu* m) noexcept : item(i), menu(m) + {} + Gtk::MenuItem* item; Gtk::Menu* menu; }; diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp index 65b415e3..7b5988b7 100644 --- a/src/gui/Port.cpp +++ b/src/gui/Port.cpp @@ -24,6 +24,7 @@ #include "Style.hpp" #include "WidgetFactory.hpp" #include "WindowFactory.hpp" +#include "ingen_config.h" #include "rgba.hpp" #include "ingen/Atom.hpp" @@ -49,7 +50,6 @@ #include <gtkmm/menu.h> #include <gtkmm/menu_elems.h> #include <gtkmm/menuitem.h> -#include <gtkmm/menushell.h> #include <gtkmm/object.h> #include <sigc++/adaptors/bind.h> #include <sigc++/functors/mem_fun.h> @@ -222,11 +222,11 @@ Port::on_value_changed(double value) const URIs& uris = _app.uris(); const Atom& current_value = model()->value(); if (current_value.type() != uris.forge.Float) { - return; // Non-float, unsupported + return; // Non-float, unsupported } if (current_value.get<float>() == static_cast<float>(value)) { - return; // No change + return; // No change } const Atom atom = _app.forge().make(float(value)); @@ -264,7 +264,7 @@ Port::build_enum_menu() auto block = std::dynamic_pointer_cast<BlockModel>(model()->parent()); Gtk::Menu* menu = Gtk::manage(new Gtk::Menu()); - PluginModel::ScalePoints points = block->plugin_model()->port_scale_points( + const PluginModel::ScalePoints points = block->plugin_model()->port_scale_points( model()->index()); for (const auto& p : points) { menu->items().push_back(Gtk::Menu_Helpers::MenuElem(p.second)); @@ -309,13 +309,13 @@ Port::build_uri_menu() rdfs::URISet ranges; LilvNodes* range = lilv_world_find_nodes( world.lilv_world(), designation, rdfs_range, nullptr); - LILV_FOREACH(nodes, r, range) { + LILV_FOREACH (nodes, r, range) { ranges.insert(URI(lilv_node_as_string(lilv_nodes_get(range, r)))); } rdfs::classes(world, ranges, false); // Get all objects in range - rdfs::Objects values = rdfs::instances(world, ranges); + const rdfs::Objects values = rdfs::instances(world, ranges); // Add a menu item for each such class for (const auto& v : values) { @@ -356,7 +356,9 @@ Port::on_event(GdkEvent* ev) Gtk::Menu* menu = build_enum_menu(); menu->popup(ev->button.button, ev->button.time); return true; - } else if (model()->is_uri()) { + } + + if (model()->is_uri()) { Gtk::Menu* menu = build_uri_menu(); if (menu) { menu->popup(ev->button.button, ev->button.time); @@ -374,7 +376,7 @@ Port::on_event(GdkEvent* ev) return false; } -inline static uint32_t +static inline uint32_t peak_color(float peak) { static const uint32_t min = 0x4A8A0EC0; @@ -384,9 +386,9 @@ peak_color(float peak) if (peak < 1.0f) { return rgba_interpolate(min, max, peak); - } else { - return rgba_interpolate(peak_min, peak_max, fminf(peak, 2.0f) - 1.0f); } + + return rgba_interpolate(peak_min, peak_max, fminf(peak, 2.0f) - 1.0f); } void @@ -550,9 +552,10 @@ Port::on_selected(gboolean b) GraphWindow* win = _app.window_factory()->parent_graph_window(block); if (win && win->documentation_is_visible() && block->plugin_model()) { - bool html = false; -#ifdef HAVE_WEBKIT - html = true; +#if USE_WEBKIT + const bool html = true; +#else + const bool html = false; #endif const std::string& doc = block->plugin_model()->port_documentation( pm->index(), html); diff --git a/src/gui/Port.hpp b/src/gui/Port.hpp index 534734ad..8e8077bc 100644 --- a/src/gui/Port.hpp +++ b/src/gui/Port.hpp @@ -38,7 +38,9 @@ namespace ingen { class URI; class Atom; -namespace client { class PortModel; } +namespace client { +class PortModel; +} // namespace client namespace gui { diff --git a/src/gui/PortMenu.cpp b/src/gui/PortMenu.cpp index 652ac05d..95ba88dc 100644 --- a/src/gui/PortMenu.cpp +++ b/src/gui/PortMenu.cpp @@ -24,6 +24,7 @@ #include "ingen/Interface.hpp" #include "ingen/Properties.hpp" #include "ingen/Resource.hpp" +#include "ingen/URI.hpp" #include "ingen/URIs.hpp" #include "ingen/client/BlockModel.hpp" #include "ingen/client/GraphModel.hpp" // IWYU pragma: keep @@ -37,6 +38,7 @@ #include <glibmm/signalproxy.h> #include <gtkmm/builder.h> #include <gtkmm/checkmenuitem.h> +#include <gtkmm/menu.h> #include <gtkmm/menuitem.h> #include <gtkmm/separatormenuitem.h> #include <sigc++/functors/mem_fun.h> @@ -55,7 +57,6 @@ namespace gui { PortMenu::PortMenu(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& xml) : ObjectMenu(cobject, xml) - , _internal_graph_port(false) { xml->get_widget("object_menu", _port_menu); xml->get_widget("port_set_min_menuitem", _set_min_menuitem); @@ -169,7 +170,7 @@ PortMenu::on_menu_expose() auto block = std::dynamic_pointer_cast<const BlockModel>(port->parent()); const std::string label = block->label() + " " + block->port_label(port); - const raul::Path path = raul::Path(block->path() + raul::Symbol("_" + port->symbol())); + const auto path = raul::Path{block->path() + raul::Symbol("_" + port->symbol())}; ingen::Resource r(*_object); r.remove_property(uris.lv2_index, uris.patch_wildcard); diff --git a/src/gui/PortMenu.hpp b/src/gui/PortMenu.hpp index 75a25cde..cf7f9c62 100644 --- a/src/gui/PortMenu.hpp +++ b/src/gui/PortMenu.hpp @@ -19,8 +19,6 @@ #include "ObjectMenu.hpp" -#include <gtkmm/menu.h> - #include <memory> namespace Glib { @@ -29,6 +27,7 @@ template <class T> class RefPtr; namespace Gtk { class Builder; +class Menu; class MenuItem; } // namespace Gtk @@ -63,14 +62,14 @@ private: void on_menu_reset_range(); void on_menu_expose(); - Gtk::Menu* _port_menu; - Gtk::MenuItem* _set_min_menuitem; - Gtk::MenuItem* _set_max_menuitem; - Gtk::MenuItem* _reset_range_menuitem; - Gtk::MenuItem* _expose_menuitem; + Gtk::Menu* _port_menu{nullptr}; + Gtk::MenuItem* _set_min_menuitem{nullptr}; + Gtk::MenuItem* _set_max_menuitem{nullptr}; + Gtk::MenuItem* _reset_range_menuitem{nullptr}; + Gtk::MenuItem* _expose_menuitem{nullptr}; /// True iff this is a (flipped) port on a GraphPortModule in its graph - bool _internal_graph_port; + bool _internal_graph_port{false}; }; } // namespace gui diff --git a/src/gui/PropertiesWindow.cpp b/src/gui/PropertiesWindow.cpp index afcfa827..958a73c9 100644 --- a/src/gui/PropertiesWindow.cpp +++ b/src/gui/PropertiesWindow.cpp @@ -14,8 +14,9 @@ along with Ingen. If not, see <http://www.gnu.org/licenses/>. */ -#include "App.hpp" #include "PropertiesWindow.hpp" + +#include "App.hpp" #include "RDFS.hpp" #include "URIEntry.hpp" #include "Window.hpp" @@ -53,6 +54,7 @@ #include <gtkmm/table.h> #include <gtkmm/treeiter.h> #include <gtkmm/widget.h> +#include <gtkmm/window.h> #include <sigc++/adaptors/bind.h> #include <sigc++/functors/mem_fun.h> #include <sigc++/signal.h> @@ -76,7 +78,6 @@ using URISet = std::set<URI>; PropertiesWindow::PropertiesWindow(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& xml) : Window(cobject) - , _value_type(0) { xml->get_widget("properties_vbox", _vbox); xml->get_widget("properties_scrolledwindow", _scrolledwindow); @@ -185,16 +186,24 @@ PropertiesWindow::datatype_supported(const rdfs::URISet& types, if (types.find(_app->uris().atom_Int) != types.end()) { *widget_type = _app->uris().atom_Int; return true; - } else if (types.find(_app->uris().atom_Float) != types.end()) { + } + + if (types.find(_app->uris().atom_Float) != types.end()) { *widget_type = _app->uris().atom_Float; return true; - } else if (types.find(_app->uris().atom_Bool) != types.end()) { + } + + if (types.find(_app->uris().atom_Bool) != types.end()) { *widget_type = _app->uris().atom_Bool; return true; - } else if (types.find(_app->uris().atom_String) != types.end()) { + } + + if (types.find(_app->uris().atom_String) != types.end()) { *widget_type = _app->uris().atom_String; return true; - } else if (types.find(_app->uris().atom_URID) != types.end()) { + } + + if (types.find(_app->uris().atom_URID) != types.end()) { *widget_type = _app->uris().atom_URID; return true; } @@ -276,8 +285,9 @@ PropertiesWindow::set_object(const std::shared_ptr<const ObjectModel>& model) } for (const auto& e : entries) { - Gtk::ListStore::iterator ki = _key_store->append(); - Gtk::ListStore::Row row = *ki; + auto ki = _key_store->append(); + auto row = *ki; + row[_combo_columns.uri_col] = e.second.string(); row[_combo_columns.label_col] = e.first; } @@ -332,7 +342,9 @@ PropertiesWindow::create_value_widget(const URI& key, widget->signal_value_changed().connect( sigc::bind(sigc::mem_fun(this, &PropertiesWindow::on_change), key)); return widget; - } else if (type == _app->uris().atom_Float) { + } + + if (type == _app->uris().atom_Float) { Gtk::SpinButton* widget = manage(new Gtk::SpinButton(0.0, 4)); widget->property_numeric() = true; widget->set_snap_to_ticks(false); @@ -344,7 +356,9 @@ PropertiesWindow::create_value_widget(const URI& key, widget->signal_value_changed().connect( sigc::bind(sigc::mem_fun(this, &PropertiesWindow::on_change), key)); return widget; - } else if (type == _app->uris().atom_Bool) { + } + + if (type == _app->uris().atom_Bool) { Gtk::CheckButton* widget = manage(new Gtk::CheckButton()); if (value.is_valid()) { widget->set_active(value.get<int32_t>()); @@ -352,7 +366,9 @@ PropertiesWindow::create_value_widget(const URI& key, widget->signal_toggled().connect( sigc::bind(sigc::mem_fun(this, &PropertiesWindow::on_change), key)); return widget; - } else if (type == _app->uris().atom_String) { + } + + if (type == _app->uris().atom_String) { Gtk::Entry* widget = manage(new Gtk::Entry()); if (value.is_valid()) { widget->set_text(value.ptr<char>()); @@ -360,14 +376,16 @@ PropertiesWindow::create_value_widget(const URI& key, widget->signal_changed().connect( sigc::bind(sigc::mem_fun(this, &PropertiesWindow::on_change), key)); return widget; - } else if (type == _app->uris().atom_URID) { + } + + if (type == _app->uris().atom_URID) { const char* str = (value.is_valid() ? world.uri_map().unmap_uri(value.get<int32_t>()) : ""); - LilvNode* pred = lilv_new_uri(lworld, key.c_str()); - URISet ranges = rdfs::range(world, pred, true); - URIEntry* widget = manage(new URIEntry(_app, ranges, str ? str : "")); + LilvNode* pred = lilv_new_uri(lworld, key.c_str()); + const URISet ranges = rdfs::range(world, pred, true); + URIEntry* widget = manage(new URIEntry(_app, ranges, str ? str : "")); widget->signal_changed().connect( sigc::bind(sigc::mem_fun(this, &PropertiesWindow::on_change), key)); lilv_node_free(pred); @@ -383,10 +401,10 @@ PropertiesWindow::create_value_widget(const URI& key, if (type == _app->uris().atom_URI || type == _app->uris().rdfs_Class || is_class) { - LilvNode* pred = lilv_new_uri(lworld, key.c_str()); - URISet ranges = rdfs::range(world, pred, true); - const char* str = value.is_valid() ? value.ptr<const char>() : ""; - URIEntry* widget = manage(new URIEntry(_app, ranges, str)); + LilvNode* pred = lilv_new_uri(lworld, key.c_str()); + const URISet ranges = rdfs::range(world, pred, true); + const char* str = value.is_valid() ? value.ptr<const char>() : ""; + URIEntry* widget = manage(new URIEntry(_app, ranges, str)); widget->signal_changed().connect( sigc::bind(sigc::mem_fun(this, &PropertiesWindow::on_change), key)); lilv_node_free(pred); @@ -465,7 +483,7 @@ PropertiesWindow::remove_property(const URI& key, const Atom& value) Atom PropertiesWindow::get_value(LV2_URID type, Gtk::Widget* value_widget) { - Forge& forge = _app->forge(); + const Forge& forge = _app->forge(); if (type == forge.Int) { auto* spin = dynamic_cast<Gtk::SpinButton*>(value_widget); @@ -484,9 +502,11 @@ PropertiesWindow::get_value(LV2_URID type, Gtk::Widget* value_widget) } } else if (type == forge.URI || type == forge.URID) { auto* uri_entry = dynamic_cast<URIEntry*>(value_widget); - if (uri_entry && URI::is_valid(uri_entry->get_text())) { - return _app->forge().make_urid(URI(uri_entry->get_text())); - } else { + if (uri_entry) { + if (URI::is_valid(uri_entry->get_text())) { + return _app->forge().make_urid(URI(uri_entry->get_text())); + } + _app->log().error("Invalid URI <%1%>\n", uri_entry->get_text()); } } else if (type == forge.String) { @@ -496,7 +516,7 @@ PropertiesWindow::get_value(LV2_URID type, Gtk::Widget* value_widget) } } - return Atom(); + return {}; } void @@ -521,12 +541,12 @@ PropertiesWindow::on_change(const URI& key) std::string PropertiesWindow::active_key() const { - const Gtk::ListStore::iterator iter = _key_combo->get_active(); + const auto iter = _key_combo->get_active(); if (!iter) { return ""; } - Glib::ustring prop_uri = (*iter)[_combo_columns.uri_col]; + const Glib::ustring prop_uri = (*iter)[_combo_columns.uri_col]; return prop_uri; } diff --git a/src/gui/PropertiesWindow.hpp b/src/gui/PropertiesWindow.hpp index 780c2ba1..3210ceaa 100644 --- a/src/gui/PropertiesWindow.hpp +++ b/src/gui/PropertiesWindow.hpp @@ -27,7 +27,6 @@ #include <gtkmm/liststore.h> #include <gtkmm/treemodel.h> #include <gtkmm/treemodelcolumn.h> -#include <gtkmm/window.h> #include <sigc++/connection.h> #include <map> @@ -54,7 +53,9 @@ class Widget; namespace ingen { -namespace client { class ObjectModel; } +namespace client { +class ObjectModel; +} // namespace client namespace gui { @@ -129,16 +130,16 @@ private: Glib::RefPtr<Gtk::ListStore> _key_store; sigc::connection _property_connection; sigc::connection _property_removed_connection; - Gtk::VBox* _vbox; - Gtk::ScrolledWindow* _scrolledwindow; - Gtk::Table* _table; - Gtk::ComboBox* _key_combo; - LV2_URID _value_type; - Gtk::Bin* _value_bin; - Gtk::Button* _add_button; - Gtk::Button* _cancel_button; - Gtk::Button* _apply_button; - Gtk::Button* _ok_button; + Gtk::VBox* _vbox{nullptr}; + Gtk::ScrolledWindow* _scrolledwindow{nullptr}; + Gtk::Table* _table{nullptr}; + Gtk::ComboBox* _key_combo{nullptr}; + LV2_URID _value_type{0}; + Gtk::Bin* _value_bin{nullptr}; + Gtk::Button* _add_button{nullptr}; + Gtk::Button* _cancel_button{nullptr}; + Gtk::Button* _apply_button{nullptr}; + Gtk::Button* _ok_button{nullptr}; }; } // namespace gui diff --git a/src/gui/RDFS.cpp b/src/gui/RDFS.cpp index ed8d7e8c..64aa893b 100644 --- a/src/gui/RDFS.cpp +++ b/src/gui/RDFS.cpp @@ -26,9 +26,7 @@ #include <utility> -namespace ingen { -namespace gui { -namespace rdfs { +namespace ingen::gui::rdfs { std::string label(World& world, const LilvNode* node) @@ -76,10 +74,10 @@ closure(World& world, const LilvNode* pred, URISet& types, bool super) world.lilv_world(), type, pred, nullptr) : lilv_world_find_nodes( world.lilv_world(), nullptr, pred, type); - LILV_FOREACH(nodes, m, matches) { + LILV_FOREACH (nodes, m, matches) { const LilvNode* klass_node = lilv_nodes_get(matches, m); if (lilv_node_is_uri(klass_node)) { - URI klass(lilv_node_as_uri(klass_node)); + const URI klass{lilv_node_as_uri(klass_node)}; if (!types.count(klass)) { ++added; klasses.insert(klass); @@ -118,20 +116,17 @@ datatypes(World& world, URISet& types, bool super) URISet types(World& world, const std::shared_ptr<const client::ObjectModel>& model) { - using PropIter = Properties::const_iterator; - using PropRange = std::pair<PropIter, PropIter>; - // Start with every rdf:type URISet types; types.insert(URI(LILV_NS_RDFS "Resource")); - PropRange range = model->properties().equal_range(world.uris().rdf_type); + const auto range = model->properties().equal_range(world.uris().rdf_type); for (auto t = range.first; t != range.second; ++t) { if (t->second.type() == world.forge().URI || t->second.type() == world.forge().URID) { const URI type(world.forge().str(t->second, false)); types.insert(type); if (world.uris().ingen_Graph == type) { - // Add lv2:Plugin as a type for graphs so plugin properties show up + // Add lv2:Plugin as a type so plugin properties show up types.insert(world.uris().lv2_Plugin); } } else { @@ -149,8 +144,8 @@ URISet properties(World& world, const std::shared_ptr<const client::ObjectModel>& model) { - URISet properties; - URISet types = rdfs::types(world, model); + URISet properties; + const URISet types = rdfs::types(world, model); LilvNode* rdf_type = lilv_new_uri(world.lilv_world(), LILV_NS_RDF "type"); @@ -161,13 +156,13 @@ properties(World& world, LilvNodes* props = lilv_world_find_nodes( world.lilv_world(), nullptr, rdf_type, rdf_Property); - LILV_FOREACH(nodes, p, props) { + LILV_FOREACH (nodes, p, props) { const LilvNode* prop = lilv_nodes_get(props, p); if (lilv_node_is_uri(prop)) { LilvNodes* domains = lilv_world_find_nodes( world.lilv_world(), prop, rdfs_domain, nullptr); unsigned n_matching_domains = 0; - LILV_FOREACH(nodes, d, domains) { + LILV_FOREACH (nodes, d, domains) { const LilvNode* domain_node = lilv_nodes_get(domains, d); if (!lilv_node_is_uri(domain_node)) { // TODO: Blank node domains (e.g. unions) @@ -208,7 +203,7 @@ instances(World& world, const URISet& types) LilvNode* type = lilv_new_uri(world.lilv_world(), t.c_str()); LilvNodes* objects = lilv_world_find_nodes( world.lilv_world(), nullptr, rdf_type, type); - LILV_FOREACH(nodes, o, objects) { + LILV_FOREACH (nodes, o, objects) { const LilvNode* object = lilv_nodes_get(objects, o); if (!lilv_node_is_uri(object)) { continue; @@ -233,7 +228,7 @@ range(World& world, const LilvNode* prop, bool recursive) world.lilv_world(), prop, rdfs_range, nullptr); URISet ranges; - LILV_FOREACH(nodes, n, nodes) { + LILV_FOREACH (nodes, n, nodes) { if (lilv_node_is_uri(lilv_nodes_get(nodes, n))) { ranges.insert(URI(lilv_node_as_string(lilv_nodes_get(nodes, n)))); } @@ -260,6 +255,4 @@ is_a(World& world, const LilvNode* inst, const LilvNode* klass) return is_instance; } -} // namespace rdfs -} // namespace gui -} // namespace ingen +} // namespace ingen::gui::rdfs diff --git a/src/gui/RDFS.hpp b/src/gui/RDFS.hpp index 4fac5546..ad4e22e8 100644 --- a/src/gui/RDFS.hpp +++ b/src/gui/RDFS.hpp @@ -29,11 +29,11 @@ namespace ingen { class World; -namespace client { class ObjectModel; } +namespace client { +class ObjectModel; +} // namespace client -namespace gui { - -namespace rdfs { +namespace gui::rdfs { /** Set of URIs. */ using URISet = std::set<URI>; @@ -77,8 +77,7 @@ URISet range(World& world, const LilvNode* prop, bool recursive); /** Return true iff `inst` is-a `klass`. */ bool is_a(World& world, const LilvNode* inst, const LilvNode* klass); -} // namespace rdfs -} // namespace gui +} // namespace gui::rdfs } // namespace ingen #endif // INGEN_GUI_RDF_HPP diff --git a/src/gui/RenameWindow.cpp b/src/gui/RenameWindow.cpp index e2c1e98c..66d8e918 100644 --- a/src/gui/RenameWindow.cpp +++ b/src/gui/RenameWindow.cpp @@ -37,6 +37,7 @@ #include <gtkmm/button.h> #include <gtkmm/entry.h> #include <gtkmm/label.h> +#include <gtkmm/window.h> #include <sigc++/functors/mem_fun.h> #include <memory> diff --git a/src/gui/RenameWindow.hpp b/src/gui/RenameWindow.hpp index 004ca784..9c97d234 100644 --- a/src/gui/RenameWindow.hpp +++ b/src/gui/RenameWindow.hpp @@ -19,8 +19,6 @@ #include "Window.hpp" -#include <gtkmm/window.h> - #include <memory> namespace Glib { @@ -63,11 +61,11 @@ private: std::shared_ptr<const client::ObjectModel> _object; - Gtk::Entry* _symbol_entry; - Gtk::Entry* _label_entry; - Gtk::Label* _message_label; - Gtk::Button* _cancel_button; - Gtk::Button* _ok_button; + Gtk::Entry* _symbol_entry{nullptr}; + Gtk::Entry* _label_entry{nullptr}; + Gtk::Label* _message_label{nullptr}; + Gtk::Button* _cancel_button{nullptr}; + Gtk::Button* _ok_button{nullptr}; }; } // namespace gui diff --git a/src/gui/Style.cpp b/src/gui/Style.cpp index 5be83688..9a9e7478 100644 --- a/src/gui/Style.cpp +++ b/src/gui/Style.cpp @@ -23,26 +23,18 @@ #include <string> -namespace ingen { -namespace gui { +namespace ingen::gui { Style::Style(App& app) - // Colours from the Tango palette with modified V - : _app(app) + : _app(app) +{ #ifdef INGEN_USE_LIGHT_THEME - , _audio_port_color(0xC8E6ABFF) // Green - , _control_port_color(0xAAC0E6FF) // Blue - , _cv_port_color(0xACE6E0FF) // Teal (between audio and control) - , _event_port_color(0xE6ABABFF) // Red - , _string_port_color(0xD8ABE6FF) // Plum -#else - , _audio_port_color(0x4A8A0EFF) // Green - , _control_port_color(0x244678FF) // Blue - , _cv_port_color(0x248780FF) // Teal (between audio and control) - , _event_port_color(0x960909FF) // Red - , _string_port_color(0x5C3566FF) // Plum + _audio_port_color = 0xC8E6ABFF; + _control_port_color = 0xAAC0E6FF; + _cv_port_color = 0xACE6E0FF; + _event_port_color = 0xE6ABABFF; + _string_port_color = 0xD8ABE6FF; #endif -{ } /** Loads settings from the rc file. Passing no parameter will load from @@ -76,22 +68,32 @@ uint32_t Style::get_port_color(const client::PortModel* p) { const URIs& uris = _app.uris(); + if (p->is_a(uris.lv2_AudioPort)) { return _audio_port_color; - } else if (p->is_a(uris.lv2_ControlPort)) { + } + + if (p->is_a(uris.lv2_ControlPort)) { return _control_port_color; - } else if (p->is_a(uris.lv2_CVPort)) { + } + + if (p->is_a(uris.lv2_CVPort)) { return _cv_port_color; - } else if (p->supports(uris.atom_String)) { + } + + if (p->supports(uris.atom_String)) { return _string_port_color; - } else if (_app.can_control(p)) { + } + + if (_app.can_control(p)) { return _control_port_color; - } else if (p->is_a(uris.atom_AtomPort)) { + } + + if (p->is_a(uris.atom_AtomPort)) { return _event_port_color; } return 0x555555FF; } -} // namespace gui -} // namespace ingen +} // namespace ingen::gui diff --git a/src/gui/Style.hpp b/src/gui/Style.hpp index bc94d64a..20d560a8 100644 --- a/src/gui/Style.hpp +++ b/src/gui/Style.hpp @@ -45,11 +45,12 @@ public: private: App& _app; - uint32_t _audio_port_color; - uint32_t _control_port_color; - uint32_t _cv_port_color; - uint32_t _event_port_color; - uint32_t _string_port_color; + // Colours from the Tango palette with modified V + uint32_t _audio_port_color{0x4A8A0EFF}; // Green + uint32_t _control_port_color{0x244678FF}; // Blue + uint32_t _cv_port_color{0x248780FF}; // Teal {between audio/control} + uint32_t _event_port_color{0x960909FF}; // Red + uint32_t _string_port_color{0x5C3566FF}; // Plum }; } // namespace gui diff --git a/src/gui/ThreadedLoader.cpp b/src/gui/ThreadedLoader.cpp index 663529da..4cd382a0 100644 --- a/src/gui/ThreadedLoader.cpp +++ b/src/gui/ThreadedLoader.cpp @@ -20,27 +20,26 @@ #include "ingen/Log.hpp" #include "ingen/Parser.hpp" -#include "ingen/Properties.hpp" #include "ingen/Serialiser.hpp" #include "ingen/URI.hpp" #include "ingen/World.hpp" #include "ingen/client/GraphModel.hpp" #include "raul/Path.hpp" -#include "raul/Symbol.hpp" +#include "raul/Semaphore.hpp" -#include <boost/optional/optional.hpp> #include <glibmm/ustring.h> #include <sigc++/adaptors/bind.h> #include <sigc++/adaptors/retype_return.h> #include <sigc++/functors/mem_fun.h> #include <cassert> +#include <filesystem> #include <memory> +#include <optional> #include <string> +#include <string_view> #include <utility> -using boost::optional; - namespace ingen { class Interface; @@ -49,9 +48,7 @@ namespace gui { ThreadedLoader::ThreadedLoader(App& app, std::shared_ptr<Interface> engine) : _app(app) - , _sem(0) , _engine(std::move(engine)) - , _exit_flag(false) , _thread(&ThreadedLoader::run, this) { if (!parser()) { @@ -78,7 +75,7 @@ void ThreadedLoader::run() { while (_sem.wait() && !_exit_flag) { - std::lock_guard<std::mutex> lock(_mutex); + const std::lock_guard<std::mutex> lock{_mutex}; while (!_events.empty()) { _events.front()(); _events.pop_front(); @@ -87,20 +84,20 @@ ThreadedLoader::run() } void -ThreadedLoader::load_graph(bool merge, - const FilePath& file_path, - const optional<raul::Path>& engine_parent, - const optional<raul::Symbol>& engine_symbol, - const optional<Properties>& engine_data) +ThreadedLoader::load_graph(bool merge, + const FilePath& file_path, + const std::optional<raul::Path>& engine_parent, + const std::optional<raul::Symbol>& engine_symbol, + const std::optional<Properties>& engine_data) { - std::lock_guard<std::mutex> lock(_mutex); + const std::lock_guard<std::mutex> lock{_mutex}; Glib::ustring engine_base = ""; if (engine_parent) { if (merge) { - engine_base = engine_parent.get(); + engine_base = *engine_parent; } else { - engine_base = engine_parent.get().base(); + engine_base = engine_parent->base(); } } @@ -115,12 +112,13 @@ ThreadedLoader::load_graph(bool merge, } void -ThreadedLoader::load_graph_event(const FilePath& file_path, - const optional<raul::Path>& engine_parent, - const optional<raul::Symbol>& engine_symbol, - const optional<Properties>& engine_data) +ThreadedLoader::load_graph_event( + const FilePath& file_path, + const std::optional<raul::Path>& engine_parent, + const std::optional<raul::Symbol>& engine_symbol, + const std::optional<Properties>& engine_data) { - std::lock_guard<std::mutex> lock(_app.world().rdf_mutex()); + const std::lock_guard<std::mutex> lock{_app.world().rdf_mutex()}; _app.world().parser()->parse_file(_app.world(), *_app.world().interface(), @@ -135,7 +133,7 @@ ThreadedLoader::save_graph( const std::shared_ptr<const client::GraphModel>& model, const URI& uri) { - std::lock_guard<std::mutex> lock(_mutex); + const std::lock_guard<std::mutex> lock{_mutex}; _events.emplace_back(sigc::hide_return( sigc::bind(sigc::mem_fun(this, &ThreadedLoader::save_graph_event), @@ -152,7 +150,7 @@ ThreadedLoader::save_graph_event( { assert(uri.scheme() == "file"); if (_app.serialiser()) { - std::lock_guard<std::mutex> lock(_app.world().rdf_mutex()); + const std::lock_guard<std::mutex> lock{_app.world().rdf_mutex()}; if (uri.string().find(".ingen") != std::string::npos) { _app.serialiser()->write_bundle(model, uri); diff --git a/src/gui/ThreadedLoader.hpp b/src/gui/ThreadedLoader.hpp index 5e9392bc..83860461 100644 --- a/src/gui/ThreadedLoader.hpp +++ b/src/gui/ThreadedLoader.hpp @@ -25,12 +25,9 @@ #include <list> #include <memory> #include <mutex> +#include <optional> #include <thread> -namespace boost { -template <class T> class optional; -} // namespace boost - namespace raul { class Path; class Symbol; @@ -43,7 +40,9 @@ class Parser; class Properties; class URI; -namespace client { class GraphModel; } +namespace client { +class GraphModel; +} // namespace client namespace gui { @@ -68,11 +67,11 @@ public: ~ThreadedLoader(); - void load_graph(bool merge, - const FilePath& file_path, - const boost::optional<raul::Path>& engine_parent, - const boost::optional<raul::Symbol>& engine_symbol, - const boost::optional<Properties>& engine_data); + void load_graph(bool merge, + const FilePath& file_path, + const std::optional<raul::Path>& engine_parent, + const std::optional<raul::Symbol>& engine_symbol, + const std::optional<Properties>& engine_data); void save_graph(const std::shared_ptr<const client::GraphModel>& model, const URI& uri); @@ -80,10 +79,10 @@ public: std::shared_ptr<Parser> parser(); private: - void load_graph_event(const FilePath& file_path, - const boost::optional<raul::Path>& engine_parent, - const boost::optional<raul::Symbol>& engine_symbol, - const boost::optional<Properties>& engine_data); + void load_graph_event(const FilePath& file_path, + const std::optional<raul::Path>& engine_parent, + const std::optional<raul::Symbol>& engine_symbol, + const std::optional<Properties>& engine_data); void save_graph_event(const std::shared_ptr<const client::GraphModel>& model, @@ -95,11 +94,11 @@ private: void run(); App& _app; - raul::Semaphore _sem; + raul::Semaphore _sem{0}; std::shared_ptr<Interface> _engine; std::mutex _mutex; std::list<Closure> _events; - bool _exit_flag; + bool _exit_flag{false}; std::thread _thread; }; diff --git a/src/gui/URIEntry.cpp b/src/gui/URIEntry.cpp index 036e7a0b..fa03a05b 100644 --- a/src/gui/URIEntry.cpp +++ b/src/gui/URIEntry.cpp @@ -20,14 +20,13 @@ #include "RDFS.hpp" #include "ingen/World.hpp" +#include "lilv/lilv.h" #include <gdk/gdk.h> -#include <glibmm/helperlist.h> #include <gtkmm/button.h> #include <gtkmm/menu.h> #include <gtkmm/menu_elems.h> #include <gtkmm/menuitem.h> -#include <gtkmm/menushell.h> #include <gtkmm/object.h> #include <sigc++/adaptors/bind.h> #include <sigc++/functors/mem_fun.h> @@ -35,8 +34,7 @@ #include <map> #include <utility> -namespace ingen { -namespace gui { +namespace ingen::gui { URIEntry::URIEntry(App* app, std::set<URI> types, const std::string& value) : Gtk::HBox(false, 4) @@ -67,7 +65,7 @@ URIEntry::build_value_menu() LilvNode* rdfs_Datatype = lilv_new_uri(lworld, LILV_NS_RDFS "Datatype"); LilvNode* rdfs_subClassOf = lilv_new_uri(lworld, LILV_NS_RDFS "subClassOf"); - rdfs::Objects values = rdfs::instances(world, _types); + const rdfs::Objects values = rdfs::instances(world, _types); for (const auto& v : values) { const LilvNode* inst = lilv_new_uri(lworld, v.second.c_str()); @@ -131,11 +129,11 @@ URIEntry::build_subclass_menu(const LilvNode* klass) // Put subclasses/types in a map keyed by label (to sort menu) std::map<std::string, const LilvNode*> entries; - LILV_FOREACH(nodes, s, subclasses) { + LILV_FOREACH (nodes, s, subclasses) { const LilvNode* node = lilv_nodes_get(subclasses, s); entries.emplace(rdfs::label(world, node), node); } - LILV_FOREACH(nodes, s, subtypes) { + LILV_FOREACH (nodes, s, subtypes) { const LilvNode* node = lilv_nodes_get(subtypes, s); entries.emplace(rdfs::label(world, node), node); } @@ -203,5 +201,4 @@ URIEntry::menu_button_event(GdkEvent* ev) return true; } -} // namespace gui -} // namespace ingen +} // namespace ingen::gui diff --git a/src/gui/URIEntry.hpp b/src/gui/URIEntry.hpp index cc8f96a3..52c9db66 100644 --- a/src/gui/URIEntry.hpp +++ b/src/gui/URIEntry.hpp @@ -34,12 +34,12 @@ class Button; class Menu; } // namespace Gtk -namespace ingen { -namespace gui { +namespace ingen::gui { class App; -class URIEntry : public Gtk::HBox { +class URIEntry : public Gtk::HBox +{ public: /** Create a widget for entering URIs. * @@ -72,7 +72,6 @@ private: Gtk::Entry* _entry; }; -} // namespace gui -} // namespace ingen +} // namespace ingen::gui #endif // INGEN_GUI_URI_ENTRY_HPP diff --git a/src/gui/WidgetFactory.cpp b/src/gui/WidgetFactory.cpp index 2bd7b5fd..b2d27e90 100644 --- a/src/gui/WidgetFactory.cpp +++ b/src/gui/WidgetFactory.cpp @@ -16,7 +16,6 @@ #include "WidgetFactory.hpp" -#include "ingen/FilePath.hpp" #include "ingen/runtime_paths.hpp" #include <cstdlib> @@ -24,12 +23,11 @@ #include <stdexcept> #include <string> -namespace ingen { -namespace gui { +namespace ingen::gui { Glib::ustring WidgetFactory::ui_filename = ""; -inline static bool +static inline bool is_readable(const std::string& filename) { std::ifstream fs(filename.c_str()); @@ -72,10 +70,9 @@ WidgetFactory::create(const std::string& toplevel_widget) if (toplevel_widget.empty()) { return Gtk::Builder::create_from_file(ui_filename); - } else { - return Gtk::Builder::create_from_file(ui_filename, toplevel_widget.c_str()); } + + return Gtk::Builder::create_from_file(ui_filename, toplevel_widget.c_str()); } -} // namespace gui -} // namespace ingen +} // namespace ingen::gui diff --git a/src/gui/WidgetFactory.hpp b/src/gui/WidgetFactory.hpp index 11ef71d1..474071ec 100644 --- a/src/gui/WidgetFactory.hpp +++ b/src/gui/WidgetFactory.hpp @@ -23,28 +23,28 @@ #include <string> -namespace ingen { -namespace gui { +namespace ingen::gui { /** Loads widgets from an XML description. * Purely static. * * \ingroup GUI */ -class WidgetFactory { +class WidgetFactory +{ public: static Glib::RefPtr<Gtk::Builder> create(const std::string& toplevel_widget=""); template<typename T> static void get_widget(const Glib::ustring& name, T*& widget) { - Glib::RefPtr<Gtk::Builder> xml = create(name); + const Glib::RefPtr<Gtk::Builder> xml = create(name); xml->get_widget(name, widget); } template<typename T> static void get_widget_derived(const Glib::ustring& name, T*& widget) { - Glib::RefPtr<Gtk::Builder> xml = create(name); + const Glib::RefPtr<Gtk::Builder> xml = create(name); xml->get_widget_derived(name, widget); } @@ -53,7 +53,6 @@ private: static Glib::ustring ui_filename; }; -} // namespace gui -} // namespace ingen +} // namespace ingen::gui #endif // INGEN_GUI_WIDGETFACTORY_HPP diff --git a/src/gui/Window.hpp b/src/gui/Window.hpp index acf75942..756ba8f0 100644 --- a/src/gui/Window.hpp +++ b/src/gui/Window.hpp @@ -22,9 +22,7 @@ #include <gtkmm/dialog.h> #include <gtkmm/window.h> -namespace ingen { - -namespace gui { +namespace ingen::gui { class App; @@ -38,8 +36,7 @@ public: explicit Window(BaseObjectType* cobject) : Gtk::Window(cobject) - { - } + {} virtual void init_window(App& app) { _app = &app; } @@ -66,8 +63,7 @@ public: explicit Dialog(BaseObjectType* cobject) : Gtk::Dialog(cobject) - { - } + {} virtual void init_dialog(App& app) { _app = &app; } @@ -82,7 +78,6 @@ public: App* _app = nullptr; }; -} // namespace gui -} // namespace ingen +} // namespace ingen::gui #endif // INGEN_GUI_WINDOW_HPP diff --git a/src/gui/WindowFactory.cpp b/src/gui/WindowFactory.cpp index 4e48f157..010ef704 100644 --- a/src/gui/WindowFactory.cpp +++ b/src/gui/WindowFactory.cpp @@ -14,9 +14,10 @@ along with Ingen. If not, see <http://www.gnu.org/licenses/>. */ +#include "WindowFactory.hpp" + #include "App.hpp" #include "GraphBox.hpp" -#include "GraphView.hpp" #include "GraphWindow.hpp" #include "LoadGraphWindow.hpp" #include "LoadPluginWindow.hpp" @@ -24,12 +25,12 @@ #include "PropertiesWindow.hpp" #include "RenameWindow.hpp" #include "WidgetFactory.hpp" -#include "WindowFactory.hpp" #include "ingen/Log.hpp" #include "ingen/client/BlockModel.hpp" #include "ingen/client/GraphModel.hpp" #include "ingen/client/ObjectModel.hpp" +#include "raul/Path.hpp" #include <gdkmm/window.h> #include <glibmm/signalproxy.h> @@ -52,11 +53,6 @@ namespace gui { WindowFactory::WindowFactory(App& app) : _app(app) - , _main_box(nullptr) - , _load_plugin_win(nullptr) - , _load_graph_win(nullptr) - , _new_subgraph_win(nullptr) - , _properties_win(nullptr) { WidgetFactory::get_widget_derived("load_plugin_win", _load_plugin_win); WidgetFactory::get_widget_derived("load_graph_win", _load_graph_win); @@ -114,9 +110,9 @@ WindowFactory::graph_box(const std::shared_ptr<const GraphModel>& graph) GraphWindow* window = graph_window(graph); if (window) { return window->box(); - } else { - return _main_box; } + + return _main_box; } GraphWindow* @@ -153,8 +149,6 @@ WindowFactory::present_graph(const std::shared_ptr<const GraphModel>& graph, GraphWindow* preferred, const std::shared_ptr<GraphView>& view) { - assert(!view || view->graph() == graph); - auto w = _graph_windows.find(graph->path()); if (w != _graph_windows.end()) { @@ -178,8 +172,6 @@ GraphWindow* WindowFactory::new_graph_window(const std::shared_ptr<const GraphModel>& graph, const std::shared_ptr<GraphView>& view) { - assert(!view || view->graph() == graph); - GraphWindow* win = nullptr; WidgetFactory::get_widget_derived("graph_win", win); if (!win) { diff --git a/src/gui/WindowFactory.hpp b/src/gui/WindowFactory.hpp index 581e2e0f..4ef79239 100644 --- a/src/gui/WindowFactory.hpp +++ b/src/gui/WindowFactory.hpp @@ -25,6 +25,7 @@ #include <cstddef> #include <map> #include <memory> +#include <string> namespace ingen { @@ -52,7 +53,8 @@ class RenameWindow; * as well as an enumeration of all windows (the goal being to reduce that * number as much as possible). */ -class WindowFactory { +class WindowFactory +{ public: explicit WindowFactory(App& app); ~WindowFactory(); @@ -106,13 +108,13 @@ private: const std::shared_ptr<GraphView>& view); App& _app; - GraphBox* _main_box; + GraphBox* _main_box{nullptr}; GraphWindowMap _graph_windows; - LoadPluginWindow* _load_plugin_win; - LoadGraphWindow* _load_graph_win; - NewSubgraphWindow* _new_subgraph_win; - PropertiesWindow* _properties_win; - RenameWindow* _rename_win; + LoadPluginWindow* _load_plugin_win{nullptr}; + LoadGraphWindow* _load_graph_win{nullptr}; + NewSubgraphWindow* _new_subgraph_win{nullptr}; + PropertiesWindow* _properties_win{nullptr}; + RenameWindow* _rename_win{nullptr}; }; } // namespace gui diff --git a/src/gui/ingen_gui.cpp b/src/gui/ingen_gui.cpp index 118a9000..8ddacb04 100644 --- a/src/gui/ingen_gui.cpp +++ b/src/gui/ingen_gui.cpp @@ -29,14 +29,13 @@ #include <memory> -namespace ingen { -namespace gui { +namespace ingen::gui { struct GUIModule : public Module { using SigClientInterface = client::SigClientInterface; void load(World& world) override { - URI uri(world.conf().option("connect").ptr<char>()); + const URI uri{world.conf().option("connect").ptr<char>()}; if (!world.interface()) { world.set_interface( world.new_interface(URI(uri), make_client(world))); @@ -63,12 +62,11 @@ struct GUIModule : public Module { std::shared_ptr<gui::App> app; }; -} // namespace gui -} // namespace ingen +} // namespace ingen::gui extern "C" { -ingen::Module* +INGEN_MODULE_EXPORT ingen::Module* ingen_module_load() { Glib::thread_init(); diff --git a/src/gui/ingen_gui.ui b/src/gui/ingen_gui.ui.in index 9e751064..9e751064 100644 --- a/src/gui/ingen_gui.ui +++ b/src/gui/ingen_gui.ui.in diff --git a/src/gui/ingen_gui_lv2.cpp b/src/gui/ingen_gui_lv2.cpp index ffa50779..31ec22c5 100644 --- a/src/gui/ingen_gui_lv2.cpp +++ b/src/gui/ingen_gui_lv2.cpp @@ -49,7 +49,8 @@ namespace ingen { /** A sink that writes atoms to a port via the UI extension. */ -struct IngenLV2AtomSink : public AtomSink { +class IngenLV2AtomSink : public AtomSink { +public: IngenLV2AtomSink(URIs& uris, LV2UI_Write_Function ui_write, LV2UI_Controller ui_controller) @@ -67,25 +68,18 @@ struct IngenLV2AtomSink : public AtomSink { return true; } +private: URIs& _uris; LV2UI_Write_Function _ui_write; LV2UI_Controller _ui_controller; }; struct IngenLV2UI { - IngenLV2UI() - : argc(0) - , argv(nullptr) - , forge(nullptr) - , world(nullptr) - , sink(nullptr) - {} - - int argc; - char** argv; - Forge* forge; - World* world; - IngenLV2AtomSink* sink; + int argc{0}; + char** argv{nullptr}; + Forge* forge{nullptr}; + World* world{nullptr}; + IngenLV2AtomSink* sink{nullptr}; std::shared_ptr<gui::App> app; std::shared_ptr<gui::GraphBox> view; std::shared_ptr<Interface> engine; diff --git a/src/gui/meson.build b/src/gui/meson.build new file mode 100644 index 00000000..3b9a7bb6 --- /dev/null +++ b/src/gui/meson.build @@ -0,0 +1,179 @@ +# Copyright 2022 David Robillard <d@drobilla.net> +# SPDX-License-Identifier: 0BSD OR GPL-3.0-or-later + +################ +# Dependencies # +################ + +gui_defines = platform_defines + +glibmm_dep = dependency( + 'glibmm-2.4', + include_type: 'system', + required: get_option('gui'), + version: '>= 2.14.0', +) + +gthread_dep = dependency( + 'gthread-2.0', + include_type: 'system', + required: get_option('gui'), + version: '>= 2.14.0', +) + +gtkmm_dep = dependency( + 'gtkmm-2.4', + include_type: 'system', + required: get_option('gui'), + version: '>= 2.14.0', +) + +ganv_dep = dependency( + 'ganv-1', + fallback: ['ganv', 'ganv_dep'], + required: get_option('gui'), + version: '>= 1.5.2', +) + +webkit_dep = dependency( + 'webkit-1.0', + include_type: 'system', + required: false, + version: '>= 1.4.0', +) + +build_gui = ( + glibmm_dep.found() + and gthread_dep.found() + and gtkmm_dep.found() + and ganv_dep.found() +) + +if webkit_dep.found() + gui_defines += ['-DHAVE_WEBKIT=1'] +else + gui_defines += ['-DHAVE_WEBKIT=0'] +endif + +########## +# Module # +########## + +if build_gui + gui_sources = files( + 'App.cpp', + 'Arc.cpp', + 'BreadCrumbs.cpp', + 'ConnectWindow.cpp', + 'GraphBox.cpp', + 'GraphCanvas.cpp', + 'GraphPortModule.cpp', + 'GraphTreeWindow.cpp', + 'GraphView.cpp', + 'GraphWindow.cpp', + 'LoadGraphWindow.cpp', + 'LoadPluginWindow.cpp', + 'MessagesWindow.cpp', + 'NewSubgraphWindow.cpp', + 'NodeMenu.cpp', + 'NodeModule.cpp', + 'ObjectMenu.cpp', + 'PluginMenu.cpp', + 'Port.cpp', + 'PortMenu.cpp', + 'PropertiesWindow.cpp', + 'RDFS.cpp', + 'RenameWindow.cpp', + 'Style.cpp', + 'SubgraphModule.cpp', + 'ThreadedLoader.cpp', + 'URIEntry.cpp', + 'WidgetFactory.cpp', + 'WindowFactory.cpp', + 'ingen_gui.cpp', + ) + + gui_dependencies = [ + boost_dep, + ganv_dep, + glibmm_dep, + gthread_dep, + gtkmm_dep, + ingen_client_dep, + ingen_dep, + lilv_dep, + raul_dep, + sigcpp_dep, + suil_dep, + thread_dep, + webkit_dep, + ] + + gui_suppressions = [] + if cpp.get_id() == 'clang' + gui_suppressions += [ + '-Wno-reserved-identifier', # Ganv + ] + endif + + gui_suppressions = cpp.get_supported_arguments(gui_suppressions) + gui_suppressions += cpp_suppressions + + gui_args = gui_suppressions + gui_defines + ['-DINGEN_GUI_INTERNAL'] + + libingen_gui = shared_library( + 'ingen_gui', + gui_sources, + cpp_args: gui_args, + dependencies: gui_dependencies, + gnu_symbol_visibility: 'hidden', + implicit_include_directories: false, + include_directories: ingen_include_dirs, + install: true, + install_dir: ingen_module_dir, + ) + + ingen_gui_dep = declare_dependency( + dependencies: gui_dependencies, + link_with: libingen_gui, + ) + + ########## + # LV2 UI # + ########## + + ingen_gui_lv2 = shared_library( + 'ingen_gui_lv2', + files('ingen_gui_lv2.cpp'), + cpp_args: gui_args, + dependencies: [ingen_gui_dep], + gnu_symbol_visibility: 'hidden', + implicit_include_directories: false, + include_directories: ingen_include_dirs, + install: true, + install_dir: lv2dir / 'ingen.lv2', + ) + + ############### + # Shared Data # + ############### + + config = configuration_data() + config.set('INGEN_VERSION', meson.project_version()) + + configure_file( + configuration: config, + input: files('ingen_gui.ui.in'), + install: true, + install_dir: ingen_data_dir, + output: 'ingen_gui.ui', + ) + + configure_file( + copy: true, + input: files('ingen_style.rc'), + install: true, + install_dir: ingen_data_dir, + output: '@PLAINNAME@', + ) +endif diff --git a/src/gui/rgba.hpp b/src/gui/rgba.hpp index bd8de2d2..bb53205e 100644 --- a/src/gui/rgba.hpp +++ b/src/gui/rgba.hpp @@ -20,10 +20,9 @@ #include <cmath> #include <cstdint> -namespace ingen { -namespace gui { +namespace ingen::gui { -static inline uint32_t +inline uint32_t rgba_to_uint(uint8_t r, uint8_t g, uint8_t b, uint8_t a) { return ((static_cast<uint32_t>(r) << 24) | @@ -32,10 +31,10 @@ rgba_to_uint(uint8_t r, uint8_t g, uint8_t b, uint8_t a) (static_cast<uint32_t>(a))); } -static inline uint8_t +inline uint8_t mono_interpolate(uint8_t v1, uint8_t v2, float f) { - return static_cast<int>(rintf((v2) * (f) + (v1) * (1 - (f)))); + return static_cast<uint8_t>(rintf((v2) * (f) + (v1) * (1 - (f)))); } #define RGBA_R(x) (static_cast<uint32_t>(x) >> 24) @@ -43,7 +42,7 @@ mono_interpolate(uint8_t v1, uint8_t v2, float f) #define RGBA_B(x) ((static_cast<uint32_t>(x) >> 8) & 0xFF) #define RGBA_A(x) (static_cast<uint32_t>(x) & 0xFF) -static inline uint32_t +inline uint32_t rgba_interpolate(uint32_t c1, uint32_t c2, float f) { return rgba_to_uint( @@ -53,7 +52,6 @@ rgba_interpolate(uint32_t c1, uint32_t c2, float f) mono_interpolate(RGBA_A(c1), RGBA_A(c2), f)); } -} // namespace gui -} // namespace ingen +} // namespace ingen::gui #endif // INGEN_GUI_RGBA_HPP diff --git a/src/gui/wscript b/src/gui/wscript deleted file mode 100644 index f2471933..00000000 --- a/src/gui/wscript +++ /dev/null @@ -1,127 +0,0 @@ -#!/usr/bin/env python - -import waflib.Utils as Utils -import waflib.Options as Options - - -def options(ctx): - opt = ctx.configuration_options() - opt.add_option('--light-theme', action='store_true', dest='light_theme', - help='use light coloured theme') - - -def configure(conf): - conf.check_pkg('glibmm-2.4 >= 2.14.0', - uselib_store='GLIBMM', - system=True, - mandatory=False) - conf.check_pkg('gthread-2.0 >= 2.14.0', - uselib_store='GTHREAD', - system=True, - mandatory=False) - conf.check_pkg('gtkmm-2.4 >= 2.14.0', - uselib_store='GTKMM', - system=True, - mandatory=False) - conf.check_pkg('ganv-1 >= 1.5.4', - uselib_store='GANV', - mandatory=False) - if not Options.options.no_webkit: - conf.check_pkg('webkit-1.0 >= 1.4.0', - uselib_store='WEBKIT', - system=True, - mandatory=False) - - if conf.env.HAVE_GANV and conf.env.HAVE_GTKMM: - conf.env.INGEN_BUILD_GUI = 1 - - if Options.options.light_theme: - conf.define('INGEN_USE_LIGHT_THEME', 1) - - -def build(bld): - obj = bld(features = 'cxx cxxshlib', - cflags = ['-fvisibility=hidden'], - export_includes = ['../../include'], - includes = ['../../', '../../include'], - name = 'libingen_gui', - target = 'ingen_gui', - install_path = '${LIBDIR}', - use = 'libingen libingen_client', - uselib = ''' - GANV - GLADEMM - GLIBMM - GNOMECANVAS - GTKMM - LILV - LV2 - RAUL - SIGCPP - SERD - SORD - SRATOM - SOUP - SUIL - WEBKIT - ''') - - obj.source = ''' - App.cpp - Arc.cpp - BreadCrumbs.cpp - ConnectWindow.cpp - GraphBox.cpp - GraphCanvas.cpp - GraphPortModule.cpp - GraphTreeWindow.cpp - GraphView.cpp - GraphWindow.cpp - LoadGraphWindow.cpp - LoadPluginWindow.cpp - MessagesWindow.cpp - NewSubgraphWindow.cpp - NodeMenu.cpp - NodeModule.cpp - ObjectMenu.cpp - PluginMenu.cpp - Port.cpp - PortMenu.cpp - PropertiesWindow.cpp - RDFS.cpp - RenameWindow.cpp - Style.cpp - SubgraphModule.cpp - ThreadedLoader.cpp - URIEntry.cpp - WidgetFactory.cpp - WindowFactory.cpp - ingen_gui.cpp - ''' - - # XML UI definition - bld(features = 'subst', - source = 'ingen_gui.ui', - target = '../../ingen_gui.ui', - install_path = '${DATADIR}/ingen', - chmod = Utils.O755, - INGEN_VERSION = bld.env.INGEN_VERSION) - - # Gtk style - bld(features = 'subst', - is_copy = True, - source = 'ingen_style.rc', - target = '../../ingen_style.rc', - install_path = '${DATADIR}/ingen', - chmod = Utils.O755) - - # LV2 UI - obj = bld(features = 'cxx cxxshlib', - cflags = ['-fvisibility=hidden'], - source = 'ingen_gui_lv2.cpp', - includes = ['.', '../../', '../../include'], - name = 'ingen_gui_lv2', - target = 'ingen_gui_lv2', - install_path = '${LV2DIR}/ingen.lv2/', - use = 'libingen libingen_gui', - uselib = 'LV2 SERD SORD SRATOM LILV RAUL GLIBMM GTKMM') |