Merge pull request #1132 from shun-iwasawa/hi_resolution

High dpi monitors support
This commit is contained in:
Jeremy Bullock 2017-04-20 23:58:37 -06:00 committed by GitHub
commit 039ecc9c2c
23 changed files with 236 additions and 105 deletions

View file

@ -3,7 +3,7 @@ pushd thirdparty/tiff-4.0.3
CFLAGS="-fPIC" CXXFLAGS="-fPIC" ./configure --disable-jbig && make
popd
cd toonz && mkdir build && cd build
source /opt/qt55/bin/qt55-env.sh
source /opt/qt56/bin/qt56-env.sh
cmake ../sources \
-DWITH_SYSTEM_SUPERLU:BOOL=OFF
# according to https://docs.travis-ci.com/user/ci-environment/#Virtualization-environments

View file

@ -1,6 +1,6 @@
sudo add-apt-repository --yes ppa:beineri/opt-qt551-trusty
sudo add-apt-repository --yes ppa:beineri/opt-qt562-trusty
sudo apt-get update
sudo apt-get install -y liblzo2-dev liblz4-dev libfreetype6-dev libpng-dev libsdl2-dev libglew-dev freeglut3-dev qt55script libsuperlu3-dev libpng-dev qt55svg qt55tools qt55multimedia wget libusb-1.0-0-dev libboost-all-dev liblzma-dev
sudo apt-get install -y liblzo2-dev liblz4-dev libfreetype6-dev libpng-dev libsdl2-dev libglew-dev freeglut3-dev qt56script libsuperlu3-dev libpng-dev qt56svg qt56tools qt56multimedia wget libusb-1.0-0-dev libboost-all-dev liblzma-dev
# someone forgot to include liblz4.pc with the package, use the version from xenial, as it only depends on libc
wget http://mirrors.kernel.org/ubuntu/pool/main/l/lz4/liblz4-1_0.0~r131-2ubuntu2_amd64.deb -O liblz4.deb
wget http://mirrors.kernel.org/ubuntu/pool/main/l/lz4/liblz4-dev_0.0~r131-2ubuntu2_amd64.deb -O liblz4-dev.deb

View file

@ -6,7 +6,7 @@ Building OpenToonz from source requires the following dependencies:
- Git
- GCC or Clang
- CMake (3.4.1 or newer).
- Qt5 (5.5 or newer)
- Qt5 (5.6 or newer)
- Boost (1.55 or newer)
- SDL2
- LibPNG

View file

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>OpenToonz_1.1</string>
<key>CFBundleGetInfoString</key>
<string></string>
<key>CFBundleIconFile</key>
<string>OpenToonz.icns</string>
<key>CFBundleIdentifier</key>
<string></string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleLongVersionString</key>
<string></string>
<key>CFBundleName</key>
<string></string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string></string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string></string>
<key>CSResourcesFileMapped</key>
<true/>
<key>LSRequiresCarbon</key>
<true/>
<key>NSHighResolutionCapable</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string></string>
</dict>
</plist>

View file

@ -538,4 +538,6 @@ if(APPLE)
${CMAKE_INSTALL_NAME_TOOL} -add_rpath ${CMAKE_INSTALL_RPATH}
$<TARGET_FILE:executable>
)
# add capability for retina displays
set_target_properties(OpenToonz_1.1 PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/../cmake/BundleInfo.plist.in)
endif()

View file

@ -0,0 +1,32 @@
#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) {}
// returns device-pixel ratio. It is 1 for normal monitors and 2 (or higher
// ratio) for high DPI monitors. Setting "Display > Set custom text size(DPI)"
// for Windows corresponds to this ratio.
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

View file

@ -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)

View file

@ -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);
}
//-----------------------------------------------------------------------------

View file

@ -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,

View file

