-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: added disable_elements
option and disable-elements
script message
#695
Conversation
…essage Allows disabling elements and various indicators by adding their IDs to the list: ```conf disable_elements=timeline,audio_indicator ``` Also includes a new script message listener `disable-elements`, that does the same thing: ```lua local id = mp.get_script_name() mp.commandv('script-message-to', 'uosc', 'disable-elements', id, 'timeline,audio_indicator') ``` It'll register what elements each script wants disabled. The element will be enabled only when it is not disabled by neither user nor any script. To cancel or re-enable the elements, just pass an empty list: ```lua mp.commandv('script-message-to', 'uosc', 'disable-elements', id, '') ``` ref #686, closes #592
Is it really necessary do destroy all disabled elements? I would have expected it to have some additional management around Sets in lua can be made with |
That But I'll simplify it a bit with a set. |
There is no need for |
diff --git a/scripts/uosc/lib/ass.lua b/scripts/uosc/lib/ass.lua
index 16ffb09..a9e742f 100644
--- a/scripts/uosc/lib/ass.lua
+++ b/scripts/uosc/lib/ass.lua
@@ -91,7 +91,7 @@ function ass_mt:tooltip(element, value, opts)
local x = element.ax + (element.bx - element.ax) / 2
local y = align_top and element.ay - offset or element.by + offset
local width_half = (opts.width_overwrite or text_width(value, opts)) / 2 + padding_x
- local min_edge_distance = width_half + opts.margin + Elements.window_border.size
+ local min_edge_distance = width_half + opts.margin + Elements:ev('window_border', 'size', 0)
x = clamp(min_edge_distance, x, display.width - min_edge_distance)
local ax, bx = round(x - width_half), round(x + width_half)
local ay = (align_top and y - opts.size * opts.lines - 2 * padding_y or y)
diff --git a/scripts/uosc/main.lua b/scripts/uosc/main.lua
index 2732717..a70b714 100644
--- a/scripts/uosc/main.lua
+++ b/scripts/uosc/main.lua
@@ -1297,7 +1297,7 @@ Manager = {
---@param element_ids string|string[]|nil `foo,bar` or `{'foo', 'bar'}`.
function Manager:disable(manager_id, element_ids)
self._disabled_by[manager_id] = comma_split(element_ids)
- self.disabled = make_set(itable_join(table.unpack(table_values(self._disabled_by))))
+ self.disabled = make_set(itable_join(unpack(table_values(self._disabled_by))))
self:_commit()
end |
I'll have a closer look at the code tomorrow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of having a hard coded number for render_order
in each element, we could have a static list with element ids and then use the index as the render_order
. That would make keeping track of what gets rendered in which order easier.
I don't like the idea of it being disjointed from the element's implementation on a new state config. It would make sense if elements were actually completely self contained entities oblivious about the outside world, but since they know about each other and use each other's states, I think it's fine for them to configure themselves like that in their Damn I wish I had time to rewrite it all. I don't like how the current element system and rendering works at all. |
It really wouldn't be that complicated. e.g. render_order_ids = {
'window_border',
'buffer_indicator',
...
}
function Element:init(id, props)
self.id = id
self.render_order = itable_index_of(render_order_ids, id)
... But if you'd rather have |
I looked into how events are propagated internally a while ago and I don't believe there is a way to get that info. |
We need to have the init passing of render_order anyway, since bunch of elements need to inherit their parent order (control buttons/speed, volume slider). |
That's only necessary in those few instances and those two things are not mutually exclusive. |
Allows disabling elements and various indicators by adding their IDs to the list:
Also includes a new script message listener
disable-elements
, that allows scripts to do the same thing:It'll register what elements each script wants disabled. The element will be enabled only when it was not disabled by neither user nor any script.
To cancel or re-enable the elements, pass an empty list:
ref #686, closes #592
This was way more work then I expected :(
I hope I didn't introduce many bugs.
Also, is it really not possible to get the name of a script that sent the message? We wouldn't need the
script_id
parameter on the message then.