Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions devel/201_84.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# [201_84] 默认关闭矩阵等数学环境的格线拖拽

## 如何测试
1. 插入任意样式的正常表格(大表格、小表格除外),格线应该可以正常拖拽
2. 插入`matrix`、`bmatrix`、`Bmatrix`、`det`、`choice`、`stack`等数学环境,格线应该不支持拖拽
3. 插入`align`、`eqnarray`、`gather`、`multline`、`alignat`、`flalign`等数学环境,格线也应该不支持拖拽

## 2026/2/13
### What
在诸多以表格为底层数据模型的数学环境下,很多组件在编辑时,格线不应支持拖拽

### How
1. 在`edit_interface_rep::is_true_table`中,增加对诸多数学环境的判断
2. 在`edit_mouse::table_line_hit`中,增加对`is_true_table`的判断,以保障鼠标悬浮的变形和拖动被`table_line_hit`时禁用
3. 清除`hovering_table=-1`这个没有必要的情况分支
8 changes: 8 additions & 0 deletions src/Edit/Interface/edit_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,14 @@ edit_interface_rep::is_true_table (path p) {
is_compound (qt, "alignat") || is_compound (qt, "alignat*") ||
is_compound (qt, "flalign") || is_compound (qt, "flalign*"))
return false;
if (is_compound (qt, "cases") || is_compound (qt, "choice") ||
is_compound (qt, "det") || is_compound (qt, "stack") ||
is_compound (qt, "array") || is_compound (qt, "array*") ||
is_compound (qt, "matrix") || is_compound (qt, "matrix*") ||
is_compound (qt, "bmatrix") || is_compound (qt, "Bmatrix") ||
is_compound (qt, "pmatrix") || is_compound (qt, "vmatrix") ||
is_compound (qt, "Vmatrix") || is_compound (qt, "smallmatrix"))
return false;
}
return true;
}
Expand Down
24 changes: 9 additions & 15 deletions src/Edit/Interface/edit_mouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,8 @@ edit_interface_rep::table_line_hit (SI x, SI y, table_hit& hit) {
hit.second_size= as_int (r[5]);
hit.fp = as_path (as_string (r[8]));

if (is_nil (hit.fp) || hit.index <= 0) return false;
if (is_nil (hit.fp) || hit.index <= 0 || !is_true_table (hit.fp))
return false;
return true;
}

Expand Down Expand Up @@ -822,13 +823,11 @@ edit_interface_rep::mouse_any (string type, SI x, SI y, int mods, time_t t,

int hovering_table= 0;
if (type == "move" || type == "dragging-left" || type == "dragging-right") {
rectangles rs;
tree r= eb->message (tree ("table-loc?"), x, y, rs);
if (is_func (r, TUPLE) && r[0] == "table-loc") {
string orient= as_string (r[1]);
if (orient == "cell") hovering_table= -1;
else if (orient == "row") hovering_table= 1;
else if (orient == "col") hovering_table= 2;
table_hit hit;
if (table_line_hit (x, y, hit)) {
if (hit.orient == "cell") hovering_table= -1;
else if (hit.orient == "row") hovering_table= 1;
else if (hit.orient == "col") hovering_table= 2;
}
}
bool hovering_hlink= false;
Expand Down Expand Up @@ -907,13 +906,8 @@ edit_interface_rep::mouse_any (string type, SI x, SI y, int mods, time_t t,
if (handle_cursor != "") set_cursor_style (handle_cursor);
else set_cursor_style ("size_all");
}
else if (hovering_table) {
if (hovering_table == -1) {
set_cursor_style ("normal");
// draw table resizing handles
}
else set_cursor_style (hovering_table == 1 ? "size_ver" : "size_hor");
}
else if (hovering_table)
set_cursor_style (hovering_table == 1 ? "size_ver" : "size_hor");
else if (hovering_hlink) set_cursor_style ("pointing_hand");
else if (hovering_image) {
set_cursor_style ("pointing_hand");
Expand Down