On 3/26/25 15:11, Tim Cuatt wrote:
Hi all,
I'm wondering if one can change the draw_vertical_connector and draw_horizontal_connector methods to virtual in Fl_Tree_Item?
That said, we have ways to enable ABI breaking features in
mid-stream maintenance releases via the FLTK_ABI_VERSION macro, so
it can certainly be added that way.
I'm not against it, but I await feedback/votes from other devs
to hear their concerns (beyond ABI macro protections), if any.
It makes sense I suppose, because the "connector lines" are
the one part of the tree items you can't really redefine easily;
these are the connection lines drawn between the items when the
tree is opened.
We'd be happy to develop and test this implementation over here and send over the changes if it sounds like a good fit with the toolkit.
Currently the Fl_Tree_Item methods draw_vertical_connector() and draw_horizontal_connector()
are protected non-virtual.
It wouldn't be hard to make an ABI protection macro that allows these to be protected virtuals.
To access this during the FLTK 1.4.x maintenance stream, you'd simply customize the ABI version macro setting and rebuild FLTK to enable such features. There's a README.abi-version.txt file on how to do this.
On 3/26/25 15:11, Tim Cuatt wrote:
I'm wondering if one can change the draw_vertical_connector and draw_horizontal_connector methods to virtual in Fl_Tree_Item?
Yes, it can be done.
Changing methods from protected to virtual will break ABI, from what my research shows, because it affects the virtual table, which itself is part of the ABI.
That said, we have ways to enable ABI breaking features in mid-stream maintenance releases via the FLTK_ABI_VERSION macro, so it can certainly be added that way.
I'm not against it, but I await feedback/votes from other devs to hear their concerns (beyond ABI macro protections), if any.
We'd be happy to develop and test this implementation over here and send over the changes if it sounds like a good fit with the toolkit.
I'd suggest going on github and providing a PR.
You don't have to implement the ABI protection macros, we can do that, but just show what changes you're looking for, and perhaps an example or two in the examples/ directory that show exercising the feature in the way you expect.
I think because those two methods are (currently) non-virtual,
you can't override them in a way that the tree can make use of
them. Kinda the purpose of making them virtual, so the tree can
access the user's overridden methods.
--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/fltkgeneral/4d860c6f-97c8-45ca-ad55-260274f7f0a4%40seriss.com.
On 3/27/25 10:49 AM, Bill Spitzak wrote:
I think if this is wanted it should be done by overriding draw(). Those are just internal details and the desired graphics may not map that well to these calls.
The attached example program (tree-custom-connectors.cxx)
demonstrates the issue by creating a custom Fl_Tree_Item class
called MyTreeItem which draws a grid as the content, and attempts
to also reimplement the
draw_vertical_connector()/draw_horizontal_connector() methods,
wanting to draw red connection lines in place of
the default dotted lines.
On the left: the app built against FLTK, where the methods are
non-virtual, causing the overrides to be ignored.
On the right is a hacked FLTK, where the two methods made
virtual, showing the "red connection lines", indicating the
override is working:
The attached example program (tree-custom-connectors.cxx) demonstrates the issue by creating a custom Fl_Tree_Item class called MyTreeItem which draws a grid as the content, and attempts to also reimplement the draw_vertical_connector()/draw_horizontal_connector() methods, wanting to draw red connection lines in place of the default dotted lines.
On the left: the app built against FLTK, where the methods are non-virtual, causing the overrides to be ignored.
On the right is a hacked FLTK, where the two methods made virtual, showing the "red connection lines", indicating the override is working:
If this is the only change needed to achieve what Rob and Tim request, then I believe it's sensible to make these two methods virtual in 1.5 and to do the same under an ABI guard (#if FL_ABI_VERSION >= 10403) in branch-1.4.
@Rob and @Tim: the only caveat would be that I don't plan to make a new public release (which would be 1.4.3) for this tiny change, i.e. it would be available only in Git for some time. There are presumably more patches to come for branch-1.4, and then this change would be included in the next release 1.4.3. Would you agree that this is a valid solution for you?
If this is the only change needed to achieve what Rob and Tim request, then I believe it's sensible to make these two methods virtual in 1.5 and to do the same under an ABI guard (#if FL_ABI_VERSION >= 10403) in branch-1.4.
@Rob and @Tim: the only caveat would be that I don't plan to make a new public release (which would be 1.4.3) for this tiny change, i.e. it would be available only in Git for some time. There are presumably more patches to come for branch-1.4, and then this change would be included in the next release 1.4.3. Would you agree that this is a valid solution for you?
Yes, this would work for us.
While we'd love to be on an official upstream release, we've shipped dev versions for years through the 1.3 and 1.4 process.
Note that there are new activities concerning release 1.4.3 because this may be needed for the next Debian release which has really high priority for us. Please follow GitHub Issue #1238 if you are interested. Solution of this issue would definitely trigger a new release, i.e. 1.4.3, as soon as possible.
Greg, I also changed my FLTK (1.5) version as described, i.e. by *only* making the two methods virtual, and I can confirm the effect you posted above in the image (as was to be expected).
@Greg: You are the one who knows best what all these methods in Fl_Tree do, and maybe you can decide which ones should be protected and/or virtual. My point here is: if we touch the interface (API) then we should "do it right" (TM) and consider maybe more methods that could be interesting for users of the class to modify.
Whether they need to be 'virtual' or not should be decided individually. Methods like drawing the connector lines might need to be virtual, even if users derive their own classes because they can be called internally from other drawing methods - but that's only an educated guess...
I would have thought these two methods would be "too internal"
to override
because of the amount of internal details needed in the method
arguments,
but apparently it's desireable, so here we are.
I think if I'd anticipated user customization beyond what is
already "open",
On 3/28/25 10:41 AM, Rob McDonald wrote:
On Friday, March 28, 2025 at 10:16:36 AM UTC-7 Albrecht-S wrote:
Note that there are new activities concerning release 1.4.3 because this may be needed for the next Debian release which has really high priority for us. Please follow GitHub Issue #1238 if you are interested. Solution of this issue would definitely trigger a new release, i.e. 1.4.3, as soon as possible.
Do you want me to put together a PR for this change -- or as it is so trivial and you've already made the change once in your test branch -- there is no need.
Regarding adding virtual, I'll handle this; expect a commit to 1.5.x today.
As I believe Albrecht mentioned in a previous reply, he didn't think this should be
added to 1.4.x as an ABI feature, so I'll leave that out.
On 3/28/25 20:53 Greg Ercolano wrote:
Regarding adding virtual, I'll handle this; expect a commit to 1.5.x today.
Thanks. FTR: Greg's commit is 9e1e043af35e979f5ad0824fb74f6e7fab57be7dAs I believe Albrecht mentioned in a previous reply, he didn't think this should be
added to 1.4.x as an ABI feature, so I'll leave that out.
This was my initial thought, but later, when I realized that it was such a trivial modification, I changed my mind.
Anyway, I can do the backport, particularly because an ABI guard against ABI version 10403 (1.4.3) would not work w/o changing the API version to 1.4.3 as well (see my previous message).
I'm thinking about changing the max-allowed ABI version to (API version + 1). This would allow to set the ABI version of the *next* release so ABI guards for that version would allow that code to be compiled. Then we could leave the API version at 1.4.2 (as long as it's not released), but users could set the ABI version to 1.4.3 (10403) and thus enable such "future" ABI features, ...