+/* ****************************************************************************
+ * Control Interaction (encoder)
+ */
+
+void
+FaderPort8::handle_encoder_pan (int steps)
+{
+ boost::shared_ptr<Stripable> s = first_selected_stripable();
+ if (s) {
+ boost::shared_ptr<AutomationControl> ac;
+ if (shift_mod () || _ctrls.fader_mode() == ModePan) {
+ ac = s->pan_width_control ();
+ } else {
+ ac = s->pan_azimuth_control ();
+ }
+ if (ac) {
+ ac->start_touch (ac->session().transport_frame());
+ if (steps == 0) {
+ ac->set_value (ac->normal(), PBD::Controllable::UseGroup);
+ } else {
+ double v = ac->internal_to_interface (ac->get_value());
+ v = std::max (0.0, std::min (1.0, v + steps * .01));
+ ac->set_value (ac->interface_to_internal(v), PBD::Controllable::UseGroup);
+ }
+ }
+ }
+}
+
+void
+FaderPort8::handle_encoder_link (int steps)
+{
+ if (_link_control.expired ()) {
+ return;
+ }
+ boost::shared_ptr<AutomationControl> ac = boost::dynamic_pointer_cast<AutomationControl> (_link_control.lock ());
+ if (!ac) {
+ return;
+ }
+
+ double v = ac->internal_to_interface (ac->get_value());
+ ac->start_touch (ac->session().transport_frame());
+
+ if (steps == 0) {
+ ac->set_value (ac->normal(), PBD::Controllable::UseGroup);
+ return;
+ }
+
+ if (ac->desc().toggled) {
+ v = v > 0 ? 0. : 1.;
+ } else if (ac->desc().integer_step) {
+ v += steps / (1.f + ac->desc().upper - ac->desc().lower);
+ } else if (ac->desc().enumeration) {
+ ac->set_value (ac->desc().step_enum (ac->get_value(), steps < 0), PBD::Controllable::UseGroup);
+ return;
+ } else {
+ v = std::max (0.0, std::min (1.0, v + steps * .01));
+ }
+ ac->set_value (ac->interface_to_internal(v), PBD::Controllable::UseGroup);
+}
+
+