Skip to content

Commit 8c548e8

Browse files
authored
[201_37] 页面滚动时菜单能够跟随滚动 (#2287)
1 parent caf84ac commit 8c548e8

File tree

5 files changed

+31
-0
lines changed

5 files changed

+31
-0
lines changed

devel/201_37.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
+ 将鼠标放在图片中,查看图片上方居中位置是否出现一个横向悬浮菜单
99
+ 在将鼠标移入图片范围内时,仔细查看是否出现了菜单位移的现象,期望不出现
1010
+ 测试左对齐、居中、右对齐按钮功能是否正常
11+
+ 弹出菜单后,上下滚动页面,菜单应始终保持在图片上方
12+
13+
## 2025/12/19 页面滚动时菜单能够跟随滚动
14+
15+
### What
16+
之前页面滚动时菜单会固定在屏幕上原来的位置,不符合常理。
1117

1218
## 2025/12/19 修复错误的图像范围检测逻辑并删除无用函数
1319

src/Plugins/Qt/QTMImagePopup.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,19 @@ QTMImagePopup::setImageTree (tree t) {
103103
this->current_tree= t;
104104
}
105105

106+
void
107+
QTMImagePopup::scrollBy (int x, int y) {
108+
cached_scroll_x-= (int) (x / cached_magf);
109+
cached_scroll_y-= (int) (y / cached_magf);
110+
}
111+
112+
void
113+
QTMImagePopup::updatePosition () {
114+
int pos_x, pos_y;
115+
getCachedPosition (pos_x, pos_y);
116+
move (pos_x, pos_y);
117+
}
118+
106119
void
107120
QTMImagePopup::cachePosition (rectangle selr, double magf, int scroll_x,
108121
int scroll_y, int canvas_x) {

src/Plugins/Qt/QTMWidget.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ QTMWidget::scrollContentsBy (int dx, int dy) {
155155
// 确保补全框也滚动到正确的位置
156156
tm_widget ()->scroll_completion_popup_by (dx, dy);
157157
tm_widget ()->scroll_math_completion_popup_by (dx, dy);
158+
tm_widget ()->scroll_image_popup_by (dx, dy);
158159
}
159160

160161
void

src/Plugins/Qt/qt_simple_widget.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,4 +776,14 @@ qt_simple_widget_rep::hide_image_popup () {
776776
imagePopUp->deleteLater ();
777777
imagePopUp= nullptr;
778778
}
779+
}
780+
781+
void
782+
qt_simple_widget_rep::scroll_image_popup_by (SI x, SI y) {
783+
if (imagePopUp) {
784+
QPoint qp (x, y);
785+
coord2 p= from_qpoint (qp);
786+
imagePopUp->scrollBy (p.x1, p.x2);
787+
imagePopUp->updatePosition ();
788+
}
779789
}

src/Plugins/Qt/qt_simple_widget.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ class qt_simple_widget_rep : public qt_widget_rep {
118118
void show_image_popup (tree current_tree, rectangle selr, double magf,
119119
int scroll_x, int scroll_y, int canvas_x);
120120
void hide_image_popup ();
121+
void scroll_image_popup_by (SI x, SI y);
121122

122123
////////////////////// backing store management
123124

0 commit comments

Comments
 (0)