support rotating widgets

This commit is contained in:
David Rose 2001-07-12 01:36:36 +00:00
parent c1ae935b1c
commit 75eb814e05
3 changed files with 99 additions and 3 deletions

View File

@ -202,6 +202,36 @@ get_exit_prefix() {
return "exit-";
}
////////////////////////////////////////////////////////////////////
// Function: PGItem::get_focus_in_prefix
// Access: Published, Static
// Description: Returns the prefix that is used to define the focus_in
// event for all PGItems. The focus_in event is the
// concatenation of this string followed by get_id().
//
// Unlike most item events, this event is thrown with no
// parameters.
////////////////////////////////////////////////////////////////////
INLINE string PGItem::
get_focus_in_prefix() {
return "fin-";
}
////////////////////////////////////////////////////////////////////
// Function: PGItem::get_focus_out_prefix
// Access: Published, Static
// Description: Returns the prefix that is used to define the focus_out
// event for all PGItems. The focus_out event is the
// concatenation of this string followed by get_id().
//
// Unlike most item events, this event is thrown with no
// parameters.
////////////////////////////////////////////////////////////////////
INLINE string PGItem::
get_focus_out_prefix() {
return "fout-";
}
////////////////////////////////////////////////////////////////////
// Function: PGItem::get_press_prefix
// Access: Published, Static
@ -250,6 +280,28 @@ get_exit_event() const {
return get_exit_prefix() + get_id();
}
////////////////////////////////////////////////////////////////////
// Function: PGItem::get_focus_in_event
// Access: Published
// Description: Returns the event name that will be thrown when the
// item gets the keyboard focus.
////////////////////////////////////////////////////////////////////
INLINE string PGItem::
get_focus_in_event() const {
return get_focus_in_prefix() + get_id();
}
////////////////////////////////////////////////////////////////////
// Function: PGItem::get_focus_out_event
// Access: Published
// Description: Returns the event name that will be thrown when the
// item loses the keyboard focus.
////////////////////////////////////////////////////////////////////
INLINE string PGItem::
get_focus_out_event() const {
return get_focus_out_prefix() + get_id();
}
////////////////////////////////////////////////////////////////////
// Function: PGItem::get_press_event
// Access: Published

View File

@ -166,11 +166,21 @@ xform(const LMatrix4f &mat) {
////////////////////////////////////////////////////////////////////
void PGItem::
activate_region(PGTop *, const LMatrix4f &transform, int sort) {
// Transform all four vertices, and get the new bounding box. This
// way the region works (mostly) even if has been rotated.
LPoint3f ll(_frame[0], 0.0, _frame[2]);
LPoint3f lr(_frame[1], 0.0, _frame[2]);
LPoint3f ul(_frame[0], 0.0, _frame[3]);
LPoint3f ur(_frame[1], 0.0, _frame[3]);
ll = ll * transform;
lr = lr * transform;
ul = ul * transform;
ur = ur * transform;
_region->set_frame(ll[0], ur[0], ll[2], ur[2]);
_region->set_frame(min(min(ll[0], lr[0]), min(ul[0], ur[0])),
max(max(ll[0], lr[0]), max(ul[0], ur[0])),
min(min(ll[2], lr[2]), min(ul[2], ur[2])),
max(max(ll[2], lr[2]), max(ul[2], ur[2])));
_region->set_sort(sort);
_region->set_active(true);
}
@ -223,6 +233,28 @@ exit(const MouseWatcherParameter &param) {
EventParameter(ep));
}
////////////////////////////////////////////////////////////////////
// Function: PGItem::focus_in
// Access: Public, Virtual
// Description: This is a callback hook function, called whenever the
// widget gets the keyboard focus.
////////////////////////////////////////////////////////////////////
void PGItem::
focus_in() {
throw_event(get_focus_in_event());
}
////////////////////////////////////////////////////////////////////
// Function: PGItem::focus_out
// Access: Public, Virtual
// Description: This is a callback hook function, called whenever the
// widget loses the keyboard focus.
////////////////////////////////////////////////////////////////////
void PGItem::
focus_out() {
throw_event(get_focus_out_event());
}
////////////////////////////////////////////////////////////////////
// Function: PGItem::press
// Access: Public, Virtual
@ -302,7 +334,10 @@ set_focus(bool focus) {
}
_focus_item = this;
}
if (!get_focus()) {
focus_in();
_flags |= F_focus;
}
} else {
if (_focus_item == this) {
@ -310,8 +345,11 @@ set_focus(bool focus) {
_focus_item = (PGItem *)NULL;
}
if (get_focus()) {
focus_out();
_flags &= ~F_focus;
}
}
_region->set_keyboard(focus);
}

View File

@ -73,6 +73,8 @@ public:
virtual void enter(const MouseWatcherParameter &param);
virtual void exit(const MouseWatcherParameter &param);
virtual void focus_in();
virtual void focus_out();
virtual void press(const MouseWatcherParameter &param);
virtual void release(const MouseWatcherParameter &param);
@ -106,11 +108,15 @@ PUBLISHED:
INLINE static string get_enter_prefix();
INLINE static string get_exit_prefix();
INLINE static string get_focus_in_prefix();
INLINE static string get_focus_out_prefix();
INLINE static string get_press_prefix();
INLINE static string get_release_prefix();
INLINE string get_enter_event() const;
INLINE string get_exit_event() const;
INLINE string get_focus_in_event() const;
INLINE string get_focus_out_event() const;
INLINE string get_press_event(const ButtonHandle &button) const;
INLINE string get_release_event(const ButtonHandle &button) const;