fix: 兼容非滚动面板颜色节点 (#155)
This commit is contained in:
@@ -1545,13 +1545,20 @@ class PddCollectService:
|
||||
if not candidates:
|
||||
return []
|
||||
|
||||
widest = max(item.bounds[2] - item.bounds[0] for item in candidates)
|
||||
minimum_width = max(48, int(widest * 0.6))
|
||||
complete = [
|
||||
item
|
||||
for item in candidates
|
||||
if item.bounds[2] - item.bounds[0] >= minimum_width
|
||||
]
|
||||
parents = {child: parent for parent in root.iter() for child in parent}
|
||||
non_scrollable_panel = _find_non_scrollable_spec_panel(root, parents)
|
||||
if non_scrollable_panel is not None:
|
||||
# 新版面板会按文字长度设置按钮宽度。它没有横向滚动视口,
|
||||
# 短按钮不代表被屏幕边缘截断,因此保留所有安全范围内的节点。
|
||||
complete = candidates
|
||||
else:
|
||||
widest = max(item.bounds[2] - item.bounds[0] for item in candidates)
|
||||
minimum_width = max(48, int(widest * 0.6))
|
||||
complete = [
|
||||
item
|
||||
for item in candidates
|
||||
if item.bounds[2] - item.bounds[0] >= minimum_width
|
||||
]
|
||||
complete.sort(key=lambda item: ((item.bounds[1] + item.bounds[3]) // 2, item.bounds[0]))
|
||||
|
||||
rows: list[list[VisibleSpecOption]] = []
|
||||
@@ -1610,6 +1617,7 @@ class PddCollectService:
|
||||
def _find_option_node(root: ET.Element, target: str) -> Optional[ET.Element]:
|
||||
parents = {child: parent for parent in root.iter() for child in parent}
|
||||
scrollables = [node for node in root.iter("node") if node.get("scrollable") == "true"]
|
||||
non_scrollable_panel = _find_non_scrollable_spec_panel(root, parents)
|
||||
right_edges = [
|
||||
bounds[2]
|
||||
for node in root.iter("node")
|
||||
@@ -1627,7 +1635,12 @@ class PddCollectService:
|
||||
continue
|
||||
if not 24 <= center_x <= screen_right - 24:
|
||||
continue
|
||||
if any(container in _ancestors(node, parents) for container in scrollables):
|
||||
ancestors = _ancestors(node, parents)
|
||||
in_scrollable = any(container in ancestors for container in scrollables)
|
||||
in_non_scrollable_panel = non_scrollable_panel is not None and (
|
||||
node is non_scrollable_panel or non_scrollable_panel in ancestors
|
||||
)
|
||||
if in_scrollable or in_non_scrollable_panel:
|
||||
return node
|
||||
return None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user