Skip to content

Instantly share code, notes, and snippets.

@ChrisK2
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisK2/739ce876df2119b43e28 to your computer and use it in GitHub Desktop.
Save ChrisK2/739ce876df2119b43e28 to your computer and use it in GitHub Desktop.
Documentation of the element table structure of the OSC
-- created by new_element()
element = {
type = "button" -- or "box" or "slider"
eventresponder = { -- eventhandlers
eventname = eventfunction,
},
visble = true, -- Should the element be visibale at all?
enabled = true, -- Should it be clickable?
softrepeat = false, -- Repeat the _down event when mouse is held down?
styledown = true, -- should the element change its style while the mouse is held down on it? for box and slider false
state = {}, -- table to store state data
hitbox = { -- coordinates of the hitbox, gets calculated from layout.geometry automatically
x1,
y1,
x2,
y2,
},
static_ass, -- stores static parts of the ASS tags, for internal use
-- if type is slider
slider = {
min = {
value = 0, -- value the slider represents at the left end
ele_pos, -- position of min.value in element drawing coordinates (gets calculated)
glob_pos, -- position of min.value in global canvas (mouse) coordinates (gets calculated)
},
max = {
value = 100, -- value the slider represents at the right end
ele_pos, -- posotion of max.value in element drawing coordinates (gets calculated)
glob_pos, -- position of max.value in global canvas (mouse) coordinates (gets calculated)
},
markerF, -- function that returns markers
posF, -- function that returns the current position
tooltipF, -- function that returns the tooltip
},
-- attached by add_layout()
layout = {
layer = 50, -- layer of the element, lower layers are rendered first
alpha = { -- alpha values of the element correstponding to ASS \a tags
[1] = 0,
[2] = 255,
[3] = 255,
[4] = 255,
},
style, -- ASS styles for the element
geometry = { -- geometry of the element
x, -- x position
y, -- y position
an, -- alignment, like \an ASS tag
w, -- width of the hitbox for mouse clicks, actual size for sliders and boxes
h, -- height of the hitbox for mouse clicks, actual size for sliders and boxes
},
-- if type is button
button = {
maxchars = nil, -- if the text in the button has more than maxchars, the text will be squeezed to the estimatd width of maxchars
},
-- if type is slider
slider = {
border = 1, -- outer border around the slider
gap = 1, -- gap between border and the slider indicator, also size of nibbles
nibbles_top = true, -- show nibbles at the top?
nibbles_bottom = true, -- show nibbles at the bottom?
stype = "slider", -- should it be displayed as a slider or as a progress bar?
adjust_tooltip = true, -- adjust the tooltip to not go bexond the left/right end of the slider
tooltip_style = "", -- ASS styles for the tooltip
tooltip_an = 2, -- position of the tooltip, 2 = above, 8 = below seekbar
},
-- if type is box
box = {
radius = 0, -- radius of the corners of the box
},
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment