From: Alan Date: Thu, 8 Feb 2024 07:32:05 +0000 (+0800) Subject: Fix #8024 - replace crappy columnview row detection X-Git-Tag: release-5.0.3~17 X-Git-Url: http://git.roojs.org/?p=roobuilder;a=commitdiff_plain;h=ed6728aad2e97f60d32a126a0f2fdfd93e14444b Fix #8024 - replace crappy columnview row detection --- diff --git a/debian/changelog b/debian/changelog index efcde44e8..df43b3326 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,7 @@ roobuilder (5.0.3) UNRELEASED; urgency=medium * error popups with tree of errors, now default to expanding current file + * row detection for drag/drop + contect menu replaced with pick/ bounds and row counting (far more reliable) -- Alan Wed, 07 Feb 2024 09:51:44 +0800 diff --git a/src/Builder4/MainWindow.bjs b/src/Builder4/MainWindow.bjs index 34980b1d4..1b3bee7c5 100644 --- a/src/Builder4/MainWindow.bjs +++ b/src/Builder4/MainWindow.bjs @@ -6,7 +6,6 @@ "# Project.Project project" : "null", "# WindowState windowstate" : "", "# bool winloading" : false, - "# default_height" : 850, "$ type" : "Gtk.WindowType.TOPLEVEL", "$ xns" : "Gtk", "* ctor" : "new Gtk.ApplicationWindow(BuilderApplication.singleton({}))", @@ -16,6 +15,7 @@ "" ], "border_width" : 0, + "default_height" : 850, "default_width" : 1200, "id" : "MainWindow", "items" : [ diff --git a/src/Builder4/MainWindow.vala b/src/Builder4/MainWindow.vala index 62dc1f94a..0dabf4709 100644 --- a/src/Builder4/MainWindow.vala +++ b/src/Builder4/MainWindow.vala @@ -67,6 +67,7 @@ public class Xcls_MainWindow : Object // set gobject values this.el.title = "Roo Application Builder"; + this.el.default_height = 850; this.el.default_width = 1200; new Xcls_headerbar( _this ); this.el.set_titlebar ( _this.headerbar.el ); diff --git a/src/Builder4/WindowLeftProps.bjs b/src/Builder4/WindowLeftProps.bjs index 8bc4cbe71..d410cf7a7 100644 --- a/src/Builder4/WindowLeftProps.bjs +++ b/src/Builder4/WindowLeftProps.bjs @@ -640,6 +640,16 @@ "items" : [ { "$ xns" : "Gtk", + "bool has_frame" : false, + "items" : [ + { + "$ xns" : "Gtk", + "* prop" : "child", + "Gtk.Align halign" : "Gtk.Align.START", + "string label" : "Delete Property / Method", + "xtype" : "Label" + } + ], "listeners" : { "clicked" : [ "( ) => {", @@ -1173,97 +1183,50 @@ " }" ], "| int getRowAt" : [ - "(double x, double in_y, out string pos) {", - "", + "(double x, double y, out string pos) {", "", + "\tvar w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);", + "\t//GLib.debug(\"got widget %s\", w == null ? \"nothing\" : w.get_type().name());", + "\tif (w == null) {", + "\t\treturn -1;", + "\t}", + "\t", + "\tvar row= w.get_ancestor(GLib.Type.from_name(\"GtkColumnViewRowWidget\"));", + "\tif (row == null) {", + "\t\treturn -1;", + "\t}", + "\t", + "\t//GLib.debug(\"got colview %s\", row == null ? \"nothing\" : row.get_type().name());", "\t ", - "", - "/*", - " \t", - "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465", - " \tvar colview = gesture.widget;", - " \tvar line_no = check_list_widget(colview, x,y);", - " if (line_no > -1) {", - " \t\tvar item = colview.model.get_item(line_no);", - " \t\t ", - " \t}", - " \t*/", - " \t\t ", - " \t\t", - " \t\t//GLib.debug(\"offset = %d y = %d\", (int) voff, (int) in_y);", - " \tvar y = in_y + _this.EditProps.el.vadjustment.value; ", - " var child = this.el.get_first_child(); ", - " \t//Gtk.Allocation alloc = { 0, 0, 0, 0 };", - " \tvar line_no = -1; ", - " \tvar reading_header = true;", - " \tvar real_y = 0;", - " \tvar header_height = 0;", - " \tpos = \"none\";", - " \tvar h = 0;", - " \twhile (child != null) {", - "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());", - " \t if (reading_header) {", - "\t\t\t\t", - "", - "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {", - "\t\t\t h += child.get_height();", - "\t\t\t\t\tchild = child.get_next_sibling();", - "\t\t\t\t\tcontinue;", - "\t\t\t\t}", - "\t\t\t\t// should be columnlistview", - "\t\t\t\tchild = child.get_first_child(); ", - "\t\t\t //GLib.debug(\"header height=%d\", h);", - "\t\t\t\theader_height = h;", - "\t\t\t\t", - "\t\t\t\treading_header = false;", - "\t\t\t\tcontinue;", - "\t }", - "\t ", - "\t\t if (child.get_type().name() != \"GtkColumnViewRowWidget\") {", - " \t\t child = child.get_next_sibling();", - " \t\t continue;", - "\t\t }", - "\t\t ", - "\t\t \tif (y < header_height) {", - "\t\t \treturn -1;", - "\t \t}", - "\t\t ", - "\t\t line_no++;", - "\t\t\tvar hh = child.get_height();", - "\t\t\tif (child.has_css_class(\"node-err\") || ", - "\t\t\t\tchild.has_css_class(\"node-warn\") || ", - "\t\t\t\tchild.has_css_class(\"node-depr\")) {", - "\t\t\t\thh += 10;", - "\t\t\t", - "\t\t\t}", - "\t\t\t", - "\t\t\t//child.get_allocation(out alloc);", - "\t\t\t//GLib.debug(\"got cell xy = %d,%d w,h= %d,%d\", alloc.x, alloc.y, alloc.width, alloc.height);", - "\t\t\t//GLib.debug(\"row %d y= %d %s\", line_no, (int) (header_height + alloc.y),", - "\t\t\t", - "\t\t\t//\tchild.visible ? \"VIS\" : \"hidden\");", - "", - "\t\t if (y > (header_height + real_y) && y <= (header_height + real_y + hh) ) {", - "\t\t \tif (y > ( header_height + real_y + (hh * 0.8))) {", - "\t\t \t\tpos = \"below\";", - "\t \t\t} else if (y > ( header_height + real_y + (hh * 0.2))) {", - "\t \t\t\tpos = \"over\";", - " \t\t\t} else {", - " \t\t\t\tpos = \"above\";", - "\t\t\t\t}", - "\t\t \t GLib.debug(\"getRowAt return : %d, %s\", line_no, pos);", - "\t\t\t return line_no;", - "\t\t }", - " ", - "", - "\t\t if (real_y + hh > y) {", - "\t\t return -1;", - "\t }", - "\t real_y += hh;", - "\t child = child.get_next_sibling(); ", - " \t}", - " return -1;", - "", + "\tvar rn = 0;", + "\tvar cr = row;", + "\t ", + "\twhile (cr.get_prev_sibling() != null) {", + "\t\trn++;", + "\t\tcr = cr.get_prev_sibling();", + "\t}", + "\t", + "\t//GLib.debug(\"row number is %d\", rn);", + "\t//GLib.debug(\"click %d, %d\", (int)x, (int)y);", + "\t// above or belw", + "\tGraphene.Rect bounds;", + "\trow.compute_bounds(this.el, out bounds);", + "\t//GLib.debug(\"click x=%d, y=%d, w=%d, h=%d\", ", + "\t//\t(int)bounds.get_x(), (int)bounds.get_y(),", + "\t//\t(int)bounds.get_width(), (int)bounds.get_height()", + "\t//\t);", + "\tvar ypos = y - bounds.get_y();", + "\t//GLib.debug(\"rel ypos = %d\", (int)ypos);\t", + "\tvar rpos = 100.0 * (ypos / bounds.get_height());", + "\t//GLib.debug(\"rel pos = %d %%\", (int)rpos);", + "\tpos = \"over\";", + "\t", + "\tif (rpos > 80) {", + "\t\tpos = \"below\";", + "\t} else if (rpos < 20) {", + "\t\tpos = \"above\";", + "\t} ", + "\treturn rn;", " }" ], "| void editProp" : [ diff --git a/src/Builder4/WindowLeftProps.vala b/src/Builder4/WindowLeftProps.vala index 249eda5e0..bcef70ac6 100644 --- a/src/Builder4/WindowLeftProps.vala +++ b/src/Builder4/WindowLeftProps.vala @@ -1792,97 +1792,50 @@ public class Xcls_LeftProps : Object return -1; } - public int getRowAt (double x, double in_y, out string pos) { - + public int getRowAt (double x, double y, out string pos) { + var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT); + //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name()); + if (w == null) { + return -1; + } + + var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget")); + if (row == null) { + return -1; + } + + //GLib.debug("got colview %s", row == null ? "nothing" : row.get_type().name()); - - /* - - from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465 - var colview = gesture.widget; - var line_no = check_list_widget(colview, x,y); - if (line_no > -1) { - var item = colview.model.get_item(line_no); - - } - */ - - - //GLib.debug("offset = %d y = %d", (int) voff, (int) in_y); - var y = in_y + _this.EditProps.el.vadjustment.value; - var child = this.el.get_first_child(); - //Gtk.Allocation alloc = { 0, 0, 0, 0 }; - var line_no = -1; - var reading_header = true; - var real_y = 0; - var header_height = 0; - pos = "none"; - var h = 0; - while (child != null) { - //GLib.debug("Got %s", child.get_type().name()); - if (reading_header) { - - - if (child.get_type().name() != "GtkColumnListView") { - h += child.get_height(); - child = child.get_next_sibling(); - continue; - } - // should be columnlistview - child = child.get_first_child(); - //GLib.debug("header height=%d", h); - header_height = h; - - reading_header = false; - continue; - } - - if (child.get_type().name() != "GtkColumnViewRowWidget") { - child = child.get_next_sibling(); - continue; - } - - if (y < header_height) { - return -1; - } - - line_no++; - var hh = child.get_height(); - if (child.has_css_class("node-err") || - child.has_css_class("node-warn") || - child.has_css_class("node-depr")) { - hh += 10; - - } - - //child.get_allocation(out alloc); - //GLib.debug("got cell xy = %d,%d w,h= %d,%d", alloc.x, alloc.y, alloc.width, alloc.height); - //GLib.debug("row %d y= %d %s", line_no, (int) (header_height + alloc.y), - - // child.visible ? "VIS" : "hidden"); - - if (y > (header_height + real_y) && y <= (header_height + real_y + hh) ) { - if (y > ( header_height + real_y + (hh * 0.8))) { - pos = "below"; - } else if (y > ( header_height + real_y + (hh * 0.2))) { - pos = "over"; - } else { - pos = "above"; - } - GLib.debug("getRowAt return : %d, %s", line_no, pos); - return line_no; - } - - - if (real_y + hh > y) { - return -1; - } - real_y += hh; - child = child.get_next_sibling(); - } - return -1; - + var rn = 0; + var cr = row; + + while (cr.get_prev_sibling() != null) { + rn++; + cr = cr.get_prev_sibling(); + } + + //GLib.debug("row number is %d", rn); + //GLib.debug("click %d, %d", (int)x, (int)y); + // above or belw + Graphene.Rect bounds; + row.compute_bounds(this.el, out bounds); + //GLib.debug("click x=%d, y=%d, w=%d, h=%d", + // (int)bounds.get_x(), (int)bounds.get_y(), + // (int)bounds.get_width(), (int)bounds.get_height() + // ); + var ypos = y - bounds.get_y(); + //GLib.debug("rel ypos = %d", (int)ypos); + var rpos = 100.0 * (ypos / bounds.get_height()); + //GLib.debug("rel pos = %d %%", (int)rpos); + pos = "over"; + + if (rpos > 80) { + pos = "below"; + } else if (rpos < 20) { + pos = "above"; + } + return rn; } } public class Xcls_deletemenu : Object @@ -1950,7 +1903,10 @@ public class Xcls_LeftProps : Object // my vars (dec) // set gobject values + this.el.has_frame = false; this.el.label = "Delete"; + var child_1 = new Xcls_Label1187( _this ); + this.el.child = child_1.el; //listeners this.el.clicked.connect( ( ) => { @@ -1965,6 +1921,29 @@ public class Xcls_LeftProps : Object // user defined functions } + public class Xcls_Label1187 : Object + { + public Gtk.Label el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_Label1187(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Delete Property / Method" ); + + // my vars (dec) + + // set gobject values + this.el.halign = Gtk.Align.START; + } + + // user defined functions + } + diff --git a/src/Builder4/WindowLeftTree.bjs b/src/Builder4/WindowLeftTree.bjs index 081140778..045fbee8c 100644 --- a/src/Builder4/WindowLeftTree.bjs +++ b/src/Builder4/WindowLeftTree.bjs @@ -1303,68 +1303,20 @@ "string name" : "left-tree-view", "xtype" : "ColumnView", "| Gtk.Widget? getWidgetAt" : [ - "(double x, double in_y) {", - "/*", - " \t", - "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465", - " \tvar colview = gesture.widget;", - " \tvar line_no = check_list_widget(colview, x,y);", - " if (line_no > -1) {", - " \t\tvar item = colview.model.get_item(line_no);", - " \t\t ", - " \t}", - " \t*/", - " \tvar y = in_y + _this.viewwin.el.vadjustment.value; ", - " var child = this.el.get_first_child(); ", - " \t//Gtk.Allocation alloc = { 0, 0, 0, 0 };", - " \tvar line_no = -1; ", - " \tvar reading_header = true;", - " \tvar curr_y = 0;", - " \tvar header_height = 0;", - " \tvar h = 0;", - " \twhile (child != null) {", - "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());", - "\t if (reading_header) {", - "\t\t\t\t", - "", - "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {", - "\t\t\t h += child.get_height();", - "\t\t\t\t\tchild = child.get_next_sibling();", - "\t\t\t\t\tcontinue;", - "\t\t\t\t}", - "\t\t\t\t// should be columnlistview", - "\t\t\t\tchild = child.get_first_child(); ", - "\t\t\t GLib.debug(\"header height=%d\", h);", - "\t\t\t\theader_height = h;", - "\t\t\t\t", - "\t\t\t\treading_header = false;", - "\t\t\t\tcontinue;", - "\t }", - "\t\t line_no++;", - "", - "\t\t\tif (y < header_height) {", - "\t\t \treturn null;", - "\t \t}", - "", - "\t\t\tvar hh = child.get_height();", - "\t\t\t//GLib.debug(\"got cell xy = %d,%d w,h= %d,%d\", alloc.x, alloc.y, alloc.width, alloc.height);", - "\t\t\tif (child.has_css_class(\"node-err\") || ", - "\t\t\t\tchild.has_css_class(\"node-warn\") || ", - "\t\t\t\tchild.has_css_class(\"node-depr\")) {", - "\t\t\t\thh += 10;", - "\t\t\t", - "\t\t\t}\t", - "\t\t if (y > curr_y && y <= header_height + hh + curr_y ) {", - "\t\t\t return (Gtk.Widget)child;", - "\t\t }", - "\t\t curr_y += hh ;", + "(double x, double y) {", "", - "\t\t if (curr_y > y) {", - "\t\t return null;", - "\t }", - "\t child = child.get_next_sibling(); ", - " \t}", - " return null;", + "\tvar w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);", + "\t//GLib.debug(\"got widget %s\", w == null ? \"nothing\" : w.get_type().name());", + "\tif (w == null) {", + "\t\treturn null;", + "\t}", + "\t", + "\tvar row= w.get_ancestor(GLib.Type.from_name(\"GtkColumnViewRowWidget\"));", + "\tif (row == null) {", + "\t\treturn null;", + "\t}", + "\treturn row;", + " ", "", " }" ], @@ -1455,98 +1407,50 @@ " }" ], "| int getRowAt" : [ - "(double x, double in_y, out string pos) {", - "", + "(double x, double y, out string pos) {", "", + "\tvar w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);", + "\t//GLib.debug(\"got widget %s\", w == null ? \"nothing\" : w.get_type().name());", + "\tif (w == null) {", + "\t\treturn -1;", + "\t}", + "\t", + "\tvar row= w.get_ancestor(GLib.Type.from_name(\"GtkColumnViewRowWidget\"));", + "\tif (row == null) {", + "\t\treturn -1;", + "\t}", + "\t", + "\t//GLib.debug(\"got colview %s\", row == null ? \"nothing\" : row.get_type().name());", "\t ", - "", - "/*", - " \t", - "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465", - " \tvar colview = gesture.widget;", - " \tvar line_no = check_list_widget(colview, x,y);", - " if (line_no > -1) {", - " \t\tvar item = colview.model.get_item(line_no);", - " \t\t ", - " \t}", - " \t*/", - " \t\t ", - " \t\t", - " \t\tGLib.debug(\"get Widget At Row x = %d y = %d\", (int) x, (int) in_y);", - " \tvar y = in_y + _this.viewwin.el.vadjustment.value; ", - " var child = this.el.get_first_child(); ", - " \t//Gtk.Allocation alloc = { 0, 0, 0, 0 };", - " \tvar line_no = -1; ", - " \tvar reading_header = true;", - " \tvar real_y = 0;", - " \tvar header_height = 0;", - " \tpos = \"none\";", - " \tvar h = 0;", - " \twhile (child != null) {", - "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());", - " \t if (reading_header) {", - "\t\t\t\t", - "", - "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {", - "\t\t\t h += child.get_height();", - "\t\t\t\t\tchild = child.get_next_sibling();", - "\t\t\t\t\tcontinue;", - "\t\t\t\t}", - "\t\t\t\t// should be columnlistview", - "\t\t\t\tchild = child.get_first_child(); ", - "\t\t\t //GLib.debug(\"header height=%d\", h);", - "\t\t\t\theader_height = h;", - "\t\t\t\t", - "\t\t\t\treading_header = false;", - "\t\t\t\tcontinue;", - "\t\t\t\t", - "\t }", - "\t ", - "\t\t if (child.get_type().name() != \"GtkColumnViewRowWidget\") {", - " \t\t child = child.get_next_sibling();", - " \t\t continue;", - "\t\t }", - "\t\t ", - "\t\t \tif (y < header_height) {", - "\t\t \treturn -1;", - "\t \t}", - "\t\t ", - "\t\t line_no++;", - "\t\t\tvar hh = child.get_height();", - "\t\t\t", - "\t\t\tif (child.has_css_class(\"node-err\") || ", - "\t\t\t\tchild.has_css_class(\"node-warn\") || ", - "\t\t\t\tchild.has_css_class(\"node-depr\")) {", - "\t\t\t\thh += 10;", - "\t\t\t", - "\t\t\t}", - "\t\t\t//child.get_allocation(out alloc);", - "\t\t\t//GLib.debug(\"got cell xy = %d,%d w,h= %d,%d\", alloc.x, alloc.y, alloc.width, alloc.height);", - "\t\t\t//GLib.debug(\"row %d y= %d %s\", line_no, (int) (header_height + alloc.y),", - "\t\t\t", - "\t\t\t//\tchild.visible ? \"VIS\" : \"hidden\");", - "", - "\t\t if (y > (header_height + real_y) && y <= (header_height + real_y + hh) ) {", - "\t\t \tif (y > ( header_height + real_y + (hh * 0.8))) {", - "\t\t \t\tpos = \"below\";", - "\t \t\t} else if (y > ( header_height + real_y + (hh * 0.2))) {", - "\t \t\t\tpos = \"over\";", - " \t\t\t} else {", - " \t\t\t\tpos = \"above\";", - "\t\t\t\t}", - "\t\t \t GLib.debug(\"getRowAt return : %d, %s\", line_no, pos);", - "\t\t\t return line_no;", - "\t\t }", - " ", - "", - "\t\t if (real_y + hh > y) {", - "\t\t return -1;", - "\t }", - "\t real_y += hh;", - "\t child = child.get_next_sibling(); ", - " \t}", - " return -1;", - "", + "\tvar rn = 0;", + "\tvar cr = row;", + "\t ", + "\twhile (cr.get_prev_sibling() != null) {", + "\t\trn++;", + "\t\tcr = cr.get_prev_sibling();", + "\t}", + "\t", + "\t//GLib.debug(\"row number is %d\", rn);", + "\t//GLib.debug(\"click %d, %d\", (int)x, (int)y);", + "\t// above or belw", + "\tGraphene.Rect bounds;", + "\trow.compute_bounds(this.el, out bounds);", + "\t//GLib.debug(\"click x=%d, y=%d, w=%d, h=%d\", ", + "\t//\t(int)bounds.get_x(), (int)bounds.get_y(),", + "\t//\t(int)bounds.get_width(), (int)bounds.get_height()", + "\t//\t);", + "\tvar ypos = y - bounds.get_y();", + "\t//GLib.debug(\"rel ypos = %d\", (int)ypos);\t", + "\tvar rpos = 100.0 * (ypos / bounds.get_height());", + "\t//GLib.debug(\"rel pos = %d %%\", (int)rpos);", + "\tpos = \"over\";", + "\t", + "\tif (rpos > 80) {", + "\t\tpos = \"below\";", + "\t} else if (rpos < 20) {", + "\t\tpos = \"above\";", + "\t} ", + "\treturn rn;", " }" ] }, diff --git a/src/Builder4/WindowLeftTree.vala b/src/Builder4/WindowLeftTree.vala index a80ebcf40..b93c57dab 100644 --- a/src/Builder4/WindowLeftTree.vala +++ b/src/Builder4/WindowLeftTree.vala @@ -438,161 +438,65 @@ public class Xcls_WindowLeftTree : Object return -1; } - public int getRowAt (double x, double in_y, out string pos) { - + public int getRowAt (double x, double y, out string pos) { + var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT); + //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name()); + if (w == null) { + return -1; + } + + var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget")); + if (row == null) { + return -1; + } + + //GLib.debug("got colview %s", row == null ? "nothing" : row.get_type().name()); - - /* - - from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465 - var colview = gesture.widget; - var line_no = check_list_widget(colview, x,y); - if (line_no > -1) { - var item = colview.model.get_item(line_no); - - } - */ - - - GLib.debug("get Widget At Row x = %d y = %d", (int) x, (int) in_y); - var y = in_y + _this.viewwin.el.vadjustment.value; - var child = this.el.get_first_child(); - //Gtk.Allocation alloc = { 0, 0, 0, 0 }; - var line_no = -1; - var reading_header = true; - var real_y = 0; - var header_height = 0; - pos = "none"; - var h = 0; - while (child != null) { - //GLib.debug("Got %s", child.get_type().name()); - if (reading_header) { - - - if (child.get_type().name() != "GtkColumnListView") { - h += child.get_height(); - child = child.get_next_sibling(); - continue; - } - // should be columnlistview - child = child.get_first_child(); - //GLib.debug("header height=%d", h); - header_height = h; - - reading_header = false; - continue; - - } - - if (child.get_type().name() != "GtkColumnViewRowWidget") { - child = child.get_next_sibling(); - continue; - } - - if (y < header_height) { - return -1; - } - - line_no++; - var hh = child.get_height(); - - if (child.has_css_class("node-err") || - child.has_css_class("node-warn") || - child.has_css_class("node-depr")) { - hh += 10; - - } - //child.get_allocation(out alloc); - //GLib.debug("got cell xy = %d,%d w,h= %d,%d", alloc.x, alloc.y, alloc.width, alloc.height); - //GLib.debug("row %d y= %d %s", line_no, (int) (header_height + alloc.y), - - // child.visible ? "VIS" : "hidden"); - - if (y > (header_height + real_y) && y <= (header_height + real_y + hh) ) { - if (y > ( header_height + real_y + (hh * 0.8))) { - pos = "below"; - } else if (y > ( header_height + real_y + (hh * 0.2))) { - pos = "over"; - } else { - pos = "above"; - } - GLib.debug("getRowAt return : %d, %s", line_no, pos); - return line_no; - } - - - if (real_y + hh > y) { - return -1; - } - real_y += hh; - child = child.get_next_sibling(); - } - return -1; - + var rn = 0; + var cr = row; + + while (cr.get_prev_sibling() != null) { + rn++; + cr = cr.get_prev_sibling(); + } + + //GLib.debug("row number is %d", rn); + //GLib.debug("click %d, %d", (int)x, (int)y); + // above or belw + Graphene.Rect bounds; + row.compute_bounds(this.el, out bounds); + //GLib.debug("click x=%d, y=%d, w=%d, h=%d", + // (int)bounds.get_x(), (int)bounds.get_y(), + // (int)bounds.get_width(), (int)bounds.get_height() + // ); + var ypos = y - bounds.get_y(); + //GLib.debug("rel ypos = %d", (int)ypos); + var rpos = 100.0 * (ypos / bounds.get_height()); + //GLib.debug("rel pos = %d %%", (int)rpos); + pos = "over"; + + if (rpos > 80) { + pos = "below"; + } else if (rpos < 20) { + pos = "above"; + } + return rn; } - public Gtk.Widget? getWidgetAt (double x, double in_y) { - /* - - from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465 - var colview = gesture.widget; - var line_no = check_list_widget(colview, x,y); - if (line_no > -1) { - var item = colview.model.get_item(line_no); - - } - */ - var y = in_y + _this.viewwin.el.vadjustment.value; - var child = this.el.get_first_child(); - //Gtk.Allocation alloc = { 0, 0, 0, 0 }; - var line_no = -1; - var reading_header = true; - var curr_y = 0; - var header_height = 0; - var h = 0; - while (child != null) { - //GLib.debug("Got %s", child.get_type().name()); - if (reading_header) { - + public Gtk.Widget? getWidgetAt (double x, double y) { - if (child.get_type().name() != "GtkColumnListView") { - h += child.get_height(); - child = child.get_next_sibling(); - continue; - } - // should be columnlistview - child = child.get_first_child(); - GLib.debug("header height=%d", h); - header_height = h; - - reading_header = false; - continue; - } - line_no++; - - if (y < header_height) { - return null; - } - - var hh = child.get_height(); - //GLib.debug("got cell xy = %d,%d w,h= %d,%d", alloc.x, alloc.y, alloc.width, alloc.height); - if (child.has_css_class("node-err") || - child.has_css_class("node-warn") || - child.has_css_class("node-depr")) { - hh += 10; - - } - if (y > curr_y && y <= header_height + hh + curr_y ) { - return (Gtk.Widget)child; - } - curr_y += hh ; - - if (curr_y > y) { - return null; - } - child = child.get_next_sibling(); - } - return null; + var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT); + //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name()); + if (w == null) { + return null; + } + + var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget")); + if (row == null) { + return null; + } + return row; + } }