GNOME Bugzilla – Bug 162790
Implementation of GDK_LINE_DOUBLE_DASH on Win32
Last modified: 2009-02-10 02:15:44 UTC
The problem is described in bug 162555, to be short: "GDK_LINE_DOUBLE_DASH is not complete on Win32. Both GDK_LINE_ON_OFF_DASH and GDK_LINE_DOUBLE_DASH are simulated by the Win32 pen style PS_DASH which means that odd segments are not drawn." Attachment 35360 [details] is the prposed patch which simulates LineDoubleDash (instead of using PS_DASH) and dash_offset of XSetDashes also.
Created attachment 35422 [details] [review] proposed patch Replaces attachment 35360 [details] [review]
You wouldn't happen to have some minimal test program that draws various dashed lines?
Would the following ChangeLog entry be a correct summary: 2005-01-09 Tor Lillqvist <tlillqvist@novell.com> Fix for #162790, by Iwan Wong: * gdk/win32/gdkdrawable-win32.c: Implement dashed lines correctly. Simplify the interface to render_line_horizontal() and render_line_vertical(). Need to draw lines "manually" also on NT-based Windowses if we have a dash offset or are drawing double-dashed lines. * gdk/win32/gdkprivate-win32.h: Keep also the dash offset, double-dash flag, and a brush for the background colour (used by the odd dashes in the double-dash line style) in the GdkGCWin32 struct. * gdk/win32/gdkgc-win32.c: Set up above new fields.
BTW, how common are dashed oblique lines? Seen such in any GTK+ app? Would it be worth it to draw them "manually" also (instead of just calling LineTo())? My guess would be no...
> BTW, how common are dashed oblique lines? Seen such in any GTK+ app? Please check Bug 162555. > Would it be worth it to draw them "manually" also > (instead of just calling LineTo())? I agree that the double dash line is not a common one. But we need to implement that for compatibility. While one claims that Gtk+ is cross platform, we need to keep the promise for every detail without obvious trade-off. GDK_LINE_SOLID/GDK_LINE_ON_OFF_DASH are most of the cases, and they are done by the native PS_DASH style. I can see no reason why we can't have a simulation of GDK_LINE_DOUBLE_DASH without affecting the performance/complexity of GDK_LINE_SOLID/GDK_LINE_ON_OFF_DASH. We ought not to forget a public feature of a cross platform toolkit forever just because it's not implemented natively or it's rare.
> > BTW, how common are dashed oblique lines? Seen such in any GTK+ app? > Please check Bug 162555. Please look up "oblique" in a dictionary ;-) Obviously, yes, horizontal and vertical dashed and double-dashed lines should be fixed, and thank you very much for working on this! But should something also be done for such lines that are neither horizontal or vertical?
> Please look up "oblique" in a dictionary ;-) Ah, I am really sorry about that. I missed the most critical word of your sentence. > But should something also be done for such lines that > are neither horizontal or vertical? IMHO, I think it would be great if it's done. However, as it needs a certain amount of effort to implement, just leave it until someone has time.
Created attachment 35839 [details] [review] revised Should reset pen_double_dash when setting line style to solid line. ChangLog entry in #3 looks sane. I will try to submit a dash lines drawing demo later.
OK, patch committed (to HEAD). Thanks!
Patch applied to gtk-2-6, too.
There seems to be soemething wrong with this patch (or with my understanding of 'dash_offset'). Simply adding the line patterns start offset to the start point f the line has the ability of very ugly effects, e.g. when drawing grids. See following attachment.
Created attachment 38288 [details] A diagram window with broken grid. The dashoffset Dia uses is kind of strange (and may be wrong in itself: x+y and as visible it draws the grid from top left to buttom right. Very disturbing the missing parts by letting GDK start at x,y plus the offset. [The goal of the dash_offset usage is to keep the line pattern in place even with different start points, drawing only a part of the image.] I think the function to use for it is SetBrushOrgEx and there needs to be some (dash_offset modulo dash_len).
This is now fixed - see bug #171641 - for the non double dash case. Not fixed for double dashing cause I do neither know a program using them not how they are supposed to look.
I hope dashed lines are by now implemented as well as they will ever be in the Win32 backend ;-) See also bug #306396 and bug #308413. Resolving as fixed.