update
This commit is contained in:
@@ -36,7 +36,7 @@ end
|
||||
function Button:render()
|
||||
local visibility = self:get_visibility()
|
||||
if visibility <= 0 then return end
|
||||
cursor:zone('primary_down', self, function() self:handle_cursor_click() end)
|
||||
cursor:zone('primary_click', self, function() self:handle_cursor_click() end)
|
||||
|
||||
local ass = assdraw.ass_new()
|
||||
local is_clickable = self.is_clickable and self.on_click ~= nil
|
||||
|
||||
@@ -108,6 +108,7 @@ function Menu:init(data, callback, opts)
|
||||
self.opts = opts or {}
|
||||
self.offset_x = 0 -- Used for submenu transition animation.
|
||||
self.mouse_nav = self.opts.mouse_nav -- Stops pre-selecting items
|
||||
self.mouse_hovered_index = nil -- Current menu's item being hovered by mouse, ignoring it's selectable or not.
|
||||
self.item_height = nil
|
||||
self.min_width = nil
|
||||
self.item_spacing = 1
|
||||
@@ -700,7 +701,8 @@ end
|
||||
|
||||
---@param shortcut? Shortcut
|
||||
function Menu:handle_cursor_up(shortcut)
|
||||
if self.proximity_raw <= -self.padding and self.drag_last_y and not self.is_dragging then
|
||||
if self.proximity_raw <= -self.padding and self.drag_last_y and not self.is_dragging
|
||||
and self.mouse_hovered_index == self.current.selected_index then
|
||||
self:activate_selected_item(shortcut, true)
|
||||
end
|
||||
if self.is_dragging then
|
||||
@@ -1456,14 +1458,16 @@ function Menu:render()
|
||||
}
|
||||
|
||||
-- Select hovered item
|
||||
if is_current and self.mouse_nav and item.selectable ~= false
|
||||
-- Do not select items if cursor is moving towards a submenu
|
||||
and (not submenu_rect or not cursor:direction_to_rectangle_distance(submenu_rect))
|
||||
if is_current and self.mouse_nav
|
||||
and (submenu_is_hovered or get_point_to_rectangle_proximity(cursor, item_rect_hitbox) <= 0) then
|
||||
menu.selected_index = index
|
||||
if not is_selected then
|
||||
is_selected = true
|
||||
request_render()
|
||||
self.mouse_hovered_index = index
|
||||
-- Do not select items if cursor is moving towards a submenu
|
||||
if item.selectable ~= false and (not submenu_rect or not cursor:direction_to_rectangle_distance(submenu_rect)) then
|
||||
menu.selected_index = index
|
||||
if not is_selected then
|
||||
is_selected = true
|
||||
request_render()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1555,7 +1559,7 @@ function Menu:render()
|
||||
|
||||
-- Select action on cursor hover
|
||||
if self.mouse_nav and get_point_to_rectangle_proximity(cursor, rect) <= 0 then
|
||||
cursor:zone('primary_down', rect, self:create_action(function(shortcut)
|
||||
cursor:zone('primary_click', rect, self:create_action(function(shortcut)
|
||||
self:activate_selected_item(shortcut, true)
|
||||
end))
|
||||
blur_action_index = false
|
||||
|
||||
@@ -249,7 +249,7 @@ function TopBar:render()
|
||||
local button_fg = is_hover and (button.hover_fg or bg) or fg
|
||||
local button_bg = is_hover and (button.hover_bg or fg) or bg
|
||||
|
||||
cursor:zone('primary_down', rect, button.command)
|
||||
cursor:zone('primary_click', rect, button.command)
|
||||
|
||||
local bg_size = self.size - margin
|
||||
local bg_ax, bg_ay = rect.ax + (is_left and margin or 0), rect.ay + margin
|
||||
@@ -302,7 +302,7 @@ function TopBar:render()
|
||||
if left_aligned then title_bx = rect.ax - margin else title_ax = rect.bx + margin end
|
||||
|
||||
-- Click action
|
||||
cursor:zone('primary_down', rect, function() mp.command('script-binding uosc/playlist') end)
|
||||
cursor:zone('primary_click', rect, function() mp.command('script-binding uosc/playlist') end)
|
||||
end
|
||||
|
||||
-- Skip rendering titles if there's not enough horizontal space
|
||||
@@ -325,7 +325,7 @@ function TopBar:render()
|
||||
local title_rect = {ax = ax, ay = title_ay, bx = ax + rect_width, by = by}
|
||||
|
||||
if options.top_bar_alt_title_place == 'toggle' then
|
||||
cursor:zone('primary_down', title_rect, function() self:toggle_title() end)
|
||||
cursor:zone('primary_click', title_rect, function() self:toggle_title() end)
|
||||
end
|
||||
|
||||
ass:rect(title_rect.ax, title_rect.ay, title_rect.bx, title_rect.by, {
|
||||
@@ -415,7 +415,7 @@ function TopBar:render()
|
||||
|
||||
-- Click action
|
||||
rect.bx = time_bx
|
||||
cursor:zone('primary_down', rect, function() mp.command('script-binding uosc/chapters') end)
|
||||
cursor:zone('primary_click', rect, function() mp.command('script-binding uosc/chapters') end)
|
||||
|
||||
title_ay = rect.by + self.title_spacing
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user