@ -263,6 +263,12 @@ int main(int argc, char *argv[]) {
}
}
// Enables high-DPI scaling. This attribute must be set before QApplication is
// constructed. Available from Qt 5.6.
#if QT_VERSION >= 0x050600
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
QApplication a(argc, argv);
#ifdef MACOSX
@ -340,6 +346,9 @@ int main(int argc, char *argv[]) {
a.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
#endif
// Enable to render smooth icons on high dpi monitors
a.setAttribute(Qt::AA_UseHighDpiPixmaps);
// Set the app's locale for numeric stuff to standard C. This is important for
// atof() and similar
// calls that are locale-dependant.
@ -360,10 +369,12 @@ int main(int argc, char *argv[]) {
// splash screen
QPixmap splashPixmap(":Resources/splash.png");
#ifdef _WIN32
a.setFont(QFont("Arial", 10));
QFont font("Arial", -1);
#else
a.setFont(QFont("Helvetica", 10));
QFont font("Helvetica", -1);
#endif
font.setPixelSize(13);
a.setFont(font);
QString offsetStr("\n\n\n\n\n\n\n\n");

View file

@ -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)
@ -765,6 +765,7 @@ TPointD SceneViewer::winToWorld(const QPoint &pos) const {
} else
return TAffine() * TPointD(0, 0);
}
return getViewMatrix().inv() * pp;
}
@ -2556,10 +2557,12 @@ void SceneViewer::invalidateToolStatus() {
*/
TRectD SceneViewer::getGeometry() const {
int devPixRatio = getDevPixRatio();
TTool *tool = TApp::instance()->getCurrentTool()->getTool();
TPointD topLeft = tool->getMatrix().inv() * winToWorld(geometry().topLeft());
TPointD bottomRight =
tool->getMatrix().inv() * winToWorld(geometry().bottomRight());
TPointD topLeft =
tool->getMatrix().inv() * winToWorld(geometry().topLeft() * devPixRatio);
TPointD bottomRight = tool->getMatrix().inv() *
winToWorld(geometry().bottomRight() * devPixRatio);
TObjectHandle *objHandle = TApp::instance()->getCurrentObject();
if (tool->getToolType() & TTool::LevelTool && !objHandle->isSpline()) {

View file

@ -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

View file

@ -75,9 +75,9 @@ int modifiers = 0;
void initToonzEvent(TMouseEvent &toonzEvent, QMouseEvent *event,
int widgetHeight, double pressure, bool isTablet,
bool isClick) {
toonzEvent.m_pos =
TPoint(event->pos().x(), widgetHeight - 1 - event->pos().y());
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;
toonzEvent.setModifiers(event->modifiers() & Qt::ShiftModifier,
@ -274,7 +274,7 @@ void SceneViewer::enterEvent(QEvent *) {
void SceneViewer::mouseMoveEvent(QMouseEvent *event) {
if (m_freezedStatus != NO_FREEZED) return;
QPoint curPos = event->pos();
QPoint curPos = event->pos() * getDevPixRatio();
bool cursorSet = false;
m_lastMousePos = curPos;
@ -359,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;
@ -417,7 +417,7 @@ void SceneViewer::mousePressEvent(QMouseEvent *event) {
if (m_mouseButton != Qt::NoButton) return;
m_pos = event->pos();
m_pos = event->pos() * getDevPixRatio();
m_mouseButton = event->button();
// when using tablet, avoid unexpected drawing behavior occurs when
@ -476,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);
@ -542,8 +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());
false, getDevPixRatio());
TPointD pos =
tool->getMatrix().inv() * winToWorld(event->pos() * getDevPixRatio());
TObjectHandle *objHandle = TApp::instance()->getCurrentObject();
if (tool->getToolType() & TTool::LevelTool && !objHandle->isSpline()) {
@ -620,8 +622,9 @@ void SceneViewer::wheelEvent(QWheelEvent *event) {
} else if (delta > 0) {
CommandManager::instance()->execute("MI_PrevDrawing");
}
} else
zoomQt(event->pos(), exp(0.001 * delta));
} else {
zoomQt(event->pos() * getDevPixRatio(), exp(0.001 * delta));
}
}
event->accept();
}
@ -1000,8 +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());
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;
@ -1036,7 +1041,9 @@ void SceneViewer::contextMenuEvent(QContextMenuEvent *e) {
if (m_freezedStatus != NO_FREEZED) return;
if (m_isLocator) return;
TPoint winPos(e->pos().x(), height() - e->pos().y());
int devPixRatio = getDevPixRatio();
TPoint winPos(e->pos().x() * devPixRatio,
height() - e->pos().y() * devPixRatio);
std::vector<int> columnIndices;
// enable to select all the columns regardless of the click position
for (int i = 0;
@ -1047,8 +1054,8 @@ void SceneViewer::contextMenuEvent(QContextMenuEvent *e) {
SceneViewerContextMenu *menu = new SceneViewerContextMenu(this);
TTool *tool = TApp::instance()->getCurrentTool()->getTool();
TPointD pos =
((tool) ? tool->getMatrix().inv() : TAffine()) * winToWorld(e->pos());
TPointD pos = ((tool) ? tool->getMatrix().inv() : TAffine()) *
winToWorld(e->pos() * devPixRatio);
menu->addEnterGroupCommands(pos);
menu->addLevelCommands(columnIndices);

View file

@ -119,7 +119,7 @@ bool PreviewSubCameraManager::mousePressEvent(SceneViewer *viewer,
if (viewer->is3DView()) return true;
m_mousePressed = true;
m_mousePressPos = event->pos();
m_mousePressPos = event->pos() * viewer->getDevPixRatio();
m_dragType = getSubCameraDragEnum(viewer, m_mousePressPos);
if (bitwiseExclude(m_dragType, OUTER))
@ -133,8 +133,7 @@ bool PreviewSubCameraManager::mousePressEvent(SceneViewer *viewer,
bool PreviewSubCameraManager::mouseMoveEvent(SceneViewer *viewer,
QMouseEvent *event) {
if (viewer->is3DView()) return true;
QPoint curPos(event->pos());
QPoint curPos(event->pos() * viewer->getDevPixRatio());
if (event->buttons() == Qt::LeftButton) {
if (!bitwiseContains(m_dragType, INNER)) {
if (abs(curPos.x() - m_mousePressPos.x()) > 10 ||

View file

@ -57,6 +57,8 @@
#include <QDebug>
#include <QEvent>
#include <QCoreApplication>
#include <QApplication>
#include <QDesktopWidget>
//===================================================================

View file

@ -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
@ -1378,7 +1380,12 @@ void CellArea::drawSoundTextCell(QPainter &p, int row, int col) {
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);
#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
@ -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);

View file

@ -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);

View file

@ -13,13 +13,8 @@
#include "cellkeyframeselection.h"
#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 H_ADJUST 0
#endif
// forward declaration
class TXsheet;

View file

@ -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

View file

@ -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
)

View file

@ -641,10 +641,11 @@ void FunctionSheetCellViewer::drawCells(QPainter &painter, int r0, int c0,
}
#ifdef _WIN32
static QFont font("Arial", 9, QFont::Normal);
static QFont font("Arial", -1, QFont::Bold);
#else
static QFont font("Helvetica", 9, QFont::Normal);
static QFont font("Helvetica", -1, QFont::Bold);
#endif
font.setPixelSize(12);
painter.setFont(font);
painter.drawText(cellRect.adjusted(10, 0, 0, 0),
Qt::AlignVCenter | Qt::AlignLeft, text);

View file

@ -237,10 +237,11 @@ DragTool *RowPanel::createDragTool(QMouseEvent *) {
void RowPanel::drawRows(QPainter &p, int r0, int r1) {
#ifdef _WIN32
static QFont font("Arial", 9, QFont::Bold);
static QFont font("Arial", -1, QFont::Bold);
#else
static QFont font("Helvetica", 9, QFont::Bold);
static QFont font("Helvetica", -1, QFont::Bold);
#endif
font.setPixelSize(12);
p.setFont(font);
QRect visibleRect = visibleRegion().boundingRect();

View file

@ -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;
}
}