Skip to content
Closed
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
19 changes: 19 additions & 0 deletions devel/201_69.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# [201_69] 表格支持鼠标缩放
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR title and description describe fixing image resizing undo issues and mention adding image-resize-mark in format-geometry-edit.scm. However, all the actual code changes in this PR are about table scaling functionality, not image resizing. The description mentions implementing mark/undo session handling for image resize, but the image resize code in format-geometry-edit.scm does not have such changes. This appears to be a significant discrepancy - either the PR description is incorrect, or the wrong changes were included in this PR.

Copilot uses AI. Check for mistakes.

## 如何测试
1. 插入标宽有框表格/普通有框表格,光标此时在表格内,应该在表格框外看到蓝色的正方形缩放手柄
2. 标宽有框表格只有底部一个手柄,可以向下拖拽;普通有框表格有右侧、底部、右下角三个手柄,可以向右、向下、对角线拖拽
3. 拖拽手柄时,对应的整行/列应当先均分空间再缩放大小(例如拖动右侧的手柄时,表格的各列宽度应当均分后再整体缩放)
4. 拖拽过程应该符合预期。鼠标在手柄范围内应该变成对应的样式,且可以拖动;鼠标在手柄外则是默认样式,且不能拖动
5. **表格缩放时,会根据现在的行列宽高重新平均分配宽高**
(等比例缩放时间复杂度高,会有延迟感。现实现表格行列加到20以上均不会出现明显延迟感)
6. 表格的右侧边框和下侧边框应该可以拖拽,仅影响最后一行/列的大小,不与缩放手柄冲突
7. 目前暂不支持大表格/小表格的缩放,理论上这两种表格的需求量不大

### 2026/1/28
### What
1. 实现了表格支持鼠标缩放
2. 微调表格的交互优化的实现

### How
在开发文档中详细阐述
2 changes: 2 additions & 0 deletions moebius/moebius/drd/drd_std.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,8 @@ init_std_drd () {
init_var (CELL_VMODE, TYPE_STRING);
init_var (CELL_HALIGN, TYPE_STRING);
init_var (CELL_VALIGN, TYPE_STRING);
init_var (CELL_HSCALE, TYPE_NUMERIC);
init_var (CELL_VSCALE, TYPE_NUMERIC);
init_var (CELL_LSEP, TYPE_LENGTH);
init_var (CELL_RSEP, TYPE_LENGTH);
init_var (CELL_BSEP, TYPE_LENGTH);
Expand Down
2 changes: 2 additions & 0 deletions moebius/moebius/vars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ string CELL_HMODE ("cell-hmode");
string CELL_VMODE ("cell-vmode");
string CELL_HALIGN ("cell-halign");
string CELL_VALIGN ("cell-valign");
string CELL_HSCALE ("cell-hscale");
string CELL_VSCALE ("cell-vscale");
string CELL_LSEP ("cell-lsep");
string CELL_RSEP ("cell-rsep");
string CELL_BSEP ("cell-bsep");
Expand Down
2 changes: 2 additions & 0 deletions moebius/moebius/vars.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ extern string CELL_HMODE;
extern string CELL_VMODE;
extern string CELL_HALIGN;
extern string CELL_VALIGN;
extern string CELL_HSCALE;
extern string CELL_VSCALE;
extern string CELL_LSEP;
extern string CELL_RSEP;
extern string CELL_BSEP;
Expand Down
55 changes: 35 additions & 20 deletions src/Edit/Interface/edit_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,31 +74,45 @@ class edit_interface_rep : virtual public editor_rep {
int mouse_adjusting; // mask with active key modifiers upon click
rectangles selection_rects;
struct table_hit {
bool vertical;
path fp;
int index;
SI first_size;
SI second_size;
bool wide_flag;
string orient;
path fp;
int index;
SI first_size;
SI second_size;
bool wide_flag;
};
bool table_resizing = false;
bool table_resize_vertical = false;
path table_resize_path = path ();
int table_resize_index = 0;
SI table_resize_start_x = 0;
SI table_resize_start_y = 0;
SI table_resize_first_size = 0;
SI table_resize_second_size= 0;
bool table_resize_wide_flag = false;
double table_resize_mark = 0.0;
bool table_resize_hit (SI x, SI y, table_hit& hit);
void table_resize_start (const table_hit& hit, SI x, SI y);
void table_resize_apply (SI x, SI y);
void table_resize_stop ();
int table_resizing_type= 0; // 0: N/A; 1: line resizing; 2: scale resizing
bool table_line_vertical= false;
path table_line_path = path ();
int table_line_index = 0;
SI table_line_start_x = 0;
SI table_line_start_y = 0;
SI table_line_first_size = 0;
SI table_line_second_size= 0;
bool table_line_wide_flag = false; // 用于格线移动的标记,只在点击时更新
double table_line_mark = 0.0;
bool table_line_hit (SI x, SI y, table_hit& hit);
void table_line_start (const table_hit& hit, SI x, SI y);
void table_line_apply (SI x, SI y);
void table_line_stop ();
int table_scale_handle_type = 0; // 0: N/A; 1: 下方; 2: 右方; 3: 右下方
path table_scale_path = path (); // 重绘时实时更新
SI table_scale_start_x = 0;
SI table_scale_start_y = 0;
SI table_scale_initial_width = 0;
SI table_scale_initial_height= 0;
bool table_scale_wide_flag= false; // 用于整体缩放的标记,重绘时实时更新
double table_scale_mark = 0.0;
bool table_scale_hit (SI x, SI y);
void table_scale_start (SI x, SI y);
void table_scale_apply (SI x, SI y);
void table_scale_stop ();
array<rectangles> alt_selection_rects;
rectangle last_visible;
rectangle last_image_brec; // 图片 bbox 缓存
SI last_image_hr; // 图片 handle 半径缓存
rectangle last_table_brec; // 表格 bbox 缓存
SI last_table_hr; // 表格 handles 半径缓存
rectangles env_rects;
rectangles foc_rects;
rectangles sem_rects;
Expand Down Expand Up @@ -164,6 +178,7 @@ class edit_interface_rep : virtual public editor_rep {
void draw_cursor (renderer ren);
void draw_selection (renderer ren, rectangle r);
void draw_image_resize_handles (renderer ren);
void draw_table_resize_handles (renderer ren);
void draw_graphics (renderer ren);
void draw_pre (renderer win, renderer ren, rectangle r);
void draw_post (renderer win, renderer ren, rectangle r);
Expand Down
Loading
Loading