gpaint-develop
[Top][All Lists]
Advanced

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

Re: [Gpaint-develop] tool objects


From: Andy Tai
Subject: Re: [Gpaint-develop] tool objects
Date: Tue, 14 May 2002 10:56:30 -0700 (PDT)

Michael, go ahead.  The drawing routines as stand now
are a mass... Making them OO should result in much
clearer code.  The mass of the current code is one
reason I was not working on "zooming." Making the code
clean also helps features like Undo, etc.  
--- "Michael A. Meffie III" <address@hidden>
wrote:
> Andy,
> 
> I would like to make some changes to gpaint related
> to the design of the
> util.c module. Before I do, I want to make sure it
> is ok with you, and
> you feel it would be change for the better.
> 
> I would like to make the gpaint tools modular and
> object-oriented,
> using a similar technique as the GIMP uses. The tool
> objects would
> be implemented as C structures with a few members
> that are
> function pointers.
> 
> There would be a base class for all tools, called
> Tool. The ibuf would
> have a pointer to the current tool object by a
> pointer to a Tool object
> (instead of a tool number.) The tool object would be
> declared in in
> tool.h, something like this:
> 
>    typedef void (* ButtonPressFunc)    (Tool *,
> GdkEventButton *);
>    typedef void (* ButtonReleaseFunc)  (Tool *,
> GdkEventButton *);
>    typedef void (* MotionFunc)         (Tool *,
> GdkEventMotion *); 
>    struct _Tool
>    {
>       int    tool_type;
>       char*  tool_name;
>       struct image_buf *ibuf; /* for draw operations
> */
>       ButtonPressFunc   button_press;
>       ButtonReleaseFunc button_release;
>       MotionFunc        motion;
>    };
> 
> The button_press, button_release, and motion methods
> would be used in
> the callback.c module on the current tool object.
> For example, to handle
> the mouse motion event:
> 
>    on_drawingarea_motion_notify_event(...)
>    {
>      ... 
>      if (active_tool) {
>        (*active_tool->motion)(active_tool, x, y);
>      }
>      ...
>    }
>   
> Each object would define this methods as needed as
> well as any tool
> context information. For example the text tool would
> keep the current
> text info. Much of the code that is currently in
> util.c would be moved
> to a new home in a tool module. Related tools could
> be implemented within
> a single module as not to create too many small
> files.
> 
> The paint brush and eraser would have a common class
> called paint_tool,
> to deal with the paint interpolation code.
> 
> I think this would improve the modularity of the
> drawing code. This
> would not change the user interface, but after the
> new tool objects are
> ready, then we could add features to enhance the
> brush and line
> attributes. For example, we need to add various
> brush tips. Hopefully
> this change would help make it easier to add new
> tool types in the
> future and to use gpaint as the basis for more
> special purpose programs.
> 
> Let me know if you think this would be a good
> project for gpaint. 
> 
> Thanks,
> Mike
> 
> --
> Michael A. Meffie III        
> http://home.neo.rr.com/meffie
> For every truth, there is an equal and opposite
> truth.
> 
> _______________________________________________
> Gpaint-develop mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/gpaint-develop


__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com



reply via email to

[Prev in Thread] Current Thread [Next in Thread]