-
Notifications
You must be signed in to change notification settings - Fork 19
Respect size hints when resizing Qml streamer #203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
retest this please |
deflect/qt/QmlStreamerImpl.cpp
Outdated
| bool QmlStreamer::Impl::_isWithinSizeHintsRange(const uint width, | ||
| const uint height) const | ||
| { | ||
| const auto minWidth = _sizeHints.minWidth; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const auto minWidth = _sizeHints.minWidth; | |
| const auto minWidth = _sizeHints.minWidth == SizeHints::UNSPECIFIED_SIZE | |
| ? 0 | |
| : _sizeHints.minWidth; | |
| const auto maxWidth = _sizeHints.maxWidth == SizeHints::UNSPECIFIED_SIZE | |
| ? std::numeric_limits<uint>() | |
| : _sizeHints.maxWidth; | |
| const auto minHeight = _sizeHints.minHeight == SizeHints::UNSPECIFIED_SIZE | |
| ? 0 | |
| : _sizeHints.minHeight; | |
| const auto maxHeight = _sizeHints.maxHeight == SizeHints::UNSPECIFIED_SIZE | |
| ? std::numeric_limits<uint>() | |
| : _sizeHints.maxHeight; | |
| return minWidth <= width && width <= maxWidth && minHeight <= height && | |
| height <= maxHeight; |
Do you think this is easier to understand?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't make a big difference to me, but I can apply your suggestion. Maybe have having a single return point is better style?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having everything constant and one return is a better style imo. But it does look a bit repeated. Anyhow, no big deal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This got me thinking and I started looking if there was a good way to check if a value is withing a range and found (https://stackoverflow.com/questions/9255887/) the following option:
template <typename T>
struct Interval
{
T low;
T high;
bool contains(const T value) const { return low <= value && value <= high; }
};
template <typename T>
Interval<T> interval(const T low, const T high)
{
return Interval<T>{low, high};
}
// Then you can be more explicit about what you mean:
if (interval(a, b).contains(value))
// ...
Might be an overkill for this use case but I like how clean this looks... :-)
No description provided.