You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However since the playlist buttons are more of a "sidebar", they are not inside osc_geo which in the box around the bottom controls. So the mouse events are ignored. In order to handle mouse events we need to create another area (like the window buttons).
layout["tethys"] =function()
add_area("pl-entries", plBox.x, plBox.y, plBox.x+plBox.w, plBox.y+plBox.h)
...functionrender()
ifosc_param.areas["pl-entries"] thenfor_,cordsinipairs(osc_param.areas["pl-entries"]) doifstate.osc_visiblethen-- activate only when OSC is actually visibleset_virt_mouse_area(cords.x1, cords.y1, cords.x2, cords.y2, "pl-entries")
endifstate.osc_visible~=state.input_enabledthenifstate.osc_visiblethenmp.enable_key_bindings("pl-entries")
elsemp.disable_key_bindings("pl-entries")
endstate.input_enabled=state.osc_visibleendif (mouse_hit_coords(cords.x1, cords.y1, cords.x2, cords.y2)) thenmouse_over_osc=trueendendend...-- near bottom of filemp.set_key_bindings({
{"mbtn_left", function(e) process_event("mbtn_left", "up") end,
function(e) process_event("mbtn_left", "down") end},
}, "pl-entries", "force")
mp.enable_key_bindings("pl-entries")
...-- bottom of fileset_virt_mouse_area(0, 0, 0, 0, "pl-entries")
The hardest part so far, is trying to wrap text so both lines are used up properly. The methods I've tried so far:
Single Line (not long enough for filenames).
Two Lines, 2nd line is last 20 characters with an ellipsis. Basically ElideMiddle. Works well.
Two Lines (or more), attempt to calculate text metrics of a line of text. Wrapping text after a little a certain amount of pixels. I calculated the character width ratio based on the height by opening all the NotoSans characters in FontForge and grabbing the width ~600. I then assumed the character height is 800 + 200 (above) + 200 (below) = 1200. So each character has a roughly 600/1200 width:height ratio. charWidth = fontSize * charWidthRatio.
While the text wrapping with TextMetrics was interesting to code, it doesn't work very well even when I try to assume the font is NotoSans-Regular. It'd probably look different on other OSes so it's not viable to merge to master. I'll be going with the ElideMiddle method.
The text was updated successfully, but these errors were encountered:
I've managed to create a new playlist list with the following dimensions. Each entry has 2 lines for the filename.
However since the playlist buttons are more of a "sidebar", they are not inside
osc_geo
which in the box around the bottom controls. So the mouse events are ignored. In order to handle mouse events we need to create another area (like the window buttons).The hardest part so far, is trying to wrap text so both lines are used up properly. The methods I've tried so far:
charWidth = fontSize * charWidthRatio
.While the text wrapping with TextMetrics was interesting to code, it doesn't work very well even when I try to assume the font is NotoSans-Regular. It'd probably look different on other OSes so it's not viable to merge to master. I'll be going with the ElideMiddle method.
The text was updated successfully, but these errors were encountered: