[cad-linux-dev] braindead gui toolkits

  • From: Eric Wilhelm <ewilhelm@xxxxxxxxxxxxx>
  • To: cad-linux-dev@xxxxxxxxxxxxx
  • Date: Wed, 27 Oct 2004 23:50:48 -0500

Ok, I'm just coming out of the woods with my adventures in Tk::Zinc.  
The text zooming did indeed work out, but it took some juggling to 
get from a "height" to a "font" (and that font is currently 
hard-coded.)  If you're feeling adventurous, feel free to dig into 
the subversion repository.
  http://ericwilhelm.homeip.net/svn/CAD-Drawing/trunk/code/CAD/Drawing/

Sorry, no tarballs yet.  Maybe once it's seen some use I'll put it on 
CPAN.

Some interesting issues come up in how to create keybindings between 
multiple windows.  For instance, the zoom function.  The "z" key 
activates zoom from any toplevel widget, but which canvas should it 
put that functionality into?  My solution is "all of them".  The 
problem then is how to tell the other canvases that you are done 
zooming (and that therefore they should be too.)  This leads to the 
sharing of the functionality CAD::Drawing::GUI and 
CAD::Drawing::GUI::View modules.  The GUI module handles the 
management of multiple canvases, while the View object is a single 
canvas (though it has to have the same drawing on it, scale and etc 
are independent.)

As for the braind-dead-ness.  I looked at GTK, QT, TK, WX, and finally 
ended up with Tk::Zinc because it was the only one that was able to 
scale text without having to do the recalculate-approximate dance 
(which leads to really bumpy zooming when you have to jump from 12pt 
to 24pt.)

So, why are we using points to describe text in a world of pixels?

Furthermore, why does the y-axis have to point downward?  Sure, that's 
how X works, but isn't the point of toolkits to make programming 
easier?  Am I thinking upside-down, or is that everyone else?

Finally, what's with the rectangles?  Okay, a rectangle can be 
described with two points, but it's just a special case of a 
polyline.  A circle usually doesn't have it's own method (we have to 
call it an arc), so why rectangles?  On top of that, we describe said 
rectangles as a list of four points?!  Isn't it a pair of pairs?

While I'm at the rectangles, why are arcs and elliptical arcs 
described as fitting inside of a rectangle?  At least with Tk::Zinc, 
I can apply rotation afterwards (to get a slanted elliptical arc 
(though that makes for some hairy math), but Tk and Wx also suffer 
from the rectangular world syndrome and don't seem to have a way to 
rotate entities.

Is there not any demand for these things?  I just want a right-side-up 
canvas with arcs described by a center and radius, scalable 
pixel-sized text, and the ability to draw angled elliptical arcs.

It's getting to the point where I just want to abandon most of the API 
and draw everything as bezier curves.  Of course, the slow-down of 
evaluating these curves in Perl would not be fun.

On a more upbeat note, working on this did give me an idea for a 
cadfs-based toolkit.  Basically, this would be like Draft in that it 
immediately displays what happens in the database.  However, to be 
able to repurpose (embed, etc) it for other applications, you would 
want a way to bind callbacks and such to this gui (particularly, a 
way for those callbacks to involve multiple viewports, etc.)  
Unfortunately, my latest effort is attached to the aging CAD::Drawing 
data-structure, but the concepts could easily be re-attached to 
something else (and should maybe be done so in a compiled language.)

--Eric
-- 
"Left to themselves, things tend to go from bad to worse."
                                        --Murphy's Corollary

Other related posts: