Skip to content

Commit 7e0f094

Browse files
committed
row drag cancel with esc
1 parent 11b64fc commit 7e0f094

File tree

4 files changed

+96
-93
lines changed

4 files changed

+96
-93
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
- toolkitgroupview is more compact
1212
- add vips_header_get builtin
1313
- add Real, Group, Vector graphic classes
14+
- better row drop
15+
- cancel row drag with Esc
1416

1517
## 9.0.11 2025/07/21
1618

TODO

Lines changed: 5 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2+
- annoying animation feedback when dragging rows
3+
14
- get judder with rotate and images smaller than the window
25

36
draw on update, then draw again on relayout
@@ -29,84 +32,12 @@
2932

3033
works for flatpak
3134

32-
# menu redesign
33-
34-
- maxpos, then create mark from coordinate should be two clicks
35-
36-
- try:
37-
38-
minpair image constant
39-
40-
fails with
41-
42-
error in binary if_then_else
43-
left = <256x256 uchar, 1 band, b-w 0x55a4921d3ed0>
44-
right = [<256x256 float, 1 band, b-w 0x55a4918a6d60>, 12]
45-
called from "minpair"
46-
47-
try:
48-
49-
if_then_else (A11 < 12).value [A11.value, 12]
50-
51-
also fails (works for Image though)
52-
53-
because constant expansion is done by the Image class
54-
55-
we'll need to do constant expansion in minpair
56-
57-
- implement Menuseparator?
58-
59-
we've implemented #separator
60-
61-
- the nip4 menus need reworking to use max_alpha 255 for scrgb
62-
63-
- add something to find unresolved symbols
64-
65-
- get rid of im_copy_set etc.
66-
67-
add copy_set to stdenv, and that uses vips_call9
68-
69-
- perspective distort could have an "interpoplate" option (always bilinear
70-
right now)
71-
72-
- rename Image_type as Image_interpretation
73-
74-
- try:
75-
76-
Matrix_build_item.Matrix_laplacian_item.action
77-
78-
Matrix_build_item.Matrix_gaussian_item.action
79-
80-
edit a cell and hit enter, lose the widgets, same happens in nip2
81-
82-
do we need to define a Matrix_base member in Matrix_gaussian_item.action?
83-
84-
- add "smooth" option to union/intersection/difference?
85-
86-
see https://iquilezles.org/articles/distfunctions/
87-
88-
translate, rotate etc? need xyz for that
89-
90-
- Grey ramp, checkerboard, grid CIELAB slice -> Test Images
91-
92-
- magic kernel
93-
94-
- use vips_addalpha() operation
95-
96-
- remove use of cache (it's tilecache only now)
97-
98-
- prewitt and scharr edge detectors
99-
100-
- puts lots of stuff into Image > New eg xyz, sdf etc.
101-
102-
- can we improve Group[]?
103-
104-
105-
10635
- could use file chooser widget in bm-workspaces, what would it look like?
10736

10837
- check all batch mode flags
10938

39+
see eg. vips-bench nip4 benchmark
40+
11041
- try to save and restore image view scale and position
11142

11243
this failed last time I tried :(
@@ -132,8 +63,6 @@
13263
see imagewindow_set_tilesource() and uncomment the call to
13364
imageui_set_bestfit() to work on this again
13465

135-
- still getting buffer ownership assert fails with libvips built in debug mode
136-
13766
- need preferences?
13867

13968
or just remove it all

src/gtk/workspaceview.ui

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,13 @@
162162
</object>
163163
</child>
164164

165+
<child>
166+
<object class="GtkEventControllerKey">
167+
<signal name="key-pressed"
168+
handler="workspaceview_key_pressed"/>
169+
</object>
170+
</child>
171+
165172
</object>
166173
</child>
167174

src/workspaceview.c

Lines changed: 82 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,30 @@ workspaceview_float_rowview(Workspaceview *wview, Rowview *rview)
977977
vobject_refresh(VOBJECT(wview->old_sview));
978978
}
979979

980+
static void
981+
workspaceview_undo_row_drag(Workspaceview *wview)
982+
{
983+
Rowview *rview = wview->drag_rview;
984+
985+
g_object_ref(rview);
986+
987+
g_assert(IS_SUBCOLUMNVIEW(wview->old_sview));
988+
g_assert(IS_ROWVIEW(rview));
989+
990+
view_child_remove(VIEW(rview));
991+
// the row number has to be wrong or reattach is skipped
992+
rview->rnum = -1;
993+
view_child_add(VIEW(wview->old_sview), VIEW(rview));
994+
995+
g_object_unref(rview);
996+
997+
// the row and the old containing column need to refresh
998+
Row *row = ROW(VOBJECT(rview)->iobject);
999+
iobject_changed(IOBJECT(row));
1000+
Subcolumn *scol = SUBCOLUMN(ICONTAINER(row)->parent);
1001+
iobject_changed(IOBJECT(scol));
1002+
}
1003+
9801004
static void
9811005
workspaceview_drop_rowview(Workspaceview *wview)
9821006
{
@@ -1013,17 +1037,7 @@ workspaceview_drop_rowview(Workspaceview *wview)
10131037

10141038
// reparent the rowview back to the original column ... this is where
10151039
// icontainer_reparent() expects to find it
1016-
g_object_ref(rview);
1017-
1018-
g_assert(IS_SUBCOLUMNVIEW(wview->old_sview));
1019-
g_assert(IS_ROWVIEW(rview));
1020-
1021-
view_child_remove(VIEW(rview));
1022-
// the row number has to be wrong or reattach is skipped
1023-
rview->rnum = -1;
1024-
view_child_add(VIEW(wview->old_sview), VIEW(rview));
1025-
1026-
g_object_unref(rview);
1040+
workspaceview_undo_row_drag(wview);
10271041

10281042
// update the model
10291043
if (col == row_col) {
@@ -1172,7 +1186,9 @@ workspaceview_drag_update(GtkEventControllerMotion *self,
11721186
mouse_x, mouse_y);
11731187

11741188
if (cview) {
1175-
// row we are over
1189+
int pos;
1190+
1191+
// row we are over, if any
11761192
Rowview *local = columnview_find_rowview(cview,
11771193
mouse_x, mouse_y);
11781194

@@ -1185,14 +1201,29 @@ workspaceview_drag_update(GtkEventControllerMotion *self,
11851201
return;
11861202

11871203
Row *row = ROW(VOBJECT(top)->iobject);
1188-
int pos = 2 * ICONTAINER(row)->pos + 1;
1204+
pos = 2 * ICONTAINER(row)->pos + 1;
11891205
if (mouse_y > bounds.origin.y + bounds.size.height / 2)
1190-
workspaceview_move_row_shadow(wview,
1191-
cview, pos + 1);
1206+
pos += 1;
11921207
else
1193-
workspaceview_move_row_shadow(wview,
1194-
cview, pos - 1);
1208+
pos -= 1;
11951209
}
1210+
else {
1211+
// we are over a column, but not over a row ... we
1212+
// could be over the titlebar, or over the entry area
1213+
// at the bottom
1214+
Columnview *title =
1215+
workspaceview_find_columnview_title(wview,
1216+
mouse_x, mouse_y);
1217+
1218+
if (title)
1219+
pos = 0;
1220+
else
1221+
// not in the title, append to end of column
1222+
// this will get renumbered on drop
1223+
pos = 100000;
1224+
}
1225+
1226+
workspaceview_move_row_shadow(wview, cview, pos);
11961227
}
11971228
else
11981229
workspaceview_move_row_shadow(wview, NULL, -1);
@@ -1302,6 +1333,39 @@ workspaceview_alert_close_clicked(GtkButton *button, void *user_data)
13021333
workspace_set_alert(ws, FALSE);
13031334
}
13041335

1336+
static gboolean
1337+
workspaceview_key_pressed(GtkEventControllerKey *self,
1338+
guint keyval, guint keycode, GdkModifierType state, gpointer user_data)
1339+
{
1340+
Workspaceview *wview = WORKSPACEVIEW(user_data);
1341+
Workspace *ws = WORKSPACE(VOBJECT(wview)->iobject);
1342+
1343+
switch (keyval) {
1344+
case GDK_KEY_Escape:
1345+
if (wview->state == WVIEW_DRAG) {
1346+
wview->state = WVIEW_WAIT;
1347+
1348+
if (wview->drag_rview) {
1349+
// cancel row drag, remove the floating column we made
1350+
workspaceview_undo_row_drag(wview);
1351+
workspaceview_unfloat(wview);
1352+
workspaceview_remove_row_shadow(wview);
1353+
workspace_queue_layout(ws);
1354+
}
1355+
else if (wview->drag_cview) {
1356+
// undo column drag is tricky
1357+
}
1358+
}
1359+
1360+
break;
1361+
1362+
default:
1363+
break;
1364+
}
1365+
1366+
return FALSE;
1367+
}
1368+
13051369
static void
13061370
workspaceview_class_init(WorkspaceviewClass *class)
13071371
{
@@ -1332,6 +1396,7 @@ workspaceview_class_init(WorkspaceviewClass *class)
13321396
BIND_CALLBACK(workspaceview_drag_end);
13331397
BIND_CALLBACK(workspaceview_error_close_clicked);
13341398
BIND_CALLBACK(workspaceview_alert_close_clicked);
1399+
BIND_CALLBACK(workspaceview_key_pressed);
13351400

13361401
object_class->dispose = workspaceview_dispose;
13371402

0 commit comments

Comments
 (0)