Vidvox / oscqueryhtml

MIT License
14 stars 1 forks source link

Toggle button data types #44

Closed mrRay closed 6 years ago

mrRay commented 6 years ago

hey dustin- sorry man, another last-minute change to throw at you: could you please make it so the T and F data types can be used interchangeably and present as toggle buttons?

this is a decidedly grey area of the OSC spec- T and F are supposed to be valueless data types, but some apps use them as toggles, so after much discussion we'd like to start pretending that they're values/toggles, too.

for example, this is an OSC method that would respond to either a T or an F. it doesn't have a VALUE yet, which means if something queried it, i think we'd expect it to return an OSC "T" (which is represented as a JSON boolean 'false').

{
    "TYPE": "T",
    "FULL_PATH": "/asdf"
}

...it may also present like this, even though it hasn't technically received a value yet (just assume that the default value is "true" because its type is "T"- if this was an "F" that'd be "false").

{
    "TYPE": "T",
    "FULL_PATH": "/asdf",
    "VALUE": [
        true
    ]
}

...if we then send an OSC "F" to this method, it would look like this (you'd actually have to return an OSC value of type F, even though the type tag string of this method is "T"):

{
    "TYPE": "T",
    "FULL_PATH": "/asdf",
    "VALUE": [
        false
    ]
}

additional notes:

dustmop commented 6 years ago

Changes 426a03..648c86 change how T, F, and i (with 2 values) types work so that all three render as buttons, and clicking them changes to their other value.

Is using a button for a two-valued toggle control okay?

There's still a problem with T and F type controls: the osc.js library I'm using does not respect values send as args for T and F; it always assumes they are true and false. I'll have to fork the library and modify it to get around this limitation.

mrRay commented 6 years ago

"There's still a problem with T and F type controls: the osc.js library I'm using does not respect values send as args for T and F; it always assumes they are true and false. I'll have to fork the library and modify it to get around this limitation."

i think there's a small misunderstanding here- from what i can see in that commit, you do not need to fork the osc lib.

"T" and "F" are valueless data types. they aren't two different values for the same data type (it's not a 'bool'- instead T and F are technically different data types). there are historic reasons for this, but the fallout is that unlike most other data types (like "i" and "f" etc etc etc), "T"/"F" do not have an associated data payload in an OSC message- they don't have a value. instead, the value is meant to be inferred from the data type. to that extent, what you're describing sounds totally fine!

right now, in commit 648c86cf6692213a56415cb822572d0b37e14b73, every time i click on, for example, "/test/my_false", it sends an OSC message with the type tag string "F". it just needs to alternate between sending a message with the type tag string "T" when the control is on and "F" when the control is off, and i think this issue will be closed?

dustmop commented 6 years ago

Ah, I see, I did misunderstand. I also think I was mixed up, confusing the values in OSCQuery json with OSC messages. That's a much easier change then, thanks for clearing it up!

dustmop commented 6 years ago

Fixed by 4812173a, and thanks to 3447df3 now a class "enabled" is added to the button when enabled.

dustmop commented 6 years ago

One final part I'm missing: if the value of the button is the non-default value when the app loads, it should add the "enabled" class. Currently that is not happening. Just leaving myself a note for later.

dustmop commented 6 years ago

Added the "enabled" class at built-time in c5a553b.