forked from qt-creator/qt-creator
Lua: Expose stretch function in box layout
Change-Id: I52bb81e01561950785252d362d31d6142844fcac Reviewed-by: <lie@spyro-soft.com> Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -686,6 +686,12 @@ void Layout::setFieldGrowthPolicy(int policy)
|
||||
lt->setFieldGrowthPolicy(QFormLayout::FieldGrowthPolicy(policy));
|
||||
}
|
||||
|
||||
void Layout::setStretch(int index, int stretch)
|
||||
{
|
||||
if (auto lt = asBox())
|
||||
lt->setStretch(index, stretch);
|
||||
}
|
||||
|
||||
QWidget *Layout::emerge() const
|
||||
{
|
||||
const_cast<Layout *>(this)->flush();
|
||||
@@ -1143,6 +1149,11 @@ LayoutModifier spacing(int space)
|
||||
return [space](Layout *layout) { layout->setSpacing(space); };
|
||||
}
|
||||
|
||||
LayoutModifier stretch(int index, int stretch)
|
||||
{
|
||||
return [index, stretch](Layout *layout) { layout->setStretch(index, stretch); };
|
||||
}
|
||||
|
||||
void addToLayout(Layout *layout, const Space &inner)
|
||||
{
|
||||
if (auto lt = layout->asBox())
|
||||
|
@@ -122,6 +122,7 @@ public:
|
||||
void setColumnStretch(int cols, int rows);
|
||||
void setSpacing(int space);
|
||||
void setFieldGrowthPolicy(int policy);
|
||||
void setStretch(int index, int stretch);
|
||||
|
||||
void attachTo(QWidget *);
|
||||
|
||||
@@ -614,6 +615,7 @@ QTCREATOR_UTILS_EXPORT void hr(Layout *);
|
||||
QTCREATOR_UTILS_EXPORT void tight(Layout *); // noMargin + spacing(0)
|
||||
|
||||
QTCREATOR_UTILS_EXPORT LayoutModifier spacing(int space);
|
||||
QTCREATOR_UTILS_EXPORT LayoutModifier stretch(int index, int stretch);
|
||||
|
||||
// Convenience
|
||||
|
||||
|
@@ -700,6 +700,7 @@ void setupGuiModule()
|
||||
gui["normalMargin"] = &normalMargin;
|
||||
gui["withFormAlignment"] = &withFormAlignment;
|
||||
gui["spacing"] = &spacing;
|
||||
gui["stretch"] = &stretch;
|
||||
|
||||
return gui;
|
||||
});
|
||||
|
@@ -260,6 +260,11 @@ function gui.normalMargin() end
|
||||
---Sets the alignment of a Grid layout according to the Form layout rules.
|
||||
function gui.withFormAlignment() end
|
||||
|
||||
---Sets the stretch factor at position index to stretch.
|
||||
---@param index integer The widget index.
|
||||
---@param stretch integer The stretch factor.
|
||||
function gui.stretch(index, stretch) end
|
||||
|
||||
--- Enum representing Text interaction flags
|
||||
---@enum TextInteractionFlag
|
||||
gui.TextInteractionFlag {
|
||||
|
Reference in New Issue
Block a user