lib_ui/ui/gl/gl_math.h
2021-05-25 14:54:41 +04:00

75 lines
1.4 KiB
C++

// This file is part of Desktop App Toolkit,
// a set of libraries for developing nice desktop applications.
//
// For license and copyright information please follow this link:
// https://github.com/desktop-app/legal/blob/master/LEGAL
//
#pragma once
#include <QtGui/QVector4D>
#include <QtCore/QSizeF>
namespace Ui::GL {
class Rect final {
public:
Rect(QRect rect)
: _x(rect.x())
, _y(rect.y())
, _width(rect.width())
, _height(rect.height()) {
}
Rect(QRectF rect)
: _x(rect.x())
, _y(rect.y())
, _width(rect.width())
, _height(rect.height()) {
}
Rect(float x, float y, float width, float height)
: _x(x)
, _y(y)
, _width(width)
, _height(height) {
}
[[nodiscard]] float x() const {
return _x;
}
[[nodiscard]] float y() const {
return _y;
}
[[nodiscard]] float width() const {
return _width;
}
[[nodiscard]] float height() const {
return _height;
}
[[nodiscard]] float left() const {
return _x;
}
[[nodiscard]] float top() const {
return _y;
}
[[nodiscard]] float right() const {
return _x + _width;
}
[[nodiscard]] float bottom() const {
return _y + _height;
}
private:
float _x = 0;
float _y = 0;
float _width = 0;
float _height = 0;
};
[[nodiscard]] QVector4D Uniform(const QRect &rect, float factor);
[[nodiscard]] QVector4D Uniform(const Rect &rect);
[[nodiscard]] QVector4D Uniform(const QColor &color);
[[nodiscard]] QSizeF Uniform(QSize size);
} // namespace Ui::GL