Пример #1
0
void GraphicsNode::
updateSizeHints() {
	qreal min_width = 0.0;// _hard_min_width;
	qreal min_height = _top_margin + _bottom_margin; // _hard_min_height;

	// sinks
	for (size_t i = 0; i < _sinks.size(); i++) {
		auto s = _sinks[i];
		auto size = s->getMinimalSize();

		min_height += size.height() + _item_padding;
		min_width = std::max(size.width(), min_width);
	}

	// central widget
	if (_central_proxy != nullptr) {
		auto wgt = _central_proxy->widget();
		if (wgt) {
			// only take the size hint if the value is valid, and if
			// the minimumSize is not set (similar to
			// QWidget/QLayout standard behavior
			auto sh = wgt->minimumSizeHint();
			auto sz = wgt->minimumSize();
			if (sh.isValid()) {
				if (sz.height() > 0)
					min_height += sz.height();
				else
					min_height += sh.height();

				if (sz.width() > 0)
					min_width = std::max(qreal(sz.width()) + 2.0*_lr_padding, min_width);
				else
					min_width = std::max(qreal(sh.width()) + 2.0*_lr_padding, min_width);
			} else {
				min_height += sh.height();
				min_width = std::max(qreal(sh.width()) + 2.0*_lr_padding, min_width);
			}
		}
	}

	// sources
	for (size_t i = 0; i < _sources.size(); i++) {
		auto s = _sources[i];
		auto size = s->getMinimalSize();

		min_height += size.height() + _item_padding;
		min_width = std::max(size.width(), min_width);
	}

	_min_width = std::max(min_width, _hard_min_width);
	_min_height = std::max(min_height, _hard_min_height);
}
QSizeF GraphicsNodeSocket::
getSize() const {
	return getMinimalSize();
}
Пример #3
0
glm::vec2 Widget::getPreferredSize()
{
    return getMinimalSize();
}