50 changes: 16 additions & 34 deletions toonz/sources/common/tfx/ttzpimagefx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void parseIndexes(std::string indexes, std::vector<std::string> &items) {
char seps[] = " ,;";
char *token;
if (indexes == "all" || indexes == "All" || indexes == "ALL")
indexes = "0-4095";
indexes = "0-4095";
char *context = 0;
token = strtok_s((char *)(indexes.c_str()), seps, &context);
while (token != NULL) {
Expand All @@ -26,7 +26,7 @@ void parseIndexes(std::string indexes, std::vector<std::string> &items) {
char *token;
if (indexes == "all" || indexes == "All" || indexes == "ALL")
indexes = "0-4095";
token = strtok((char *)(indexes.c_str()), seps);
token = strtok((char *)(indexes.c_str()), seps);
while (token != NULL) {
items.push_back(token);
token = strtok(NULL, seps);
Expand All @@ -38,48 +38,30 @@ void parseIndexes(std::string indexes, std::vector<std::string> &items) {

void insertIndexes(std::vector<std::string> items,
PaletteFilterFxRenderData *t) {
#ifdef _MSC_VER
for (int i = 0; i < (int)items.size(); i++) {
char *starttoken, *endtoken;
char subseps[] = "-";
std::string tmp = items[i];
char *context = 0;
starttoken = strtok_s((char *)tmp.c_str(), subseps, &context);
endtoken = strtok_s(NULL, subseps, &context);
if (!endtoken && isInt(starttoken)) {
int index;
index = std::stoi(starttoken);
t->m_colors.insert(index);
} else {
if (isInt(starttoken) && isInt(endtoken)) {
int start, end;
start = std::stoi(starttoken);
end = std::stoi(endtoken);
for (int i = start; i <= end; i++) t->m_colors.insert(i);
}
}
}
#ifdef _MSC_VER
char *context = 0;
starttoken = strtok_s((char *)tmp.c_str(), subseps, &context);
endtoken = strtok_s(NULL, subseps, &context);
#else
for (int i = 0; i < (int)items.size(); i++) {
char *starttoken, *endtoken;
char subseps[] = "-";
std::string tmp = items[i];
starttoken = strtok((char *)tmp.c_str(), subseps);
endtoken = strtok(NULL, subseps);
if (!endtoken && isInt(starttoken)) {
starttoken = strtok((char *)tmp.c_str(), subseps);
endtoken = strtok(NULL, subseps);
#endif
if (!starttoken || !isInt(starttoken)) continue;
if (!endtoken) {
int index;
index = std::stoi(starttoken);
t->m_colors.insert(index);
} else {
if (isInt(starttoken) && isInt(endtoken)) {
int start, end;
start = std::stoi(starttoken);
end = std::stoi(endtoken);
for (int i = start; i <= end; i++) t->m_colors.insert(i);
}
} else if (isInt(endtoken)) {
int start, end;
start = std::stoi(starttoken);
end = std::stoi(endtoken);
for (int i = start; i <= end; i++) t->m_colors.insert(i);
}
}
#endif
}

//**********************************************************************************************
Expand Down
34 changes: 29 additions & 5 deletions toonz/sources/common/tvrender/tsimplecolorstyles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,21 @@ void drawAntialiasedOutline(const std::vector<TOutlinePoint> &_v,
outline.finish();
}

void drawAliasedOutline(const std::vector<TOutlinePoint> &_v,
const TStroke *stroke) {
static const int stride = 2 * sizeof(TOutlinePoint);

glEnableClientState(GL_VERTEX_ARRAY);

glVertexPointer(2, GL_DOUBLE, stride, &_v[0]);
glDrawArrays(GL_LINE_STRIP, 0, _v.size() / 2);

glVertexPointer(2, GL_DOUBLE, stride, &_v[1]);
glDrawArrays(GL_LINE_STRIP, 0, _v.size() / 2);

glDisableClientState(GL_VERTEX_ARRAY);
}

} // namespace

//*************************************************************************************
Expand Down Expand Up @@ -609,9 +624,10 @@ void TSolidColorStyle::drawRegion(const TColorFunction *cf,

//=============================================================================

void TSolidColorStyle::drawStroke(const TColorFunction *cf,
TStrokeOutline *outline,
const TStroke *stroke) const {
void TSolidColorStyle::doDrawStroke(const TColorFunction *cf,
TStrokeOutline *outline,
const TStroke *stroke,
bool antialias) const {
struct locals {
static inline void fillOutlinedStroke(const std::vector<TOutlinePoint> &v) {
static const int stride = sizeof(TOutlinePoint);
Expand Down Expand Up @@ -655,12 +671,20 @@ stencil->endMask();
locals::fillOutlinedStroke(v);
stencil->endMask();
stencil->enableMask(TStencilControl::SHOW_OUTSIDE);
drawAntialiasedOutline(v, stroke);

if (antialias)
drawAntialiasedOutline(v, stroke);
else
drawAliasedOutline(v, stroke);

stencil->disableMask();

} else {
// outline with antialiasing
drawAntialiasedOutline(v, stroke);
if (antialias)
drawAntialiasedOutline(v, stroke);
else
drawAliasedOutline(v, stroke);

// center line
locals::fillOutlinedStroke(v);
Expand Down
5 changes: 4 additions & 1 deletion toonz/sources/common/tvrender/tstrokeprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,10 @@ void OutlineStrokeProp::draw(const TVectorRenderData &rd) {
m_styleVersionNumber = m_colorStyle->getVersionNumber();
}

m_colorStyle->drawStroke(rd.m_cf, &m_outline, m_stroke);
if (rd.m_antiAliasing)
m_colorStyle->drawStroke(rd.m_cf, &m_outline, m_stroke);
else
m_colorStyle->drawAliasedStroke(rd.m_cf, &m_outline, m_stroke);
}

glPopMatrix();
Expand Down
9 changes: 6 additions & 3 deletions toonz/sources/include/tools/stylepicker.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "tpalette.h"

class TStroke;
class QWidget;

#undef DVAPI
#undef DVVAR
Expand All @@ -22,15 +23,17 @@ class TStroke;
class DVAPI StylePicker {
TImageP m_image;
TPaletteP m_palette;
const QWidget *m_widget;

public:
StylePicker() {}
StylePicker(const QWidget *parent) : m_widget(parent) {}

// usa come palette la palette dell'immagine
StylePicker(const TImageP &image);
StylePicker(const QWidget *parent, const TImageP &image);

// palette esterna (ad es. se image e' di tipo raster)
StylePicker(const TImageP &image, const TPaletteP &palette);
StylePicker(const QWidget *parent, const TImageP &image,
const TPaletteP &palette);

// pickStyleId(point, radius)
//
Expand Down
5 changes: 4 additions & 1 deletion toonz/sources/include/tools/tool.h
Original file line number Diff line number Diff line change
Expand Up @@ -594,9 +594,10 @@ class TTool::Viewer {
int guidedStrokePickMode = 0;
int m_guidedFrontStroke = -1;
int m_guidedBackStroke = -1;
QWidget *m_viewerWidget = nullptr;

public:
Viewer() {}
Viewer(QWidget *widget) : m_viewerWidget(widget) {}
virtual ~Viewer() {}

const ImagePainter::VisualSettings &visualSettings() const {
Expand Down Expand Up @@ -706,6 +707,8 @@ class TTool::Viewer {

void getGuidedFrameIdx(int *backIdx, int *frontIdx);
void doPickGuideStroke(const TPointD &pos);

QWidget *viewerWidget() { return m_viewerWidget; }
};

#endif
3 changes: 3 additions & 0 deletions toonz/sources/include/toonz/preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,9 @@ class DVAPI Preferences final : public QObject // singleton
bool isShowColumnNumbersEnabled() const {
return getBoolValue(showColumnNumbers);
}
bool isParentColorsInXsheetColumnEnabled() const {
return getBoolValue(parentColorsInXsheetColumn);
}
bool isSyncLevelRenumberWithXsheetEnabled() const {
return getBoolValue(syncLevelRenumberWithXsheet);
}
Expand Down
1 change: 1 addition & 0 deletions toonz/sources/include/toonz/preferencesitemids.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ enum PreferencesItemId {
showXSheetToolbar,
expandFunctionHeader,
showColumnNumbers,
parentColorsInXsheetColumn,
syncLevelRenumberWithXsheet,
currentTimelineEnabled,
currentColumnColor,
Expand Down
3 changes: 3 additions & 0 deletions toonz/sources/include/toonz/sceneproperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ class DVAPI TSceneProperties {
struct CellMark {
QString name;
TPixel32 color;
bool operator==(const CellMark &cm) {
return name == cm.name && color == cm.color;
}
};

private:
Expand Down
1 change: 1 addition & 0 deletions toonz/sources/include/toonzqt/glwidget_for_highdpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class GLWidgetForHighDpi : public QOpenGLWidget, protected QOpenGLFunctions {
int width() const { return QOpenGLWidget::width() * getDevPixRatio(); }
int height() const { return QOpenGLWidget::height() * getDevPixRatio(); }
QRect rect() const { return QRect(0, 0, width(), height()); }
int getDevPixRatio() const { return getDevicePixelRatio(this); }
};

#endif
2 changes: 1 addition & 1 deletion toonz/sources/include/toonzqt/gutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ svgToPixmap(const QString &svgFilePath, const QSize &size = QSize(),
// 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 DVAPI getDevPixRatio();
int DVAPI getDevicePixelRatio(const QWidget *widget = nullptr);

//-----------------------------------------------------------------------------

Expand Down
2 changes: 2 additions & 0 deletions toonz/sources/include/toonzqt/swatchviewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ class DVAPI SwatchViewer final : public QWidget {
SwatchViewer *m_viewer;
bool m_started;

TRenderSettings m_info;

ContentRender(TRasterFx *fx, int frame, const TDimension &size,
SwatchViewer *viewer);
~ContentRender();
Expand Down
17 changes: 16 additions & 1 deletion toonz/sources/include/tsimplecolorstyles.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ class DVAPI TOutlineStyle : public TColorStyle {

virtual void drawStroke(const TColorFunction *cf, TStrokeOutline *outline,
const TStroke *stroke) const = 0;
// draw aliased stroke. currently reimplemented by TSolidColorStyle only
virtual void drawAliasedStroke(const TColorFunction *cf,
TStrokeOutline *outline,
const TStroke *stroke) const {
drawStroke(cf, outline, stroke);
};

protected:
// Not assignable
Expand Down Expand Up @@ -158,8 +164,17 @@ class DVAPI TSolidColorStyle : public TOutlineStyle {
void drawRegion(const TColorFunction *cf, const bool antiAliasing,
TRegionOutline &outline) const override;

void doDrawStroke(const TColorFunction *cf, TStrokeOutline *outline,
const TStroke *s, bool antialias) const;

void drawStroke(const TColorFunction *cf, TStrokeOutline *outline,
const TStroke *s) const override;
const TStroke *s) const override {
doDrawStroke(cf, outline, s, true);
}
void drawAliasedStroke(const TColorFunction *cf, TStrokeOutline *outline,
const TStroke *s) const override {
doDrawStroke(cf, outline, s, false);
}

int getTagId() const override;

Expand Down
2 changes: 1 addition & 1 deletion toonz/sources/include/tversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ToonzVersion {

private:
const char *applicationName = "OpenToonz";
const float applicationVersion = 1.5;
const float applicationVersion = 1.6;
const float applicationRevision = 0;
const char *applicationNote = "";
};
Expand Down
8 changes: 8 additions & 0 deletions toonz/sources/stdfx/artcontourfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ void ArtContourFx::doDryCompute(TRectD &rect, double frame,
TRectD controlBox;
m_controller->getBBox(frame, controlBox, ri2);

if (controlBox == TConsts::infiniteRectD) controlBox = rect;

TDimension dim = convert(controlBox).getSize();
TRectD controlRect(controlBox.getP00(), TDimensionD(dim.lx, dim.ly));

Expand Down Expand Up @@ -223,6 +225,12 @@ void ArtContourFx::doCompute(TTile &tile, double frame,

TRectD controlBox;
m_controller->getBBox(frame, controlBox, ri2);

if (controlBox == TConsts::infiniteRectD) {
TDimension tileDim = tile.getRaster()->getSize();
controlBox = TRectD(tile.m_pos, TDimensionD(tileDim.lx, tileDim.ly));
}

TTile ctrTile;
ctrTile.m_pos = controlBox.getP00();
TDimension dim = convert(controlBox).getSize();
Expand Down
7 changes: 7 additions & 0 deletions toonz/sources/stdfx/iwa_tilefx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ void Iwa_TileFx::transform(double frame, int port, const TRectD &rectOnOutput,
TRectD &rectOnInput, TRenderSettings &infoOnInput) {
infoOnInput = infoOnOutput;

if (!m_input.isConnected()) {
rectOnInput.empty();
return;
}

TRectD inputBox;
m_input->getBBox(frame, inputBox, infoOnOutput);

Expand Down Expand Up @@ -161,6 +166,8 @@ void Iwa_TileFx::transform(double frame, int port, const TRectD &rectOnOutput,

int Iwa_TileFx::getMemoryRequirement(const TRectD &rect, double frame,
const TRenderSettings &info) {
if (!m_input.isConnected()) return 0;

TRectD inputBox;
m_input->getBBox(frame, inputBox, info);

Expand Down
21 changes: 12 additions & 9 deletions toonz/sources/stdfx/particlesengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -752,15 +752,18 @@ void Particles_Engine::do_render(

(*part_ports[part->level])->getBBox(ndx, bbox, riIdentity);

// A particle's bbox MUST be finite. Gradients and such which have an
// infinite bbox
// are just NOT rendered.

// NOTE: No fx returns half-planes or similar (ie if any coordinate is
// either
// (std::numeric_limits<double>::max)() or its opposite, then the rect IS
// THE infiniteRectD)
if (bbox.isEmpty() || bbox == TConsts::infiniteRectD) return;
// Now sources with infinite bounding box are retrieved with the output tile
// size. This is especially for levels deformed by plastic mesh which must
// have some finite bbox but return infinite bbox because "it's hard work to
// calculate". (see PlasticDeformerFx::doGetBBox() and the issue
// opentoonz#1330) NOTE: No fx returns half-planes or similar (ie if any
// coordinate is either (std::numeric_limits<double>::max)() or its
// opposite, then the rect IS THE infiniteRectD)
if (bbox.isEmpty())
return;
else if (bbox == TConsts::infiniteRectD)
bbox *= TRectD(tile->m_pos, TDimensionD(tile->getRaster()->getLx(),
tile->getRaster()->getLy()));
}

// Now, these are the particle rendering specifications
Expand Down
2 changes: 1 addition & 1 deletion toonz/sources/stdfx/rgbkeyfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class RGBKeyFx final : public GlobalControllableFx {
void doCompute(TTile &tile, double frame, const TRenderSettings &) override;

bool canHandle(const TRenderSettings &info, double frame) override {
return true;
return false;
}
};

Expand Down
9 changes: 8 additions & 1 deletion toonz/sources/stdfx/tilefx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ void TileFx::transform(double frame, int port, const TRectD &rectOnOutput,
TRenderSettings &infoOnInput) {
infoOnInput = infoOnOutput;

if (!m_input.isConnected()) {
rectOnInput.empty();
return;
}

TRectD inputBox;
m_input->getBBox(frame, inputBox, infoOnOutput);

Expand All @@ -116,6 +121,8 @@ void TileFx::transform(double frame, int port, const TRectD &rectOnOutput,

int TileFx::getMemoryRequirement(const TRectD &rect, double frame,
const TRenderSettings &info) {
if (!m_input.isConnected()) return 0;

TRectD inputBox;
m_input->getBBox(frame, inputBox, info);

Expand Down Expand Up @@ -157,7 +164,7 @@ void TileFx::doCompute(TTile &tile, double frame, const TRenderSettings &ri) {
//------------------------------------------------------------------------------
//! Make the tile of the image contained in \b inputTile in \b tile
/*
*/
*/
void TileFx::makeTile(const TTile &inputTile, const TTile &tile) const {
// Build the mirroring pattern. It obviously repeats itself out of 2x2 tile
// blocks.
Expand Down
7 changes: 5 additions & 2 deletions toonz/sources/tnzbase/trasterfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,11 @@ TAffine TRasterFx::handledAffine(const TRenderSettings &info, double frame) {
bool TRasterFx::getBBox(double frame, TRectD &bBox,
const TRenderSettings &info) {
bool ret = doGetBBox(frame, bBox, info);
bBox = info.m_affine * bBox;
enlargeToI(bBox);
if (!bBox.isEmpty()) { // TODO: check if bbox can always be empty when ret ==
// false
bBox = info.m_affine * bBox;
enlargeToI(bBox);
}
return ret;
}

Expand Down
2 changes: 1 addition & 1 deletion toonz/sources/tnztools/edittool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,7 @@ void EditTool::drawMainHandle() {
TAffine parentAff = xsh->getParentPlacement(objId, frame);
TAffine aff = xsh->getPlacement(objId, frame);
TPointD center = Stage::inch * xsh->getCenter(objId, frame);
int devPixRatio = getDevPixRatio();
int devPixRatio = getDevicePixelRatio(m_viewer->viewerWidget());
// the gadget appears on the center of the level. orientation and dimension
// are independent of the movement of the level
glPushMatrix();
Expand Down
18 changes: 9 additions & 9 deletions toonz/sources/tnztools/edittoolgadgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "tparamuiconcept.h"

#include "historytypes.h"
#include "toonzqt/gutil.h"

#include <QApplication>
#include <QDesktopWidget>
Expand All @@ -26,11 +27,6 @@ using namespace EditToolGadgets;
GLdouble FxGadget::m_selectedColor[3] = {0.2, 0.8, 0.1};

namespace {
int getDevPixRatio() {
static int devPixRatio = QApplication::desktop()->devicePixelRatio();
return devPixRatio;
}

TPointD hadamard(const TPointD &v1, const TPointD &v2) {
return TPointD(v1.x * v2.x, v1.y * v2.y);
}
Expand Down Expand Up @@ -199,14 +195,14 @@ void FxGadget::setValue(const TPointParamP &param, const TPointD &pos) {
//---------------------------------------------------------------------------

void FxGadget::setPixelSize() {
setPixelSize(sqrt(tglGetPixelSize2()) * getDevPixRatio());
setPixelSize(sqrt(tglGetPixelSize2()) * m_controller->getDevPixRatio());
}

//---------------------------------------------------------------------------

void FxGadget::drawTooltip(const TPointD &tooltipPos,
std::string tooltipPosText) {
double unit = sqrt(tglGetPixelSize2()) * getDevPixRatio();
double unit = sqrt(tglGetPixelSize2()) * m_controller->getDevPixRatio();
glPushMatrix();
glTranslated(tooltipPos.x, tooltipPos.y, 0.0);
double sc = unit * 1.6;
Expand Down Expand Up @@ -494,7 +490,7 @@ void AngleFxGadget::draw(bool picking) {
else
glColor3d(0, 0, 1);
glPushName(getId());
double pixelSize = sqrt(tglGetPixelSize2()) * getDevPixRatio();
double pixelSize = sqrt(tglGetPixelSize2()) * m_controller->getDevPixRatio();
double r = pixelSize * 40;
double a = pixelSize * 10, b = pixelSize * 5;
tglDrawCircle(m_pos, r);
Expand Down Expand Up @@ -579,7 +575,7 @@ void AngleRangeFxGadget::draw(bool picking) {
glColor3d(0, 0, 1);
};

double pixelSize = sqrt(tglGetPixelSize2()) * getDevPixRatio();
double pixelSize = sqrt(tglGetPixelSize2()) * m_controller->getDevPixRatio();
double r = pixelSize * 200;
double a = pixelSize * 30;

Expand Down Expand Up @@ -2063,3 +2059,7 @@ int FxGadgetController::getCurrentFrame() const { return m_tool->getFrame(); }
//---------------------------------------------------------------------------

void FxGadgetController::invalidateViewer() { m_tool->invalidate(); }

int FxGadgetController::getDevPixRatio() {
return getDevicePixelRatio(m_tool->getViewer()->viewerWidget());
}
2 changes: 2 additions & 0 deletions toonz/sources/tnztools/edittoolgadgets.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ class FxGadgetController final : public QObject {

bool hasGadget() { return m_gadgets.size() != 0; }

int getDevPixRatio();

public slots:

void onFxSwitched();
Expand Down
2 changes: 1 addition & 1 deletion toonz/sources/tnztools/filltool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2172,7 +2172,7 @@ int FillTool::pick(const TImageP &image, const TPointD &pos, const int frame) {
TVectorImageP vi = image;
if (!ti && !vi) return 0;

StylePicker picker(image);
StylePicker picker(getViewer()->viewerWidget(), image);
double scale2 = 1.0;
if (vi) {
TAffine aff = getViewer()->getViewMatrix() * getCurrentColumnMatrix(frame);
Expand Down
2 changes: 1 addition & 1 deletion toonz/sources/tnztools/fingertool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ void FingerTool::pick(const TPointD &pos) {

int subsampling = level->getImageSubsampling(getCurrentFid());

StylePicker picker(image);
StylePicker picker(getViewer()->viewerWidget(), image);

int styleId =
picker.pickStyleId(TScale(1.0 / subsampling) * pos + TPointD(-0.5, -0.5),
Expand Down
2 changes: 1 addition & 1 deletion toonz/sources/tnztools/hookselection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void HooksData::storeHookPositions(const std::vector<int> &ids) {
if (ids.empty()) return;
TTool::Application *app = TTool::getApplication();
TXshLevelP level = app->getCurrentLevel()->getLevel();
assert(level = m_level);
assert(level == m_level);
if (level != m_level || !m_level || m_level->getSimpleLevel()->isReadOnly())
return;
HookSet *hookSet = m_level->getHookSet();
Expand Down
8 changes: 4 additions & 4 deletions toonz/sources/tnztools/rgbpickertool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ void RGBPickerTool::passivePick() {
TRectD area = TRectD(m_mousePixelPosition.x, m_mousePixelPosition.y,
m_mousePixelPosition.x, m_mousePixelPosition.y);

StylePicker picker(image);
StylePicker picker(getViewer()->viewerWidget(), image);

if (LutManager::instance()->isValid()) m_viewer->bindFBO();

Expand Down Expand Up @@ -458,7 +458,7 @@ void RGBPickerTool::pick() {

TRectD area = TRectD(m_mousePixelPosition.x - 1, m_mousePixelPosition.y - 1,
m_mousePixelPosition.x + 1, m_mousePixelPosition.y + 1);
StylePicker picker(image, palette);
StylePicker picker(getViewer()->viewerWidget(), image, palette);

if (LutManager::instance()->isValid()) m_viewer->bindFBO();

Expand Down Expand Up @@ -491,7 +491,7 @@ void RGBPickerTool::pickRect() {
}
m_selectingRect.empty();
if (area.getLx() <= 1 || area.getLy() <= 1) return;
StylePicker picker(image, palette);
StylePicker picker(getViewer()->viewerWidget(), image, palette);

if (LutManager::instance()->isValid()) m_viewer->bindFBO();

Expand All @@ -511,7 +511,7 @@ void RGBPickerTool::pickStroke() {
TPalette *palette = ph->getPalette();
if (!palette) return;

StylePicker picker(image, palette);
StylePicker picker(getViewer()->viewerWidget(), image, palette);
TStroke *stroke = new TStroke(*m_stroke);

if (LutManager::instance()->isValid()) m_viewer->bindFBO();
Expand Down
6 changes: 5 additions & 1 deletion toonz/sources/tnztools/shifttracetool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ void ShiftTraceTool::drawControlRect() { // TODO
inksOnly);
color = (m_ghostIndex == 0) ? backOniColor : frontOniColor;
double unit = sqrt(tglGetPixelSize2());
unit *= getDevPixRatio();
unit *= getDevicePixelRatio(m_viewer->viewerWidget());
TRectD coloredBox = box.enlarge(3.0 * unit);
tglColor(color);
glBegin(GL_LINE_STRIP);
Expand Down Expand Up @@ -348,6 +348,10 @@ void ShiftTraceTool::onActivate() {
}

void ShiftTraceTool::onDeactivate() {
// Deactivating Shift and Trace mode resets the pseudo tool with keeping the
// Edit Shift checkbox unchanged
QAction *shiftTrace = CommandManager::instance()->getAction("MI_ShiftTrace");
if (!shiftTrace->isChecked()) return;
QAction *action = CommandManager::instance()->getAction("MI_EditShift");
action->setChecked(false);
}
Expand Down
11 changes: 6 additions & 5 deletions toonz/sources/tnztools/stylepicker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@

//---------------------------------------------------------

StylePicker::StylePicker(const TImageP &image)
: m_image(image), m_palette(image->getPalette()) {}
StylePicker::StylePicker(const QWidget *parent, const TImageP &image)
: m_widget(parent), m_image(image), m_palette(image->getPalette()) {}

//---------------------------------------------------------

StylePicker::StylePicker(const TImageP &image, const TPaletteP &palette)
: m_image(image), m_palette(palette) {}
StylePicker::StylePicker(const QWidget *parent, const TImageP &image,
const TPaletteP &palette)
: m_widget(parent), m_image(image), m_palette(palette) {}

//---------------------------------------------------------

Expand Down Expand Up @@ -86,7 +87,7 @@ int StylePicker::pickStyleId(const TPointD &pos, double radius, double scale2,
// la thickness, cioe' la min distance dalla outline e non dalla centerLine
strokeFound = vi->getNearestStroke(pos, w, index, dist2);
if (strokeFound) {
int devPixRatio = getDevPixRatio();
int devPixRatio = getDevicePixelRatio(m_widget);
dist2 *= scale2;
TStroke *stroke = vi->getStroke(index);
thick = stroke->getThickPoint(w).thick;
Expand Down
6 changes: 3 additions & 3 deletions toonz/sources/tnztools/stylepickertool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void StylePickerTool::pick(const TPointD &pos, const TMouseEvent &e,
TAffine aff =
getViewer()->getViewMatrix() * getColumnMatrix(superPickedColumnId);
double scale2 = aff.det();
StylePicker superPicker(pickedImage);
StylePicker superPicker(getViewer()->viewerWidget(), pickedImage);
int picked_subsampling =
picked_level->getImageSubsampling(pickedCell.getFrameId());
int superPicked_StyleId = superPicker.pickStyleId(
Expand Down Expand Up @@ -159,7 +159,7 @@ void StylePickerTool::pick(const TPointD &pos, const TMouseEvent &e,
TAffine aff = getViewer()->getViewMatrix() * getCurrentColumnMatrix();
double scale2 = aff.det();
int subsampling = level->getImageSubsampling(getCurrentFid());
StylePicker picker(image);
StylePicker picker(getViewer()->viewerWidget(), image);
int styleId =
picker.pickStyleId(TScale(1.0 / subsampling) * pos + TPointD(-0.5, -0.5),
10.0, scale2, modeValue);
Expand Down Expand Up @@ -215,7 +215,7 @@ void StylePickerTool::mouseMove(const TPointD &pos, const TMouseEvent &e) {
TAffine aff = getViewer()->getViewMatrix() * getCurrentColumnMatrix();
double scale2 = aff.det();
int subsampling = level->getImageSubsampling(getCurrentFid());
StylePicker picker(image);
StylePicker picker(getViewer()->viewerWidget(), image);
TPointD pickPos(TScale(1.0 / subsampling) * pos + TPointD(-0.5, -0.5));
int inkStyleId = picker.pickStyleId(pickPos, 10.0, scale2, 1);
int paintStyleId = picker.pickStyleId(pickPos, 10.0, scale2, 0);
Expand Down
11 changes: 6 additions & 5 deletions toonz/sources/tnztools/toolutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,9 @@ void ToolUtils::drawBalloon(const TPointD &pos, std::string text,
const TPixel32 &color, TPoint delta,
double pixelSize, bool isPicking,
std::vector<TRectD> *otherBalloons) {
int devPixRatio = getDevPixRatio();
TTool::Viewer *viewer =
TTool::getApplication()->getCurrentTool()->getTool()->getViewer();
int devPixRatio = getDevicePixelRatio(viewer->viewerWidget());
QString qText = QString::fromStdString(text);
QFont font("Arial"); // ,QFont::Bold);
font.setPixelSize(13 * devPixRatio);
Expand Down Expand Up @@ -1553,9 +1555,6 @@ void ToolUtils::drawBalloon(const TPointD &pos, std::string text,
int y1 = textRect.bottom() + mrg;

if (isPicking) {
TTool::Viewer *viewer =
TTool::getApplication()->getCurrentTool()->getTool()->getViewer();

if (viewer->is3DView()) {
double x0 = pos.x + textRect.left() * pixelSize,
y0 = pos.y + delta.y * pixelSize;
Expand Down Expand Up @@ -1645,7 +1644,9 @@ void ToolUtils::drawBalloon(const TPointD &pos, std::string text,

void ToolUtils::drawHook(const TPointD &pos, ToolUtils::HookType type,
bool highlighted, bool onionSkin) {
int devPixRatio = getDevPixRatio();
TTool::Viewer *viewer =
TTool::getApplication()->getCurrentTool()->getTool()->getViewer();
int devPixRatio = getDevicePixelRatio(viewer->viewerWidget());
int r = 10, d = r + r;
QImage image(d * devPixRatio, d * devPixRatio, QImage::Format_ARGB32);
image.fill(Qt::transparent);
Expand Down
2 changes: 1 addition & 1 deletion toonz/sources/toonz/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set(VERSION 1.5)
set(VERSION 1.6)

set(MOC_HEADERS
addfilmstripframespopup.h
Expand Down
2 changes: 1 addition & 1 deletion toonz/sources/toonz/cameracapturelevelcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void CameraCaptureLevelHistogram::mousePressEvent(QMouseEvent* event) {
m_offset = pos.x() - SIDE_MARGIN - m_black;
else if (m_currentItem == GammaSlider)
m_offset = pos.x() - SIDE_MARGIN - gammaToHPos(m_gamma, m_black, m_white);
else if (m_currentItem == BlackSlider)
else if (m_currentItem == WhiteSlider)
m_offset = pos.x() - SIDE_MARGIN - m_white;
else if (m_currentItem == ThresholdSlider)
m_offset = pos.x() - SIDE_MARGIN - m_threshold;
Expand Down
2 changes: 1 addition & 1 deletion toonz/sources/toonz/cameracapturelevelcontrol_qt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void CameraCaptureLevelHistogram::mousePressEvent(QMouseEvent* event) {
m_offset = pos.x() - SIDE_MARGIN - m_black;
else if (m_currentItem == GammaSlider)
m_offset = pos.x() - SIDE_MARGIN - gammaToHPos(m_gamma, m_black, m_white);
else if (m_currentItem == BlackSlider)
else if (m_currentItem == WhiteSlider)
m_offset = pos.x() - SIDE_MARGIN - m_white;
else if (m_currentItem == ThresholdSlider)
m_offset = pos.x() - SIDE_MARGIN - m_threshold;
Expand Down
6 changes: 3 additions & 3 deletions toonz/sources/toonz/canvassizepopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ int getPixelLength(double measuredLength, TMeasure *measure, double dpi,
double inchValue = measure->getCurrentUnit()->convertFrom(measuredLength);
return tround(inchValue * dpi);
}
}
} // namespace
//=============================================================================
// PeggingWidget
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -266,7 +266,7 @@ void PeggingWidget::on00() {
m_01->setIcon(m_topPix.transformed(QMatrix().rotate(m_cutLx ? -90 : 90),
Qt::SmoothTransformation));
m_11->setIcon(
m_topRightPix.transformed(QMatrix().rotate(m_cutLx || m_cutLx ? -90 : 90),
m_topRightPix.transformed(QMatrix().rotate(m_cutLx || m_cutLy ? -90 : 90),
Qt::SmoothTransformation));
m_10->setIcon(m_topPix.transformed(QMatrix().rotate(m_cutLy ? 0 : 180),
Qt::SmoothTransformation));
Expand Down Expand Up @@ -601,7 +601,7 @@ void CanvasSizePopup::showEvent(QShowEvent *e) {
TPointD dpi = m_sl->getDpi();
double dimLx = getMeasuredLength(dim.lx, m_xMeasure, dpi.x,
m_unit->currentData().toString());
double dimLy = getMeasuredLength(dim.ly, m_yMeasure, dpi.y,
double dimLy = getMeasuredLength(dim.ly, m_yMeasure, dpi.y,
m_unit->currentData().toString());
m_currentXSize->setText(QString::number(dimLx));
m_currentYSize->setText(QString::number(dimLy));
Expand Down
2 changes: 1 addition & 1 deletion toonz/sources/toonz/cleanuppopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ void CleanupPopup::buildCleanupList() {
const TXshCell &cell = xsh->getCell(r, c);
if (cell.isEmpty()) continue;
TXshSimpleLevel *sl = cell.getSimpleLevel();
if (!sl && locals::supportsCleanup(sl)) continue;
if (!(sl && locals::supportsCleanup(sl))) continue;
/*---もし新しいLevelなら、Levelのリストに登録---*/
std::map<TXshSimpleLevel *, FramesList>::iterator it =
cleanupList.find(sl);
Expand Down
8 changes: 5 additions & 3 deletions toonz/sources/toonz/colormodelviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,16 @@ void ColorModelViewer::contextMenuEvent(QContextMenuEvent *event) {
/*! If left button is pressed recall \b pick() in event pos.
*/
void ColorModelViewer::mousePressEvent(QMouseEvent *event) {
if (event->button() == Qt::LeftButton) pick(event->pos() * getDevPixRatio());
if (event->button() == Qt::LeftButton)
pick(event->pos() * getDevicePixelRatio(this));
}

//-----------------------------------------------------------------------------
/*! If left button is moved recall \b pick() in event pos.
*/
void ColorModelViewer::mouseMoveEvent(QMouseEvent *event) {
if (event->buttons() & Qt::LeftButton) pick(event->pos() * getDevPixRatio());
if (event->buttons() & Qt::LeftButton)
pick(event->pos() * getDevicePixelRatio(this));
}

//-----------------------------------------------------------------------------
Expand All @@ -296,7 +298,7 @@ void ColorModelViewer::pick(const QPoint &p) {
/*- 画面外ではPickできない -*/
if (!m_imageViewer->rect().contains(p)) return;

StylePicker picker(img, currentPalette);
StylePicker picker(this, img, currentPalette);

QPoint viewP = m_imageViewer->mapFrom(this, p);
TPointD pos = m_imageViewer->getViewAff().inv() *
Expand Down
21 changes: 9 additions & 12 deletions toonz/sources/toonz/comboviewerpane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,13 +646,12 @@ void ComboViewerPanel::changeWindowTitle() {
name = name + tr(" :: Level: ") + imageName;

if (!m_sceneViewer->is3DView()) {
TAffine aff = m_sceneViewer->getViewMatrix();
TAffine aff = m_sceneViewer->getViewMatrix() *
m_sceneViewer->getNormalZoomScale().inv();
if (m_sceneViewer->getIsFlippedX()) aff = aff * TScale(-1, 1);
if (m_sceneViewer->getIsFlippedY()) aff = aff * TScale(1, -1);
name = name + " :: Zoom : " +
QString::number((int)(100.0 * sqrt(aff.det()) *
m_sceneViewer->getDpiFactor())) +
"%";
QString::number(tround(100.0 * sqrt(aff.det()))) + "%";
}

// If the current level exists and some option is set in the preference,
Expand All @@ -666,13 +665,12 @@ void ComboViewerPanel::changeWindowTitle() {
// neither
->isEnabled() &&
!m_sceneViewer->is3DView()) {
TAffine aff = m_sceneViewer->getViewMatrix();
TAffine aff = m_sceneViewer->getViewMatrix() *
m_sceneViewer->getNormalZoomScale().inv();
if (m_sceneViewer->getIsFlippedX()) aff = aff * TScale(-1, 1);
if (m_sceneViewer->getIsFlippedY()) aff = aff * TScale(1, -1);
name = name + " :: Zoom : " +
QString::number((int)(100.0 * sqrt(aff.det()) *
m_sceneViewer->getDpiFactor())) +
"%";
QString::number(tround(100.0 * sqrt(aff.det()))) + "%";
}

}
Expand All @@ -686,13 +684,12 @@ void ComboViewerPanel::changeWindowTitle() {

name = name + tr("Level: ") + imageName;
if (!m_sceneViewer->is3DView()) {
TAffine aff = m_sceneViewer->getViewMatrix();
TAffine aff = m_sceneViewer->getViewMatrix() *
m_sceneViewer->getNormalZoomScale().inv();
if (m_sceneViewer->getIsFlippedX()) aff = aff * TScale(-1, 1);
if (m_sceneViewer->getIsFlippedY()) aff = aff * TScale(1, -1);
name = name + " :: Zoom : " +
QString::number((int)(100.0 * sqrt(aff.det()) *
m_sceneViewer->getDpiFactor())) +
"%";
QString::number(tround(100.0 * sqrt(aff.det()))) + "%";
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions toonz/sources/toonz/filebrowsermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ DvDirModelFileFolderNode::DvDirModelFileFolderNode(DvDirModelNode *parent,
//-----------------------------------------------------------------------------

bool DvDirModelFileFolderNode::exists() {
return m_existsChecked ? m_exists : m_peeks
return m_existsChecked ? m_exists
: m_peeks
? m_existsChecked = true,
m_exists = TFileStatus(m_path).doesExist() : true;
}
Expand Down Expand Up @@ -1235,12 +1236,12 @@ void DvDirModelRootNode::updateSceneFolderNodeVisibility(bool forceHide) {
bool show = (forceHide) ? false : !m_sceneFolderNode->getPath().isEmpty();
if (show && m_sceneFolderNode->getRow() == -1) {
int row = getChildCount();
DvDirModel::instance()->notifyBeginInsertRows(QModelIndex(), row, row + 1);
DvDirModel::instance()->notifyBeginInsertRows(QModelIndex(), row, row);
addChild(m_sceneFolderNode);
DvDirModel::instance()->notifyEndInsertRows();
} else if (!show && m_sceneFolderNode->getRow() != -1) {
int row = m_sceneFolderNode->getRow();
DvDirModel::instance()->notifyBeginRemoveRows(QModelIndex(), row, row + 1);
DvDirModel::instance()->notifyBeginRemoveRows(QModelIndex(), row, row);
// remove the last child of the root node
m_children.erase(m_children.begin() + row, m_children.begin() + row + 1);
DvDirModel::instance()->notifyEndRemoveRows();
Expand Down Expand Up @@ -1335,7 +1336,7 @@ DvDirModelNode *DvDirModel::getNode(const QModelIndex &index) const {
QModelIndex DvDirModel::index(int row, int column,
const QModelIndex &parent) const {
if (column != 0) return QModelIndex();
DvDirModelNode *parentNode = m_root;
DvDirModelNode *parentNode = m_root;
if (parent.isValid()) parentNode = getNode(parent);
if (row < 0 || row >= parentNode->getChildCount()) return QModelIndex();
DvDirModelNode *node = parentNode->getChild(row);
Expand Down
4 changes: 2 additions & 2 deletions toonz/sources/toonz/flipbook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2122,8 +2122,8 @@ void FlipBook::adaptGeometryToCurrentSize() {
if (!img) return;

TAffine toWidgetRef(m_imageViewer->getImgToWidgetAffine());
TRectD pixGeomD(TScale(1.0 / (double)getDevPixRatio()) * toWidgetRef *
getImageBoundsD(img));
TRectD pixGeomD(TScale(1.0 / (double)getDevicePixelRatio(this)) *
toWidgetRef * getImageBoundsD(img));
// TRectD pixGeomD(toWidgetRef * getImageBoundsD(img));
TRect pixGeom(tceil(pixGeomD.x0), tceil(pixGeomD.y0), tfloor(pixGeomD.x1) - 1,
tfloor(pixGeomD.y1) - 1);
Expand Down
4 changes: 2 additions & 2 deletions toonz/sources/toonz/imageviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ void ImageViewer::pickColor(QMouseEvent *event, bool putValueToStyleEditor) {
return;
}

StylePicker picker(img);
StylePicker picker(this, img);

TPointD pos =
getViewAff().inv() * TPointD(curPos.x() - (qreal)(width()) / 2,
Expand Down Expand Up @@ -1040,7 +1040,7 @@ void ImageViewer::rectPickColor(bool putValueToStyleEditor) {
return;
}

StylePicker picker(img);
StylePicker picker(this, img);

if (!img->raster()) { // vector image
TPointD pressedWinPos = convert(m_pressedMousePos) + m_winPosMousePosOffset;
Expand Down
10 changes: 9 additions & 1 deletion toonz/sources/toonz/iocommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,10 @@ void IoCmd::newScene() {

if (!saveSceneIfNeeded(QApplication::tr("New Scene"))) return;

// temporary clear the current level to prevent UI to access deleted level
// while switching scenes
app->getCurrentLevel()->setLevel(nullptr);

IconGenerator::instance()->clearRequests();
IconGenerator::instance()->clearSceneIcons();
ImageManager::instance()->clear();
Expand Down Expand Up @@ -1909,6 +1913,11 @@ bool IoCmd::loadScene(const TFilePath &path, bool updateRecentFile,
}
QApplication::setOverrideCursor(Qt::WaitCursor);

TApp *app = TApp::instance();
// temporary clear the current level to prevent UI to access deleted level
// while switching scenes
app->getCurrentLevel()->setLevel(nullptr);

TUndoManager::manager()->reset();
IconGenerator::instance()->clearRequests();
IconGenerator::instance()->clearSceneIcons();
Expand Down Expand Up @@ -1963,7 +1972,6 @@ bool IoCmd::loadScene(const TFilePath &path, bool updateRecentFile,
project->setFolder("project", scenePath);
scene->setProject(project);
}
TApp *app = TApp::instance();
app->getCurrentScene()->setScene(scene);
app->getCurrentScene()->notifyNameSceneChange();
app->getCurrentFrame()->setFrame(0);
Expand Down
8 changes: 5 additions & 3 deletions toonz/sources/toonz/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,7 @@ int main(int argc, char *argv[]) {

// splash screen
QPixmap splashPixmap = QIcon(":Resources/splash.svg").pixmap(QSize(610, 344));
splashPixmap.setDevicePixelRatio(QApplication::desktop()->devicePixelRatio());
// QPixmap splashPixmap(":Resources/splash.png");

#ifdef _WIN32
QFont font("Segoe UI", -1);
#else
Expand Down Expand Up @@ -736,7 +735,10 @@ int main(int argc, char *argv[]) {

TFilePath fp = ToonzFolder::getModuleFile("mainwindow.ini");
QSettings settings(toQString(fp), QSettings::IniFormat);
w.restoreGeometry(settings.value("MainWindowGeometry").toByteArray());
if (settings.contains("MainWindowGeometry"))
w.restoreGeometry(settings.value("MainWindowGeometry").toByteArray());
else // maximize window on the first launch
w.setWindowState(w.windowState() | Qt::WindowMaximized);

ExpressionReferenceManager::instance()->init();

Expand Down
6 changes: 3 additions & 3 deletions toonz/sources/toonz/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ void MainWindow::onUpgradeTabPro() {}
void MainWindow::onAbout() {
QLabel *label = new QLabel();
QPixmap pixmap = QIcon(":Resources/splash.svg").pixmap(QSize(610, 344));
pixmap.setDevicePixelRatio(QApplication::desktop()->devicePixelRatio());
pixmap.setDevicePixelRatio(getDevicePixelRatio(this));
label->setPixmap(pixmap);

DVGui::Dialog *dialog = new DVGui::Dialog(this, true);
Expand Down Expand Up @@ -1899,8 +1899,8 @@ void MainWindow::defineActions() {
QT_TR_NOOP("&Apply Lip Sync Data to Column"), "Alt+L",
"dialogue");
createMenuXsheetAction(MI_AutoLipSyncPopup,
QT_TR_NOOP("&Apply Auto Lip Sync to Column"), "Ctrl+Alt+L",
"dialogue");
QT_TR_NOOP("&Apply Auto Lip Sync to Column"),
"Ctrl+Alt+L", "dialogue");

// Menu - Cells

Expand Down
9 changes: 8 additions & 1 deletion toonz/sources/toonz/preferencespopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1255,6 +1255,8 @@ QString PreferencesPopup::getUIString(PreferencesItemId id) {
{expandFunctionHeader,
tr("Expand Function Editor Header to Match Xsheet Toolbar Height*")},
{showColumnNumbers, tr("Show Column Numbers in Column Headers")},
{parentColorsInXsheetColumn,
tr("Show Column Parent's Color in the Xsheet")},
{syncLevelRenumberWithXsheet,
tr("Sync Level Strip Drawing Number Changes with the Xsheet")},
{currentTimelineEnabled,
Expand Down Expand Up @@ -1635,6 +1637,9 @@ QWidget* PreferencesPopup::createInterfacePage() {
insertUI(CurrentLanguageName, lay, languageItemList);
insertUI(interfaceFont, lay); // creates QFontComboBox
insertUI(interfaceFontStyle, lay, buildFontStyleList());
qobject_cast<QComboBox*>(m_controlIdMap.key(interfaceFontStyle))
->setSizeAdjustPolicy(QComboBox::AdjustToContents);

QGridLayout* colorCalibLay = insertGroupBoxUI(colorCalibrationEnabled, lay);
{ insertUI(colorCalibrationLutPaths, colorCalibLay); }
insertUI(displayIn30bit, lay);
Expand Down Expand Up @@ -1695,7 +1700,8 @@ QWidget* PreferencesPopup::createVisualizationPage() {

QWidget* PreferencesPopup::createLoadingPage() {
m_levelFormatNames = new QComboBox;
m_editLevelFormat = new QPushButton(tr("Edit"));
m_levelFormatNames->setSizeAdjustPolicy(QComboBox::AdjustToContents);
m_editLevelFormat = new QPushButton(tr("Edit"));

QPushButton* addLevelFormat = new QPushButton("+");
QPushButton* removeLevelFormat = new QPushButton("-");
Expand Down Expand Up @@ -1965,6 +1971,7 @@ QWidget* PreferencesPopup::createXsheetPage() {
QGridLayout* xshToolbarLay = insertGroupBoxUI(showXSheetToolbar, lay);
{ insertUI(expandFunctionHeader, xshToolbarLay); }
insertUI(showColumnNumbers, lay);
insertUI(parentColorsInXsheetColumn, lay);
insertUI(syncLevelRenumberWithXsheet, lay);
insertUI(currentTimelineEnabled, lay);
insertUI(currentColumnColor, lay);
Expand Down
16 changes: 8 additions & 8 deletions toonz/sources/toonz/ruler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ double Ruler::getPan() const {
if (m_viewer->is3DView()) // Vertical 3D
return m_viewer->getPan3D().y;
else // Vertical 2D
return aff.a23 / getDevPixRatio();
return aff.a23 / m_viewer->getDevPixRatio();
else if (m_viewer->is3DView()) // Horizontal 3D
return m_viewer->getPan3D().x;
return aff.a13 / getDevPixRatio(); // Horizontal 2D
return aff.a13 / m_viewer->getDevPixRatio(); // Horizontal 2D
}

//-----------------------------------------------------------------------------
Expand All @@ -137,7 +137,7 @@ void Ruler::drawVertical(QPainter &p) {
for (i = 0; i < count; i++) {
QColor color = (m_moving && count - 1 == i ? QColor(getHandleDragColor())
: QColor(getHandleColor()));
double v = guides[i] / (double)getDevPixRatio();
double v = guides[i] / (double)m_viewer->getDevPixRatio();
int y = (int)(origin - zoom * v);
p.fillRect(QRect(x0, y - 1, x1 - x0, 2), QBrush(color));
}
Expand Down Expand Up @@ -192,7 +192,7 @@ void Ruler::drawHorizontal(QPainter &p) {
for (i = 0; i < count; i++) {
QColor color = (m_moving && count - 1 == i ? QColor(getHandleDragColor())
: QColor(getHandleColor()));
double v = guides[i] / (double)getDevPixRatio();
double v = guides[i] / (double)m_viewer->getDevPixRatio();
int x = (int)(origin + zoom * v);
p.fillRect(QRect(x - 1, y0, 2, y1 - y0), QBrush(color));
}
Expand Down Expand Up @@ -258,7 +258,7 @@ void Ruler::mousePressEvent(QMouseEvent *e) {
int i;
int count = guides.size();
for (i = 0; i < count; i++) {
double g = guides[i] / (double)getDevPixRatio();
double g = guides[i] / (double)m_viewer->getDevPixRatio();
double dist2 = (g - v) * (g - v);
if (selected < 0 || dist2 < minDist2) {
minDist2 = dist2;
Expand All @@ -268,7 +268,7 @@ void Ruler::mousePressEvent(QMouseEvent *e) {
if (e->button() == Qt::LeftButton) {
if (selected < 0 || minDist2 > 25) {
// crea una nuova guida
guides.push_back(v * getDevPixRatio());
guides.push_back(v * m_viewer->getDevPixRatio());
m_viewer->update();
// aggiorna sprop!!!!
} else if (selected < count - 1)
Expand All @@ -294,7 +294,7 @@ void Ruler::mousePressEvent(QMouseEvent *e) {
void Ruler::mouseMoveEvent(QMouseEvent *e) {
if (m_moving) {
m_hiding = m_vertical ? (e->pos().x() < 0) : (e->pos().y() < 0);
getGuides().back() = posToValue(e->pos()) * getDevPixRatio();
getGuides().back() = posToValue(e->pos()) * m_viewer->getDevPixRatio();
// aggiorna sprop!!!!
update();
m_viewer->update();
Expand All @@ -308,7 +308,7 @@ void Ruler::mouseMoveEvent(QMouseEvent *e) {

int count = guides.size();
for (int i = 0; i < count; i++) {
double g = guides[i] / (double)getDevPixRatio();
double g = guides[i] / (double)m_viewer->getDevPixRatio();
double dist2 = (g - v) * (g - v);
if (dist2 < 25) {
setToolTip(tr(
Expand Down
13 changes: 12 additions & 1 deletion toonz/sources/toonz/sceneviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,17 @@ class TShiftTraceToggleCommand final : public MenuItemHandler {
if (std::string(m_cmdId) == MI_ShiftTrace) {
cm->enable(MI_EditShift, checked);
cm->enable(MI_NoShift, checked);
if (checked) OnioniSkinMaskGUI::resetShiftTraceFrameOffset();
if (checked) {
OnioniSkinMaskGUI::resetShiftTraceFrameOffset();
// activate edit shift
if (isChecked(MI_EditShift))
TApp::instance()->getCurrentTool()->setPseudoTool("T_ShiftTrace");
} else {
// deactivate edit shift
if (isChecked(MI_EditShift))
TApp::instance()->getCurrentTool()->unsetPseudoTool();
}

// cm->getAction(MI_NoShift)->setChecked(false);
TApp::instance()->getCurrentOnionSkin()->notifyOnionSkinMaskChanged();
} else if (std::string(m_cmdId) == MI_EditShift) {
Expand Down Expand Up @@ -741,6 +751,7 @@ class TFlipPrevStrokeDirectionCommand final : public MenuItemHandler {

SceneViewer::SceneViewer(ImageUtils::FullScreenWidget *parent)
: GLWidgetForHighDpi(parent)
, TTool::Viewer(this)
, m_pressure(0)
, m_lastMousePos(0, 0)
, m_mouseButton(Qt::NoButton)
Expand Down
8 changes: 8 additions & 0 deletions toonz/sources/toonz/sceneviewerevents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,14 @@ void SceneViewer::mouseMoveEvent(QMouseEvent *event) {
void SceneViewer::onMove(const TMouseEvent &event) {
if (m_freezedStatus != NO_FREEZED) return;

// in case mouseReleaseEvent is not called, finish the action for the previous
// button first.
if (m_mouseButton != Qt::NoButton && event.m_buttons == Qt::NoButton) {
TMouseEvent preEvent = event;
preEvent.m_button = m_mouseButton;
onRelease(preEvent);
}

int devPixRatio = getDevPixRatio();
QPointF curPos = event.mousePos() * devPixRatio;
bool cursorSet = false;
Expand Down
8 changes: 4 additions & 4 deletions toonz/sources/toonz/subcameramanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ inline bool bitwiseContains(UCHAR flag, UCHAR state) {
inline bool bitwiseExclude(UCHAR flag, UCHAR state) {
return bitwiseContains(~state, flag);
}
}
} // namespace

//********************************************************************************
// Classes implementation
Expand Down Expand Up @@ -119,7 +119,7 @@ bool PreviewSubCameraManager::mousePressEvent(SceneViewer *viewer,
if (viewer->is3DView()) return true;

m_mousePressed = true;
m_mousePressPos = event.mousePos() * getDevPixRatio();
m_mousePressPos = event.mousePos() * viewer->getDevPixRatio();
m_dragType = getSubCameraDragEnum(viewer, m_mousePressPos);

if (bitwiseExclude(m_dragType, OUTER))
Expand All @@ -133,7 +133,7 @@ bool PreviewSubCameraManager::mousePressEvent(SceneViewer *viewer,
bool PreviewSubCameraManager::mouseMoveEvent(SceneViewer *viewer,
const TMouseEvent &event) {
if (viewer->is3DView()) return true;
QPointF curPos(event.mousePos() * getDevPixRatio());
QPointF curPos(event.mousePos() * viewer->getDevPixRatio());
if (event.buttons() == Qt::LeftButton) {
if (!bitwiseContains(m_dragType, INNER)) {
if (std::abs(curPos.x() - m_mousePressPos.x()) > 10 ||
Expand Down Expand Up @@ -334,7 +334,7 @@ TPoint PreviewSubCameraManager::getSubCameraDragDistance(

//-----------------------------------------------------------------------------
/*! Delete sub camera frame. Executed from context menu of the viewer.
*/
*/
void PreviewSubCameraManager::deleteSubCamera(SceneViewer *viewer) {
TCamera *camera =
TApp::instance()->getCurrentScene()->getScene()->getCurrentCamera();
Expand Down
380 changes: 240 additions & 140 deletions toonz/sources/toonz/xshcolumnviewer.cpp

Large diffs are not rendered by default.

16 changes: 12 additions & 4 deletions toonz/sources/toonz/xshcolumnviewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,14 @@ class ChangeObjectWidget : public QListWidget {
void wheelEvent(QWheelEvent *event) override;
void focusOutEvent(QFocusEvent *e) override;
void focusInEvent(QFocusEvent *e) override {}
void selectCurrent(const QString &text);

void addText(const QString &text, const QString &display);
void addText(const QString &text, const QColor &textColor);
void addText(const TStageObjectId &id, const QString &display,
const QColor &identColor);

protected slots:
virtual void onTextChanged(const QString &) = 0;
virtual void onItemSelected(QListWidgetItem *) = 0;
};

//=============================================================================
Expand All @@ -112,8 +116,11 @@ class ChangeObjectParent final : public ChangeObjectWidget {

void refresh() override;

static QString getNameTr(const TStageObjectId id);
void selectCurrent(const TStageObjectId &id);

protected slots:
void onTextChanged(const QString &) override;
void onItemSelected(QListWidgetItem *) override;
};

//=============================================================================
Expand All @@ -128,9 +135,10 @@ class ChangeObjectHandle final : public ChangeObjectWidget {
~ChangeObjectHandle();

void refresh() override;
void selectCurrent(const QString &text);

protected slots:
void onTextChanged(const QString &) override;
void onItemSelected(QListWidgetItem *) override;
};

//=============================================================================
Expand Down
8 changes: 7 additions & 1 deletion toonz/sources/toonz/xsheetviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ TStageObjectId XsheetViewer::getObjectId(int col) const {

void XsheetViewer::setCurrentColumn(int col) {
TColumnHandle *columnHandle = TApp::instance()->getCurrentColumn();
if (col != columnHandle->getColumnIndex()) {
if (col != columnHandle->getColumnIndex() || !columnHandle->getColumn()) {
columnHandle->setColumnIndex(col);
// E' necessario per il caso in cui si passa da colonna di camera a altra
// colonna
Expand Down Expand Up @@ -592,6 +592,12 @@ void XsheetViewer::scroll(QPoint delta) {

//-----------------------------------------------------------------------------

int XsheetViewer::getColumnScrollValue() {
return m_columnScrollArea->horizontalScrollBar()->value();
}

//-----------------------------------------------------------------------------

void XsheetViewer::onPrepareToScrollOffset(const QPointF &offset) {
refreshContentSize((int)offset.x(), (int)offset.y());
}
Expand Down
13 changes: 13 additions & 0 deletions toonz/sources/toonz/xsheetviewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,12 @@ class XsheetViewer final : public QFrame, public SaveLoadQSettings {
setMeshColumnBorderColor)
Q_PROPERTY(QColor SelectedMeshColumnColor READ getSelectedMeshColumnColor
WRITE setSelectedMeshColumnColor)
// Table color
QColor m_tableColor;
Q_PROPERTY(QColor TableColor READ getTableColor WRITE setTableColor)
// Peg node
QColor m_pegColor;
Q_PROPERTY(QColor PegColor READ getPegColor WRITE setPegColor)
// SoundText column
QColor m_soundTextColumnColor;
QColor m_soundTextColumnBorderColor;
Expand Down Expand Up @@ -672,6 +678,7 @@ class XsheetViewer final : public QFrame, public SaveLoadQSettings {
void setCurrentRow(int row);

void scroll(QPoint delta);
int getColumnScrollValue();

void setAutoPanSpeed(const QPoint &speed);
void setAutoPanSpeed(const QRect &widgetBounds, const QPoint &mousePos);
Expand Down Expand Up @@ -935,6 +942,12 @@ class XsheetViewer final : public QFrame, public SaveLoadQSettings {
QColor getSelectedMeshColumnColor() const {
return m_selectedMeshColumnColor;
}
// Table node
void setTableColor(const QColor &color) { m_tableColor = color; }
QColor getTableColor() const { return m_tableColor; }
// Peg node
void setPegColor(const QColor &color) { m_pegColor = color; }
QColor getPegColor() const { return m_pegColor; }
// SoundText column
void setSoundTextColumnColor(const QColor &color) {
m_soundTextColumnColor = color;
Expand Down
29 changes: 15 additions & 14 deletions toonz/sources/toonzfarm/tfarmcontroller/tfarmcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ TFilePath getGlobalRoot() {
// Leggo la globalRoot da File txt
#ifdef MACOSX
// If MACOSX, change to MACOSX path
std::string unixpath = "./" + tver.getAppName() +
".app/Contents/Resources/configfarmroot.txt";
std::string unixpath =
"./" + tver.getAppName() + ".app/Contents/Resources/configfarmroot.txt";
#else
// set path to something suitable for most linux (Unix?) systems
std::string unixpath = "/etc/" + tver.getAppName() + "/opentoonz.conf";
Expand Down Expand Up @@ -104,21 +104,23 @@ TFilePath getLocalRoot() {
TFilePath lroot;

#ifdef _WIN32
std::string regpath = "SOFTWARE\\" + tver.getAppName() + "\\" + tver.getAppName() +
"\\" + tver.getAppVersionString() + "\\FARMROOT";
std::string regpath = "SOFTWARE\\" + tver.getAppName() + "\\" +
tver.getAppName() + "\\" + tver.getAppVersionString() +
"\\FARMROOT";
TFilePath name(regpath);
lroot = TFilePath(TSystem::getSystemValue(name).toStdString()) +
TFilePath("toonzfarm");
#else
// Leggo la localRoot da File txt
#ifdef MACOSX
// If MACOSX, change to MACOSX path
std::string unixpath = "./" + tver.getAppName() +
".app/Contents/Resources/configfarmroot.txt";
std::string unixpath =
"./" + tver.getAppName() + ".app/Contents/Resources/configfarmroot.txt";
#else
// set path to something suitable for most linux (Unix?) systems
#ifdef FREEBSD
std::string unixpath = "/usr/local/etc/" + tver.getAppName() + "/opentoonz.conf";
std::string unixpath =
"/usr/local/etc/" + tver.getAppName() + "/opentoonz.conf";
#else
std::string unixpath = "/etc/" + tver.getAppName() + "/opentoonz.conf";
#endif
Expand Down Expand Up @@ -767,7 +769,7 @@ inline QString toString(const TFarmTask &task, int ver) {
ss += QString::number(task.m_platform) + ",";

int depCount = 0;
if (task.m_dependencies) depCount= task.m_dependencies->getTaskCount();
if (task.m_dependencies) depCount = task.m_dependencies->getTaskCount();

ss += QString::number(depCount);

Expand Down Expand Up @@ -1160,7 +1162,7 @@ CtrlFarmTask *FarmController::getTaskToStart(FarmServerProxy *server) {
task->m_platform == server->m_platform)) &&
(((task->m_status == Waiting && task->m_priority > maxPriority) ||
(task->m_status == Aborted && task->m_failureCount < 3)) &&
task->m_parentId != "")) {
task->m_parentId != "")) {
bool dependenciesCompleted = true;

if (task->m_dependencies) {
Expand Down Expand Up @@ -1320,7 +1322,7 @@ bool FarmController::tryToStartTask(CtrlFarmTask *task) {
m_tasks.find(TaskId(*itSubTaskId));
if (itSubTask != m_tasks.end()) {
CtrlFarmTask *subTask = itSubTask->second;
if (tryToStartTask(subTask)) started= true;
if (tryToStartTask(subTask)) started = true;
}
}

Expand Down Expand Up @@ -1775,8 +1777,7 @@ void FarmController::taskSubmissionError(const QString &taskId, int errCode) {
}

parentTask->m_status = parentTaskState;
if (parentTask->m_status == Aborted ||
parentTask->m_status == Aborted) {
if (parentTask->m_status == Aborted) {
parentTask->m_completionDate = task->m_completionDate;
if (parentTask->m_toBeDeleted) m_tasks.erase(itParent);
}
Expand Down Expand Up @@ -1861,7 +1862,7 @@ void FarmController::taskCompleted(const QString &taskId, int exitCode) {
switch (exitCode) {
case 0:
task->m_status = Completed;
if (isAScript(task)) task->m_successfullSteps= task->m_stepCount;
if (isAScript(task)) task->m_successfullSteps = task->m_stepCount;
break;
case RENDER_LICENSE_NOT_FOUND:
task->m_status = Waiting;
Expand Down Expand Up @@ -2342,7 +2343,7 @@ void ControllerService::onStart(int argc, char *argv[]) {
msg += "\n";
m_userLog->info(msg);

// std::cout << msg;
// std::cout << msg;

#ifdef __sgi
{ remove("/tmp/.tfarmcontroller.dat"); }
Expand Down
2 changes: 1 addition & 1 deletion toonz/sources/toonzlib/plasticdeformerfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ std::string PlasticDeformerFx::getAlias(double frame,
meshColumnObj->getPlasticSkeletonDeformation();
if (sd) alias += ", " + toString(sd, meshColumnObj->paramsTime(frame));

alias + "]";
alias += "]";

return alias;
}
Expand Down
2 changes: 2 additions & 0 deletions toonz/sources/toonzlib/preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,8 @@ void Preferences::definePreferenceItems() {
define(showXSheetToolbar, "showXSheetToolbar", QMetaType::Bool, true);
define(expandFunctionHeader, "expandFunctionHeader", QMetaType::Bool, false);
define(showColumnNumbers, "showColumnNumbers", QMetaType::Bool, false);
define(parentColorsInXsheetColumn, "parentColorsInXsheetColumn",
QMetaType::Bool, false);
define(syncLevelRenumberWithXsheet, "syncLevelRenumberWithXsheet",
QMetaType::Bool, true);
define(currentTimelineEnabled, "currentTimelineEnabled", QMetaType::Bool,
Expand Down
38 changes: 17 additions & 21 deletions toonz/sources/toonzlib/sceneproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,22 @@
#include "tiio.h"

namespace {
const TSceneProperties::CellMark cellMarkDefault[12] = {
{QObject::tr("Red"), TPixel32(167, 55, 55)},
{QObject::tr("Orange"), TPixel32(195, 115, 40)},
{QObject::tr("Yellow"), TPixel32(214, 183, 22)},
{QObject::tr("Light Green"), TPixel32(165, 179, 57)},
{QObject::tr("Green"), TPixel32(82, 157, 79)},
{QObject::tr("Light Blue"), TPixel32(71, 142, 165)},
{QObject::tr("Blue"), TPixel32(64, 103, 172)},
{QObject::tr("Dark Blue"), TPixel32(60, 49, 187)},
{QObject::tr("Purple"), TPixel32(108, 66, 170)},
{QObject::tr("Pink"), TPixel32(161, 75, 140)},
{QObject::tr("Dark Pink"), TPixel32(111, 29, 108)},
{QObject::tr("White"), TPixel32(255, 255, 255)}};

const QList<TSceneProperties::CellMark> getDefaultCellMarks() {
return QList<TSceneProperties::CellMark>{
{QObject::tr("Red"), TPixel32(167, 55, 55)},
{QObject::tr("Orange"), TPixel32(195, 115, 40)},
{QObject::tr("Yellow"), TPixel32(214, 183, 22)},
{QObject::tr("Light Green"), TPixel32(165, 179, 57)},
{QObject::tr("Green"), TPixel32(82, 157, 79)},
{QObject::tr("Light Blue"), TPixel32(71, 142, 165)},
{QObject::tr("Blue"), TPixel32(64, 103, 172)},
{QObject::tr("Dark Blue"), TPixel32(60, 49, 187)},
{QObject::tr("Purple"), TPixel32(108, 66, 170)},
{QObject::tr("Pink"), TPixel32(161, 75, 140)},
{QObject::tr("Dark Pink"), TPixel32(111, 29, 108)},
{QObject::tr("White"), TPixel32(255, 255, 255)}};
}
} // namespace

//=============================================================================

Expand Down Expand Up @@ -69,7 +70,7 @@ TSceneProperties::TSceneProperties()
m_notesColor.push_back(TPixel32(150, 245, 255));

// Default Cell Marks
for (int i = 0; i < 12; i++) m_cellMarks.push_back(cellMarkDefault[i]);
m_cellMarks = getDefaultCellMarks();
}

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -863,12 +864,7 @@ void TSceneProperties::setCellMark(const TSceneProperties::CellMark &mark,
// check if the cell mark settings are modified
bool TSceneProperties::hasDefaultCellMarks() const {
if (m_cellMarks.size() != 12) return false;
for (int i = 0; i < 12; i++) {
if (m_cellMarks.at(i).name != cellMarkDefault[i].name ||
m_cellMarks.at(i).color != cellMarkDefault[i].color)
return false;
}
return true;
return m_cellMarks == getDefaultCellMarks();
}

//-----------------------------------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions toonz/sources/toonzlib/tcolumnfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,10 @@ void TLevelColumnFx::doCompute(TTile &tile, double frame,
TVectorRenderData rd(TVectorRenderData::ProductionSettings(), aff,
TRect(size), vpalette);

// obtain jaggy image when the Closest Pixel is set
if (info.m_quality == TRenderSettings::ClosestPixel_FilterResampleQuality)
rd.m_antiAliasing = false;

if (!m_offlineContext || m_offlineContext->getLx() < size.lx ||
m_offlineContext->getLy() < size.ly) {
if (m_offlineContext) delete m_offlineContext;
Expand Down
13 changes: 7 additions & 6 deletions toonz/sources/toonzqt/addfxcontextmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,18 +556,19 @@ void AddFxContextMenu::onAddFx(QAction *action) {
m_currentCursorScenePos.setY(0);
}

int colId = m_app->getCurrentColumn()->getColumnIndex();
// prevent crash when the camera column is selected
if (colId < 0) colId = 0;

// the signal xsheetChanged is to be emitted in this function
TFxCommand::addFx(fx, fxs, m_app,
m_app->getCurrentColumn()->getColumnIndex(),
TFxCommand::addFx(fx, fxs, m_app, colId,
m_app->getCurrentFrame()->getFrameIndex());

// move the zerary fx node to the clicked position
if (fx->isZerary() &&
fx->getAttributes()->getDagNodePos() != TConst::nowhere) {
TXsheet *xsh = m_app->getCurrentXsheet()->getXsheet();
TXshZeraryFxColumn *column =
xsh->getColumn(m_app->getCurrentColumn()->getColumnIndex())
->getZeraryFxColumn();
TXsheet *xsh = m_app->getCurrentXsheet()->getXsheet();
TXshZeraryFxColumn *column = xsh->getColumn(colId)->getZeraryFxColumn();
if (column)
column->getZeraryColumnFx()->getAttributes()->setDagNodePos(
fx->getAttributes()->getDagNodePos());
Expand Down
5 changes: 0 additions & 5 deletions toonz/sources/toonzqt/functionpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -994,11 +994,6 @@ void FunctionPanel::drawCurrentCurve(QPainter &painter) {
p.y() + easeHeight + easeTick);
break;

painter.setBrush(
Qt::NoBrush); // isSelected ? QColor(255,126,0) : Qt::white);
painter.setPen(isHighlighted ? QColor(255, 126, 0) : m_selectedColor);
painter.drawLine(p.x(), p.y() - 15, p.x(), p.y() + 15);
break;
default:
break;
}
Expand Down
56 changes: 34 additions & 22 deletions toonz/sources/toonzqt/fxschematicnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1239,22 +1239,19 @@ void FxSchematicPort::paint(QPainter *painter,
const QStyleOptionGraphicsItem *option,
QWidget *widget) {
if (m_isPassThrough && getLinkCount() > 0) return;

// large scaled
if (getDock()->getNode()->isNormalIconView()) {
switch (getType()) {
case eFxInputPort:
case eFxGroupedInPort: {
QRect sourceRect =
QRect targetRect =
scene()->views()[0]->matrix().mapRect(boundingRect()).toRect();
static QIcon fxPortRedIcon(":Resources/fxport_red.svg");
static QIcon fxPortPassThroughRedIcon(":Resources/fxport_pt_red.svg");
QPixmap redPm = (m_isPassThrough)
? fxPortPassThroughRedIcon.pixmap(sourceRect.size())
: fxPortRedIcon.pixmap(sourceRect.size());
sourceRect = QRect(0, 0, sourceRect.width() * getDevPixRatio(),
sourceRect.height() * getDevPixRatio());
painter->drawPixmap(boundingRect(), redPm, sourceRect);
? fxPortPassThroughRedIcon.pixmap(targetRect.size())
: fxPortRedIcon.pixmap(targetRect.size());
painter->drawPixmap(boundingRect().toRect(), redPm);
} break;

case eFxOutputPort:
Expand All @@ -1263,8 +1260,7 @@ void FxSchematicPort::paint(QPainter *painter,
scene()->views()[0]->matrix().mapRect(boundingRect()).toRect();
static QIcon fxPortBlueIcon(":Resources/fxport_blue.svg");
QPixmap bluePm = fxPortBlueIcon.pixmap(sourceRect.size());
sourceRect = QRect(0, 0, sourceRect.width() * getDevPixRatio(),
sourceRect.height() * getDevPixRatio());
sourceRect = QRect(0, 0, bluePm.width(), bluePm.height());
painter->drawPixmap(boundingRect(), bluePm, sourceRect);
FxSchematicDock *parentDock =
dynamic_cast<FxSchematicDock *>(parentItem());
Expand All @@ -1288,9 +1284,7 @@ void FxSchematicPort::paint(QPainter *painter,
scene()->views()[0]->matrix().mapRect(boundingRect()).toRect();
QPixmap linkPm =
QIcon(":Resources/schematic_link.svg").pixmap(sourceRect.size());
sourceRect = QRect(0, 0, sourceRect.width() * getDevPixRatio(),
sourceRect.height() * getDevPixRatio());
painter->drawPixmap(boundingRect(), linkPm, sourceRect);
painter->drawPixmap(boundingRect().toRect(), linkPm);
} break;
}
}
Expand All @@ -1314,9 +1308,7 @@ void FxSchematicPort::paint(QPainter *painter,
scene()->views()[0]->matrix().mapRect(boundingRect()).toRect();
QPixmap linkPm = QIcon(":Resources/schematic_link_small.svg")
.pixmap(sourceRect.size());
sourceRect = QRect(0, 0, sourceRect.width() * getDevPixRatio(),
sourceRect.height() * getDevPixRatio());
painter->drawPixmap(boundingRect(), linkPm, sourceRect);
painter->drawPixmap(boundingRect().toRect(), linkPm);
} break;
}
painter->drawRect(boundingRect());
Expand Down Expand Up @@ -1624,13 +1616,25 @@ void FxSchematicPort::mouseMoveEvent(QGraphicsSceneMouseEvent *me) {
if (!m_ghostLinks.isEmpty() && !m_ghostLinks[0]->isVisible())
m_ghostLinks[0]->show();
bool cntr = me->modifiers() == Qt::ControlModifier;

if (!m_linkingTo) {
if (m_currentTargetPort) {
m_currentTargetPort->resetSnappedLinksOnDynamicPortFx();
m_currentTargetPort = 0;
}
return;
}

FxSchematicPort *targetPort = dynamic_cast<FxSchematicPort *>(m_linkingTo);
assert(targetPort);

if (m_currentTargetPort == targetPort) return;

if (m_currentTargetPort) {
m_currentTargetPort->resetSnappedLinksOnDynamicPortFx();
m_currentTargetPort = 0;
}
if (!m_linkingTo) return;
FxSchematicPort *targetPort = dynamic_cast<FxSchematicPort *>(m_linkingTo);
assert(targetPort);

m_currentTargetPort = targetPort;
TFx *targetFx = targetPort->getOwnerFx();
TZeraryColumnFx *colFx = dynamic_cast<TZeraryColumnFx *>(targetFx);
Expand All @@ -1651,8 +1655,16 @@ void FxSchematicPort::mouseMoveEvent(QGraphicsSceneMouseEvent *me) {
targetFx->dynamicPortGroup(groupId)->ports();
int portId = getIndex(targetFxPort, groupedPorts);
if (portId == -1) return;
if (targetFx != m_ownerFx && cntr && getType() == eFxOutputPort)
targetPort->handleSnappedLinksOnDynamicPortFx(groupedPorts, portId);
if (targetFx != m_ownerFx && getType() == eFxOutputPort) {
// inserting a link above
if (cntr)
targetPort->handleSnappedLinksOnDynamicPortFx(groupedPorts, portId);
// replacing a link
else
targetPort->handleSnappedLinksOnDynamicPortFx(groupedPorts, portId,
portId);
}
// switching links in the connected ports
else if (targetFx == m_ownerFx && getType() == eFxInputPort) {
if (!m_ghostLinks.isEmpty()) {
for (SchematicLink *ghostLink : m_ghostLinks)
Expand Down Expand Up @@ -3914,9 +3926,9 @@ QRectF FxSchematicPassThroughNode::boundingRect() const {
qreal width = m_width;
QRectF recF = m_nameItem->boundingRect();
if (m_showName) {
width = recF.width();
width = recF.width();
if (width > m_width) xAdj = (width - m_width) / 2;
yAdj = 30;
yAdj = 30;
}
return QRectF(-5 - xAdj, -5 - yAdj, std::max(m_width, width) + 10,
m_height + 10 + yAdj);
Expand Down
48 changes: 43 additions & 5 deletions toonz/sources/toonzqt/gutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,38 @@
#include <QFileInfo>
#include <QDesktopWidget>
#include <QSvgRenderer>
#include <QScreen>
#include <QWindow>

using namespace DVGui;

namespace {
inline bool hasScreensWithDifferentDevPixRatio() {
static bool ret = false;
static bool checked = false;
if (!checked) { // check once
int dpr = QApplication::desktop()->devicePixelRatio();
for (auto screen : QGuiApplication::screens()) {
if ((int)screen->devicePixelRatio() != dpr) {
ret = true;
break;
}
}
checked = true;
}
return ret;
}

int getHighestDevicePixelRatio() {
static int highestDevPixRatio = 0;
if (highestDevPixRatio == 0) {
for (auto screen : QGuiApplication::screens())
highestDevPixRatio =
std::max(highestDevPixRatio, (int)screen->devicePixelRatio());
}
return highestDevPixRatio;
}
} // namespace
//-----------------------------------------------------------------------------

QString fileSizeString(qint64 size, int precision) {
Expand Down Expand Up @@ -78,7 +107,7 @@ QPixmap rasterToQPixmap(const TRaster32P &ras, bool premultiplied,
bool setDevPixRatio) {
QPixmap pixmap = QPixmap::fromImage(rasterToQImage(ras, premultiplied));
if (setDevPixRatio) {
pixmap.setDevicePixelRatio(getDevPixRatio());
pixmap.setDevicePixelRatio(getDevicePixelRatio());
}
return pixmap;
}
Expand Down Expand Up @@ -158,7 +187,7 @@ QPixmap scalePixmapKeepingAspectRatio(QPixmap pixmap, QSize size,

QPixmap svgToPixmap(const QString &svgFilePath, const QSize &size,
Qt::AspectRatioMode aspectRatioMode, QColor bgColor) {
static int devPixRatio = getDevPixRatio();
static int devPixRatio = getHighestDevicePixelRatio();
QSvgRenderer svgRenderer(svgFilePath);
QSize pixmapSize;
QRectF renderRect;
Expand Down Expand Up @@ -197,7 +226,16 @@ QPixmap svgToPixmap(const QString &svgFilePath, const QSize &size,

//-----------------------------------------------------------------------------

int getDevPixRatio() {
int getDevicePixelRatio(const QWidget *widget) {
if (hasScreensWithDifferentDevPixRatio() && widget) {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
return widget->screen()->devicePixelRatio();
#else
if (!widget->windowHandle()) widget->winId();
if (widget->windowHandle())
return widget->windowHandle()->devicePixelRatio();
#endif
}
static int devPixRatio = QApplication::desktop()->devicePixelRatio();
return devPixRatio;
}
Expand All @@ -224,7 +262,7 @@ QString getIconThemePath(const QString &fileSVGPath) {

QPixmap compositePixmap(QPixmap pixmap, const qreal &opacity, const QSize &size,
const int leftAdj, const int topAdj, QColor bgColor) {
static int devPixRatio = getDevPixRatio();
static int devPixRatio = getHighestDevicePixelRatio();

// Sets size of destination pixmap for source to be drawn onto, if size is
// empty use source pixmap size, else use custom size.
Expand Down Expand Up @@ -269,7 +307,7 @@ QPixmap recolorPixmap(QPixmap pixmap, QColor color) {

QIcon createQIcon(const char *iconSVGName, bool useFullOpacity,
bool isForMenuItem) {
static int devPixRatio = getDevPixRatio();
static int devPixRatio = getHighestDevicePixelRatio();

QIcon themeIcon = QIcon::fromTheme(iconSVGName);

Expand Down
67 changes: 32 additions & 35 deletions toonz/sources/toonzqt/schematicnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ SchematicName::SchematicName(QGraphicsItem *parent, double width, double height)
popup = new QMenu();
popup->setObjectName(QLatin1String("qt_edit_menu"));

actionCut = popup->addAction(tr("Cu&t") + ACCEL_KEY(QKeySequence::Cut),
this, SLOT(onCut()));
actionCut = popup->addAction(tr("Cu&t") + ACCEL_KEY(QKeySequence::Cut), this,
SLOT(onCut()));
actionCut->setObjectName(QStringLiteral("edit-cut"));

actionCopy = popup->addAction(tr("&Copy") + ACCEL_KEY(QKeySequence::Copy),
this, SLOT(onCopy()));
this, SLOT(onCopy()));
actionCopy->setObjectName(QStringLiteral("edit-copy"));

actionPaste = popup->addAction(
tr("&Paste") + ACCEL_KEY(QKeySequence::Paste), this, SLOT(onPaste()));
actionPaste = popup->addAction(tr("&Paste") + ACCEL_KEY(QKeySequence::Paste),
this, SLOT(onPaste()));
actionPaste->setObjectName(QStringLiteral("edit-paste"));

actionDelete = popup->addAction(
Expand All @@ -66,7 +66,7 @@ SchematicName::SchematicName(QGraphicsItem *parent, double width, double height)

actionSelectAll =
popup->addAction(tr("Select &All") + ACCEL_KEY(QKeySequence::SelectAll),
this, SLOT(onSelectAll()));
this, SLOT(onSelectAll()));
actionSelectAll->setObjectName(QStringLiteral("select-all"));

connect(document(), SIGNAL(contentsChanged()), this,
Expand Down Expand Up @@ -194,8 +194,8 @@ void SchematicName::onCut() {
QString plainText = toPlainText();

if (cursor.hasSelection()) {
int p = cursor.selectionStart();
int n = cursor.selectionEnd() - p;
int p = cursor.selectionStart();
int n = cursor.selectionEnd() - p;
QString selection = plainText.mid(p, n);
clipboard->setText(selection);
plainText.remove(p, n);
Expand Down Expand Up @@ -228,7 +228,7 @@ void SchematicName::onPaste() {
QTextCursor cursor = textCursor();
QString plainText = toPlainText();
QString clipboardText = clipboard->text();
clipboardText.remove(QRegExp("[\\n\\r]")); // remove all newlines
clipboardText.remove(QRegExp("[\\n\\r]")); // remove all newlines

int n, p = cursor.position();
if (cursor.hasSelection()) {
Expand All @@ -252,8 +252,8 @@ void SchematicName::onDelete() {
QString plainText = toPlainText();

if (cursor.hasSelection()) {
int p = cursor.selectionStart();
int n = cursor.selectionEnd() - p;
int p = cursor.selectionStart();
int n = cursor.selectionEnd() - p;
plainText.remove(p, n);
acceptName(plainText);
cursor.setPosition(p);
Expand Down Expand Up @@ -303,10 +303,8 @@ void SchematicThumbnailToggle::paint(QPainter *painter,
if (m_isDown)
pixmap = offIcon.pixmap(sourceRect.size());
else
pixmap = onIcon.pixmap(sourceRect.size());
sourceRect = QRect(0, 0, sourceRect.width() * getDevPixRatio(),
sourceRect.height() * getDevPixRatio());
painter->drawPixmap(rect, pixmap, sourceRect);
pixmap = onIcon.pixmap(sourceRect.size());
painter->drawPixmap(rect, pixmap);
}

//--------------------------------------------------------
Expand Down Expand Up @@ -424,9 +422,7 @@ void SchematicToggle::paint(QPainter *painter,
QRect sourceRect =
scene()->views()[0]->matrix().mapRect(QRect(0, 0, 18, 17));
QPixmap redPm = pix.pixmap(sourceRect.size());
QRect newRect = QRect(0, 0, sourceRect.width() * getDevPixRatio(),
sourceRect.height() * getDevPixRatio());
painter->drawPixmap(rect, redPm, newRect);
painter->drawPixmap(rect, redPm);
} else if (!m_imageOff.isNull()) {
QPen pen(m_colorOn);
pen.setWidthF(0.5);
Expand All @@ -437,9 +433,7 @@ void SchematicToggle::paint(QPainter *painter,
QRect sourceRect =
scene()->views()[0]->matrix().mapRect(QRect(0, 0, 18, 17));
QPixmap redPm = m_imageOff.pixmap(sourceRect.size());
QRect newRect = QRect(0, 0, sourceRect.width() * getDevPixRatio(),
sourceRect.height() * getDevPixRatio());
painter->drawPixmap(rect, redPm, newRect);
painter->drawPixmap(rect, redPm);
}
}

Expand Down Expand Up @@ -493,7 +487,7 @@ void SchematicToggle::contextMenuEvent(QGraphicsSceneContextMenuEvent *cme) {

//--------------------------------------------------------
/*! for Spline Aim and CP toggles
*/
*/
void SchematicToggle_SplineOptions::paint(
QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget) {
Expand All @@ -504,9 +498,7 @@ void SchematicToggle_SplineOptions::paint(
(m_state == 2 && !m_imageOn2.isNull()) ? m_imageOn2 : m_imageOn;
QRect sourceRect = scene()->views()[0]->matrix().mapRect(rect.toRect());
QPixmap redPm = pix.pixmap(sourceRect.size());
QRect newRect = QRect(0, 0, sourceRect.width() * getDevPixRatio(),
sourceRect.height() * getDevPixRatio());
painter->drawPixmap(rect, redPm, newRect);
painter->drawPixmap(rect.toRect(), redPm);
}
painter->setBrush(Qt::NoBrush);
painter->setPen(QColor(180, 180, 180, 255));
Expand All @@ -515,7 +507,7 @@ void SchematicToggle_SplineOptions::paint(

//--------------------------------------------------------
/*! for Spline Aim and CP toggles
*/
*/
void SchematicToggle_SplineOptions::mousePressEvent(
QGraphicsSceneMouseEvent *me) {
SchematicToggle::mousePressEvent(me);
Expand Down Expand Up @@ -561,8 +553,8 @@ void SchematicHandleSpinBox::paint(QPainter *painter,

void SchematicHandleSpinBox::mouseMoveEvent(QGraphicsSceneMouseEvent *me) {
if (m_buttonState == Qt::LeftButton) {
bool increase = false;
int delta = me->screenPos().y() - me->lastScreenPos().y();
bool increase = false;
int delta = me->screenPos().y() - me->lastScreenPos().y();
if (delta < 0) increase = true;
m_delta += abs(delta);
if (m_delta > 5) {
Expand Down Expand Up @@ -844,6 +836,7 @@ void SchematicPort::mouseMoveEvent(QGraphicsSceneMouseEvent *me) {

// Snapping
SchematicPort *linkingTo = searchPort(me->scenePos());

if (!linkingTo) {
for (SchematicLink *ghostLink : m_ghostLinks) {
ghostLink->updateEndPos(me->scenePos());
Expand All @@ -855,8 +848,12 @@ void SchematicPort::mouseMoveEvent(QGraphicsSceneMouseEvent *me) {
m_linkingTo = nullptr;
}
}
// if to be connected something
else if (linkingTo != this) {
// if to be connected something new
else if (linkingTo != this && m_linkingTo != linkingTo) {
if (m_linkingTo) {
m_linkingTo->highLight(false);
m_linkingTo->update();
}
m_linkingTo = linkingTo;
for (SchematicLink *ghostLink : m_ghostLinks) {
ghostLink->updatePath(ghostLink->getStartPort(), linkingTo);
Expand Down Expand Up @@ -1083,13 +1080,13 @@ SchematicNode::~SchematicNode() {}
//--------------------------------------------------------

/*!Reimplements the pure virtual QGraphicsItem::boundingRect() method.
*/
*/
QRectF SchematicNode::boundingRect() const { return QRectF(0, 0, 1, 1); }

//--------------------------------------------------------

/*! Reimplements the pure virtual QGraphicsItem::paint() method.
*/
*/
void SchematicNode::paint(QPainter *painter,
const QStyleOptionGraphicsItem *option,
QWidget *widget) {
Expand Down Expand Up @@ -1123,7 +1120,7 @@ void SchematicNode::paint(QPainter *painter,
//--------------------------------------------------------

/*! Reimplements the QGraphicsItem::mouseMoveEvent() method.
*/
*/
void SchematicNode::mouseMoveEvent(QGraphicsSceneMouseEvent *me) {
QList<QGraphicsItem *> items = scene()->selectedItems();
if (items.empty()) return;
Expand Down Expand Up @@ -1166,7 +1163,7 @@ void SchematicNode::mouseReleaseEvent(QGraphicsSceneMouseEvent *me) {

//--------------------------------------------------------
/* Add a pair (portId, SchematicPort*port) in the mapping
*/
*/
SchematicPort *SchematicNode::addPort(int portId, SchematicPort *port) {
QMap<int, SchematicPort *>::iterator it;
it = m_ports.find(portId);
Expand Down Expand Up @@ -1206,7 +1203,7 @@ SchematicPort *SchematicNode::getPort(int portId) const {

/*! Returns a list of all node connected by links to a SchematicPort identified
* by \b portId.
*/
*/
QList<SchematicNode *> SchematicNode::getLinkedNodes(int portId) const {
QList<SchematicNode *> list;
SchematicPort *port = getPort(portId);
Expand Down
29 changes: 15 additions & 14 deletions toonz/sources/toonzqt/schematicviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,14 @@ void SchematicSceneViewer::mousePressEvent(QMouseEvent *me) {
} else if (m_cursorMode == CursorMode::Hand) {
m_mousePanPoint = m_touchDevice == QTouchDevice::TouchScreen
? mapToScene(me->pos())
: me->pos() * getDevPixRatio();
: me->pos() * getDevicePixelRatio(this);
m_panning = true;
return;
}
} else if (m_buttonState == Qt::MidButton) {
m_mousePanPoint = m_touchDevice == QTouchDevice::TouchScreen
? mapToScene(me->pos())
: me->pos() * getDevPixRatio();
: me->pos() * getDevicePixelRatio(this);
}
bool drawRect = true;
QList<QGraphicsItem *> pointedItems = items(me->pos());
Expand Down Expand Up @@ -291,12 +291,12 @@ void SchematicSceneViewer::mouseMoveEvent(QMouseEvent *me) {
m_buttonState == Qt::MidButton) {
QPointF usePos = m_touchDevice == QTouchDevice::TouchScreen
? mapToScene(me->pos())
: me->pos() * getDevPixRatio();
: me->pos() * getDevicePixelRatio(this);
QPointF deltaPoint = usePos - m_mousePanPoint;
panQt(deltaPoint);
m_mousePanPoint = m_touchDevice == QTouchDevice::TouchScreen
? mapToScene(me->pos())
: me->pos() * getDevPixRatio();
: me->pos() * getDevicePixelRatio(this);
} else {
if (m_cursorMode == CursorMode::Zoom && m_zooming) {
int deltaY = (m_oldWinPos.y() - me->pos().y()) * 10;
Expand Down Expand Up @@ -594,8 +594,9 @@ void SchematicSceneViewer::gestureEvent(QGestureEvent *e) {
}

if (changeFlags & QPinchGesture::CenterPointChanged) {
QPointF centerDelta = (gesture->centerPoint() * getDevPixRatio()) -
(gesture->lastCenterPoint() * getDevPixRatio());
QPointF centerDelta =
(gesture->centerPoint() * getDevicePixelRatio(this)) -
(gesture->lastCenterPoint() * getDevicePixelRatio(this));
if (centerDelta.manhattanLength() > 1) {
// panQt(centerDelta.toPoint());
}
Expand Down Expand Up @@ -630,14 +631,14 @@ void SchematicSceneViewer::touchEvent(QTouchEvent *e, int type) {
}
}
if (m_panning) {
QPointF curPos =
m_touchDevice == QTouchDevice::TouchScreen
? mapToScene(panPoint.pos().toPoint())
: mapToScene(panPoint.pos().toPoint()) * getDevPixRatio();
QPointF lastPos =
m_touchDevice == QTouchDevice::TouchScreen
? mapToScene(panPoint.lastPos().toPoint())
: mapToScene(panPoint.lastPos().toPoint()) * getDevPixRatio();
QPointF curPos = m_touchDevice == QTouchDevice::TouchScreen
? mapToScene(panPoint.pos().toPoint())
: mapToScene(panPoint.pos().toPoint()) *
getDevicePixelRatio(this);
QPointF lastPos = m_touchDevice == QTouchDevice::TouchScreen
? mapToScene(panPoint.lastPos().toPoint())
: mapToScene(panPoint.lastPos().toPoint()) *
getDevicePixelRatio(this);
QPointF centerDelta = curPos - lastPos;
panQt(centerDelta);
}
Expand Down
31 changes: 13 additions & 18 deletions toonz/sources/toonzqt/stageschematicnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -763,9 +763,7 @@ void StageSchematicNodePort::paint(QPainter *painter,
else
pixmap = QIcon(":Resources/port_red.svg").pixmap(sourceRect.size());
}
sourceRect = QRect(0, 0, sourceRect.width() * getDevPixRatio(),
sourceRect.height() * getDevPixRatio());
painter->drawPixmap(imgRect, pixmap, sourceRect);
painter->drawPixmap(imgRect, pixmap);
}
}

Expand Down Expand Up @@ -904,8 +902,8 @@ QRectF StageSchematicSplinePort::boundingRect() const {
void StageSchematicSplinePort::paint(QPainter *painter,
const QStyleOptionGraphicsItem *option,
QWidget *widget) {
QRect rect(0, 0, 16, 8);
QRect sourceRect = scene()->views()[0]->matrix().mapRect(rect);
QRect sourceRect =
scene()->views()[0]->matrix().mapRect(boundingRect().toRect());
QPixmap pixmap;

if (!m_parent->isParentPort()) {
Expand All @@ -921,9 +919,7 @@ void StageSchematicSplinePort::paint(QPainter *painter,
static QIcon splineParentIcon(":Resources/spline_parent_port.svg");
pixmap = splineParentIcon.pixmap(sourceRect.size());
}
sourceRect = QRect(0, 0, sourceRect.width() * getDevPixRatio(),
sourceRect.height() * getDevPixRatio());
painter->drawPixmap(rect, pixmap, sourceRect);
painter->drawPixmap(boundingRect().toRect(), pixmap);
}

//--------------------------------------------------------
Expand Down Expand Up @@ -1560,11 +1556,11 @@ void StageSchematicNode::onHandleReleased() {
StageSchematicPegbarNode::StageSchematicPegbarNode(StageSchematicScene *scene,
TStageObject *pegbar)
: StageSchematicNode(scene, pegbar, 90, 18) {
SchematicViewer *viewer = scene->getSchematicViewer();
std::string name = m_stageObject->getFullName();
std::string id = m_stageObject->getId().toString();
m_name = QString::fromStdString(name);
m_nameItem = new SchematicName(this, 72, 20);
SchematicViewer *viewer = scene->getSchematicViewer();
std::string name = m_stageObject->getFullName();
std::string id = m_stageObject->getId().toString();
m_name = QString::fromStdString(name);
m_nameItem = new SchematicName(this, 72, 20);
m_nameItem->setDefaultTextColor(viewer->getTextColor());
m_nameItem->setName(m_name);
m_nameItem->setPos(16, -1);
Expand Down Expand Up @@ -2008,8 +2004,8 @@ StageSchematicCameraNode::StageSchematicCameraNode(StageSchematicScene *scene,
TStageObject *pegbar)
: StageSchematicNode(scene, pegbar, 90, 18) {
SchematicViewer *viewer = scene->getSchematicViewer();
std::string name = m_stageObject->getFullName();
m_name = QString::fromStdString(name);
std::string name = m_stageObject->getFullName();
m_name = QString::fromStdString(name);

m_nameItem = new SchematicName(this, 54, 20);
m_nameItem->setDefaultTextColor(viewer->getTextColor());
Expand Down Expand Up @@ -2089,8 +2085,8 @@ StageSchematicSplineNode::StageSchematicSplineNode(StageSchematicScene *scene,
TStageObjectSpline *spline)
: SchematicNode(scene), m_spline(spline), m_isOpened(false) {
SchematicViewer *viewer = scene->getSchematicViewer();
m_width = 90;
m_height = 18;
m_width = 90;
m_height = 18;
assert(spline);

m_dock = new StageSchematicSplineDock(this, true, eStageSplinePort);
Expand Down Expand Up @@ -2162,7 +2158,6 @@ void StageSchematicSplineNode::setSchematicNodePos(const QPointF &pos) const {

QPixmap StageSchematicSplineNode::getPixmap() {
return IconGenerator::instance()->getIcon(m_spline);
return QPixmap();
}

//--------------------------------------------------------
Expand Down
55 changes: 32 additions & 23 deletions toonz/sources/toonzqt/swatchviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <QCoreApplication>

#include <QDebug>
#include <QGuiApplication>

using namespace TFxUtil;

Expand Down Expand Up @@ -162,9 +163,9 @@ TRaster32P createCrossIcon() {
//! Disegna una freccia lunga \b len pixel.
/*!La punta della freccia si trova a coordinate (0,ly/2), la coda a
* (len-1,ly/2).
*/
*/
TRaster32P createArrowShape(int len) {
int d = 5;
int d = 5;
if (len < d) len = d;
TPixel32 c0(210, 210, 210);
TPixel32 c1(10, 10, 10);
Expand Down Expand Up @@ -557,11 +558,11 @@ void SwatchViewer::updateRaster() {
assert(i0 != i1);
assert(0 <= i0 && i0 < (int)m_points.size());
assert(0 <= i1 && i1 < (int)m_points.size());
TPoint p0 = world2win(m_points[i0].m_param->getValue(m_frame));
TPoint p1 = world2win(m_points[i1].m_param->getValue(m_frame));
TPoint delta = p1 - p0;
int len = tround(sqrt((double)(delta * delta)));
double phi = 0;
TPoint p0 = world2win(m_points[i0].m_param->getValue(m_frame));
TPoint p1 = world2win(m_points[i1].m_param->getValue(m_frame));
TPoint delta = p1 - p0;
int len = tround(sqrt((double)(delta * delta)));
double phi = 0;
if (len > 0) phi = atan2((double)delta.y, (double)delta.x) * M_180_PI;

if (len > 500) {
Expand Down Expand Up @@ -774,12 +775,12 @@ void SwatchViewer::wheelEvent(QWheelEvent *event) {

default: // Qt::MouseEventSynthesizedByQt,
// Qt::MouseEventSynthesizedByApplication
{
std::cout << "not supported event: Qt::MouseEventSynthesizedByQt, "
"Qt::MouseEventSynthesizedByApplication"
<< std::endl;
break;
}
{
std::cout << "not supported event: Qt::MouseEventSynthesizedByQt, "
"Qt::MouseEventSynthesizedByApplication"
<< std::endl;
break;
}

} // end switch

Expand Down Expand Up @@ -1012,10 +1013,9 @@ bool SwatchViewer::event(QEvent *e) {
}
*/

if (e->type() == QEvent::Gesture &&
CommandManager::instance()
->getAction(MI_TouchGestureControl)
->isChecked()) {
if (e->type() == QEvent::Gesture && CommandManager::instance()
->getAction(MI_TouchGestureControl)
->isChecked()) {
gestureEvent(static_cast<QGestureEvent *>(e));
return true;
}
Expand Down Expand Up @@ -1056,6 +1056,19 @@ SwatchViewer::ContentRender::ContentRender(TRasterFx *fx, int frame,
SLOT(onCanceled(TThread::RunnableP)),
Qt::QueuedConnection); // Starts will need to come *strictly before*
// cancels

m_info.m_isSwatch = true;
m_info.m_affine = m_aff;
m_info.m_cameraBox = TRectD(-0.5 * TPointD(m_size.lx, m_size.ly),
TDimensionD(m_size.lx, m_size.ly));

if (m_fx->getAlias(m_frame, m_info).find("plasticDeformerFx") !=
std::string::npos &&
QThread::currentThread() == qGuiApp->thread()) {
m_info.m_offScreenSurface.reset(new QOffscreenSurface());
m_info.m_offScreenSurface->setFormat(QSurfaceFormat::defaultFormat());
m_info.m_offScreenSurface->create();
}
}

//-----------------------------------------------------------------------------
Expand All @@ -1075,13 +1088,9 @@ void SwatchViewer::ContentRender::run() {
m_viewer->m_renderer.declareRenderStart(renderId);
m_viewer->m_renderer.declareFrameStart(m_frame);

TRenderSettings info;
info.m_isSwatch = true;
info.m_affine = m_aff;

TTile tile;
m_fx->allocateAndCompute(tile, -0.5 * TPointD(m_size.lx, m_size.ly), m_size,
0, (double)m_frame, info);
0, (double)m_frame, m_info);
m_raster = tile.getRaster();

m_viewer->m_renderer.declareFrameEnd(m_frame);
Expand Down Expand Up @@ -1155,7 +1164,7 @@ void SwatchCacheManager::setFx(const TFxP &fx) {

// In the zerary case, extract the actual fx
TZeraryColumnFx *zcfx = dynamic_cast<TZeraryColumnFx *>(child);
if (zcfx) child = zcfx->getZeraryFx();
if (zcfx) child = zcfx->getZeraryFx();

assert(child && child->getIdentifier() != 0);
m_childrenFxIds.insert(child->getIdentifier());
Expand Down
96 changes: 48 additions & 48 deletions toonz/sources/translations/chinese/image.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="zh_CN" sourcelanguage="en">
<TS version="2.1" language="zh_CN" sourcelanguage="en_US">
<context>
<name>AviWriterProperties</name>
<message>
Expand All @@ -19,150 +19,150 @@
<message>
<location filename="../../image/exr/tiio_exr.cpp" line="227"/>
<source>Bits Per Pixel</source>
<translation type="unfinished"></translation>
<translation>像素位数</translation>
</message>
<message>
<location filename="../../image/exr/tiio_exr.cpp" line="228"/>
<source>48(RGB Half Float)</source>
<translation type="unfinished"></translation>
<translation>48(RGB 半浮点)</translation>
</message>
<message>
<location filename="../../image/exr/tiio_exr.cpp" line="229"/>
<source>64(RGBA Half Float)</source>
<translation type="unfinished"></translation>
<translation>64(RGBA 半浮点)</translation>
</message>
<message>
<location filename="../../image/exr/tiio_exr.cpp" line="231"/>
<source>Compression Type</source>
<translation type="unfinished">压缩方式</translation>
<translation>压缩方式</translation>
</message>
<message>
<location filename="../../image/exr/tiio_exr.cpp" line="233"/>
<source>No compression</source>
<translation type="unfinished"></translation>
<translation>不压缩</translation>
</message>
<message>
<location filename="../../image/exr/tiio_exr.cpp" line="236"/>
<source>Run Length Encoding (RLE)</source>
<translation type="unfinished"></translation>
<translation>行程编码</translation>
</message>
<message>
<location filename="../../image/exr/tiio_exr.cpp" line="239"/>
<source>ZIP compression per Scanline (ZIPS)</source>
<translation type="unfinished"></translation>
<translation></translation>
</message>
<message>
<location filename="../../image/exr/tiio_exr.cpp" line="242"/>
<source>ZIP compression per scanline band (ZIP)</source>
<translation type="unfinished"></translation>
<translation></translation>
</message>
<message>
<location filename="../../image/exr/tiio_exr.cpp" line="245"/>
<source>PIZ-based wavelet compression (PIZ)</source>
<translation type="unfinished"></translation>
<translation></translation>
</message>
<message>
<location filename="../../image/exr/tiio_exr.cpp" line="247"/>
<source>Storage Type</source>
<translation type="unfinished"></translation>
<translation>存储类型</translation>
</message>
<message>
<location filename="../../image/exr/tiio_exr.cpp" line="248"/>
<source>Scan-line based</source>
<translation type="unfinished"></translation>
<translation>基于扫描线</translation>
</message>
<message>
<location filename="../../image/exr/tiio_exr.cpp" line="249"/>
<source>Tile based</source>
<translation type="unfinished"></translation>
<translation>基于块</translation>
</message>
</context>
<context>
<name>GifWriterProperties</name>
<message>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="307"/>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="310"/>
<source>Global Palette</source>
<translation type="unfinished"></translation>
<translation>全局调色板</translation>
</message>
<message>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="308"/>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="311"/>
<source>Global Palette + Sierra Dither</source>
<translation type="unfinished"></translation>
<translation>全局调色板 + Sierra抖动</translation>
</message>
<message>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="309"/>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="312"/>
<source>Global Palette + Bayer2 Dither</source>
<translation type="unfinished"></translation>
<translation>全局调色版 + 拜尔2抖动</translation>
</message>
<message>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="310"/>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="313"/>
<source>Global Palette + Bayer1 Dither</source>
<translation type="unfinished"></translation>
<translation>全局调色版 + 拜尔1抖动</translation>
</message>
<message>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="311"/>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="314"/>
<source>Diff Palette</source>
<translation type="unfinished"></translation>
<translation>差异调色板</translation>
</message>
<message>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="312"/>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="315"/>
<source>Diff Palette + Sierra Dither</source>
<translation type="unfinished"></translation>
<translation>差异调色板 + Sierra抖动</translation>
</message>
<message>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="313"/>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="316"/>
<source>Diff Palette + Bayer2 Dither</source>
<translation type="unfinished"></translation>
<translation>差异调色板 + 拜尔1抖动</translation>
</message>
<message>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="314"/>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="317"/>
<source>Diff Palette + Bayer1 Dither</source>
<translation type="unfinished"></translation>
<translation>差异调色板 + 拜尔1抖动</translation>
</message>
<message>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="315"/>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="318"/>
<source>New Pal Per Frame</source>
<translation type="unfinished"></translation>
<translation>新建每帧调色板</translation>
</message>
<message>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="316"/>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="319"/>
<source>New Pal Per Frame + Sierra Dither</source>
<translation type="unfinished"></translation>
<translation>新建每帧调色板 + Sierra抖动</translation>
</message>
<message>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="317"/>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="320"/>
<source>New Pal Per Frame + Bayer2 Dither</source>
<translation type="unfinished"></translation>
<translation>新建每帧调色板 + 拜尔2抖动</translation>
</message>
<message>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="318"/>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="321"/>
<source>New Pal Per Frame + Bayer1 Dither</source>
<translation type="unfinished"></translation>
<translation>新建每帧调色板 + 拜尔1抖动</translation>
</message>
<message>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="319"/>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="322"/>
<source>Opaque, Dither, 256 Colors Only</source>
<translation type="unfinished"></translation>
<translation>不透明,抖动,仅256色</translation>
</message>
<message>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="328"/>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="335"/>
<source>Scale</source>
<translation>缩放</translation>
</message>
<message>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="329"/>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="336"/>
<source>Looping</source>
<translation>循环</translation>
</message>
<message>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="330"/>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="337"/>
<source>Mode</source>
<translation type="unfinished"></translation>
<translation>模式</translation>
</message>
<message>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="331"/>
<location filename="../../image/ffmpeg/tiio_gif.cpp" line="338"/>
<source>Max Colors</source>
<translation type="unfinished"></translation>
<translation>最大色数</translation>
</message>
<message>
<source>Generate Palette</source>
Expand Down Expand Up @@ -195,7 +195,7 @@
<message>
<location filename="../../image/ffmpeg/tiio_ffmpeg.cpp" line="213"/>
<source>FFmpeg returned error-code: %1</source>
<translation type="unfinished"></translation>
<translation>FFmpeg 返回的错误编码: %1</translation>
</message>
<message>
<location filename="../../image/ffmpeg/tiio_ffmpeg.cpp" line="217"/>
Expand Down Expand Up @@ -365,7 +365,7 @@ Please try raising the FFmpeg timeout in Preferences.</source>
<message>
<location filename="../../image/tga/tiio_tga.cpp" line="523"/>
<source>Bits Per Pixel</source>
<translation>像素的位数</translation>
<translation>像素位数</translation>
</message>
<message>
<location filename="../../image/tga/tiio_tga.cpp" line="524"/>
Expand Down Expand Up @@ -403,7 +403,7 @@ Please try raising the FFmpeg timeout in Preferences.</source>
<message>
<location filename="../../image/tif/tiio_tif.cpp" line="732"/>
<source>Bits Per Pixel</source>
<translation>像素的位数</translation>
<translation>像素位数</translation>
</message>
<message>
<location filename="../../image/tif/tiio_tif.cpp" line="733"/>
Expand Down
12 changes: 6 additions & 6 deletions toonz/sources/translations/chinese/tnztools.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="zh_CN" sourcelanguage="en">
<TS version="2.1" language="zh_CN" sourcelanguage="en_US">
<context>
<name>ArrowToolOptionsBox</name>
<message>
Expand Down Expand Up @@ -745,7 +745,7 @@
</message>
<message>
<source>Lock Alpha</source>
<translation type="unfinished">锁定透明度</translation>
<translation>锁定透明度</translation>
</message>
</context>
<context>
Expand Down Expand Up @@ -815,7 +815,7 @@
Do you want to continue?</source>
<translation>当前列已经包含了一个骨架组。替换它会换掉全部现有的顶点动画。

您要继续吗?</translation>
你要继续吗?</translation>
</message>
<message>
<source>Ok</source>
Expand Down Expand Up @@ -875,7 +875,7 @@ Do you want to continue?</source>
Do you want to proceed?</source>
<translation>之前的顶点名称会被放弃,所有关联的关键帧也会丢失。

您要继续吗?</translation>
你要继续吗?</translation>
</message>
<message>
<source>Edit Mesh</source>
Expand Down Expand Up @@ -1061,7 +1061,7 @@ Do you want to proceed?</source>
</message>
<message>
<source>Rotate</source>
<translation type="unfinished"></translation>
<translation>旋转</translation>
</message>
</context>
<context>
Expand Down Expand Up @@ -1616,7 +1616,7 @@ moved to the end of the first page of the palette.</source>
</message>
<message>
<source>Lock Alpha</source>
<translation type="unfinished">锁定透明度</translation>
<translation>锁定透明度</translation>
</message>
</context>
<context>
Expand Down
Loading