Hot Rect handling


#1

Hi Jules,

Would be cool if you can implement in Component a method to
let know that your hot rectangle has changed.

I’m creating a widget quite big which will be probably be used inside a ViewPort, but I don’t want to hardcode the ViewPort inide the widget.

In my mouseDrag function, I would like to tell that my hot rect has changed.

Thanks,


#2

Any thought ?

Thanks,


#3

Not exactly sure what you mean by a hot rect! If you mean the bit that’s visible, then that’d be quite difficult to do, as components don’t really have a concept of that (they could be overlapped by all kinds of semi-transparent stuff, and there’s not much point in making them all store a representation of the visible area, because it’s never really needed)


#4

By hot rect, I mean the current work area of the widget.

Most of the time it will be the whole widget, but when doing some rectangle selection in some widget, it allows the viewport to follow the mousedrag that is use the extend the selection.

See what I mean ?

Thanks,


#5

Sure, I see. It’s not a good design strategy though, to try to optimise it like that. You’d be better off doing something like smart caching its content based on the last bits that needed to be drawn or moused-over. Or just using more subcomponents and let them take the strain.


#6

I think there has been some misunderstanding.
It’s not optimization stuff.

Just the fact that the currently visible area of the viewport should follow the mouse dragging selection inside its child widget.


#7

Sorry - don’t understand. The only way the viewport could track the mouse is if you tell it to scroll. I don’t see how else it could know what to do?


#8

Well I’m thinking about an equivalent
to scrollRectToVisible in java swing JComponent.
You don’t know if your parent is a kind of viewport
but if it is then it will what to do about it.

http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JComponent.html#scrollRectToVisible(java.awt.Rectangle)

Thanks,


#9

Ah, I see. That’s not a bad idea.