sidorares / ntk

node.js desktop UI toolkit
91 stars 12 forks source link

consider using vec2 for points? #1

Open dominictarr opened 11 years ago

dominictarr commented 11 years ago

One thing I'd like to suggest, is to use https://github.com/tmpvar/vec2.js to represent point & sizes instead of just x, y, width, height properties.

Then all the code about intersections, layouts, dragging&dropping, animation etc, becomes a great deal more modular, and decoupled from the fact that it's for a window manager, or whatever.

(for example, the layout code that I used in tiles I originally used in the browser. it's only coupled to geometry, and geometry is timeless. https://github.com/dominictarr/vec2-layout/blob/master/grid.js

I'm using it like this https://github.com/dominictarr/tiles/blob/master/xorg.js#L70-L77

With a bounds = new Vec2() for the x, y coords, and bounds.size = new Vec2() for the width and height. I've been considering changing it to win.pos = new Vec2(); win.size = new Vec2() but on the other hand, it's more self contained with just one property.

sidorares commented 11 years ago

I'm ok for vec2 I'll take a look later today (or feel free to send PR yourself)

sidorares commented 11 years ago

I added you as x11 and ntk github/npm collaborator. For simple changes like adding new request/event feel free to commit directly, bump version and publish

dominictarr commented 11 years ago

okay, cool - I like to do pull requests anyway, just so that everyone knows what is happening.

do you do IRC? I hang out in #stackvm in freenode.

sidorares commented 11 years ago

I'm often on #polyhack - I'll join stackvm as well