|
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 |
|
|
Toshihiro Shimizu |
890ddd |
QPixmap DVAPI rasterToQPixmap(const TRaster32P &ras, bool premultiplied = true);
|
|
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 |
//-----------------------------------------------------------------------------
|
|
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 |
|
|
Shinya Kitaoka |
120a6e |
inline QSize DVAPI dimension2QSize(const TDimension &sz) {
|
|
Shinya Kitaoka |
120a6e |
return QSize(sz.lx, sz.ly);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
inline TDimension DVAPI 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);
|
|
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 |
|
|
Toshihiro Shimizu |
890ddd |
inline QPointF DVAPI toQPointF(const TPointD &p) { return QPointF(p.x, p.y); }
|
|
Toshihiro Shimizu |
890ddd |
inline QPointF DVAPI toQPointF(const TPoint &p) { return QPointF(p.x, p.y); }
|
|
Toshihiro Shimizu |
890ddd |
inline QPoint DVAPI toQPoint(const TPoint &p) { return QPoint(p.x, p.y); }
|
|
Shinya Kitaoka |
120a6e |
inline TPointD DVAPI toTPointD(const QPointF &p) {
|
|
Shinya Kitaoka |
120a6e |
return TPointD(p.x(), p.y());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
inline TPointD DVAPI toTPointD(const QPoint &p) {
|
|
Shinya Kitaoka |
120a6e |
return TPointD(p.x(), p.y());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
inline TPoint DVAPI toTPoint(const QPoint &p) { return TPoint(p.x(), p.y()); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline QRect DVAPI toQRect(const TRect &r) {
|
|
Shinya Kitaoka |
120a6e |
return QRect(r.x0, r.y0, r.getLx(), r.getLy());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
inline QRectF DVAPI toQRectF(const TRectD &r) {
|
|
Shinya Kitaoka |
120a6e |
return QRectF(r.x0, r.y0, r.getLx(), r.getLy());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
inline QRectF DVAPI toQRectF(const TRect &r) {
|
|
Shinya Kitaoka |
120a6e |
return QRectF(r.x0, r.y0, r.getLx(), r.getLy());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
inline TRect DVAPI toTRect(const QRect &r) {
|
|
Shinya Kitaoka |
120a6e |
return TRect(r.left(), r.top(), r.right(), r.bottom());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
inline TRectD DVAPI toTRectD(const QRectF &r) {
|
|
Shinya Kitaoka |
120a6e |
return TRectD(r.left(), r.top(), r.right(), r.bottom());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
inline TRectD DVAPI 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 {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
TabBarContainter(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 |
//-----------------------------------------------------------------------------
|
|
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
|