Set Layer Visibility via Combo Box

Home Forums General Programming Set Layer Visibility via Combo Box

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #12107
    auricle
    Participant
      • Topics: 2
      • Replies: 6
      • Total: 8

      Hello all,

      I’m totally new to programming and I’m trying to wrap my head around layer visibility to work for a panel I’m working on.

      I want to use a combo box to show/hide layers. So, if the first option is selected layer 1 is shown and the others hidden, if the second is selected then layer 2 is shown and the others hidden.

      Can anyone give me any ideas how to do this?

      Thank you.

      #12108
      zeoka
      Participant
        • Topics: 73
        • Replies: 466
        • Total: 539
        • ★★★

        I’m not remember the exact command in my head but for the “logic” :

        combval = Panel:getModulatorByName(“mycombno”):getModulatorValue

        mylayer1 = (the defintion i don’t remember,someting with “canvas” a property of the panel )
        mylayer2 = same thing
        mylayer3 = etc…..
        if comval == 1 then
        mylayer1:setPropertyInt(“layerVisibility”,1) (the difinition may be not exact)
        else
        mylayer1:setPropertyInt(“layerVisibility”,0)
        end
        if comval == 2 then
        mylayer2:setPropertyInt(“layerVisibility”,1) (the difinition may be not exact)
        else
        mylayer2:setPropertyInt(“layerVisibility”,0)
        end

        Etc….

        You must separate the condition in several ,instead of make 1 condition :
        if blah
        elseif blah
        elseif blah
        end

        See some panels to get the exact command or someoneelse will gives here

        Hope this helps a little…..

        • This reply was modified 10 years, 8 months ago by zeoka.
        • This reply was modified 10 years, 8 months ago by zeoka.
        • This reply was modified 10 years, 8 months ago by zeoka.
        #12112
        atom
        Keymaster
          • Topics: 159
          • Replies: 2945
          • Total: 3104
          • ★★★★★

          there is a demo panel that illustrates this

          #12137
          auricle
          Participant
            • Topics: 2
            • Replies: 6
            • Total: 8

            Thanks for your help, guys.

            Atom – I checked out the demo panel but the layers are switched from checkboxes not a combo boxes. The function used in the example relies on the component name – layerBlue, layerRed, etc to determine which layer to set visibility. I am not experienced enough to adapt this code to a combo box where I would need to change visibility depending on the value selected within the combo box.

            #12141
            atom
            Keymaster
              • Topics: 159
              • Replies: 2945
              • Total: 3104
              • ★★★★★

              I’ll modify the demo to include combo boxes.

              #12142
              auricle
              Participant
                • Topics: 2
                • Replies: 6
                • Total: 8

                Thanks Atom. I’d greatly appreciate that.

                #12161
                atom
                Keymaster
                  • Topics: 159
                  • Replies: 2945
                  • Total: 3104
                  • ★★★★★

                  I updated it in the SVN repo, here is the copy.

                  Attachments:
                  You must be logged in to view attached files.
                  #12163
                  drsteve
                  Participant
                    • Topics: 3
                    • Replies: 33
                    • Total: 36

                    Hi. I am still trying to learn whatever I can about ctrlr, so I downloaded this demo. What does this mean: “To see the layers demo make this layer invisible and make the layer ‘Layers Demo’ visible” and where does someone do that–making layers visible and invisible?

                    I see that you can select the Current tab by the combo box, by tabs themselves, or by the slider. That seems to be useful. Can different tabs have different devices assigned to them?

                    Thanks.

                    Steve

                    #12167
                    zeoka
                    Participant
                      • Topics: 73
                      • Replies: 466
                      • Total: 539
                      • ★★★

                      There is a space in the tab property “Called when the current tab in an uiTabs component is changed” where you can create a midi message by lua (it changes a label in the demo) when the current tab change…
                      Whatever you change the tabs by slider or tab or combo it will send a midi message for example

                      #12186
                      auricle
                      Participant
                        • Topics: 2
                        • Replies: 6
                        • Total: 8

                        I updated it in the SVN repo, here is the copy.

                        Thank you kindly, Atom. That’s perfect.

                        Just out of interest. Is it possible to use this ‘is component visible’ property of a Modulator to hide/show modulators instead of using layers?

                        #12189
                        atom
                        Keymaster
                          • Topics: 159
                          • Replies: 2945
                          • Total: 3104
                          • ★★★★★

                          You can use the property, or you can just set the visibility flag directly

                          c = panel:getModulatorByName("blah"):getComponent()
                          c:setVisible (true) -- visible
                          c:setVisible (false) -- invisible
                          
                          #12201
                          auricle
                          Participant
                            • Topics: 2
                            • Replies: 6
                            • Total: 8

                            Well I’m stuck. I can’t get it to work – I must be missing something. Would someone please take a look and tell me where I’m going wrong?

                            There are three layers. The Base layer which is static and two other layers which should be switched depending on whether ID 1 or 2 is selected (ID 0 should switch them both off). The combo box with the script is called Osc1Mode.

                            Any help would be great.

                            Attachments:
                            You must be logged in to view attached files.
                            #12205
                            atom
                            Keymaster
                              • Topics: 159
                              • Replies: 2945
                              • Total: 3104
                              • ★★★★★

                              I fixed it for you, you had some type-os and most important stuff, if you rename your modulators (and you did rename the combo that switches the layers) you need to remember that in the code, if you reference something by name

                              panel:getCombo(NAME)
                              

                              the NAME is the actual name of the combo you want to fetch

                              Attachments:
                              You must be logged in to view attached files.
                              #12207
                              auricle
                              Participant
                                • Topics: 2
                                • Replies: 6
                                • Total: 8

                                Thank you very much, Atom! I greatly appreciate it.

                              Viewing 14 posts - 1 through 14 (of 14 total)
                              • The forum ‘Programming’ is closed to new topics and replies.
                              There is currently 0 users and 81 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
                              Ctrlr