|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef GUTIL_H
|
|
Toshihiro Shimizu |
890ddd |
#define GUTIL_H
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tcommon.h"
|
|
Toshihiro Shimizu |
890ddd |
#include <qimage></qimage>
|
|
Toshihiro Shimizu |
890ddd |
#include <qframe></qframe>
|
|
Toshihiro Shimizu |
890ddd |
#include <qcolor></qcolor>
|
|
Toshihiro Shimizu |
890ddd |
#include "traster.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#undef DVAPI
|
|
Toshihiro Shimizu |
890ddd |
#undef DVVAR
|
|
Toshihiro Shimizu |
890ddd |
#ifdef TOONZQT_EXPORTS
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_EXPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_EXPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_IMPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_IMPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// forward declaration
|
|
Toshihiro Shimizu |
890ddd |
class TMouseEvent;
|
|
Toshihiro Shimizu |
890ddd |
class QMouseEvent;
|
|
Toshihiro Shimizu |
890ddd |
class QTabletEvent;
|
|
Toshihiro Shimizu |
890ddd |
class QKeyEvent;
|
|
Toshihiro Shimizu |
890ddd |
class QUrl;
|
|
Toshihiro Shimizu |
890ddd |
class TFilePath;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
// Constant definition
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace {
|
|
Toshihiro Shimizu |
890ddd |
const QColor grey120(120, 120, 120);
|
|
Toshihiro Shimizu |
890ddd |
const QColor grey210(210, 210, 210);
|
|
Toshihiro Shimizu |
890ddd |
const QColor grey225(225, 225, 225);
|
|
Toshihiro Shimizu |
890ddd |
const QColor grey190(190, 190, 190);
|
|
Toshihiro Shimizu |
890ddd |
const QColor grey150(150, 150, 150);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
} // namespace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class QPainter;
|
|
Toshihiro Shimizu |
890ddd |
class QIcon;
|
|
Toshihiro Shimizu |
890ddd |
class TFilePath;
|
|
Toshihiro Shimizu |
890ddd |
class QPainterPath;
|
|
Toshihiro Shimizu |
890ddd |
class TStroke;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Campbell Barton |
ea4f7e |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QString DVAPI fileSizeString(qint64 size, int precision = 2);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Campbell Barton |
ea4f7e |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QImage DVAPI rasterToQImage(const TRasterP &ras, bool premultiplied = true,
|
|
Shinya Kitaoka |
120a6e |
bool mirrored = true);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun_iwasawa |
3cc41f |
QPixmap DVAPI rasterToQPixmap(const TRaster32P &ras, bool premultiplied = true,
|
|
shun_iwasawa |
3cc41f |
bool setDevPixRatio = false);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TRaster32P DVAPI rasterFromQImage(QImage image, bool premultiply = true,
|
|
Shinya Kitaoka |
120a6e |
bool mirror = true);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TRaster32P DVAPI rasterFromQPixmap(QPixmap pixmap, bool premultiply = true,
|
|
Shinya Kitaoka |
120a6e |
bool mirror = true);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DVAPI drawPolygon(QPainter &p, const std::vector<qpointf> &points,</qpointf>
|
|
Shinya Kitaoka |
120a6e |
bool fill = false, const QColor colorFill = Qt::white,
|
|
Shinya Kitaoka |
120a6e |
const QColor colorLine = Qt::black);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DVAPI drawArrow(QPainter &p, const QPointF a, const QPointF b,
|
|
Shinya Kitaoka |
120a6e |
const QPointF c, bool fill = false,
|
|
Shinya Kitaoka |
120a6e |
const QColor colorFill = Qt::white,
|
|
Shinya Kitaoka |
120a6e |
const QColor colorLine = Qt::black);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QPixmap DVAPI scalePixmapKeepingAspectRatio(QPixmap p, QSize size,
|
|
Shinya Kitaoka |
120a6e |
QColor color = Qt::white);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
shun_iwasawa |
3cc41f |
|
|
shun_iwasawa |
3cc41f |
QPixmap DVAPI
|
|
shun_iwasawa |
3cc41f |
svgToPixmap(const QString &svgFilePath, const QSize &size = QSize(),
|
|
shun_iwasawa |
3cc41f |
Qt::AspectRatioMode aspectRatioMode = Qt::IgnoreAspectRatio,
|
|
shun_iwasawa |
3cc41f |
QColor bgColor = Qt::transparent);
|
|
shun_iwasawa |
3cc41f |
|
|
shun_iwasawa |
3cc41f |
//-----------------------------------------------------------------------------
|
|
shun_iwasawa |
3cc41f |
// returns device-pixel ratio. It is 1 for normal monitors and 2 (or higher
|
|
shun_iwasawa |
3cc41f |
// ratio) for high DPI monitors. Setting "Display > Set custom text size(DPI)"
|
|
shun_iwasawa |
3cc41f |
// for Windows corresponds to this ratio.
|
|
shun_iwasawa |
3cc41f |
int DVAPI getDevPixRatio();
|
|
shun_iwasawa |
3cc41f |
|
|
shun_iwasawa |
3cc41f |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
QIcon DVAPI createQIcon(const char *iconSVGName);
|
|
Toshihiro Shimizu |
890ddd |
QIcon DVAPI createQIconPNG(const char *iconPNGName);
|
|
Toshihiro Shimizu |
890ddd |
QIcon DVAPI createQIconOnOff(const char *iconSVGName, bool withOver = true);
|
|
Toshihiro Shimizu |
890ddd |
QIcon DVAPI createQIconOnOffPNG(const char *iconPNGName, bool withOver = true);
|
|
Toshihiro Shimizu |
890ddd |
|
|
|
2fc36c |
inline QSize dimension2QSize(const TDimension &sz) {
|
|
Shinya Kitaoka |
120a6e |
return QSize(sz.lx, sz.ly);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
|
2fc36c |
inline TDimension qsize2Dimension(const QSize &sz) {
|
|
Shinya Kitaoka |
120a6e |
return TDimension(sz.width(), sz.height());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
QString DVAPI toQString(const TFilePath &path);
|
|
Toshihiro Shimizu |
890ddd |
bool DVAPI isSpaceString(const QString &str);
|
|
Toshihiro Shimizu |
890ddd |
bool DVAPI isValidFileName(const QString &fileName);
|
|
Toshihiro Shimizu |
890ddd |
bool DVAPI isValidFileName_message(const QString &fileName);
|
|
manongjohn |
7f3150 |
bool DVAPI isReservedFileName(const QString &fileName);
|
|
manongjohn |
7f3150 |
bool DVAPI isReservedFileName_message(const QString &fileName);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QString DVAPI elideText(const QString &columnName, const QFont &font,
|
|
Shinya Kitaoka |
120a6e |
int width);
|
|
Shinya Kitaoka |
120a6e |
QString DVAPI elideText(const QString &columnName, const QFontMetrics &fm,
|
|
Shinya Kitaoka |
120a6e |
int width, const QString &elideSymbol);
|
|
Toshihiro Shimizu |
890ddd |
QUrl DVAPI pathToUrl(const TFilePath &path);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool DVAPI isResource(const QString &path);
|
|
Toshihiro Shimizu |
890ddd |
bool DVAPI isResource(const QUrl &url);
|
|
Toshihiro Shimizu |
890ddd |
bool DVAPI isResourceOrFolder(const QUrl &url);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool DVAPI acceptResourceDrop(const QList<qurl> &urls);</qurl>
|
|
Toshihiro Shimizu |
890ddd |
bool DVAPI acceptResourceOrFolderDrop(const QList<qurl> &urls);</qurl>
|
|
Toshihiro Shimizu |
890ddd |
|
|
|
2fc36c |
inline QPointF toQPointF(const TPointD &p) { return QPointF(p.x, p.y); }
|
|
|
2fc36c |
inline QPointF toQPointF(const TPoint &p) { return QPointF(p.x, p.y); }
|
|
|
2fc36c |
inline QPoint toQPoint(const TPoint &p) { return QPoint(p.x, p.y); }
|
|
shun_iwasawa |
0cae24 |
inline TPointD toTPointD(const QPointF &p) { return TPointD(p.x(), p.y()); }
|
|
shun_iwasawa |
0cae24 |
inline TPointD toTPointD(const QPoint &p) { return TPointD(p.x(), p.y()); }
|
|
|
2fc36c |
inline TPoint toTPoint(const QPoint &p) { return TPoint(p.x(), p.y()); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
|
2fc36c |
inline QRect toQRect(const TRect &r) {
|
|
Shinya Kitaoka |
120a6e |
return QRect(r.x0, r.y0, r.getLx(), r.getLy());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
|
2fc36c |
inline QRectF toQRectF(const TRectD &r) {
|
|
Shinya Kitaoka |
120a6e |
return QRectF(r.x0, r.y0, r.getLx(), r.getLy());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
|
2fc36c |
inline QRectF toQRectF(const TRect &r) {
|
|
Shinya Kitaoka |
120a6e |
return QRectF(r.x0, r.y0, r.getLx(), r.getLy());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
|
2fc36c |
inline TRect toTRect(const QRect &r) {
|
|
Shinya Kitaoka |
120a6e |
return TRect(r.left(), r.top(), r.right(), r.bottom());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
|
2fc36c |
inline TRectD toTRectD(const QRectF &r) {
|
|
Shinya Kitaoka |
120a6e |
return TRectD(r.left(), r.top(), r.right(), r.bottom());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
|
2fc36c |
inline TRectD toTRectD(const QRect &r) {
|
|
Shinya Kitaoka |
120a6e |
return TRectD(r.left(), r.top(), r.right() + 1, r.bottom() + 1);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QPainterPath DVAPI strokeToPainterPath(TStroke *stroke);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
// This widget is only used to set the background color of the tabBar
|
|
Toshihiro Shimizu |
890ddd |
// using the styleSheet.
|
|
Toshihiro Shimizu |
890ddd |
// It is also used to take 6px on the left before the tabBar
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class DVAPI TabBarContainter final : public QFrame {
|
|
Jeremy Bullock |
0f89c5 |
Q_OBJECT
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
TabBarContainter(QWidget *parent = 0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Jeremy Bullock |
0f89c5 |
QColor m_bottomBelowLineColor, m_bottomAboveLineColor;
|
|
Jeremy Bullock |
0f89c5 |
Q_PROPERTY(QColor BottomBelowLineColor READ getBottomBelowLineColor WRITE
|
|
Jeremy Bullock |
0f89c5 |
setBottomBelowLineColor);
|
|
Jeremy Bullock |
0f89c5 |
Q_PROPERTY(QColor BottomAboveLineColor READ getBottomAboveLineColor WRITE
|
|
Jeremy Bullock |
0f89c5 |
setBottomAboveLineColor);
|
|
Shinya Kitaoka |
473e70 |
void paintEvent(QPaintEvent *event) override;
|
|
Jeremy Bullock |
0f89c5 |
void setBottomBelowLineColor(const QColor &color) {
|
|
Jeremy Bullock |
0f89c5 |
m_bottomBelowLineColor = color;
|
|
Jeremy Bullock |
0f89c5 |
}
|
|
Jeremy Bullock |
0f89c5 |
QColor getBottomBelowLineColor() const { return m_bottomBelowLineColor; }
|
|
Jeremy Bullock |
0f89c5 |
void setBottomAboveLineColor(const QColor &color) {
|
|
Jeremy Bullock |
0f89c5 |
m_bottomAboveLineColor = color;
|
|
Jeremy Bullock |
0f89c5 |
}
|
|
Jeremy Bullock |
0f89c5 |
QColor getBottomAboveLineColor() const { return m_bottomAboveLineColor; }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
// This widget is only used to set the background color of the playToolBar
|
|
Toshihiro Shimizu |
890ddd |
// using the styleSheet. And to put a line in the upper zone
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class DVAPI ToolBarContainer final : public QFrame {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
ToolBarContainer(QWidget *parent = 0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Shinya Kitaoka |
473e70 |
void paintEvent(QPaintEvent *event) override;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QString DVAPI operator+(const QString &a, const TFilePath &fp);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#endif // GUTIL_H
|