mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-04 09:00:44 +00:00
Add the ability to create spacers, for better layouts
This commit is contained in:
@@ -513,6 +513,19 @@ which typically has some widgets be only large enough for their content and othe
|
||||
)");
|
||||
virtual QWidget *CreateGridContainer() = 0;
|
||||
|
||||
DOCUMENT(R"(Creates and returns a spacer widget.
|
||||
|
||||
This widget is completely empty but consumes empty space, meaning all other non-greedy widgets in
|
||||
the same container will be minimally sized. This can be useful for simple layouts.
|
||||
|
||||
:param bool horizontal: ``True`` if this spacer should consume horizontal space, ``False`` if this
|
||||
spacer should consume vertical space. Typically this matches the direction of the layout it is
|
||||
in.
|
||||
:return: The handle to the newly created widget.
|
||||
:rtype: ``QWidget``
|
||||
)");
|
||||
virtual QWidget *CreateSpacer(bool horizontal) = 0;
|
||||
|
||||
DOCUMENT(R"(Removes all child widgets from a parent and makes them invisible.
|
||||
|
||||
These widgets remain valid and can be re-added to another parent or the same parent.
|
||||
|
||||
@@ -220,6 +220,15 @@ QWidget *MiniQtHelper::CreateGridContainer()
|
||||
return ret;
|
||||
}
|
||||
|
||||
QWidget *MiniQtHelper::CreateSpacer(bool horizontal)
|
||||
{
|
||||
QWidget *ret = new QWidget();
|
||||
ret->setSizePolicy(horizontal ? QSizePolicy::Expanding : QSizePolicy::Preferred,
|
||||
horizontal ? QSizePolicy::Preferred : QSizePolicy::Expanding);
|
||||
ret->setMinimumSize(1, 1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void MiniQtHelper::ClearContainedWidgets(QWidget *parent)
|
||||
{
|
||||
if(!parent)
|
||||
@@ -427,6 +436,7 @@ QWidget *MiniQtHelper::CreateGroupBox(bool collapsible)
|
||||
ret = new CollapseGroupBox();
|
||||
else
|
||||
ret = new QGroupBox();
|
||||
ret->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
ret->setLayout(new QVBoxLayout());
|
||||
return ret;
|
||||
}
|
||||
@@ -449,6 +459,7 @@ QWidget *MiniQtHelper::CreateOutputRenderingWidget()
|
||||
{
|
||||
CustomPaintWidget *widget = new CustomPaintWidget(NULL);
|
||||
widget->SetContext(m_Ctx);
|
||||
widget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
return widget;
|
||||
}
|
||||
|
||||
@@ -597,6 +608,7 @@ QWidget *MiniQtHelper::CreateTextBox(bool singleLine, WidgetCallback changed)
|
||||
AddWidgetCallback(w, QObject::connect(w, &RDTextEdit::textChanged, [this, w, changed]() {
|
||||
changed(&m_Ctx, w, w->toPlainText());
|
||||
}));
|
||||
w->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
return w;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ public:
|
||||
QWidget *CreateHorizontalContainer() override;
|
||||
QWidget *CreateVerticalContainer() override;
|
||||
QWidget *CreateGridContainer() override;
|
||||
QWidget *CreateSpacer(bool horizontal) override;
|
||||
|
||||
void ClearContainedWidgets(QWidget *parent) override;
|
||||
void AddGridWidget(QWidget *parent, int row, int column, QWidget *child, int rowSpan,
|
||||
|
||||
@@ -150,7 +150,10 @@ struct MiniQtInvoker : ObjectForwarder<IMiniQtHelper>
|
||||
{
|
||||
return InvokeRetFunction<QWidget *>(&IMiniQtHelper::CreateGridContainer);
|
||||
}
|
||||
|
||||
QWidget *CreateSpacer(bool horizontal)
|
||||
{
|
||||
return InvokeRetFunction<QWidget *>(&IMiniQtHelper::CreateSpacer, horizontal);
|
||||
}
|
||||
void ClearContainedWidgets(QWidget *parent)
|
||||
{
|
||||
InvokeVoidFunction(&IMiniQtHelper::ClearContainedWidgets, parent);
|
||||
|
||||
Reference in New Issue
Block a user