Author: toshok
Date: 2007-07-12 17:13:02 -0400 (Thu, 12 Jul 2007)
New Revision: 81903
Modified:
trunk/moon/plugin/ChangeLog
trunk/moon/plugin/plugin-class.cpp
trunk/moon/src/ChangeLog
trunk/moon/src/runtime.cpp
trunk/moon/src/runtime.h
trunk/moon/src/uielement.cpp
trunk/moon/src/uielement.h
Log:
In src:
* runtime.h, runtime.cpp, uielement.cpp, uielement.h: Add mouse
capturing. This should be on Visual and not UIElement, but we
don't dispatch events that way.
2007-07-12 Chris Toshok <[EMAIL PROTECTED]>
In plugin:
* plugin-class.cpp (moonlight_dependency_object_invoke): implement
captureMouse/releaseMouseCapture. going to move these to a
UIElement specific wrapper next.
2007-07-12 Chris Toshok <[EMAIL PROTECTED]>
Modified: trunk/moon/plugin/ChangeLog
===================================================================
--- trunk/moon/plugin/ChangeLog 2007-07-12 20:57:20 UTC (rev 81902)
+++ trunk/moon/plugin/ChangeLog 2007-07-12 21:13:02 UTC (rev 81903)
@@ -1,5 +1,11 @@
2007-07-12 Chris Toshok <[EMAIL PROTECTED]>
+ * plugin-class.cpp (moonlight_dependency_object_invoke): implement
+ captureMouse/releaseMouseCapture. going to move these to a
+ UIElement specific wrapper next.
+
+2007-07-12 Chris Toshok <[EMAIL PROTECTED]>
+
* plugin-class.cpp, plugin-class.h: a few things:
refactor the listener proxying stuff to share code. when creating
Modified: trunk/moon/plugin/plugin-class.cpp
===================================================================
--- trunk/moon/plugin/plugin-class.cpp 2007-07-12 20:57:20 UTC (rev 81902)
+++ trunk/moon/plugin/plugin-class.cpp 2007-07-12 21:13:02 UTC (rev 81903)
@@ -1141,13 +1141,11 @@
// XXX these next two methods should live in a UIElement
// wrapper class, not in the DependencyObject wrapper.
else if (name_matches (name, "captureMouse")) {
- // not yet implemented
- DEBUG_WARN_NOTIMPLEMENTED ();
+ BOOLEAN_TO_NPVARIANT (((UIElement*)dob)->CaptureMouse (),
*result);
return true;
}
else if (name_matches (name, "releaseMouseCapture")) {
- // not yet implemented
- DEBUG_WARN_NOTIMPLEMENTED ();
+ BOOLEAN_TO_NPVARIANT (((UIElement*)dob)->ReleaseMouseCapture
(), *result);
return true;
}
else
Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog 2007-07-12 20:57:20 UTC (rev 81902)
+++ trunk/moon/src/ChangeLog 2007-07-12 21:13:02 UTC (rev 81903)
@@ -1,5 +1,11 @@
2007-07-12 Chris Toshok <[EMAIL PROTECTED]>
+ * runtime.h, runtime.cpp, uielement.cpp, uielement.h: Add mouse
+ capturing. This should be on Visual and not UIElement, but we
+ don't dispatch events that way.
+
+2007-07-12 Chris Toshok <[EMAIL PROTECTED]>
+
* downloader.h, downloader.cpp: make the Downloader object a bit
more C++ friendly, and make all the private data private.
Modified: trunk/moon/src/runtime.cpp
===================================================================
--- trunk/moon/src/runtime.cpp 2007-07-12 20:57:20 UTC (rev 81902)
+++ trunk/moon/src/runtime.cpp 2007-07-12 21:13:02 UTC (rev 81903)
@@ -108,6 +108,7 @@
buffer = NULL;
toplevel = NULL;
+ capture_element = NULL;
Realloc ();
}
@@ -157,6 +158,22 @@
}
}
+bool
+Surface::SetMouseCapture (UIElement *capture)
+{
+ if (capture != NULL && capture_element != NULL)
+ return false;
+
+ capture_element = capture;
+
+ if (capture_element == NULL) {
+ // generate the proper Enter/Leave events here for the object
+ // under the mouse pointer
+ }
+
+ return true;
+}
+
void
Surface::SetCursor (MouseCursor new_cursor)
{
@@ -359,7 +376,9 @@
Surface *s = (Surface*)closure;
MouseCursor new_cursor = MouseCursorDefault;
- s->toplevel->HandleMotion (s->cairo, s->last_event_state,
s->last_event_x, s->last_event_y, &new_cursor);
+
+ UIElement *input_element = s->capture_element ? s->capture_element :
s->toplevel;
+ input_element->HandleMotion (s->cairo, s->last_event_state,
s->last_event_x, s->last_event_y, &new_cursor);
s->SetCursor (new_cursor);
}
@@ -488,7 +507,8 @@
s->last_event_state = state;
MouseCursor new_cursor = MouseCursorDefault;
- s->toplevel->HandleMotion (s->cairo, state, x, y, &new_cursor);
+ UIElement *input_element = s->capture_element ? s->capture_element :
s->toplevel;
+ input_element->HandleMotion (s->cairo, state, x, y, &new_cursor);
s->SetCursor (new_cursor);
return TRUE;
@@ -509,9 +529,15 @@
}
MouseCursor new_cursor = MouseCursorDefault;
- s->toplevel->HandleMotion (s->cairo, event->state, x, y,
&new_cursor);
- s->toplevel->Enter (s->cairo, event->state, x, y);
+ if (s->capture_element) {
+ s->capture_element->HandleMotion (s->cairo,
event->state, x, y, &new_cursor);
+ }
+ else {
+ s->toplevel->HandleMotion (s->cairo, event->state, x,
y, &new_cursor);
+ s->toplevel->Enter (s->cairo, event->state, x, y);
+ }
+
s->SetCursor (new_cursor);
s->last_event_x = x;
@@ -519,7 +545,8 @@
s->last_event_state = event->state;
} else {
- s->toplevel->Leave ();
+ if (s->capture_element == NULL)
+ s->toplevel->Leave ();
}
return TRUE;
@@ -569,7 +596,8 @@
x -= widget->allocation.x;
y -= widget->allocation.y;
}
- s->toplevel->HandleButtonRelease (s->cairo, button->state, x, y);
+ UIElement *input_element = s->capture_element ? s->capture_element :
s->toplevel;
+ input_element->HandleButtonRelease (s->cairo, button->state, x, y);
return TRUE;
}
@@ -590,7 +618,8 @@
x -= widget->allocation.x;
y -= widget->allocation.y;
}
- s->toplevel->HandleButtonPress (s->cairo, button->state, x, y);
+ UIElement *input_element = s->capture_element ? s->capture_element :
s->toplevel;
+ input_element->HandleButtonPress (s->cairo, button->state, x, y);
return FALSE;
}
Modified: trunk/moon/src/runtime.h
===================================================================
--- trunk/moon/src/runtime.h 2007-07-12 20:57:20 UTC (rev 81902)
+++ trunk/moon/src/runtime.h 2007-07-12 21:13:02 UTC (rev 81903)
@@ -50,6 +50,9 @@
void SetCursor (MouseCursor cursor);
+ bool SetMouseCapture (UIElement *capture);
+ UIElement* GetMouseCapture () { return capture_element; }
+
void Resize (int width, int height);
int GetWidth () { return width; }
int GetHeight () { return height; }
@@ -100,6 +103,10 @@
// This currently can only be a canvas.
UIElement *toplevel;
+
+ // The element currently capturing the mouse
+ UIElement *capture_element;
+
// the currently shown cursor
MouseCursor cursor;
Modified: trunk/moon/src/uielement.cpp
===================================================================
--- trunk/moon/src/uielement.cpp 2007-07-12 20:57:20 UTC (rev 81902)
+++ trunk/moon/src/uielement.cpp 2007-07-12 21:13:02 UTC (rev 81903)
@@ -339,6 +339,29 @@
Emit (LeaveEvent);
}
+bool
+UIElement::CaptureMouse ()
+{
+ Surface *s = GetSurface ();
+ if (s == NULL)
+ return false;
+
+ return s->SetMouseCapture (this);
+}
+
+bool
+UIElement::ReleaseMouseCapture ()
+{
+ Surface *s = GetSurface ();
+ if (s == NULL)
+ return false;
+
+ if (s->GetMouseCapture() != this)
+ return false;
+
+ return s->SetMouseCapture (NULL);
+}
+
void
UIElement::ComputeBounds ()
{
@@ -516,3 +539,15 @@
{
return item->parent;
}
+
+bool
+uielement_capture_mouse (UIElement *item)
+{
+ return item->CaptureMouse ();
+}
+
+bool
+uielement_release_mouse_capture (UIElement *item)
+{
+ return item->ReleaseMouseCapture ();
+}
Modified: trunk/moon/src/uielement.h
===================================================================
--- trunk/moon/src/uielement.h 2007-07-12 20:57:20 UTC (rev 81902)
+++ trunk/moon/src/uielement.h 2007-07-12 21:13:02 UTC (rev 81903)
@@ -199,7 +199,25 @@
//
virtual void Leave ();
+
//
+ // CaptureMouse:
+ //
+ // Attempts to capture the mouse. If successful, all mouse
+ // events will be transmitted directly to this element.
+ // Leave/Enter events will no longer be sent.
+ //
+ bool CaptureMouse ();
+
+ //
+ // ReleaseMouseCapture:
+ //
+ // Attempts to release the mouse. If successful, any
+ // applicable Leave/Enter events for the current mouse
+ // position will be sent.
+ //
+ bool ReleaseMouseCapture ();
+
// GetTotalOpacity
// Get the cumulative opacity of this element, including all it's
parents
double GetTotalOpacity ();
@@ -258,6 +276,9 @@
void uielement_transform_point (UIElement *item, double *x, double
*y);
UIElement *uielement_get_parent (UIElement *item);
+bool uielement_capture_mouse (UIElement *item);
+bool uielement_release_mouse_capture (UIElement *item);
+
void uielement_init ();
G_END_DECLS
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches