<Transform> "less than" "more than" "equals" types

Bug #1376277 reported by Sergey Ukolov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mixxx
Fix Released
Wishlist
Daniel Schürmann

Bug Description

Requesting new Transforms with boolean output for programming skin logics. This Transforms should compare input value with given in parameters and output boolean value - 1 or 0.

Example:
we have 3 on input and with
<Transform>
        <lessthan>4</lessthan>
</Transform>
we got 1 on output.

With
<Transform>
        <morethan>4</morethan>
</Transform>
we got 0.

Absolutely not critical request, but can save much time on building custom widgets.

Max Linke (max-linke)
Changed in mixxx:
importance: Undecided → Wishlist
status: New → Confirmed
Revision history for this message
RJ Skerry-Ryan (rryan) wrote :

One issue with <Transform> blocks is that they need to be reversible for bi-directional links. That's why it's only add and invert right now. We can add non-invertible transforms but the skinner will need to understand the implications when used in a bi-directional connection.

Revision history for this message
Daniel Schürmann (daschuer) wrote :

Can you explain you use case a bit more?

Do you need it for something like this:

<Connection>
  <ConfigKey>[Master],num_decks</ConfigKey>
  <Transform>
    <lessthan>4</lessthan>
  </Transform>
  <BindProperty>visible</BindProperty>
</Connection>

The same could be achieved by

<Connection>
  <ConfigKey>[Master],num_decks</ConfigKey>
  <Transform>
    <Invert/>
    <Add>4</Add>
  </Transform>
  <BindProperty>visible</BindProperty>
</Connection>

if we change the property conversion
to
if (value > 0 ) {
    visible = true;
}
Around here:
https://github.com/mixxxdj/mixxx/blob/38dcd763c2ffc46e6958ca687a8a83e928059c4d/src/widget/controlwidgetconnection.cpp#L124

Revision history for this message
Sergey Ukolov (zezic) wrote :

Yes, it needed for similar thing.
I made 3-position switch of mix orientation, for example (it checks 0, 1 or 2 input), and, yes, it's construction could be simplier if we have (value > 0 ) instead of (value != 0).

Revision history for this message
RJ Skerry-Ryan (rryan) wrote :

Converting it to bool means you can't use a transformation to bind a control to a numeric property. I'd rather add an explicit comparison transform even if it's non-invertible. We can add documentation about not using that on a two-way connection.

Revision history for this message
Daniel Schürmann (daschuer) wrote :

What about this?

void ControlWidgetPropertyConnection::slotControlValueChanged(double v) {
    QVariant parameter;
    QWidget* pWidget = m_pWidoget->toQWidget();
    QVariant property = pWidget->getProperty(m_propertyName.constData());
    if (property.Type() == QMetaType::Bool) {
            parameter = getControlParameterForValue(v) > 0;
    } else {
            parameter = getControlParameterForValue(v);
    }

    if (!pWidget->setProperty(m_propertyName.constData(),
                  vParameter)) {
            qDebug() << "Setting property" << m_propertyName
                    << "to widget failed. Value:" << dParameter;
        }
    }
}

Revision history for this message
RJ Skerry-Ryan (rryan) wrote :

Hm, works for me. It might be clearer to a first-time reader of the XML what is going on with explicit <GreaterThan> <LessThan> etc.

Revision history for this message
Daniel Schürmann (daschuer) wrote :

Yes, of cause but this does not suffer the back conversion issue.
I am exited if my code works.

Revision history for this message
Daniel Schürmann (daschuer) wrote :
Changed in mixxx:
assignee: nobody → Daniel Schürmann (daschuer)
milestone: none → 1.12.0
status: Confirmed → Fix Committed
RJ Skerry-Ryan (rryan)
Changed in mixxx:
status: Fix Committed → Fix Released
Revision history for this message
Swiftb0y (swiftb0y) wrote :

Mixxx now uses GitHub for bug tracking. This bug has been migrated to:
https://github.com/mixxxdj/mixxx/issues/7590

lock status: Metadata changes locked and limited to project staff
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.