update clocks and video-frames at FPS
[ardour.git] / gtk2_ardour / processor_box.cc
index 9f5a8bddf36485d5849de673d394f56a661484a6..1f219352f79586a11204a5d2da87e0e9efb35a57 100644 (file)
 #include "gtk2ardour-config.h"
 #endif
 
+#ifdef COMPILER_MSVC
+#define rintf(x) round((x) + 0.5)
+#endif
+
 #include <cmath>
 #include <iostream>
 #include <set>
@@ -72,7 +76,6 @@
 #include "return_ui.h"
 #include "route_processor_selection.h"
 #include "send_ui.h"
-#include "utils.h"
 
 #include "i18n.h"
 
@@ -100,6 +103,7 @@ static const uint32_t midi_port_color = 0x960909FF; //Red
 ProcessorEntry::ProcessorEntry (ProcessorBox* parent, boost::shared_ptr<Processor> p, Width w)
        : _button (ArdourButton::led_default_elements)
        , _position (PreFader)
+       , _selectable(true)
        , _parent (parent)
        , _processor (p)
        , _width (w)
@@ -111,6 +115,7 @@ ProcessorEntry::ProcessorEntry (ProcessorBox* parent, boost::shared_ptr<Processo
        
        _button.set_diameter (3);
        _button.set_distinct_led_click (true);
+       _button.set_fallthrough_to_parent(true);
        _button.set_led_left (true);
        _button.signal_led_clicked.connect (sigc::mem_fun (*this, &ProcessorEntry::led_clicked));
        _button.set_text (name (_width));
@@ -468,7 +473,7 @@ ProcessorEntry::build_send_options_menu ()
        if (send) {
 
                items.push_back (CheckMenuElem (_("Link panner controls")));
-               CheckMenuItem* c = dynamic_cast<CheckMenuItem*> (&items.back ());
+               Gtk::CheckMenuItem* c = dynamic_cast<Gtk::CheckMenuItem*> (&items.back ());
                c->set_active (send->panner_shell()->is_linked_to_route());
                c->signal_toggled().connect (sigc::mem_fun (*this, &ProcessorEntry::toggle_panner_link));
 
@@ -1192,14 +1197,14 @@ ProcessorBox::leave_notify (GdkEventCrossing*)
        return false;
 }
 
-void
+bool
 ProcessorBox::processor_operation (ProcessorOperation op) 
 {
        ProcSelection targets;
 
        get_selected_processors (targets);
 
-       if (targets.empty()) {
+/*     if (targets.empty()) {
 
                int x, y;
                processor_display.get_pointer (x, y);
@@ -1210,12 +1215,20 @@ ProcessorBox::processor_operation (ProcessorOperation op)
                        targets.push_back (pointer.first->processor ());
                }
        }
+*/
 
+       if ( (op == ProcessorsDelete) && targets.empty() )
+               return false;  //nothing to delete.  return false so the editor-mixer, because the user was probably intending to delete something in the editor
+       
        switch (op) {
        case ProcessorsSelectAll:
                processor_display.select_all ();
                break;
 
+       case ProcessorsSelectNone:
+               processor_display.select_none ();
+               break;
+
        case ProcessorsCopy:
                copy_processors (targets);
                break;
@@ -1253,6 +1266,8 @@ ProcessorBox::processor_operation (ProcessorOperation op)
        default:
                break;
        }
+       
+       return true;
 }
 
 ProcessorWindowProxy* 
@@ -1298,6 +1313,12 @@ ProcessorBox::processor_button_press_event (GdkEventButton *ev, ProcessorEntry*
 
                ret = true;
 
+       } else if (Keyboard::is_context_menu_event (ev)) {
+
+               show_processor_menu (ev->time);
+               
+               ret = true;
+
        } else if (processor && ev->button == 1 && selected) {
 
                // this is purely informational but necessary for route params UI
@@ -1326,10 +1347,6 @@ ProcessorBox::processor_button_release_event (GdkEventButton *ev, ProcessorEntry
                                sigc::mem_fun(*this, &ProcessorBox::idle_delete_processor),
                                boost::weak_ptr<Processor>(processor)));
 
-       } else if (Keyboard::is_context_menu_event (ev)) {
-
-               show_processor_menu (ev->time);
-
        } else if (processor && Keyboard::is_button2_event (ev)
 #ifndef GTKOSX
                   && (Keyboard::no_modifier_keys_pressed (ev) && ((ev->state & Gdk::BUTTON2_MASK) == Gdk::BUTTON2_MASK))
@@ -1740,6 +1757,7 @@ ProcessorBox::add_processor_to_display (boost::weak_ptr<Processor> p)
        }
 
        boost::shared_ptr<PluginInsert> plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor);
+       
        ProcessorEntry* e = 0;
        if (plugin_insert) {
                e = new PluginInsertProcessorEntry (this, plugin_insert, _width);
@@ -1747,6 +1765,13 @@ ProcessorBox::add_processor_to_display (boost::weak_ptr<Processor> p)
                e = new ProcessorEntry (this, processor, _width);
        }
 
+       boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (processor);
+       boost::shared_ptr<PortInsert> ext = boost::dynamic_pointer_cast<PortInsert> (processor);
+       
+       //faders and meters are not deletable, copy/paste-able, so they shouldn't be selectable
+       if (!send && !plugin_insert && !ext)
+               e->set_selectable(false);
+
        /* Set up this entry's state from the GUIObjectState */
        XMLNode* proc = entry_gui_object_state (e);
        if (proc) {
@@ -2107,8 +2132,8 @@ ProcessorBox::paste_processor_state (const XMLNodeList& nlist, boost::shared_ptr
 
                                boost::shared_ptr<Pannable> sendpan(new Pannable (*_session));
                                XMLNode n (**niter);
-                                InternalSend* s = new InternalSend (*_session, sendpan, _route->mute_master(),
-                                                                   boost::shared_ptr<Route>(), Delivery::Aux); 
+                               InternalSend* s = new InternalSend (*_session, sendpan, _route->mute_master(),
+                                               _route, boost::shared_ptr<Route>(), Delivery::Aux);
 
                                IOProcessor::prepare_for_reset (n, s->name());