Summary
Refactor .text_input() from a chainable ElementBuilder modifier method into a terminal method (as an alternative to .children() and .empty()).
Motivation
Currently, .text_input() permits adding non-floating children which does not make sense layout-wise. Turning it into a terminal method allows developers to configure layout modifiers like .padding() directly on the housing element itself and ensures that internal text input components, such as the scrollbar, correctly envelope the entire layout including the padding.
Proposed API
ui.element().id("editor").width(fixed!(400.0)).height(fixed!(120.0))
.layout(|l| l.padding(12))
.text_input(|t| t
.multiline()
.font_size(24)
);
Currently, developers must use a boilerplate wrapper element to achieve proper internal padding:
ui.element().width(fixed!(400.0)).height(fixed!(120.0))
.layout(|l| l.padding(12))
.children(|ui| {
ui.element().id("editor").width(grow!()).height(grow!())
.text_input(|t| t
.multiline()
.font_size(24)
)
.empty();
});
And this still doesn't work properly with the input's scrollbar as that would be limited to the padded off area or with the overflow caused by scrolling.
Behavior
- Switch to
.text_input() to a terminal method (-> Id) on ElementBuilder.
- Parent element padding configurations dynamically adjust the internal text input bounds.
- The scrollable area includes the added padding, the padding can thus be scrolled away.
- The scrollbars extend to include the padded perimeter.
- The
.text_input() does not create a text-input child ghost. It is applied on the actual element it terminates.
Summary
Refactor
.text_input()from a chainableElementBuildermodifier method into a terminal method (as an alternative to.children()and.empty()).Motivation
Currently,
.text_input()permits adding non-floating children which does not make sense layout-wise. Turning it into a terminal method allows developers to configure layout modifiers like.padding()directly on the housing element itself and ensures that internal text input components, such as the scrollbar, correctly envelope the entire layout including the padding.Proposed API
Currently, developers must use a boilerplate wrapper element to achieve proper internal padding:
And this still doesn't work properly with the input's scrollbar as that would be limited to the padded off area or with the overflow caused by scrolling.
Behavior
.text_input()to a terminal method (-> Id) onElementBuilder..text_input()does not create a text-input child ghost. It is applied on the actual element it terminates.