UI trickz – how would you like to see this coded?

Home Forums General Programming UI trickz – how would you like to see this coded?

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • #72778
    human fly
    • Topics: 124
    • Replies: 1070
    • Total: 1194
    • ★★★★

    here’s a litte panel where i’ve been resolving a little UI thing.
    i’ve muddled through and got it working, overcoming some issues
    that came up – and i’ve got a couple of notions on how i will
    improve it next, but i just thought i’d chuck it out there. it’s
    basically a logic thing, and 2 sets of modulators interact. had
    to do it the ‘long way’ while i figured out how it worked, but
    i’m interested to see what you guys would do. the methods used
    are a bit horrorshow long 🙂 and if you look at the last couple
    of methods prefixed ‘temp’ you’ll see where i want to go with it.
    it’s all annotated, i think it should be reasonably clear:


    oops found a bug with it..there’s one situation where the
    led display is wrong. d*mn, thought i’d covered everything.
    if one partial button is off, and the other shows double,
    correctly, pulling down th level to zero does not change it
    to the correct display. not sure how/why yet.

    human fly
    • Topics: 124
    • Replies: 1070
    • Total: 1194
    • ★★★★

    ok fixed that, and am answering my own questions again,
    -in time-honoured tradition – so here’s the fix, and
    the method is much reduced also:


    learnt a lil’thing with this, creating functions locally 😀
    (that way i didn’t need duplicates of something created
    elsewhere, and just had to copy for the 2nd pair and just
    changed the modulator numbers at the top -hey i’m a noob,
    i get excited by these things..) yes, simplistic for youz,
    i know…

    human fly
    • Topics: 124
    • Replies: 1070
    • Total: 1194
    • ★★★★

    ok nobody’s into this yet.. i’ve reduced it quite a bit here,
    but the logic is still infantilistic (…) – i went further
    but was getting ahead of things, so here it’s just with
    ‘pre’-functions for the leds. i got the last version wrong,
    because i forgot getComponent(). it is still very long.


    are uiTabs ‘just’ components? i get no real benefit declaring
    and giving them an ‘alias’ here. and i still think i could do
    it as a single method to cover partialOnOff and ‘levelZero’.
    (don’t worry, you don’t have to get into this, it’s just my
    own log – it’s quite a neat UI device though. i like the use
    of text labels for leds instead of having to import graphics..)

    human fly
    • Topics: 124
    • Replies: 1070
    • Total: 1194
    • ★★★★

    (more newb’ observations on Lua)

    getModulatorByName or getComponent ?

    i noticed something here whilst doing this method.
    the ‘partialOps’ method was failing where the ‘leds’ were called,
    and i had to add ‘getComponent’ for each led entry.

    -whereas the same thing was working in the ‘levelZero’ methods,
    without ‘getComponent’

    looking at it again just now, i saw the cause for this:
    in ‘partialOps’ i’m declaring the led labeltexts using getModulatorByName,
    local ledA1 = panel:getModulatorByName("ledText1")
    but in the ‘levelZero’ methods, i went straight to getComponent,
    local ledA1 = panel:getComponent("ledText1")
    and it works just the same – and i didn’t need to use getComponent later,
    and could just refer to them directly by their declared names:
    ledA1:setProperty("uiLabelTextColour","FF00FF00", false)
    instead of:
    ledA1:getComponent():setProperty("uiLabelTextColour","FF00FF00", false)

    that makes sense, as i’m not interested in using these as ‘modulators’
    with a value, and they are slaves to the modulators they depend on.

    so now i should be able to have the little functions bothOn,doubleA/B, allOff
    in a preload ‘library’ method (like goodweather’s ‘miscellaneous’), and
    reduce the size of the other methods – still feel there must be ways of
    making the whole thing smaller.

    *edit*: yeah in fact this is a good example of the distinction
    between Modulators and Components: if the item is just a panel display
    object, where we don’t care about a value, it can be dealt with as a
    Component. Where the value is needed it is addressed as Modulator.

    Managed to reduce the methods a little bit like this. Mainly it makes
    things clearer to read, as well.
    *edit2* er, hold fire on that…am now not so sure about that
    statement about modulators/components: it returning nil for
    modulators as i have it currently.
    on the upside, it now looks as if i can get rid of the 2 levelZero
    methods altogether, as they are now covered by the main partialOps method
    -which i’ve managed to reduce from…49+kb 😀 back down to 18kb, which
    was the objective.

    • This reply was modified 4 years, 10 months ago by human fly. Reason: additional info
    • Topics: 45
    • Replies: 550
    • Total: 595
    • ★★★

    I started documenting this in the Step by Step guide 2.0…
    This is my interpretation but I must not be far from the truth 😉

    In a panel you insert components but they are encapsulated in parent objects called modulators.
    A Modulator has properties (modulator properties) and contains a Component object and a Midi object.
    The Component object has generic properties valid for all components and specific component properties depending on the component type (uiLbabel, uiButton…).
    The Midi object has midi properties.

    When you select an object from panel, you see the different properties sections in the right side column.

    In your example above, ledA1 is in the first case a modulator and in the second case a component.
    This means that in the second case you cannot reach the modulator properties directly and that in the first case you need to use getComponent() to go to the component level under the modulator.

    human fly
    • Topics: 124
    • Replies: 1070
    • Total: 1194
    • ★★★★

    yes yes 🙂 it was interesting to try this out, by trying
    to declare an ‘assign’ method just using Component: didn’t work.

    i did manage to combine my 2 method sides into a single method
    – by the time i’d finished the main ‘partialOps’, the other one
    wasn’t needed, i realised. so that was a success. but then i
    thought: what if i could pre-create the mini functions/local functions
    in a ‘miscellaneous’/’library’ type method, and call them from there?
    for this to be efficient, i’d need to pre-declare everything, in an
    ‘assign’ method.

    that has not been loading, so i looked at your DSI panel again, and
    saw that you call ‘assignModulators’ in your panel startup method.
    so i’ll try again later with that.

    but look at this, the current declarations (ha Mum, look no Modulators)
    – this works –

    function partialOps()
    	-- This stops issues during panel bootup
    	if panel:getRestoreState() == true or panel:getProgramState() == true 
    	then return end
    --note: now includes levelZero methods!
    --partials_onoff controls views and LEDs
    	local p1 = panel:getModulatorByName("Partial1_OnOff_Pt1"):getModulatorValue()
    	local p2 = panel:getModulatorByName("Partial2_OnOff_Pt1"):getModulatorValue()
    	local p3 = panel:getModulatorByName("Partial3_OnOff_Pt1"):getModulatorValue()
    	local p4 = panel:getModulatorByName("Partial4_OnOff_Pt1"):getModulatorValue()
    --tvaLevel zero is same as partial Off, AND with partial onoff
    	local l1 = panel:getModulatorByName("tvaLevel_p1pt1"):getModulatorValue()
    	local l2 = panel:getModulatorByName("tvaLevel_p2pt1"):getModulatorValue()
    	local l3 = panel:getModulatorByName("tvaLevel_p3pt1"):getModulatorValue()
    	local l4 = panel:getModulatorByName("tvaLevel_p4pt1"):getModulatorValue()
    --ledTextA 1st row//normal onoff//
    	local ledA1 = panel:getComponent("ledText1")
    	local ledA2 = panel:getComponent("ledText2")
    	local ledA3 = panel:getComponent("ledText3")
    	local ledA4 = panel:getComponent("ledText4")
    --ledTextB 2nd row//shows partial is at both inputs//
    	local ledB1 = panel:getComponent("ledText5")
    	local ledB2 = panel:getComponent("ledText6")
    	local ledB3 = panel:getComponent("ledText7")
    	local ledB4 = panel:getComponent("ledText8")
    --tab OnClick buttons//showhide with partial onoff
    	local p1click = panel:getComponent("tabP1OnClick")
    	local p2click = panel:getComponent("tabP2OnClick")
    	local p3click = panel:getComponent("tabP3OnClick")
    	local p4click = panel:getComponent("tabP4OnClick")
    --tab showhide
    	local tabsWGp1 = panel:getComponent("tabsWGp1pt1")
    	local tabsWGp2 = panel:getComponent("tabsWGp2pt1")
    	local tabsWGp3 = panel:getComponent("tabsWGp3pt1")
    	local tabsWGp4 = panel:getComponent("tabsWGp4pt1")

    and then:

    -- 1st pair
    	function doubleA1()
    	ledA1:setProperty("uiLabelTextColour","FF00FF00", false) --on
    	ledB1:setProperty("uiLabelTextColour","FFD28008", false) --on
    	ledA2:setProperty("uiLabelTextColour","FF0E2B01", false) --off
    	ledB2:setProperty("uiLabelTextColour","FF0E2B01", false) --off
    	function doubleB1()
    	ledA1:setProperty("uiLabelTextColour","FF0E2B01", false) --off
    	ledB1:setProperty("uiLabelTextColour","FF0E2B01", false) --off
    	ledA2:setProperty("uiLabelTextColour","FF00FF00", false) --on
    	ledB2:setProperty("uiLabelTextColour","FFD28008", false) --on
    	function allOff1()
    	ledA1:setProperty("uiLabelTextColour","FF0E2B01", false) --off
    	ledB1:setProperty("uiLabelTextColour","FF0E2B01", false) --off
    	ledA2:setProperty("uiLabelTextColour","FF0E2B01", false) --off
    	ledB2:setProperty("uiLabelTextColour","FF0E2B01", false) --off
    	function bothOn1()
    	ledA1:setProperty("uiLabelTextColour","FF00FF00", false) --on
    	ledB1:setProperty("uiLabelTextColour","FF0E2B01", false) --off
    	ledA2:setProperty("uiLabelTextColour","FF00FF00", false) --on
    	ledB2:setProperty("uiLabelTextColour","FF0E2B01", false) --off

    and then a load of options like this (the 16 configs 0000-1111):

    -- 1 --bin0001//only checkp1, p2 is off,no need to compare 2nd pair, p3 and p4 are off//
    	elseif p1 == 1 and p2 == 0 and p3 == 0 and p4 == 0 then
    	panel:sendMidiMessageNow(CtrlrMidiMessage({0xf0, 0x41, 0x10, 0x16, 0x12, 0x04, 0x00, 0x0c, 0x01, 0x6f, 0xf7}))		
    		if		l1 ~= 0 then doubleA1()	allOff2()
    		elseif	l1 == 0 then allOff1()	allOff2()
    	p1click:setProperty("uiButtonTextColourOff","FF1291DF", false)
    	p2click:setProperty("uiButtonTextColourOff","FF0E2B01", false)
    	p3click:setProperty("uiButtonTextColourOff","FF0E2B01", false)
    	p4click:setProperty("uiButtonTextColourOff","FF0E2B01", false)

    which is looking ok to me 😀 .. better if i can work in those other
    actions, but ok for now, and much reduced. note that i don’t mention
    Modulator for any of the label text modulators, i go straight to

    human fly
    • Topics: 124
    • Replies: 1070
    • Total: 1194
    • ★★★★

    the good thing about this form for my panel is that if i need
    to do it again for 7 other D110 parts, all i have to do is amend
    a few number characters in the declarations and the rest can remain
    the same, if it is all local.

    (i am just musing that there is probably some logic trick
    where i can compare those local subfunctions – um but i don’t
    think i want to go there lol, it’s working, and i still have
    a lot more to do on the main panel if it is ever going to be

    here’s the demo panel file (no resources needed 211kb)

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘Programming’ is closed to new topics and replies.
There is currently 0 users and 56 guests online
No users are currently active
Forum Statistics
Threads: 2,495, Posts: 17,374, Members: 77,605
Most users ever online was 12 on January 22, 2019 3:47 pm