From 4ef41be9596cf997cd80175cfc7de2074a182d0d Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 1 Aug 2020 15:20:45 +0200 Subject: Use auto with casts and allocations to remove redundancy --- src/gui/GraphBox.cpp | 8 ++++---- src/gui/GraphCanvas.cpp | 26 +++++++++++++------------- src/gui/GraphPortModule.cpp | 4 ++-- src/gui/GraphTreeWindow.cpp | 2 +- 4 files changed, 20 insertions(+), 20 deletions(-) (limited to 'src/gui') diff --git a/src/gui/GraphBox.cpp b/src/gui/GraphBox.cpp index 7856932d..e457dfd8 100644 --- a/src/gui/GraphBox.cpp +++ b/src/gui/GraphBox.cpp @@ -426,7 +426,7 @@ GraphBox::show_status(const ObjectModel* model) show_port_status(port, port->value()); } else if ((block = dynamic_cast(model))) { - const PluginModel* plugin = dynamic_cast(block->plugin()); + const auto* plugin = dynamic_cast(block->plugin()); if (plugin) { msg << fmt(" (%1%)", plugin->human_name()); } @@ -442,7 +442,7 @@ GraphBox::show_port_status(const PortModel* port, const Atom& value) const BlockModel* parent = dynamic_cast(port->parent().get()); if (parent) { - const PluginModel* plugin = dynamic_cast(parent->plugin()); + const auto* plugin = dynamic_cast(parent->plugin()); if (plugin) { const std::string& human_name = plugin->port_human_name(port->index()); if (!human_name.empty()) { @@ -681,8 +681,8 @@ GraphBox::event_export_image() } } - Gtk::CheckButton* bg_but = new Gtk::CheckButton("Draw _Background", true); - Gtk::Alignment* extra = new Gtk::Alignment(1.0, 0.5, 0.0, 0.0); + auto* bg_but = new Gtk::CheckButton("Draw _Background", true); + auto* extra = new Gtk::Alignment(1.0, 0.5, 0.0, 0.0); bg_but->set_active(true); extra->add(*Gtk::manage(bg_but)); extra->show_all(); diff --git a/src/gui/GraphCanvas.cpp b/src/gui/GraphCanvas.cpp index bb60caa5..969c3849 100644 --- a/src/gui/GraphCanvas.cpp +++ b/src/gui/GraphCanvas.cpp @@ -265,12 +265,12 @@ show_module_human_names(GanvNode* node, void* data) bool b = *static_cast(data); if (GANV_IS_MODULE(node)) { Ganv::Module* module = Glib::wrap(GANV_MODULE(node)); - NodeModule* nmod = dynamic_cast(module); + auto* nmod = dynamic_cast(module); if (nmod) { nmod->show_human_names(b); } - GraphPortModule* pmod = dynamic_cast(module); + auto* pmod = dynamic_cast(module); if (pmod) { pmod->show_human_names(b); } @@ -292,7 +292,7 @@ ensure_port_labels(GanvNode* node, void* data) if (GANV_IS_MODULE(node)) { Ganv::Module* module = Glib::wrap(GANV_MODULE(node)); for (Ganv::Port* p : *module) { - ingen::gui::Port* port = dynamic_cast(p); + auto* port = dynamic_cast(p); if (port) { port->ensure_label(); } @@ -393,7 +393,7 @@ GraphCanvas::get_port_view(const SPtr& port) // Port on this graph if (module) { - GraphPortModule* ppm = dynamic_cast(module); + auto* ppm = dynamic_cast(module); return ppm ? *ppm->begin() : dynamic_cast(module); @@ -401,7 +401,7 @@ GraphCanvas::get_port_view(const SPtr& port) module = dynamic_cast(_views[port->parent()]); if (module) { for (auto* p : *module) { - gui::Port* pv = dynamic_cast(p); + auto* pv = dynamic_cast(p); if (pv && pv->model() == port) { return pv; } @@ -437,7 +437,7 @@ GraphCanvas::disconnection(const SPtr& arc) if (tail && head) { remove_edge_between(tail, head); if (arc->head()->is_a(_app.uris().lv2_AudioPort)) { - gui::Port* const h = dynamic_cast(head); + auto* const h = dynamic_cast(head); if (h) { h->activity(_app.forge().make(0.0f)); // Reset peaks } @@ -572,12 +572,12 @@ destroy_node(GanvNode* node, void* data) App* app = static_cast(data); Ganv::Module* module = Glib::wrap(GANV_MODULE(node)); - NodeModule* node_module = dynamic_cast(module); + auto* node_module = dynamic_cast(module); if (node_module) { app->interface()->del(node_module->block()->uri()); } else { - GraphPortModule* port_module = dynamic_cast(module); + auto* port_module = dynamic_cast(module); if (port_module && strcmp(port_module->port()->path().symbol(), "control") && strcmp(port_module->port()->path().symbol(), "notify")) { @@ -612,18 +612,18 @@ GraphCanvas::destroy_selection() static void serialise_node(GanvNode* node, void* data) { - Serialiser* serialiser = static_cast(data); + auto* serialiser = static_cast(data); if (!GANV_IS_MODULE(node)) { return; } Ganv::Module* module = Glib::wrap(GANV_MODULE(node)); - NodeModule* node_module = dynamic_cast(module); + auto* node_module = dynamic_cast(module); if (node_module) { serialiser->serialise(node_module->block()); } else { - GraphPortModule* port_module = dynamic_cast(module); + auto* port_module = dynamic_cast(module); if (port_module) { serialiser->serialise(port_module->port()); } @@ -633,12 +633,12 @@ serialise_node(GanvNode* node, void* data) static void serialise_arc(GanvEdge* arc, void* data) { - Serialiser* serialiser = static_cast(data); + auto* serialiser = static_cast(data); if (!GANV_IS_EDGE(arc)) { return; } - gui::Arc* garc = dynamic_cast(Glib::wrap(GANV_EDGE(arc))); + auto* garc = dynamic_cast(Glib::wrap(GANV_EDGE(arc))); if (garc) { serialiser->serialise_arc(Sord::Node(), garc->model()); } diff --git a/src/gui/GraphPortModule.cpp b/src/gui/GraphPortModule.cpp index a80afe57..27babbfd 100644 --- a/src/gui/GraphPortModule.cpp +++ b/src/gui/GraphPortModule.cpp @@ -65,8 +65,8 @@ GraphPortModule::GraphPortModule(GraphCanvas& canvas, GraphPortModule* GraphPortModule::create(GraphCanvas& canvas, const SPtr& model) { - GraphPortModule* ret = new GraphPortModule(canvas, model); - Port* port = Port::create(canvas.app(), *ret, model, true); + auto* ret = new GraphPortModule(canvas, model); + Port* port = Port::create(canvas.app(), *ret, model, true); ret->set_port(port); if (model->is_numeric()) { diff --git a/src/gui/GraphTreeWindow.cpp b/src/gui/GraphTreeWindow.cpp index dd80c906..f3d77c76 100644 --- a/src/gui/GraphTreeWindow.cpp +++ b/src/gui/GraphTreeWindow.cpp @@ -50,7 +50,7 @@ GraphTreeWindow::GraphTreeWindow(BaseObjectType* cobject, _graphs_treeview->append_column(*name_col); _graphs_treeview->append_column(*enabled_col); - Gtk::CellRendererToggle* enabled_renderer = dynamic_cast( + auto* enabled_renderer = dynamic_cast( _graphs_treeview->get_column_cell_renderer(1)); enabled_renderer->property_activatable() = true; -- cgit v1.2.1