Browse Source

Fix contents of the text input element not always being clipped, see #143

Michael Ragazzon 5 years ago
parent
commit
aaea5d9151

+ 2 - 0
Include/RmlUi/Core/Elements/ElementFormControlInput.h

@@ -70,6 +70,8 @@ protected:
 	void OnRender() override;
 	/// Calls the element's underlying type.
 	void OnResize() override;
+	/// Calls the element's underlying type.
+	void OnLayout() override;
 
 	/// Checks for necessary functional changes in the control as a result of changed attributes.
 	/// @param[in] changed_attributes The list of changed attributes.

+ 6 - 0
Source/Core/Elements/ElementFormControlInput.cpp

@@ -91,6 +91,12 @@ void ElementFormControlInput::OnResize()
 	type->OnResize();
 }
 
+void ElementFormControlInput::OnLayout()
+{
+	RMLUI_ASSERT(type);
+	type->OnLayout();
+}
+
 // Checks for necessary functional changes in the control as a result of changed attributes.
 void ElementFormControlInput::OnAttributeChange(const ElementAttributes& changed_attributes)
 {

+ 4 - 0
Source/Core/Elements/InputType.cpp

@@ -65,6 +65,10 @@ void InputType::OnResize()
 {
 }
 
+void InputType::OnLayout()
+{
+}
+
 // Checks for necessary functional changes in the control as a result of changed attributes.
 bool InputType::OnAttributeChange(const ElementAttributes& RMLUI_UNUSED_PARAMETER(changed_attributes))
 {

+ 3 - 0
Source/Core/Elements/InputType.h

@@ -65,6 +65,9 @@ public:
 	/// Called every time the host element's size changes.
 	virtual void OnResize();
 
+	/// Called every time the host element is layed out.
+	virtual void OnLayout();
+
 	/// Checks for necessary functional changes in the control as a result of changed attributes.
 	/// @param[in] changed_attributes The list of changed attributes.
 	/// @return True if no layout is required, false if the layout needs to be dirtied.

+ 5 - 0
Source/Core/Elements/InputTypeText.cpp

@@ -70,6 +70,11 @@ void InputTypeText::OnResize()
 	widget->OnResize();
 }
 
+void InputTypeText::OnLayout()
+{
+	widget->OnLayout();
+}
+
 // Checks for necessary functional changes in the control as a result of changed attributes.
 bool InputTypeText::OnAttributeChange(const ElementAttributes& changed_attributes)
 {

+ 3 - 0
Source/Core/Elements/InputTypeText.h

@@ -62,6 +62,9 @@ public:
 	/// Called when the parent element's size changes.
 	void OnResize() override;
 
+	/// Called when the parent element is layed out.
+	void OnLayout() override;
+
 	/// Checks for necessary functional changes in the control as a result of changed attributes.
 	/// @param[in] changed_attributes The list of changed attributes.
 	/// @return True if no layout is required, false if the layout needs to be dirtied.

+ 1 - 1
Tests/Data/VisualTests/issue_143_overflow_in_absolutely_positioned_input.rml

@@ -3,7 +3,7 @@
     <title>Overflow in absolutely positioned input</title>
     <link type="text/rcss" href="../style.rcss"/>
 	<link rel="GitHub issue #143" href="https://github.com/mikke89/RmlUi/issues/143" />
-	<meta name="Description" content="An &lt;input&gt; with a too long value starts out overflowing. When selecting some text in it, then removing the selection (by clicking, arrow key, home/end or taking the focus out) the text does get clipped. Now when something else needs clipping, the &lt;input&gt; overflows again. It only happens when the &lt;input&gt; is position: absolute." />
+	<meta name="Description" content="The contents of input text element (purple) should always be clipped and never overflow. The also applies when hovering the mouse cursor over the designated area." />
 	<style>
 		body {
 			background: #ddd;