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
Click to view contents
local vb = renoise.ViewBuilder()
local text_toggle_val = renoise.Document.ObservableBoolean(false)
local bitmap_toggle_val = renoise.Document.ObservableBoolean(true)
local bitmap_toggle = vb:checkbox {
width = 100,
height = 50,
value = true,
value = bitmap_toggle_val.value,
bind = bitmap_toggle_val
}
bitmap_toggle:add_child(
vb:vertical_aligner {
mode = "center",
width = 100,
vb:horizontal_aligner {
mode = "center",
vb:row {
margin = -2,
vb:column {
width = 98,
vb:row {
height = 48,
vb:checkbox {
active = false,
value = true,
width = 200,
height = 200,
value = bitmap_toggle_val.value,
bind = bitmap_toggle_val
}
}
}
}
}
}
)
bitmap_toggle:add_child(
vb:vertical_aligner {
mode = "center",
width = 100,
vb:horizontal_aligner {
mode = "center",
vb:bitmap {
bitmap = "Icons/TrackScope_M.bmp",
mode = "body_color",
notifier = function()
bitmap_toggle_val.value = not bitmap_toggle_val.value
end
}
}
}
)
local text_toggle = vb:checkbox {
width = 100,
height = 50,
value = text_toggle_val.value,
bind = text_toggle_val
}
text_toggle:add_child(
vb:vertical_aligner {
mode = "center",
width = 100,
vb:horizontal_aligner {
mode = "center",
vb:row {
margin = -2,
vb:column {
width = 98,
vb:row {
height = 48,
vb:checkbox {
active = false,
value = true,
width = 200,
height = 200,
value = text_toggle_val.value,
bind = text_toggle_val
}
}
}
}
}
}
)
text_toggle:add_child(
vb:vertical_aligner {
mode = "center",
width = 100,
vb:horizontal_aligner {
mode = "center",
vb:text {
text = "Toggle Button",
}
}
}
)
local presentation = vb:row {
margin = 20,
spacing = 30,
vb:column {
vb:text {
text = "Text toggle",
align = "center",
width = 100,
},
text_toggle,
},
vb:column {
vb:text {
text = "Bitmap toggle",
align = "center",
width = 100,
},
bitmap_toggle,
},
vb:column {
vb:text {
text = "Normal vb:button",
align = "center",
width = 100,
},
vb:button {
text = "Normal button",
width = 100,
height = 50,
}
}
}
return presentation
Gifanim: