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

# Re: [Sc-devel] relative coordinates in SCUserView

```
On 11 Dec 2007, at 10:39, Jan Trutzschler wrote:

```
```getting the normalized position is fairly simple. it would like this:
```
```
```
: ) Yes I understand that. (and it would be just as easy to map pixels to 0-1)
```
```
I might be misunderstanding you, but when I design a GUI, I think in terms of "this view should be 120 pixels from the left" and not "this view should be 0.2393 * viewWidth
```from the left".

```
I think it's natural to think about views and drawing in terms of pixels.
```
```
Interesting if there are differences in background here. I'm not an engineer so I tend to think in "real" numbers. An engineer perhaps likes to think about everything
```in terms of 0-1. ??? : )

Not that I'm labeling you an engineer Jan!!!

t

```
```(
var w;
w = SCWindow.new.front;
SCUserView(w, w.view.bounds)
.mouseMoveAction_{|v, x, y|
```
"normalized position %".format((v.mousePosition / v.bounds.extent)).postln;
```		"relative position %".format(v.mousePosition).postln;
"absolute position %".format((x@y)).postln;

}
)

jan

On Dec 11, 2007, at 11:10 AM, thor wrote:

```
```
On 10 Dec 2007, at 21:11, Jan Trutzschler wrote:

```
```Here is another option:

```
you can get the relative mouse position by using the view's method mousePosition, which returns a Point. Should that be a normalized Position between 0 and 1 or just pixels?
```
That's good way of solving things.

```
Personally when working with GUIs and drawings I calculate in real pixels
```and it would be awkward to map to 0-1 and back into pixels.

Perhaps both?

(that's what I do in my ParaSpace class)

thor

_______________________________________________
Sc-devel mailing list
Sc-devel@xxxxxxxxxxxxxxx
http://www.create.ucsb.edu/mailman/listinfo/sc-devel
```
```
_______________________________________________
Sc-devel mailing list
Sc-devel@xxxxxxxxxxxxxxx
http://www.create.ucsb.edu/mailman/listinfo/sc-devel
```
```

```