Skip to content

Commit

Permalink
fix border problem
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkShawn2020 committed Dec 17, 2024
1 parent db33843 commit c149777
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
13 changes: 6 additions & 7 deletions src/TransparentOverlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,6 @@ def init_ui(self):
self.ensure_components_initialized() # Ensure components are initialized first
if self.image_manager.target_image is None:
self.geometry_manager.center_window()
else:
self.geometry_manager.update_geometry(
self.config["position"]["x"],
self.config["position"]["y"],
self.config["size"]["width"],
self.config["size"]["height"],
)

self.show()

Expand All @@ -134,6 +127,12 @@ def on_match_found(self, match_result):
x, y, w, h = [int(v / self.scale_factor) for v in match_result]
logger.debug(f"[on_match_found] 匹配结果: ({x}, {y}, {w}, {h})")

# 增加边框
x -= self.config.data.border.width
y -= self.config.data.border.width
w += self.config.data.border.width * 2
h += self.config.data.border.width * 2

# 更新匹配状态信息
self.last_match_info = (x, y, w, h)

Expand Down
4 changes: 2 additions & 2 deletions src/geometry_manager.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from PyQt6.QtWidgets import QApplication
from PyQt6.QtWidgets import QApplication, QWidget

from src.config import Config


class GeometryManager:
def __init__(self, widget, config: Config):
def __init__(self, widget: QWidget, config: Config):
self.widget = widget
self.config = config
self.border_width = config.data.border.width
Expand Down
4 changes: 2 additions & 2 deletions src/window_painter.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def paint(self, event):

# 绘制边框
rect = QRect(
self.border_width // 2,
self.border_width // 2,
self.border_width >> 1,
self.border_width >> 1,
self.widget.width() - self.border_width,
self.widget.height() - self.border_width,
)
Expand Down

0 comments on commit c149777

Please sign in to comment.