Re: GnomeCanvas



>  Yesterday I tried to understand the GnomeCanvas and I looked into the
>  sources of gnumeric, gnomecal and testgnome. While sneaking through
>  the code I got a few ideas and a few questions:

First, let me explain that the canvas does not specify any semantics
for the items by itself.  The plain items "are just there" and don't
have any behavior of their own.

I think this is the right way to do the canvas, because different
applications may want different semantics.

>  1.) What about a highlight function, that will highlight the item in
>  the near of the cursor. I figured out that you call the (point)
>  function to determine the nearest item whithe every mouse move.	I´m
>  not sure if this can be done via the drawable of the (draw) function,
>  or a new (highlight) function, which will copy most of the (draw)
>  algorithm. 

Miguel posted a nice function "prepare_for_highlighting()" or
similar.  This is more or less the approach I am using in gnomecal for
prelighting the days in the monthly calendars; I pass a month canvas
item to a function that hooks the necessary signals to do
highlighting.

>  2.) In the gnumeric it is very difficult to hit the cursor or a circle 
>  with a mouse click. Although I have seen, that e.g the item_grid
>  installs an event handler that catches all events, and filters the
>  right mouse click to display an context sensitive menu. 
>  
>  What if an item installs a "menu) function in the GnomeCanvas and the
>  canvas calls this function for all objects in the near of the
>  cursor. Like in glade, you would be able to select the other item,
>  without a hassle. e.g. The menu would could look like:
>  
>    line1  ->
>    line2  ->
>    circle -> 
>    rect   ->
>    cursor ->
>    ---------
>    cut
>    paste
>    ...
>  
>  - While traversing the menu, the items could highlight to give a
>    visual feedback. 
>  - Selecting only an item (e.g like circle) while set the circle as the 
>    current selection

Tk's canvas has a function that lets you get a list of items that are
completely or partially contained within a rectangular area.  This is
just the sort of function you would use, I think.  I still have to
implement this function in the GnomeCanvas.  I just added this to my
TODO list.

>  3.) Wouldn´t the functionality of the Stipples in gnumeric be better
>      placed into GnomeCanvas?

Yes.  The canvas has to handle some aspects of stippling by itself.
This in the TODO.

>  4.) Is the GnomeCanvas thought as an all purpose Canvas, or is it
>  thought as a spezialiced drawing widget? E.g. am I able to insert a baboon
>  object within the canvas, to build up a document processor?

If Baboon components are widgets, then you can insert them in the
canvas.  I guess Baboon would want something a bit more generic, but I
really don't know.

[Widget items are a bit broken in the canvas right now; I will finish
fixing them as I work on the gnomecal.]

>  5.) Is somebody working on the spline interpolation in the
>  gnome-canvas-line item? I would like to do this. I thought about
>  computing the interpolated pixels within the realize phase and to hold 
>  a second list of GnomeCanvasPoints within the GnomeCanvasLine
>  structure.

I am thinking of just using Tk's code for this.  It seems to work
nicely.

In the future, I would like to have Bézier curves as well.  Maybe the
final version would let you select between parabolic splines (like
those in Tk) and real Béziers.

>  6.) Is it possible to build up a generic widget from the item arguments, 
>  so that one can change the arguments from a properties entry in the
>  right click menu. The generic widget could be replaced by the item
>  programmer with a specialized widget.

I guess that could be done without too much trouble.  You can use
gtk_object_query_args() to query the arguments that an item accepts
and use that information to build a configuration dialog.

Again, this is very specific to each application.

>  7.) Last but not least a question about inheritance: What if I would
>  like to produce a small drawing application with lines, circles,
>  rectangles, polygons and variable fill style, line width, color? 
>  
>  If I want to change the properties of the item I want to have a
>  notebook dialog with e.g three tabulators: 
>  <line style> <fill style> <other> 
>  
>  Naturally various items in my drawing application have various properties.
>  But all properties belong at least within a few classes. Now I´m
>  thinking in the objective-c way and would like to say a line conforms
>  to the line_style protocol, that means it implements all arguments to
>  change the line style. Then I´m able to write a custom widget to
>  change the line style and to insert this widget in the properties
>  notebook line style page. Do you understand what I mean?

The number of primitive canvas items is small enough that you can make
a custom dialog for each of them -- of course you can write little
abstractions like "create_line_style_configurator_panel()" and such.
If you want to make it a bit more automatic, you can use
gtk_object_query_args() as described above.

  Federico



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]