Jump to content


Photo

VB hacks - toggle buttons


  • Please log in to reply
2 replies to this topic

#1 joule

joule

    Guruh Motha Fakka is Levitating and Knows Everything About Renoise Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPip
  • 1445 posts
  • Gender:Not Telling
  • Location:Sweden
  • Interests:music, philosophy, engineering

Posted 01 June 2017 - 17:16

I just thought I share an example of how to make toggle buttons by using some ViewBuilder tricks. Both text button toggles or bitmap toggles can be made this way.
 
They look and behave pretty decent, but they are indeed not "100%". Inversed font colors and mouse-over highlights will misbehave, but in a way that in most cases shouldn't be too disturbing (depending on your theme).
 
Here is some code to show the principle. Feel free to make a proper class out of it if you find it useful :)

Spoiler


Gifanim:

toggles.gif

#2 Raul (ulneiz)

Raul (ulneiz)

    Guruh Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPip
  • 937 posts
  • Gender:Male
  • Location:Spain

Posted 06 June 2017 - 17:59

Very interesting. I use a very different method. I simply use a hidden checkbox to be able to change the color of the button. Actually, the intention is to be able to replace the checkbox with a button with its characteristics, colors, bitmap, text ... That way you do not have to name the checkbox outside. Using just one button, it takes up less space. Only you will have a hidden checkbox working.
 
Lately I have been able to build a virtual piano with buttons with the original look of the piano, with the keys superimposed correctly. If I have time I will share it, since I have not seen something like that in the forums...
 
I love all these tricks, thanks!!!

:excl: Development of my tool: GT16-Colors

 

:excl: My API wishlist R3.1 (updated 24 July 2017):

Spoiler

 

:excl: My Renoise 3.1 wishlist (updated 18 July 2017):

Spoiler

#3 joule

joule

    Guruh Motha Fakka is Levitating and Knows Everything About Renoise Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPip
  • 1445 posts
  • Gender:Not Telling
  • Location:Sweden
  • Interests:music, philosophy, engineering

Posted 06 June 2017 - 18:18

I don't think there is any other way than the above (or fetching/parsing renoise preferences) to build a toggle button with the correct active color. Or maybe that's what you meant?

 

I'm guessing that you use the checkbox notifier and then set "checkbox.value == true" as a trigger for this function? Kind of like an invisible relay to do other stuff?

 

If that's the case, I recommend using Document observables instead. Using GUI elements for this is not the 'clean way' of doing it ;)

 

Something like the below can be very handy if you want to trigger the same function in several different ways (i e from several different places). Also note in the Documents API that there are other observable document types.

local do_something = renoise.Document.ObservableBang()

do_something:add_notifier(
function()
  print("the do_something object was banged! anything can happen here.")
end
)

do_something:bang()


Edited by joule, 06 June 2017 - 18:23.