[Dillo-dev]About porting Dillo to FLTK.
Hi there, We've had long email threads (between our core developers and some FLTK core devs.) dicussing about how the port of dillo to FLTK could be done. We've explored different paths (in abstract) and posting all the threads to dillo-dev would add more to confussion than clarity because each one was explored as it were the chosen one. For simplicity and to keep all the developers in dillo-dev well informed (and certainly inviting the interested ones to take part in the process), I prepared this recapitulation about the more relevant issues. It's a long document with a lot of information. Cheers Jorge.- PS: Previous background on this topic can be found at dillo-dev's archives: http://www.dillo.org/search-dillo-dev.html. For instance: search for "FLTK" by "jcid" sorted by "Relevance". This will not only bring my posts but also the ones from Michael Sweet that I forwarded to dillo-dev. ----------------------------------------------------------------
[Sebastian] Furthermore, I have plans to extract at least the core of Dw, and make an own library of it. The package is already finished, I'm just polishing another package, which uses Dw. (This is "rtfl", the program for which the macros in "debug.h" are for.)
Perhaps it is at least possible, to make Dw itself independent of the widget toolkit (Gtk/FLTK), ...
[Sebastian] Dw can be rather simply extracted, and probably it is the best to start with a testbed. I've attached a test program (I searched for it somewhere in the mailing list, therefore the french identifiers :-), you have to build dillo first, to run it. Perhaps it is simpler to include it into the dillo tarball itself.
[Sebastian] Another aspect is portability: When using other toolkits than Gtk, GtkDwViewport may be replaced.
For archieving this, the following new design will be sufficient:
+--------------------+ 1 * +-------------------+ | DwRenderingContext |---------->| DwRenderingWindow | +--------------------+ +-------------------+ 1 ^ | 1 | | viewport | | child (the top-level DwWidget) | | * | V 0..1 +----------+ 0..1 | DwWidget |--. parent +----------+ | * | | `-------' (children)
[Sebastian] As for the actual porting, I'm currently working on two topics, which should make porting simpler, since they reduce the Gtk/Gdk specific stuff into single modules:
1. I'm currently changing the design of image handling as I described in doc/DwImage.txt in the tarball, section "Future Extensions". As I've seen now, this is also necessary for topic 2.
2. After this, I'll implement the ideas I wrote before (abstraction of the actual drawing), in the best case, it should be a simple matter to write a replacement for the viewport, plus some changes in dw_style.[ch]. (Dependance of the GtkObject model not yet considered.)
[Matt] Abstraction is definitely the best thing to do here. I am pretty sure we can cross reference between the a-layer and whatever FLTK has to offer. Spontaneously I see the need for buttons and input fields, line, box, text and image drawing, image scaling and the dreaded 16-bit vs. 32-bit coordinates.
[Jorge] Once again, I'd wish to know how a seasoned FLTK developer foresees the merging path (from their point of view). With regard to Dw, you're the authoritative source! ;)
[Matt] At this point - if you guys are still interested - I guess I should take an extensive tour through the Dw code and see, which parts map directly onto FLTK, and which parts would need modifications or even rewriting.
------------------ 32 bit coordinates ------------------
[Jorge]
Hi Michael,
We have been extensively discussing how to port Dillo to FLTK with Mattias M. and Sebastian. One of the key points is how to provide for a widget that overcomes the problem of 16 bit coordinates (GtkLayout currently solves this).
In a formar email you told me that FLTK2.0 had 32 bit coordinates, but suggested me to use 1.2.x release that would also come with 32 bit coordinates.
Matt was somewhat surprised by this...
[Matt] I talked to Mike. He changed the coordinates to 32 bit in his local version already. So in short, fltk 1.2 will have 32 bit coordinates. Versions 1.1 and 1.0 will not be changed anymore, however 1.2 should become the standard as soon as we release it, since it is source code compatible to 1.1.
[Matt] I went through the current CVS code yesterday, and it seems like we had a mixup between 1.1 and 1.2. Not a biggie, but I re-merged with a previous CVS version. The current CVS is now fully 32 bit. tested and working.
[Jorge] So we have to use 1.2.x CVS, but which docs are recommended for it?
[Matt] The 1.2 cvs contains the full 1.1 documentation and is beeing corrected to reflect 1.2 changes and additions. I am in the process of adding doxygen style comments to all fltk classes and methods (95% done), so simply running the command 'doxygen' will create a second, more 'techie' documentation in docs/html/index.html.
------- Signals -------
[Jorge] Appart from that, the 32 bit issue and the signals (perhaps solved with Fl_Signal).
[Sebastian] As for signals: This should be rather simple to re-implement. I just hacked a prototype of very simple framework for signals, which can be downloaded at <http://www.dillo.org/misc_files/signals-0.0.1.tar.gz>. It lacks events returning boolean (which we need), and some more features (which we do not need), but shows that signals aren't really a problem.
------- Plugins -------
OK, there's no plugin API in FLTK.
Do you mean what GtkPlug/GtkSocket does? There protocol has been (or is currently?) standardized at freedesktop.org, if an implemtation is possible (and why should it not?), this is certainly a candidate for merging into FLTK.
[Matt] Yeah, I talked to Bill, and we decided that we will create an Fl utility library that offers cross platform access to files and sockets, provides threads and locks, and also some standardised plugin interface. We will be smarter this time and write it in FLTK2 with an FLTK1 compatibility layer... .
------------------------------ About how to approach the port ------------------------------
[Sebastian] I'm more than ever convinced that this was the right decision, especially since then, incremental resizing has been added, what would have been very difficult in Gtk. Furthermore, this shows the benefit of having an own widget set, which can be infinitively changed to our needs.
[Jorge] In that case, it seems that the path to go is to port Dw to FLTK, and maybe get rid of some widgets (as DwImage) when they can be replaced by an FLTK embedded one.
In anycase, Matt is better qualified than me to comment on this.
[Matt] All images in FLTK can be resized at any point.
I understand that you prefer to have your own widget set, and I surely don't want to convince you different (because we wanted the same thing and that's why we wrote FLTK in the first place). However, should you decide to go with FLTK, then all the source code is available to you, so you can do the same modifications that you would do in your code. If those changes (or additions) are useful for the FLTK toolkit, I'll be happy to do them for you (ah, that's where the benefit is for you).
[Jorge] This is a very interesting collaboration scenery. I believe we could start as Sebastian suggests, and merge those features you see could benefit FLTK. (as for images, and maybe the "complex resize" widget using size hints to name two).
[Sebastian] To make this clear again: What we currently have is an own widget toolkit within Gtk, i.e. Dw widgets, from which the page is build, are not Gtk widgets, but instead, for Gtk, a tree of Dw widgets is a just _one_ huge Gtk widget. (With the exception of Gtk widgets embedded into Dw.)
I'd like to stick with the same design (with FLTK instead of Gtk), also on the long run. For this, there are rather few requirements for the GUI toolkit, mainly only the 32 bit issue. Integrating both toolkits, in the way that Dw widgets will become FLTK widgets, will however make things generally more complicated, we will have a hybrid which has to deal with both rendering HTML (and other) documents on one hand and GUIs on the other hand. The duplicate code in the current design (like event handling), is rather minimal, but integrating would mean one of the following possibilities:
1. Making FLTK as abstract as possible: This would make Dw as complex as it is now, but instead add an unneccessary dependency, where the development of dillo will often have to deal with the limits which any GUI toolkit has.
2. Incorperating stuff from Dw into FLTK: This would IMO a very bad decision of the FLTK team. Dw was designed for rendering documents etc., and its layout mechanism has several ad hoc features (size hints, width extremes, incremental resizing), which should not be in a toolkit for GUIs. Actually, the design is quite ugly at some points.
Furthermore, the design often changes, some historical examples:
- Dw widgets had baselines from the beginning, but they were fist used much later. (I was indeed hesitating at the beginning.) - Tables made it neccessary to introduce width extremes. (Very ad hoc: Why not height extremes? Because texts are -- in most languages -- written horizontally, and then vertically split into lines.)
- Also with tables (although noticed some time later), it became clear that the current resizing mechanism was inefficient and had to be extended. (Notice that Dw requires that several resizes per second must be handled, much more what is neededfor GUIs.)
These were certainly not the last changes, e.g. for CSS, we will have some other requirements, which are yet not specified. Also, this shows that most requirements are not obvious before they are first needed.
If FLTK wants to adopt Dw features, it will be neccecary to change FLTK often, and since it is not part of dillo, the development of dillo will be slowed down, until new FLTK releases.
3. We move stuff from Dw into our own version of FLTK: This would probably the worst possible desicion, we would fork FLTK and have to maintain it, also the parts which deal with pure GUI aspects.
Dw will work fine with FLTK in the way analogue to the current way, and the problems with this split are really not as dramatic as Jorge describes it. The FLTK developers should not make the mistake to take just one (probably rather prominent) project and change their work so that it just fits within it. And dillo should keep it dependencies as low as neccessary.
------------ Porting Plan ------------
[Sebastian] I'd suggest the following:
1. Finish the planned abstractions. The general idea is to have the Gtk/FLTK specific code in small modules, which may be rewritten in a simple way.
2. Extract Dw from dillo, and write a test program for several aspects of Dw.
3. Rewrite those modules mentioned in 1, and adjust the test program. This step will still make Gtk necessary, because of the Gtk object model, but UI control, event handling etc. will be done by FLTK.
AFAIS, the affected modules are the new GtkDwViewport, ImgBuf, and DwStyle. The abstraction in step 1 may taken a bit more extreme, by splitting up the latter two into toolkit-dependant and -independant parts, we'll see. The dillo widgets themselves should not be modified, if this is really necessary, this is a fault of the said abstraction.
After this, we will have a version of Dw, which works with FLTK. The next step is to see how the parts we take from Gtk (object model with signals) and GLib (several utilities) can be replaced, so that we can get rid of the Gtk dependencies. Another topic it the port of the actual UI; AFAIS, there should be no major problems.
Appendix -------- -------------- About printing --------------
[Jorge] Is printing lost because the widget tree is not native FLTK, or is it assured by using FLTK's drawing primitives?
[Sebastian] Some remarks on this. First, we still have a "native" FLTK widget, just that we have one large, complex FLTK widget (which complexity is manages by Dw), instead of multiple smaller and simpler FLTK widgets. The reimplementation of the viewport should use FLTK methods for drawing, so there is no problem at all.
Second, the abstraction described above should make this possible with any toolkit, it should be simple to write a printing "viewport".
Third, printing will anyway become more complex, for several reasons. For one reason, I quote myself from a mail I sent Jorge, this may also be interesting for Matt:
<q> I'm very sceptical about the idea to use the current rendering for printing, for two reasons: First, the current rendering is designed for dealing with viewports, not for pages. Pages are in some ways different, e.g. you must break pages (instead of having one page of unlimited height), and you cannot widen the page, you must break a word, when it does not fit into the line, while it is more reasonable to let the user scroll to the right, when this is possible. (Furthermore, from a typographic point of view, dillo's typesetting quality is sufficient for screen rendering, but rather poor for printing, especially page breaking cannot be done as simply as line breaking.)
Second, most of the complexity has its roots in the requirement of incremental rendering, which is neither needed, nor desired for printing. Actually, it makes use for printing more complicated and inefficient. (Although one rendering iteration has a nearly constant time, it is as a whole still slower than a simple non-iterative run.)
[...] </q>
Furthermore, even if we would use Dw for printing (with ugly page breaks etc.), we would need another widget tree, with the same content of the current one, but with a state, which is different, e.g. the top-level available width, which is the window width for the screen, but the standard paper width for the printer.
participants (1)
-
Jorge Arellano Cid