fix other panels for high dpi monitors
This commit is contained in:
parent
3807327b41
commit
7c988d9428
14 changed files with 156 additions and 102 deletions
29
toonz/sources/include/toonzqt/glwidget_for_highdpi.h
Normal file
29
toonz/sources/include/toonzqt/glwidget_for_highdpi.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef GLWIDGET_FOR_HIGHDPI_H
|
||||
#define GLWIDGET_FOR_HIGHDPI_H
|
||||
|
||||
#include <QGLWidget>
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
|
||||
// use obsolete QGLWidget instead of QOpenGLWidget for now...
|
||||
// TODO: replace with the "modern" OpenGL source and transfer to QOpenGLWidget
|
||||
class GLWidgetForHighDpi : public QGLWidget {
|
||||
public:
|
||||
GLWidgetForHighDpi(QWidget *parent = Q_NULLPTR,
|
||||
const QGLWidget *shareWidget = Q_NULLPTR,
|
||||
Qt::WindowFlags f = Qt::WindowFlags())
|
||||
: QGLWidget(parent, shareWidget, f) {}
|
||||
|
||||
int getDevPixRatio() const {
|
||||
static int devPixRatio = QApplication::desktop()->devicePixelRatio();
|
||||
return devPixRatio;
|
||||
}
|
||||
// modify sizes for high DPI monitors
|
||||
int width() const { return QGLWidget::width() * getDevPixRatio(); }
|
||||
int height() const { return QGLWidget::height() * getDevPixRatio(); }
|
||||
QRect rect() const { return QRect(0, 0, width(), height()); }
|
||||
};
|
||||
|
||||
#endif
|
|
@ -21,6 +21,7 @@
|
|||
#include "toonzqt/doublefield.h"
|
||||
#include "toonzqt/colorfield.h"
|
||||
#include "toonzqt/tabbar.h"
|
||||
#include "toonzqt/glwidget_for_highdpi.h"
|
||||
|
||||
// Toonz includes
|
||||
//#include "../toonz/tapp.h" //iwsw commented out temporarily
|
||||
|
@ -32,7 +33,6 @@
|
|||
#include <QSlider>
|
||||
#include <QToolButton>
|
||||
#include <QScrollArea>
|
||||
#include <QOpenGLWidget>
|
||||
#include <QMouseEvent>
|
||||
#include <QPointF>
|
||||
|
||||
|
@ -135,7 +135,7 @@ public:
|
|||
|
||||
enum CurrentWheel { none, leftWheel, rightTriangle };
|
||||
|
||||
class DVAPI HexagonalColorWheel final : public QOpenGLWidget {
|
||||
class DVAPI HexagonalColorWheel final : public GLWidgetForHighDpi {
|
||||
Q_OBJECT
|
||||
|
||||
// backgoround color (R160, G160, B160)
|
||||
|
|
|
@ -200,7 +200,7 @@ public:
|
|||
|
||||
ImageViewer::ImageViewer(QWidget *parent, FlipBook *flipbook,
|
||||
bool showHistogram)
|
||||
: QOpenGLWidget(parent)
|
||||
: GLWidgetForHighDpi(parent)
|
||||
, m_pressedMousePos(0, 0)
|
||||
, m_mouseButton(Qt::NoButton)
|
||||
, m_draggingZoomSelection(false)
|
||||
|
@ -322,7 +322,8 @@ void ImageViewer::contextMenuEvent(QContextMenuEvent *event) {
|
|||
|
||||
bool addedSep = false;
|
||||
|
||||
if (m_isHistogramEnable && visibleRegion().contains(event->pos())) {
|
||||
if (m_isHistogramEnable &&
|
||||
visibleRegion().contains(event->pos() * getDevPixRatio())) {
|
||||
menu->addSeparator();
|
||||
addedSep = true;
|
||||
action = menu->addAction(tr("Show Histogram"));
|
||||
|
@ -729,18 +730,20 @@ void ImageViewer::updateCursor(const TPoint &curPos) {
|
|||
/*! If middle button is pressed pan the image. Update current mouse position.
|
||||
*/
|
||||
void ImageViewer::mouseMoveEvent(QMouseEvent *event) {
|
||||
TPoint curPos = TPoint(event->pos().x(), event->pos().y());
|
||||
QPoint curQPos = event->pos() * getDevPixRatio();
|
||||
|
||||
TPoint curPos = TPoint(curQPos.x(), curQPos.y());
|
||||
|
||||
if (m_visualSettings.m_defineLoadbox && m_flipbook) {
|
||||
if (m_mouseButton == Qt::LeftButton)
|
||||
updateLoadbox(curPos);
|
||||
else if (m_mouseButton == Qt::MidButton)
|
||||
panQt(event->pos() - m_pos);
|
||||
panQt(curQPos - m_pos);
|
||||
else
|
||||
updateCursor(curPos);
|
||||
update();
|
||||
event->ignore();
|
||||
m_pos = event->pos();
|
||||
m_pos = curQPos;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -762,11 +765,11 @@ void ImageViewer::mouseMoveEvent(QMouseEvent *event) {
|
|||
}
|
||||
|
||||
if (m_compareSettings.m_dragCompareX || m_compareSettings.m_dragCompareY)
|
||||
dragCompare(event->pos() - m_pos);
|
||||
dragCompare(curQPos - m_pos);
|
||||
else if (m_mouseButton == Qt::MidButton)
|
||||
panQt(event->pos() - m_pos);
|
||||
panQt(curQPos - m_pos);
|
||||
|
||||
m_pos = event->pos();
|
||||
m_pos = curQPos;
|
||||
|
||||
// pick the color if the histogram popup is opened
|
||||
if (m_isHistogramEnable && m_histogramPopup->isVisible() && !m_isColorModel) {
|
||||
|
@ -830,8 +833,10 @@ void ImageViewer::pickColor(QMouseEvent *event, bool putValueToStyleEditor) {
|
|||
if (!m_isHistogramEnable) return;
|
||||
if (!m_histogramPopup->isVisible()) return;
|
||||
|
||||
QPoint curPos = event->pos() * getDevPixRatio();
|
||||
|
||||
// avoid to pick outside of the flip
|
||||
if ((!m_image) || !rect().contains(event->pos())) {
|
||||
if ((!m_image) || !rect().contains(curPos)) {
|
||||
// throw transparent color
|
||||
m_histogramPopup->updateInfo(TPixel32::Transparent, TPointD(-1, -1));
|
||||
return;
|
||||
|
@ -839,7 +844,7 @@ void ImageViewer::pickColor(QMouseEvent *event, bool putValueToStyleEditor) {
|
|||
|
||||
StylePicker picker(m_image);
|
||||
|
||||
TPoint mousePos = TPoint(event->pos().x(), height() - 1 - event->pos().y());
|
||||
TPoint mousePos = TPoint(curPos.x(), height() - 1 - curPos.y());
|
||||
TRectD area = TRectD(mousePos.x, mousePos.y, mousePos.x, mousePos.y);
|
||||
|
||||
// iwsw commented out temporarily
|
||||
|
@ -854,7 +859,7 @@ void ImageViewer::pickColor(QMouseEvent *event, bool putValueToStyleEditor) {
|
|||
// Preferences::instance()->isDoColorCorrectionByUsing3DLutEnabled())
|
||||
// get3DLutUtil()->releaseFBO();
|
||||
|
||||
QPoint viewP = mapFrom(this, event->pos());
|
||||
QPoint viewP = mapFrom(this, curPos);
|
||||
TPointD pos = getViewAff().inv() *
|
||||
TPointD(viewP.x() - width() / 2, -viewP.y() + height() / 2);
|
||||
TPointD imagePos = TPointD(0.5 * m_image->getBBox().getLx() + pos.x,
|
||||
|
@ -952,7 +957,7 @@ void ImageViewer::mouseDoubleClickEvent(QMouseEvent *event) {
|
|||
//------------------------------------------------------------------------------
|
||||
|
||||
void ImageViewer::mousePressEvent(QMouseEvent *event) {
|
||||
m_pos = event->pos();
|
||||
m_pos = event->pos() * getDevPixRatio();
|
||||
m_pressedMousePos = TPoint(m_pos.x(), m_pos.y());
|
||||
m_mouseButton = event->button();
|
||||
m_draggingZoomSelection = false;
|
||||
|
@ -1036,8 +1041,8 @@ void ImageViewer::mouseReleaseEvent(QMouseEvent *event) {
|
|||
void ImageViewer::wheelEvent(QWheelEvent *event) {
|
||||
if (event->orientation() == Qt::Horizontal) return;
|
||||
int delta = event->delta() > 0 ? 120 : -120;
|
||||
QPoint center(event->pos().x() - width() / 2,
|
||||
-event->pos().y() + height() / 2);
|
||||
QPoint center(event->pos().x() * getDevPixRatio() - width() / 2,
|
||||
-event->pos().y() * getDevPixRatio() + height() / 2);
|
||||
zoomQt(center, exp(0.001 * delta));
|
||||
}
|
||||
|
||||
|
@ -1146,7 +1151,8 @@ void ImageViewer::adaptView(const QRect &geomRect) {
|
|||
void ImageViewer::doSwapBuffers() { glFlush(); }
|
||||
|
||||
void ImageViewer::changeSwapBehavior(bool enable) {
|
||||
setUpdateBehavior(enable ? PartialUpdate : NoPartialUpdate);
|
||||
// do nothing for now as setUpdateBehavior is not available with QGLWidget
|
||||
// setUpdateBehavior(enable ? PartialUpdate : NoPartialUpdate);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
@ -7,8 +7,7 @@
|
|||
//#include "toonzqt/ghibli_3dlut_util.h"
|
||||
|
||||
#include "toonz/imagepainter.h"
|
||||
|
||||
#include <QOpenGLWidget>
|
||||
#include "toonzqt/glwidget_for_highdpi.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
@ -22,7 +21,7 @@ class HistogramPopup;
|
|||
// ImageViewer
|
||||
//--------------------
|
||||
|
||||
class ImageViewer final : public QOpenGLWidget {
|
||||
class ImageViewer final : public GLWidgetForHighDpi {
|
||||
Q_OBJECT
|
||||
enum DragType {
|
||||
eNone,
|
||||
|
|
|
@ -268,7 +268,7 @@ int main(int argc, char *argv[]) {
|
|||
#if QT_VERSION >= 0x050600
|
||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
#endif
|
||||
|
||||
|
||||
QApplication a(argc, argv);
|
||||
|
||||
#ifdef MACOSX
|
||||
|
@ -345,7 +345,7 @@ int main(int argc, char *argv[]) {
|
|||
// weird flickering effects when dragging panel separators.
|
||||
a.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
|
||||
#endif
|
||||
|
||||
|
||||
// Enable to render smooth icons on high dpi monitors
|
||||
a.setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
|
||||
|
|
|
@ -466,7 +466,7 @@ public:
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
SceneViewer::SceneViewer(ImageUtils::FullScreenWidget *parent)
|
||||
: QGLWidget(parent, touchProxy())
|
||||
: GLWidgetForHighDpi(parent, touchProxy())
|
||||
, m_pressure(0)
|
||||
, m_lastMousePos(0, 0)
|
||||
, m_mouseButton(Qt::NoButton)
|
||||
|
@ -2557,7 +2557,7 @@ void SceneViewer::invalidateToolStatus() {
|
|||
*/
|
||||
|
||||
TRectD SceneViewer::getGeometry() const {
|
||||
int devPixRatio = TApp::instance()->getDevPixRatio();
|
||||
int devPixRatio = getDevPixRatio();
|
||||
TTool *tool = TApp::instance()->getCurrentTool()->getTool();
|
||||
TPointD topLeft =
|
||||
tool->getMatrix().inv() * winToWorld(geometry().topLeft() * devPixRatio);
|
||||
|
@ -2581,14 +2581,3 @@ TRectD SceneViewer::getGeometry() const {
|
|||
void SceneViewer::doDeleteSubCamera() {
|
||||
PreviewSubCameraManager::instance()->deleteSubCamera(this);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/*! modify sizes for high DPI monitors
|
||||
*/
|
||||
int SceneViewer::width() const {
|
||||
return QGLWidget::width() * TApp::instance()->getDevPixRatio();
|
||||
}
|
||||
|
||||
int SceneViewer::height() const {
|
||||
return QGLWidget::height() * TApp::instance()->getDevPixRatio();
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
// TnzQt includes
|
||||
#include "toonzqt/menubarcommand.h"
|
||||
#include "toonzqt/flipconsole.h"
|
||||
#include "toonzqt/glwidget_for_highdpi.h"
|
||||
// iwsw commented out temporarily
|
||||
//#include "toonzqt/ghibli_3dlut_util.h"
|
||||
|
||||
|
@ -23,9 +24,6 @@
|
|||
#include "pane.h"
|
||||
#include "previewer.h"
|
||||
|
||||
// Qt includes
|
||||
#include <QGLWidget>
|
||||
|
||||
//=====================================================================
|
||||
|
||||
// Forward declarations
|
||||
|
@ -57,7 +55,7 @@ public:
|
|||
// SceneViewer
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class SceneViewer final : public QGLWidget,
|
||||
class SceneViewer final : public GLWidgetForHighDpi,
|
||||
public TTool::Viewer,
|
||||
public Previewer::Listener {
|
||||
Q_OBJECT
|
||||
|
@ -245,10 +243,6 @@ public:
|
|||
|
||||
TPoint worldToPos(const TPointD &worldPos) const override;
|
||||
|
||||
// modify sizes for high DPI monitors
|
||||
int width() const;
|
||||
int height() const;
|
||||
|
||||
protected:
|
||||
// Paint vars
|
||||
TAffine m_drawCameraAff;
|
||||
|
|
|
@ -75,8 +75,7 @@ int modifiers = 0;
|
|||
|
||||
void initToonzEvent(TMouseEvent &toonzEvent, QMouseEvent *event,
|
||||
int widgetHeight, double pressure, bool isTablet,
|
||||
bool isClick) {
|
||||
int devPixRatio = TApp::instance()->getDevPixRatio();
|
||||
bool isClick, int devPixRatio) {
|
||||
toonzEvent.m_pos = TPoint(event->pos().x() * devPixRatio,
|
||||
widgetHeight - 1 - event->pos().y() * devPixRatio);
|
||||
toonzEvent.m_pressure = isTablet ? int(255 * pressure) : 255;
|
||||
|
@ -275,7 +274,7 @@ void SceneViewer::enterEvent(QEvent *) {
|
|||
void SceneViewer::mouseMoveEvent(QMouseEvent *event) {
|
||||
if (m_freezedStatus != NO_FREEZED) return;
|
||||
|
||||
QPoint curPos = event->pos() * TApp::instance()->getDevPixRatio();
|
||||
QPoint curPos = event->pos() * getDevPixRatio();
|
||||
bool cursorSet = false;
|
||||
m_lastMousePos = curPos;
|
||||
|
||||
|
@ -360,7 +359,7 @@ void SceneViewer::mouseMoveEvent(QMouseEvent *event) {
|
|||
tool->setViewer(this);
|
||||
TMouseEvent toonzEvent;
|
||||
initToonzEvent(toonzEvent, event, height(), m_pressure, m_tabletEvent,
|
||||
false);
|
||||
false, getDevPixRatio());
|
||||
TPointD worldPos = winToWorld(curPos);
|
||||
TPointD pos = tool->getMatrix().inv() * worldPos;
|
||||
|
||||
|
@ -418,7 +417,7 @@ void SceneViewer::mousePressEvent(QMouseEvent *event) {
|
|||
|
||||
if (m_mouseButton != Qt::NoButton) return;
|
||||
|
||||
m_pos = event->pos() * TApp::instance()->getDevPixRatio();
|
||||
m_pos = event->pos() * getDevPixRatio();
|
||||
m_mouseButton = event->button();
|
||||
|
||||
// when using tablet, avoid unexpected drawing behavior occurs when
|
||||
|
@ -477,7 +476,8 @@ void SceneViewer::mousePressEvent(QMouseEvent *event) {
|
|||
if (m_pressure > 0 && !m_tabletEvent) m_tabletEvent = true;
|
||||
|
||||
if (TApp::instance()->isPenCloseToTablet()) m_tabletEvent = true;
|
||||
initToonzEvent(toonzEvent, event, height(), m_pressure, m_tabletEvent, true);
|
||||
initToonzEvent(toonzEvent, event, height(), m_pressure, m_tabletEvent, true,
|
||||
getDevPixRatio());
|
||||
// if(!m_tabletEvent) qDebug() << "-----------------MOUSE PRESS 'PURO'.
|
||||
// POSSIBILE EMBOLO";
|
||||
TPointD pos = tool->getMatrix().inv() * winToWorld(m_pos);
|
||||
|
@ -543,9 +543,9 @@ void SceneViewer::mouseReleaseEvent(QMouseEvent *event) {
|
|||
{
|
||||
TMouseEvent toonzEvent;
|
||||
initToonzEvent(toonzEvent, event, height(), m_pressure, m_tabletEvent,
|
||||
false);
|
||||
TPointD pos = tool->getMatrix().inv() *
|
||||
winToWorld(event->pos() * TApp::instance()->getDevPixRatio());
|
||||
false, getDevPixRatio());
|
||||
TPointD pos =
|
||||
tool->getMatrix().inv() * winToWorld(event->pos() * getDevPixRatio());
|
||||
|
||||
TObjectHandle *objHandle = TApp::instance()->getCurrentObject();
|
||||
if (tool->getToolType() & TTool::LevelTool && !objHandle->isSpline()) {
|
||||
|
@ -623,8 +623,7 @@ void SceneViewer::wheelEvent(QWheelEvent *event) {
|
|||
CommandManager::instance()->execute("MI_PrevDrawing");
|
||||
}
|
||||
} else {
|
||||
zoomQt(event->pos() * TApp::instance()->getDevPixRatio(),
|
||||
exp(0.001 * delta));
|
||||
zoomQt(event->pos() * getDevPixRatio(), exp(0.001 * delta));
|
||||
}
|
||||
}
|
||||
event->accept();
|
||||
|
@ -1004,9 +1003,10 @@ void SceneViewer::mouseDoubleClickEvent(QMouseEvent *event) {
|
|||
TTool *tool = TApp::instance()->getCurrentTool()->getTool();
|
||||
if (!tool || !tool->isEnabled()) return;
|
||||
TMouseEvent toonzEvent;
|
||||
initToonzEvent(toonzEvent, event, height(), m_pressure, m_tabletEvent, true);
|
||||
TPointD pos = tool->getMatrix().inv() *
|
||||
winToWorld(event->pos() * TApp::instance()->getDevPixRatio());
|
||||
initToonzEvent(toonzEvent, event, height(), m_pressure, m_tabletEvent, true,
|
||||
getDevPixRatio());
|
||||
TPointD pos =
|
||||
tool->getMatrix().inv() * winToWorld(event->pos() * getDevPixRatio());
|
||||
TObjectHandle *objHandle = TApp::instance()->getCurrentObject();
|
||||
if (tool->getToolType() & TTool::LevelTool && !objHandle->isSpline()) {
|
||||
pos.x /= m_dpiScale.x;
|
||||
|
@ -1041,7 +1041,7 @@ void SceneViewer::contextMenuEvent(QContextMenuEvent *e) {
|
|||
if (m_freezedStatus != NO_FREEZED) return;
|
||||
if (m_isLocator) return;
|
||||
|
||||
int devPixRatio = TApp::instance()->getDevPixRatio();
|
||||
int devPixRatio = getDevPixRatio();
|
||||
TPoint winPos(e->pos().x() * devPixRatio,
|
||||
height() - e->pos().y() * devPixRatio);
|
||||
std::vector<int> columnIndices;
|
||||
|
|
|
@ -512,10 +512,11 @@ void RenameCellField::showInRowCol(int row, int col, bool multiColumnSelected) {
|
|||
m_col = col;
|
||||
|
||||
#ifdef _WIN32
|
||||
static QFont font("Arial", XSHEET_FONT_SIZE, QFont::Normal);
|
||||
static QFont font("Arial", -1, QFont::Normal);
|
||||
#else
|
||||
static QFont font("Helvetica", XSHEET_FONT_SIZE, QFont::Normal);
|
||||
static QFont font("Helvetica", -1, QFont::Normal);
|
||||
#endif
|
||||
font.setPixelSize(XSHEET_FONT_PX_SIZE);
|
||||
setFont(font);
|
||||
setAlignment(Qt::AlignRight | Qt::AlignBottom);
|
||||
|
||||
|
@ -1269,10 +1270,11 @@ void CellArea::drawLevelCell(QPainter &p, int row, int col, bool isReference) {
|
|||
: m_viewer->getTextColor());
|
||||
|
||||
#ifdef _WIN32
|
||||
static QFont font("Arial", XSHEET_FONT_SIZE, QFont::Normal);
|
||||
static QFont font("Arial", -1, QFont::Normal);
|
||||
#else
|
||||
static QFont font("Helvetica", XSHEET_FONT_SIZE, QFont::Normal);
|
||||
static QFont font("Helvetica", -1, QFont::Normal);
|
||||
#endif
|
||||
font.setPixelSize(XSHEET_FONT_PX_SIZE);
|
||||
p.setFont(font);
|
||||
|
||||
// do not draw frame number under RenameCellField
|
||||
|
@ -1376,16 +1378,21 @@ void CellArea::drawSoundTextCell(QPainter &p, int row, int col) {
|
|||
QString text = cell.getSoundTextLevel()->getFrameText(fid.getNumber() - 1);
|
||||
p.setPen(Qt::black);
|
||||
QRect nameRect = rect.adjusted(8, -H_ADJUST, -10, H_ADJUST);
|
||||
// il nome va scritto se e' diverso dalla cella precedente oppure se
|
||||
// siamo su una marker line
|
||||
static QFont font("Helvetica", XSHEET_FONT_SIZE, QFont::Normal);
|
||||
// il nome va scritto se e' diverso dalla cella precedente oppure se
|
||||
// siamo su una marker line
|
||||
#ifdef _WIN32
|
||||
static QFont font("Arial", -1, QFont::Normal);
|
||||
#else
|
||||
static QFont font("Helvetica", -1, QFont::Normal);
|
||||
#endif
|
||||
font.setPixelSize(XSHEET_FONT_PX_SIZE);
|
||||
p.setFont(font);
|
||||
|
||||
#if QT_VERSION >= 0x050500
|
||||
QFontMetrics metric(font);
|
||||
QString elidaName = elideText(text, metric, nameRect.width(), "~");
|
||||
#else
|
||||
QString elidaName = elideText(text, font, nameRect.width(), "~");
|
||||
QString elidaName = elideText(text, font, nameRect.width(), "~");
|
||||
#endif
|
||||
|
||||
if (!sameLevel || prevCell.m_frameId != fid)
|
||||
|
@ -1487,11 +1494,12 @@ void CellArea::drawPaletteCell(QPainter &p, int row, int col,
|
|||
: m_viewer->getTextColor());
|
||||
// il nome va scritto se e' diverso dalla cella precedente oppure se
|
||||
// siamo su una marker line
|
||||
#ifndef _WIN32
|
||||
static QFont font("Arial", XSHEET_FONT_SIZE, QFont::Normal);
|
||||
#ifdef _WIN32
|
||||
static QFont font("Arial", -1, QFont::Normal);
|
||||
#else
|
||||
static QFont font("Helvetica", XSHEET_FONT_SIZE, QFont::Normal);
|
||||
static QFont font("Helvetica", -1, QFont::Normal);
|
||||
#endif
|
||||
font.setPixelSize(XSHEET_FONT_PX_SIZE);
|
||||
p.setFont(font);
|
||||
QFontMetrics fm(font);
|
||||
|
||||
|
|
|
@ -312,7 +312,7 @@ void ChangeObjectParent::refresh() {
|
|||
QString text;
|
||||
QList<QString> pegbarList;
|
||||
QList<QString> columnList;
|
||||
int maxTextLength = 0;
|
||||
QString theLongestTxt;
|
||||
int i;
|
||||
for (i = 0; i < objectCount; i++) {
|
||||
TStageObjectId id = tree->getStageObject(i)->getId();
|
||||
|
@ -334,12 +334,20 @@ void ChangeObjectParent::refresh() {
|
|||
newText = QString("Col ") + indexStr;
|
||||
columnList.append(newText);
|
||||
}
|
||||
if (newText.length() > maxTextLength) maxTextLength = newText.length();
|
||||
if (newText.length() > theLongestTxt.length()) theLongestTxt = newText;
|
||||
}
|
||||
for (i = 0; i < columnList.size(); i++) addItem(columnList.at(i));
|
||||
for (i = 0; i < pegbarList.size(); i++) addItem(pegbarList.at(i));
|
||||
|
||||
m_width = maxTextLength * XSHEET_FONT_SIZE + 2;
|
||||
#ifdef _WIN32
|
||||
static QFont font("Arial", -1, QFont::Bold);
|
||||
#else
|
||||
static QFont font("Helvetica", -1, QFont::Normal);
|
||||
#endif
|
||||
// set font size in pixel
|
||||
font.setPixelSize(XSHEET_FONT_PX_SIZE);
|
||||
|
||||
m_width = QFontMetrics(font).width(theLongestTxt) + 2;
|
||||
selectCurrent(text);
|
||||
}
|
||||
|
||||
|
@ -451,7 +459,12 @@ RenameColumnField::RenameColumnField(QWidget *parent, XsheetViewer *viewer)
|
|||
|
||||
void RenameColumnField::show(QPoint pos, int col) {
|
||||
move(pos);
|
||||
static QFont font("Helvetica", XSHEET_FONT_SIZE, QFont::Normal);
|
||||
#ifdef _WIN32
|
||||
static QFont font("Arial", -1, QFont::Normal);
|
||||
#else
|
||||
static QFont font("Helvetica", -1, QFont::Normal);
|
||||
#endif
|
||||
font.setPixelSize(XSHEET_FONT_PX_SIZE);
|
||||
setFont(font);
|
||||
m_col = col;
|
||||
|
||||
|
@ -578,10 +591,11 @@ void ColumnArea::drawLevelColumnHead(QPainter &p, int col) {
|
|||
|
||||
// Preparing painter
|
||||
#ifdef _WIN32
|
||||
QFont font("Arial", XSHEET_FONT_SIZE, QFont::Normal);
|
||||
static QFont font("Arial", -1, QFont::Normal);
|
||||
#else
|
||||
QFont font("Helvetica", XSHEET_FONT_SIZE, QFont::Normal);
|
||||
static QFont font("Helvetica", -1, QFont::Normal);
|
||||
#endif
|
||||
font.setPixelSize(XSHEET_FONT_PX_SIZE);
|
||||
|
||||
p.setFont(font);
|
||||
p.setRenderHint(QPainter::SmoothPixmapTransform, true);
|
||||
|
@ -789,8 +803,12 @@ void ColumnArea::drawSoundColumnHead(QPainter &p, int col) {
|
|||
TColumnSelection *selection = m_viewer->getColumnSelection();
|
||||
|
||||
p.setRenderHint(QPainter::SmoothPixmapTransform, true);
|
||||
QFont font("Helvetica");
|
||||
font.setPointSize(XSHEET_FONT_SIZE);
|
||||
#ifdef _WIN32
|
||||
static QFont font("Arial", -1, QFont::Normal);
|
||||
#else
|
||||
static QFont font("Helvetica", -1, QFont::Normal);
|
||||
#endif
|
||||
font.setPixelSize(XSHEET_FONT_PX_SIZE);
|
||||
p.setFont(font);
|
||||
|
||||
int x = m_viewer->columnToX(col);
|
||||
|
@ -940,10 +958,12 @@ void ColumnArea::drawPaletteColumnHead(QPainter &p, int col) {
|
|||
TColumnSelection *selection = m_viewer->getColumnSelection();
|
||||
|
||||
#ifdef _WIN32
|
||||
QFont font("Arial", XSHEET_FONT_SIZE, QFont::Normal);
|
||||
static QFont font("Arial", -1, QFont::Normal);
|
||||
#else
|
||||
QFont font("Helvetica", XSHEET_FONT_SIZE, QFont::Normal);
|
||||
static QFont font("Helvetica", -1, QFont::Normal);
|
||||
#endif
|
||||
font.setPixelSize(XSHEET_FONT_PX_SIZE);
|
||||
|
||||
p.setFont(font);
|
||||
p.setRenderHint(QPainter::SmoothPixmapTransform, true);
|
||||
|
||||
|
@ -1074,8 +1094,12 @@ void ColumnArea::drawSoundTextColumnHead(QPainter &p, int col) {
|
|||
TColumnSelection *selection = m_viewer->getColumnSelection();
|
||||
|
||||
p.setRenderHint(QPainter::SmoothPixmapTransform, true);
|
||||
QFont font("Helvetica");
|
||||
font.setPointSize(XSHEET_FONT_SIZE);
|
||||
#ifdef _WIN32
|
||||
static QFont font("Arial", -1, QFont::Normal);
|
||||
#else
|
||||
static QFont font("Helvetica", -1, QFont::Normal);
|
||||
#endif
|
||||
font.setPixelSize(XSHEET_FONT_PX_SIZE);
|
||||
p.setFont(font);
|
||||
|
||||
int x = m_viewer->columnToX(col);
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
#include "toonzqt/spreadsheetviewer.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define XSHEET_FONT_SIZE 9
|
||||
#define XSHEET_FONT_PX_SIZE 12
|
||||
#define H_ADJUST 2
|
||||
#else
|
||||
#define XSHEET_FONT_SIZE 11
|
||||
#define XSHEET_FONT_PX_SIZE 14
|
||||
#define H_ADJUST 0
|
||||
#endif
|
||||
|
||||
|
|
|
@ -89,10 +89,13 @@ void RowArea::drawRows(QPainter &p, int r0, int r1) {
|
|||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
static QFont font("Arial", XSHEET_FONT_SIZE, QFont::Bold);
|
||||
static QFont font("Arial", -1, QFont::Bold);
|
||||
#else
|
||||
static QFont font("Helvetica", XSHEET_FONT_SIZE, QFont::Normal);
|
||||
static QFont font("Helvetica", -1, QFont::Normal);
|
||||
#endif
|
||||
// set font size in pixel
|
||||
font.setPixelSize(XSHEET_FONT_PX_SIZE);
|
||||
|
||||
p.setFont(font);
|
||||
|
||||
// marker interval
|
||||
|
|
|
@ -86,6 +86,7 @@ set(MOC_HEADERS
|
|||
../include/toonzqt/flipconsoleowner.h
|
||||
../include/toonzqt/combohistogram.h
|
||||
../include/toonzqt/fxiconmanager.h
|
||||
../include/toonzqt/glwidget_for_highdpi.h
|
||||
pluginhost.h
|
||||
)
|
||||
|
||||
|
|
|
@ -548,7 +548,7 @@ QPixmap makeSquareShading(const ColorModel &color, ColorChannel channel,
|
|||
//*****************************************************************************
|
||||
|
||||
HexagonalColorWheel::HexagonalColorWheel(QWidget *parent)
|
||||
: QOpenGLWidget(parent)
|
||||
: GLWidgetForHighDpi(parent)
|
||||
, m_bgColor(128, 128, 128) // defaul value in case this value does not set
|
||||
// in the style sheet
|
||||
{
|
||||
|
@ -597,20 +597,20 @@ void HexagonalColorWheel::initializeGL() {
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void HexagonalColorWheel::resizeGL(int width, int height) {
|
||||
float d = (width - 5.0f) / 2.5f;
|
||||
bool isHorizontallyLong = ((d * 1.732f) < height) ? false : true;
|
||||
void HexagonalColorWheel::resizeGL(int w, int h) {
|
||||
float d = (w - 5.0f) / 2.5f;
|
||||
bool isHorizontallyLong = ((d * 1.732f) < h) ? false : true;
|
||||
|
||||
if (isHorizontallyLong) {
|
||||
m_triEdgeLen = (float)height / 1.732f;
|
||||
m_triHeight = (float)height / 2.0f;
|
||||
m_wheelPosition.setX(((float)width - (m_triEdgeLen * 2.5f + 5.0f)) / 2.0f);
|
||||
m_triEdgeLen = (float)h / 1.732f;
|
||||
m_triHeight = (float)h / 2.0f;
|
||||
m_wheelPosition.setX(((float)w - (m_triEdgeLen * 2.5f + 5.0f)) / 2.0f);
|
||||
m_wheelPosition.setY(0.0f);
|
||||
} else {
|
||||
m_triEdgeLen = d;
|
||||
m_triHeight = m_triEdgeLen * 0.866f;
|
||||
m_wheelPosition.setX(0.0f);
|
||||
m_wheelPosition.setY(((float)height - (m_triHeight * 2.0f)) / 2.0f);
|
||||
m_wheelPosition.setY(((float)h - (m_triHeight * 2.0f)) / 2.0f);
|
||||
}
|
||||
|
||||
// set all vertices positions
|
||||
|
@ -637,16 +637,16 @@ void HexagonalColorWheel::resizeGL(int width, int height) {
|
|||
m_leftp[2].setY(0.0f);
|
||||
|
||||
// GL settings
|
||||
glViewport(0, 0, width, height);
|
||||
glViewport(0, 0, w, h);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(0.0, (GLdouble)width, (GLdouble)height, 0.0, 1.0, -1.0);
|
||||
glOrtho(0.0, (GLdouble)w, (GLdouble)h, 0.0, 1.0, -1.0);
|
||||
|
||||
// iwsw commented out temporarily
|
||||
/*
|
||||
if(Preferences::instance()->isDoColorCorrectionByUsing3DLutEnabled() &&
|
||||
m_ghibli3DLutUtil)
|
||||
m_ghibli3DLutUtil->onResize(width,height);
|
||||
m_ghibli3DLutUtil->onResize(w,h);
|
||||
*/
|
||||
}
|
||||
|
||||
|
@ -777,15 +777,16 @@ void HexagonalColorWheel::mousePressEvent(QMouseEvent *event) {
|
|||
|
||||
// check whether the mouse cursor is in the wheel or in the triangle (or
|
||||
// nothing).
|
||||
QPoint curPos = event->pos() * getDevPixRatio();
|
||||
|
||||
QPolygonF wheelPolygon;
|
||||
// in the case of the wheel
|
||||
wheelPolygon << m_wp[1] << m_wp[2] << m_wp[3] << m_wp[4] << m_wp[5]
|
||||
<< m_wp[6];
|
||||
wheelPolygon.translate(m_wheelPosition);
|
||||
if (wheelPolygon.toPolygon().containsPoint(event->pos(), Qt::OddEvenFill)) {
|
||||
if (wheelPolygon.toPolygon().containsPoint(curPos, Qt::OddEvenFill)) {
|
||||
m_currentWheel = leftWheel;
|
||||
clickLeftWheel(event->pos());
|
||||
clickLeftWheel(curPos);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -793,9 +794,9 @@ void HexagonalColorWheel::mousePressEvent(QMouseEvent *event) {
|
|||
// in the case of the triangle
|
||||
wheelPolygon << m_leftp[0] << m_leftp[1] << m_leftp[2];
|
||||
wheelPolygon.translate(m_wheelPosition);
|
||||
if (wheelPolygon.toPolygon().containsPoint(event->pos(), Qt::OddEvenFill)) {
|
||||
if (wheelPolygon.toPolygon().containsPoint(curPos, Qt::OddEvenFill)) {
|
||||
m_currentWheel = rightTriangle;
|
||||
clickRightTriangle(event->pos());
|
||||
clickRightTriangle(curPos);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -811,10 +812,10 @@ void HexagonalColorWheel::mouseMoveEvent(QMouseEvent *event) {
|
|||
case none:
|
||||
break;
|
||||
case leftWheel:
|
||||
clickLeftWheel(event->pos());
|
||||
clickLeftWheel(event->pos() * getDevPixRatio());
|
||||
break;
|
||||
case rightTriangle:
|
||||
clickRightTriangle(event->pos());
|
||||
clickRightTriangle(event->pos() * getDevPixRatio());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue