Skip to content

Commit cf6d124

Browse files
committed
better subrow finding
1 parent dd1d2d6 commit cf6d124

File tree

7 files changed

+64
-57
lines changed

7 files changed

+64
-57
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## master
22

33
- better change handling in ientry improves matrixview behaviour
4+
- better subrow finding fixes replace from file in nested columns
45

56
## 9.0.4 2025/03/20
67

TODO

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
- try
2+
3+
nip4 ~/lady_orig.ws
4+
drag A2 into column I
5+
press V (down) on A2, segv
6+
7+
18
- "reset" in display bar resets the position of scale/offset widgets, but does
29
not reset the menu items (eg. tick on falsecolour)
310

@@ -32,39 +39,14 @@
3239

3340
- prewitt and scharr edge detectors
3441

42+
- puts lots of stuff into Image > New eg xyz, sdf etc.
3543

44+
- can we improve Group[]?
3645

3746

3847

39-
- row reset doesn't always work
40-
41-
try joanne's workspace ... need to be able to reset the image pair
42-
43-
rowview_reset_menu() just runs model_clear_edited() on every sub-row
44-
45-
in turn runs heapmodel_clear_edited()
46-
47-
image replace from file usually won't reset properly since it rewrites the
48-
formula and there's nothing to reset
49-
5048
- could use file chooser widget in bm-workspaces, what would it look like?
5149

52-
- ^V in an imagewindow swaps the image without rewriting the formula, could
53-
we do something like that for replace from file?
54-
55-
no, the result wouldn't be saved
56-
57-
- try
58-
59-
nip4 ~/lady-orig.ws
60-
61-
open A2, find A2.targets.image, right-click, replace from file, no file
62-
dialog appears
63-
64-
what stops replace from file on a dirty row?
65-
66-
see rowview_action(), there's no rhs->graphic
67-
6850
- check all batch mode flags
6951

7052
- try to save and restore image view scale and position

src/columnview.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -655,14 +655,24 @@ columnview_rowview_hit(View *view, void *a, void *b)
655655
if (!gtk_widget_compute_bounds(rview->frame, GTK_WIDGET(sview), &bounds))
656656
return NULL;
657657

658-
if (sview_point->y > bounds.origin.y &&
659-
sview_point->y < bounds.origin.y + bounds.size.height)
658+
if (sview_point->x > bounds.origin.x &&
659+
sview_point->y > bounds.origin.y &&
660+
sview_point->y < bounds.origin.y + bounds.size.height) {
661+
if (rview->rhsview &&
662+
rview->rhsview->scol) {
663+
View *sub;
664+
if ((sub = view_map(rview->rhsview->scol,
665+
columnview_rowview_hit, sview_point, sview)))
666+
return sub;
667+
}
668+
660669
return rview;
670+
}
661671

662672
return NULL;
663673
}
664674

665-
/* Find the columnview for a point.
675+
/* Find the rowview for a point.
666676
*/
667677
Rowview *
668678
columnview_find_rowview(Columnview *cview, int x, int y)

src/rowview.c

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,13 @@ rowview_attach(Rowview *rview, GtkWidget *child, int x)
8787
GtkWidget *parent = gtk_widget_get_parent(child);
8888
if (parent) {
8989
if (IS_ROWVIEW(parent)) {
90-
// if the parent is the rview, this is the first _attach of a
91-
// template child and it will have a single ref, held by
92-
// rview
93-
//
94-
// add an extra ref (dropped in _dispose) to keep the child alive
95-
// across any later reparenting during row drag
90+
/* If the parent is the rview, this is the first _attach of a
91+
* template child and it will have a single ref, held by
92+
* rview.
93+
*
94+
* Add an extra ref (dropped in _dispose) to keep the child alive
95+
* across any later reparenting during row drag.
96+
*/
9697
gtk_widget_unparent(child);
9798
g_object_ref(child);
9899
}
@@ -437,28 +438,24 @@ static void
437438
rowview_action(GSimpleAction *action, GVariant *parameter, View *view)
438439
{
439440
Rowview *rview = ROWVIEW(view);
440-
View *graphic = rview->rhsview->graphic;
441441
Row *row = ROW(VOBJECT(rview)->iobject);
442-
Rhs *rhs = row->child_rhs;
442+
Model *graphic = row->child_rhs->graphic;
443443
Workspace *ws = row->ws;
444444
const char *name = g_action_get_name(G_ACTION(action));
445445

446-
if (graphic &&
447-
g_str_equal(name, "row-edit"))
448-
model_edit(GTK_WIDGET(rview), MODEL(rhs));
446+
if (g_str_equal(name, "row-edit") && graphic)
447+
model_edit(GTK_WIDGET(rview), MODEL(graphic));
449448
else if (g_str_equal(name, "row-duplicate"))
450449
rowview_duplicate(rview);
451-
else if (g_str_equal(name, "row-saveas") &&
452-
rhs->graphic)
453-
classmodel_graphic_save(CLASSMODEL(rhs->graphic), GTK_WIDGET(rview));
450+
else if (g_str_equal(name, "row-saveas") && graphic)
451+
classmodel_graphic_save(CLASSMODEL(graphic), GTK_WIDGET(rview));
454452
else if (g_str_equal(name, "row-delete")) {
455453
if (workspace_selected_num(ws) < 2)
456454
row_select(row);
457455
workspace_selected_remove_yesno(ws, view_get_window(VIEW(rview)));
458456
}
459-
else if (g_str_equal(name, "row-replace") &&
460-
rhs->graphic)
461-
classmodel_graphic_replace(CLASSMODEL(rhs->graphic), GTK_WIDGET(rview));
457+
else if (g_str_equal(name, "row-replace") && graphic)
458+
classmodel_graphic_replace(CLASSMODEL(graphic), GTK_WIDGET(rview));
462459
else if (g_str_equal(name, "row-group"))
463460
rowview_group(rview);
464461
else if (g_str_equal(name, "row-ungroup"))
@@ -580,3 +577,16 @@ rowview_get_visible(Rowview *rview)
580577
{
581578
return rview->visible;
582579
}
580+
581+
Rowview *
582+
rowview_get_top(Rowview *rview)
583+
{
584+
View *enclosing = VIEW(rview)->parent->parent;
585+
586+
if (IS_COLUMNVIEW(enclosing))
587+
// rview in a subcolumnview in a columnview, so a top-level rowview
588+
return rview;
589+
else
590+
// rview in a subcolumnview in a rhsview, so a nested rowview
591+
return rowview_get_top(RHSVIEW(enclosing)->rview);
592+
}

src/rowview.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ struct _Rowview {
4545
gboolean visible; /* Currently visible */
4646
int rnum; /* Row of subcolumn we are in */
4747

48-
GtkWidget *top; /* Enclosing box for our widgets */
4948
GtkWidget *spin; /* Class display open/close widgets */
5049
GtkWidget *frame; /* Row name box */
5150
GtkWidget *label; /* Row label */
@@ -76,3 +75,4 @@ View *rowview_new(void);
7675
void rowview_get_position(Rowview *rview, int *x, int *y, int *w, int *h);
7776
void rowview_set_visible(Rowview *rview, gboolean visible);
7877
gboolean rowview_get_visible(Rowview *rview);
78+
Rowview *rowview_get_top(Rowview *rview);

src/view.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ typedef struct _ViewClass {
107107
void (*scrollto)(View *, ModelScrollPosition);
108108
void (*layout)(View *);
109109

110-
/* A GAction in the enclosing window.
110+
/* A GAction on this view.
111111
*/
112112
void (*action)(GSimpleAction *action, GVariant *parameter, View *view);
113113
} ViewClass;

src/workspaceview.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,15 +1035,17 @@ workspaceview_drag_begin(GtkEventControllerMotion *self,
10351035
wview->obj_y = cview->y;
10361036
}
10371037
else if (cview) {
1038-
Rowview *rview = columnview_find_rowview(cview, start_x, start_y);
1038+
Rowview *local = columnview_find_rowview(cview, start_x, start_y);
1039+
1040+
if (local) {
1041+
Rowview *top = rowview_get_top(local);
10391042

1040-
if (rview) {
10411043
graphene_rect_t bounds;
1042-
if (!gtk_widget_compute_bounds(GTK_WIDGET(rview->frame),
1044+
if (!gtk_widget_compute_bounds(GTK_WIDGET(top->frame),
10431045
wview->fixed, &bounds))
10441046
return;
10451047

1046-
wview->drag_rview = rview;
1048+
wview->drag_rview = top;
10471049
wview->state = WVIEW_SELECT;
10481050
wview->obj_x = bounds.origin.x;
10491051
wview->obj_y = bounds.origin.y;
@@ -1125,16 +1127,18 @@ workspaceview_drag_update(GtkEventControllerMotion *self,
11251127

11261128
if (cview) {
11271129
// row we are over
1128-
Rowview *rview = columnview_find_rowview(cview,
1130+
Rowview *local = columnview_find_rowview(cview,
11291131
mouse_x, mouse_y);
11301132

1131-
if (rview) {
1133+
if (local) {
1134+
Rowview *top = rowview_get_top(local);
1135+
11321136
graphene_rect_t bounds;
1133-
if (!gtk_widget_compute_bounds(GTK_WIDGET(rview->frame),
1137+
if (!gtk_widget_compute_bounds(GTK_WIDGET(top->frame),
11341138
wview->fixed, &bounds))
11351139
return;
11361140

1137-
Row *row = ROW(VOBJECT(rview)->iobject);
1141+
Row *row = ROW(VOBJECT(top)->iobject);
11381142
int pos = 2 * ICONTAINER(row)->pos + 1;
11391143
if (mouse_y > bounds.origin.y + bounds.size.height / 2)
11401144
workspaceview_move_row_shadow(wview,

0 commit comments

Comments
 (0)