Skip to content

Commit f7771d5

Browse files
committed
wip
1 parent a6f93b7 commit f7771d5

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

devel/201_37.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
+**2025/12/26 图片悬浮菜单渲染修复** 这次修复之前,会有这样的情况:先出现了一个菜单,然后菜单消失,又出现了一个尺寸与先前不同的菜单。注意!!这个过程很短暂,需要将鼠标尽可能的接近像素级移入图片,如果移动足够缓慢,甚至可以看到先出现的菜单一直停留在页面上,直到再次移动鼠标
1717
+ 修复之后,期望鼠标移入图片范围后,菜单仅出现一次,且出现的菜单尺寸是经过调整的,与当前页面缩放相适应
1818

19+
## 2025/12/27 修复悬停菜单位置偏移问题
20+
### What
21+
悬停菜单位置偏移,和使用 autoSize () 的位置有关系
1922

2023
## 2025/12/27 修改图标
2124
### What

src/Plugins/Qt/QTMImagePopup.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,12 @@ void
9292
QTMImagePopup::showImagePopup (rectangle selr, double magf, int scroll_x,
9393
int scroll_y, int canvas_x) {
9494
cachePosition (selr, magf, scroll_x, scroll_y, canvas_x);
95-
if (cached_magf <= 0.16) {
96-
setFixedSize (0, 0);
97-
return;
98-
}
9995
hide ();
100-
autoSize ();
10196
int x, y;
10297
getCachedPosition (x, y);
10398
QPoint topLeft (x, y);
10499
move (topLeft);
100+
autoSize ();
105101
raise ();
106102
updateButtonStates ();
107103
show ();
@@ -144,7 +140,7 @@ QTMImagePopup::autoSize () {
144140
const int baseHeight= 50;
145141
double totalScale= Scale * cached_magf * 3.3;
146142
#if defined(Q_OS_MAC)
147-
const int IconSize= int (50 * Scale);
143+
const int IconSize= int (80 * totalScale);
148144
#else
149145
const int IconSize= int (40 * totalScale);
150146
#endif
@@ -172,10 +168,16 @@ QTMImagePopup::cachePosition (rectangle selr, double magf, int scroll_x,
172168
// 计算菜单显示位置
173169
void
174170
QTMImagePopup::getCachedPosition (int& x, int& y) {
175-
x= ((cached_image_mid_x - cached_scroll_x - 500) * cached_magf +
176-
cached_canvas_x) /
177-
256 -
178-
(this->width () / 2);
179-
y= -((cached_image_mid_y - 5000 - cached_scroll_y) * cached_magf) / 256 -
180-
this->height () * 1.2;
171+
// 坐标转换:TeXmacs坐标 → 屏幕坐标
172+
173+
// x坐标
174+
double image_center_screen_x=
175+
((cached_image_mid_x - cached_scroll_x) * cached_magf + cached_canvas_x) /
176+
256.0;
177+
x= (int) (image_center_screen_x - (this->width () / 2.0));
178+
179+
// y坐标
180+
double image_center_screen_y=
181+
-((cached_image_mid_y - cached_scroll_y) * cached_magf) / 256.0;
182+
y= (int) (image_center_screen_y - (this->height () / 4.0));
181183
}

0 commit comments

Comments
 (0)