Skip to content

FlexLayout indeterminate behavior #592

@agg23

Description

@agg23

Describe the bug
In attempting to determine the source of nodegui/react-nodegui#162 (comment), I rebuilt roughly the same widget structure that nodegui-react should have produced, seen below. This structure displays indeterminate sizing when modifying bits of the layout, just as in the React example.

To Reproduce

import { QMainWindow, QWidget } from '.';
import { QPushButton } from './lib/QtWidgets/QPushButton';
import { FlexLayout } from './lib/core/FlexLayout';

const win = new QMainWindow();
win.resize(500, 500);

const outer = new QWidget();
const outerLayout = new FlexLayout();
outerLayout.setFlexNode(outer.getFlexNode());
outer.setLayout(outerLayout);

const inner = new QWidget();
outerLayout.addWidget(inner);
const innerLayout = new FlexLayout();
innerLayout.setFlexNode(inner.getFlexNode());
inner.setLayout(innerLayout);

const button = new QPushButton();
button.setText('Toggle On');
button.addEventListener('clicked', () => {
    button.setText(button.text() === 'Toggle On' ? 'Toggle Off' : 'Toggle On');
});
innerLayout.addWidget(button);

const centralWidget = new QWidget();
const centralLayout = new FlexLayout();

centralLayout.setFlexNode(centralWidget.getFlexNode());
centralLayout.addWidget(outer);
centralWidget.setLayout(centralLayout);

win.setCentralWidget(centralWidget);
win.show();
(global as any).win = win;

Expected behavior
The layout should not vary when modifying non-layout properties of widgets.

Screenshots
Initial Render:
Screen Shot 2020-06-02 at 1 52 08 PM

First Click:
Screen Shot 2020-06-02 at 1 52 32 PM

After Resizing:
Screen Shot 2020-06-02 at 1 52 53 PM

Desktop (please complete the following information):

  • OS: macOS 10.15.5
  • NodeGUI version: Latest master (0.21.0+)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions