Browse Source

Make Context::GetElementAtPoint public (see #39)

Michael Ragazzon 6 years ago
parent
commit
6ab231af46
2 changed files with 8 additions and 9 deletions
  1. 7 8
      Include/RmlUi/Core/Context.h
  2. 1 1
      Source/Core/Context.cpp

+ 7 - 8
Include/RmlUi/Core/Context.h

@@ -127,15 +127,20 @@ public:
 	/// Returns the hover element.
 	/// Returns the hover element.
 	/// @return The element the mouse cursor is hovering over. The element is returned with a borrowed reference.
 	/// @return The element the mouse cursor is hovering over. The element is returned with a borrowed reference.
 	Element* GetHoverElement();
 	Element* GetHoverElement();
-
 	/// Returns the focus element.
 	/// Returns the focus element.
 	/// @return The element with input focus. The element is returned with a borrowed reference.
 	/// @return The element with input focus. The element is returned with a borrowed reference.
 	Element* GetFocusElement();
 	Element* GetFocusElement();
-
 	/// Returns the root element that holds all the documents
 	/// Returns the root element that holds all the documents
 	/// @return The root element. The element is returned with a borrowed reference.
 	/// @return The root element. The element is returned with a borrowed reference.
 	Element* GetRootElement();
 	Element* GetRootElement();
 
 
+	// Returns the youngest descendent of the given element which is under the given point in screen coordinates.
+	// @param[in] point The point to test.
+	// @param[in] ignore_element If set, this element and its descendents will be ignored.
+	// @param[in] element Used internally.
+	// @return The element under the point, or nullptr if nothing is.
+	Element* GetElementAtPoint(Vector2f point, const Element* ignore_element = nullptr, Element* element = nullptr) const;
+
 	/// Brings the document to the front of the document stack.
 	/// Brings the document to the front of the document stack.
 	/// @param[in] document The document to pull to the front of the stack.
 	/// @param[in] document The document to pull to the front of the stack.
 	void PullDocumentToFront(ElementDocument* document);
 	void PullDocumentToFront(ElementDocument* document);
@@ -285,12 +290,6 @@ private:
 
 
 	// Updates the current hover elements, sending required events.
 	// Updates the current hover elements, sending required events.
 	void UpdateHoverChain(const Dictionary& parameters, const Dictionary& drag_parameters, const Vector2i& old_mouse_position);
 	void UpdateHoverChain(const Dictionary& parameters, const Dictionary& drag_parameters, const Vector2i& old_mouse_position);
-	// Returns the youngest descendent of the given element which is under the given point in screen coordinates.
-	// @param[in] point The point to test.
-	// @param[in] ignore_element If set, this element and its descendents will be ignored.
-	// @param[in] element Used internally.
-	// @return The element under the point, or nullptr if nothing is.
-	Element* GetElementAtPoint(Vector2f point, const Element* ignore_element = nullptr, Element* element = nullptr);
 
 
 	// Creates the drag clone from the given element. The old drag clone will be released if
 	// Creates the drag clone from the given element. The old drag clone will be released if
 	// necessary.
 	// necessary.

+ 1 - 1
Source/Core/Context.cpp

@@ -989,7 +989,7 @@ void Context::UpdateHoverChain(const Dictionary& parameters, const Dictionary& d
 }
 }
 
 
 // Returns the youngest descendent of the given element which is under the given point in screen coodinates.
 // Returns the youngest descendent of the given element which is under the given point in screen coodinates.
-Element* Context::GetElementAtPoint(Vector2f point, const Element* ignore_element, Element* element)
+Element* Context::GetElementAtPoint(Vector2f point, const Element* ignore_element, Element* element) const
 {
 {
 	if (element == nullptr)
 	if (element == nullptr)
 	{
 	{