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

Re: Adding property to "line"



On 7 Aug 2003, Sven Vermeulen wrote:
> Hi,
>
> If I were to add a property to the "line" object, how would I proceed? I
> was thinking of the following:
>
> - Add a variable "gboolean isdouble" to the Line structure in
> objects/standard/line.c.

Yes.

> - Add a toggle_button to dia_line_style_selector_init in lib/widgets.c, bind
> a function that switches the "isdouble" variable

No.  Add a new boolean property by adding

 { "is_double", PROP_TYPE_BOOL, PROP_FLAG_VISIBLE, N_("Doubled line"), }

to line_props, and

 { "is_double", PROP_TYPE_BOOL, offsetof(Line, isDouble), }

to line_offsets, both in objects/standard/line.c

This is if you want to do it by having a checkbox for the line object only.
If you want to make it a line style, like dashed and dotted, you won't need
to touch the objects, just add to the line style list in lib/widgets.c and
lib/dia_enums.h, and then it's really up to the renderers to render it
correctly.

> and then find in what function the line-rendering is achieved, and in
> that function check the value of isdouble, and depending on that value,
> render one or two lines.

Yes; that function would be line_draw in objects/standard/line.  Note that
arrow drawing is combined with line drawing, which complicates matters a
bit.  The line_width given to draw_line_with_arrows is used not just for
the rendering, but also to determine where to cut off the line.

Again, if you do it by adding a line style, the rendering function will be
in the various renderers.  However, figuring out the arrow calculations
might be tricky.

> I know the rendering is achieved using several functions (each one more
> general than the other). What function should I be looking for?

line_draw, if going the object way, draw_line in the renderers otherwise.

> By checking out the other properties, I guess I'll also have to define a
> (e.g.) PROP_STD_LINE_DOUBLE and add it to the LineProperties. 

You have to decide whether this is a line style like dashed etc, or a flag
on some objects only.  The two have very different implications.

-Lars

-- 
Lars Clausen (http://shasta.cs.uiuc.edu/~lrclause)| HĂ„rdgrim of Numenor
"I do not agree with a word that you say, but I   |----------------------------
will defend to the death your right to say it."   | Where are we going, and
    --Evelyn Beatrice Hall paraphrasing Voltaire  | what's with the handbasket?



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] Mail converted by Mofo Magic and the Flying D

 
All trademarks and copyrights are the property of their respective owners.

Other Directory Sites: SeekWonder | Directory Owners Forum

GuideSMACK