simple display (from: GUI library for D)

KennyTM~ kennytm at gmail.com
Sun Apr 10 14:39:03 PDT 2011


On Apr 9, 11 04:26, Adam D. Ruppe wrote:
> We discussed this first in the GUI library thread, but since it
> meandered so much, I decided to split off into a new subject. Much
> of what I say here will be old to anyone who saw the previous thread.
> There's some new stuff nearer to the bottom though.
>
> I, with input from others, have started writing a little module
> for simple uses of a display. You can write to a bitmap, display it
> to a window, and handle events all in an easy way. The basics are
> cross platform, but you can use native function calls too.
>
> http://arsdnet.net/dcode/simpledisplay.d
>
> It's still very much in progress, but I think it's now at the point
> where the direction I'm taking it is clear.
>
[snip]

Thanks for the great work!

Taking the version on that link, I have ported it to use the native 
Cocoa/Core Graphics in OS X, instead of X11. You can check out the diff 
in https://github.com/kennytm/simpledisplay.d/commit/a790.

Only Snow Leopard (10.6) is supported.

I have only tested that it works on the pendulum example and the HSL 
picker, so things like drawText and drawPixel may not work properly yet. 
The implementation part is quite messy right now due to Objective-C.

Since dmd does not have "pragma(framework)", you'll need to supply the 
"-L-framework -LAppKit" options to dmd to link it.

And a few things:

  1. *Please use spaces instead of tabs.*
  2. Color's constructor's arguments should better be "red" "green" 
"blue" "alpha" rather than "a" "b" "c" "d".
  3. The unit of "pulseTimeout" should be documented (milliseconds).
  4. In the function "fromHsl", there is a (h is real.nan). However, 
'is' on primitives is reduced to '==' and (nan == nan) is false, so (h 
is real.nan) will always be false. You should use std.math.isNaN().
  5. Why use the ANSI version (LoadIconA, etc.), not the Unicode version 
(LoadIconW, etc.) of API on Windows? I think the latter is preferred.


More information about the Digitalmars-d mailing list