Merge remote-tracking branch 'origin/master' into autopaint_autoapply_undo

This commit is contained in:
shun_iwasawa 2017-11-09 15:27:53 +09:00
commit 9a458198b4
57 changed files with 274 additions and 236 deletions

View file

@ -60,42 +60,12 @@ enum {
NormalEraserCursor,
RectEraserCursor,
RectEraserCursorWhite,
FillCursorWhite,
TapeCursorWhite,
PickerCursorWhite,
PickerCursorWhiteLine,
PickerCursorWhiteArea,
PickerCursorOrganize,
PickerCursorWhiteOrganize,
PickerRGB,
PickerRGBWhite,
FillCursorF,
FillCursorFWhite,
FillCursorP,
FillCursorPWhite,
FillCursorR,
FillCursorRWhite,
FillCursorA,
FillCursorAWhite,
FillCursorAF,
FillCursorAFWhite,
FillCursorAP,
FillCursorAPWhite,
FillCursorAR,
FillCursorARWhite,
FillCursorL,
FillCursorLWhite,
FillCursorLF,
FillCursorLFWhite,
FillCursorLP,
FillCursorLPWhite,
FillCursorLR,
FillCursorLRWhite,
MoveEWCursor,
MoveNSCursor,
@ -105,7 +75,15 @@ enum {
ScaleHVCursor,
FxGadgetCursor,
RulerModifyCursor,
RulerNewCursor
RulerNewCursor,
// extra options for decorating the cursor
Ex_Negate = 0x100, // used for black bg
Ex_FreeHand = 0x200,
Ex_PolyLine = 0x400,
Ex_Rectangle = 0x800,
Ex_Line = 0x1000,
Ex_Area = 0x2000
};
} // namespace

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 314 B

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 467 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 506 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 538 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 509 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 538 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 509 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 535 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 490 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 480 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 512 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 487 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 514 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 486 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 511 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 416 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 322 B

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 338 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 355 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 340 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 359 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 345 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 360 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 341 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 304 B

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 335 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 332 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 299 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 B

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 310 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 444 B

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 555 B

View file

@ -2489,7 +2489,9 @@ BrushData::BrushData()
, m_join(0)
, m_miter(0)
, m_modifierSize(0.0)
, m_modifierOpacity(0.0) {}
, m_modifierOpacity(0.0)
, m_modifierEraser(0.0)
, m_modifierLockAlpha(0.0) {}
//----------------------------------------------------------------------------------------------------------
@ -2510,7 +2512,9 @@ BrushData::BrushData(const std::wstring &name)
, m_join(0)
, m_miter(0)
, m_modifierSize(0.0)
, m_modifierOpacity(0.0) {}
, m_modifierOpacity(0.0)
, m_modifierEraser(0.0)
, m_modifierLockAlpha(0.0) {}
//----------------------------------------------------------------------------------------------------------
@ -2560,6 +2564,12 @@ void BrushData::saveData(TOStream &os) {
os.openChild("Modifier_Opacity");
os << m_modifierOpacity;
os.closeChild();
os.openChild("Modifier_Eraser");
os << (int)m_modifierEraser;
os.closeChild();
os.openChild("Modifier_LockAlpha");
os << (int)m_modifierLockAlpha;
os.closeChild();
}
//----------------------------------------------------------------------------------------------------------
@ -2599,6 +2609,10 @@ void BrushData::loadData(TIStream &is) {
is >> m_modifierSize, is.matchEndTag();
else if (tagName == "Modifier_Opacity")
is >> m_modifierOpacity, is.matchEndTag();
else if (tagName == "Modifier_Eraser")
is >> val, m_modifierEraser = val, is.matchEndTag();
else if (tagName == "Modifier_LockAlpha")
is >> val, m_modifierLockAlpha = val, is.matchEndTag();
else
is.skipCurrentTag();
}

View file

@ -42,6 +42,7 @@ struct BrushData final : public TPersist {
bool m_selective, m_pencil, m_breakAngles, m_pressure;
int m_cap, m_join, m_miter;
double m_modifierSize, m_modifierOpacity;
bool m_modifierEraser, m_modifierLockAlpha;
BrushData();
BrushData(const std::wstring &name);

View file

@ -9,6 +9,7 @@
#include <assert.h>
#include <map>
#include <QDebug>
#include <QPainter>
namespace {
@ -22,7 +23,7 @@ const struct {
{ToolCursor::CutterCursor, "cutter", 6, 24}, // 12,20},
{ToolCursor::EraserCursor, "eraser", 7, 21}, // 15,16},
{ToolCursor::DistortCursor, "selection_distort", 11, 6},
{ToolCursor::FillCursor, "fill", 6, 23},
{ToolCursor::FillCursor, "fill", 3, 26},
{ToolCursor::MoveCursor, "move", 15, 15},
{ToolCursor::MoveEWCursor, "move_ew", 15, 15},
{ToolCursor::MoveNSCursor, "move_ns", 15, 15},
@ -54,7 +55,7 @@ const struct {
{ToolCursor::ScaleGlobalCursor, "scale_global", 15, 15},
{ToolCursor::ScaleHVCursor, "scale_hv", 15, 15},
{ToolCursor::StrokeSelectCursor, "stroke_select", 11, 6},
{ToolCursor::TapeCursor, "tape", 9, 23},
{ToolCursor::TapeCursor, "tape", 4, 23},
{ToolCursor::TrackerCursor, "tracker", 12, 15},
{ToolCursor::TypeInCursor, "type_in", 16, 19},
{ToolCursor::TypeOutCursor, "type_out", 16, 19},
@ -65,41 +66,12 @@ const struct {
{ToolCursor::SplineEditorCursor, "stroke_select", 11, 6},
{ToolCursor::SplineEditorCursorAdd, "selection_add", 11, 6},
{ToolCursor::SplineEditorCursorSelect, "selection_convert", 11, 6},
{ToolCursor::NormalEraserCursor, "normaleraser", 10, 21},
{ToolCursor::RectEraserCursor, "recteraser", 10, 21},
{ToolCursor::RectEraserCursorWhite, "recteraser_white", 10, 21},
{ToolCursor::FillCursorWhite, "fill_white", 6, 23},
{ToolCursor::TapeCursorWhite, "tape_white", 9, 23},
{ToolCursor::PickerCursorWhiteLine, "picker_style_white_line", 7, 22},
{ToolCursor::PickerCursorWhiteArea, "picker_style_white_area", 7, 22},
{ToolCursor::PickerCursorWhite, "picker_style_white", 7, 22},
{ToolCursor::NormalEraserCursor, "normaleraser", 3, 26},
{ToolCursor::RectEraserCursor, "recteraser", 3, 26},
{ToolCursor::PickerCursorOrganize, "picker_style_organize", 7, 22},
{ToolCursor::PickerCursorWhiteOrganize, "picker_style_white_organize", 7,
22},
{ToolCursor::PickerRGB, "picker_rgb", 7, 22},
{ToolCursor::PickerRGBWhite, "picker_rgb_white", 7, 22},
{ToolCursor::FillCursorF, "fill_f", 6, 23},
{ToolCursor::FillCursorFWhite, "fill_f_white", 6, 23},
{ToolCursor::FillCursorP, "fill_p", 6, 23},
{ToolCursor::FillCursorPWhite, "fill_p_white", 6, 23},
{ToolCursor::FillCursorR, "fill_r", 6, 23},
{ToolCursor::FillCursorRWhite, "fill_r_white", 6, 23},
{ToolCursor::FillCursorA, "fill_a", 6, 23},
{ToolCursor::FillCursorAWhite, "fill_a_white", 6, 23},
{ToolCursor::FillCursorAF, "fill_a_f", 6, 23},
{ToolCursor::FillCursorAFWhite, "fill_a_f_white", 6, 23},
{ToolCursor::FillCursorAP, "fill_a_p", 6, 23},
{ToolCursor::FillCursorAPWhite, "fill_a_p_white", 6, 23},
{ToolCursor::FillCursorAR, "fill_a_r", 6, 23},
{ToolCursor::FillCursorARWhite, "fill_a_r_white", 6, 23},
{ToolCursor::FillCursorL, "karasu", 6, 23},
{ToolCursor::FillCursorLWhite, "karasu_white", 6, 23},
{ToolCursor::FillCursorLF, "karasu_f", 6, 23},
{ToolCursor::FillCursorLFWhite, "karasu_f_white", 6, 23},
{ToolCursor::FillCursorLP, "karasu_p", 6, 23},
{ToolCursor::FillCursorLPWhite, "karasu_p_white", 6, 23},
{ToolCursor::FillCursorLR, "karasu_r", 6, 23},
{ToolCursor::FillCursorLRWhite, "karasu_r_white", 6, 23},
{ToolCursor::FillCursorL, "karasu", 7, 25},
{ToolCursor::RulerModifyCursor, "ruler_modify", 7, 7},
{ToolCursor::RulerNewCursor, "ruler_new", 7, 7},
{0, 0, 0, 0}};
@ -108,6 +80,16 @@ struct CursorData {
QPixmap pixmap;
int x, y;
};
const struct {
int decorateType;
const char *pixmapFilename;
} decorateInfo[] = {{ToolCursor::Ex_FreeHand, "ex_freehand"},
{ToolCursor::Ex_PolyLine, "ex_polyline"},
{ToolCursor::Ex_Rectangle, "ex_rectangle"},
{ToolCursor::Ex_Line, "ex_line"},
{ToolCursor::Ex_Area, "ex_area"},
{0, 0}};
};
//=============================================================================
@ -126,19 +108,44 @@ public:
return &_instance;
}
void doDecoration(QPixmap &pixmap, int decorationFlag) {
if (decorationFlag == 0) return;
if (decorationFlag > ToolCursor::Ex_Negate) {
QPainter p(&pixmap);
p.setCompositionMode(QPainter::CompositionMode_SourceOver);
for (int i = 0; decorateInfo[i].pixmapFilename; i++)
if (decorationFlag & decorateInfo[i].decorateType) {
QString path =
QString(":Resources/") + decorateInfo[i].pixmapFilename + ".png";
p.drawPixmap(0, 0, QPixmap(path));
}
}
// negate
if (decorationFlag & ToolCursor::Ex_Negate) {
QImage img = pixmap.toImage();
img.invertPixels(QImage::InvertRgb); // leave the alpha channel unchanged
pixmap = QPixmap::fromImage(img);
}
}
const CursorData &getCursorData(int cursorType) {
// se e' gia' in tabella lo restituisco
std::map<int, CursorData>::iterator it;
it = m_cursors.find(cursorType);
if (it != m_cursors.end()) return it->second;
int decorationsFlag = cursorType & ~(0xFF);
int baseCursorType = cursorType & 0xFF;
// provo a cercarlo in cursorInfo[]
int i;
for (i = 0; cursorInfo[i].pixmapFilename; i++)
if (cursorType == cursorInfo[i].cursorType) {
if (baseCursorType == cursorInfo[i].cursorType) {
QString path =
QString(":Resources/") + cursorInfo[i].pixmapFilename + ".png";
CursorData data;
data.pixmap = QPixmap(path);
if (decorationsFlag != 0) doDecoration(data.pixmap, decorationsFlag);
data.x = cursorInfo[i].x;
data.y = cursorInfo[i].y;
it = m_cursors.insert(std::make_pair(cursorType, data)).first;

View file

@ -1775,48 +1775,23 @@ FillTool::FillTool(int targetType)
//-----------------------------------------------------------------------------
int FillTool::getCursorId() const {
bool isBlackBG = ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg;
if (m_colorType.getValue() == LINES) {
if (m_fillType.getValue() == NORMALFILL)
return (isBlackBG) ? ToolCursor::FillCursorLWhite
: ToolCursor::FillCursorL;
else if (m_fillType.getValue() == FREEHANDFILL)
return (isBlackBG) ? ToolCursor::FillCursorLFWhite
: ToolCursor::FillCursorLF;
else if (m_fillType.getValue() == POLYLINEFILL)
return (isBlackBG) ? ToolCursor::FillCursorLPWhite
: ToolCursor::FillCursorLP;
else // Rect
return (isBlackBG) ? ToolCursor::FillCursorLRWhite
: ToolCursor::FillCursorLR;
} else if (m_colorType.getValue() == AREAS) {
if (m_fillType.getValue() == NORMALFILL)
return (isBlackBG) ? ToolCursor::FillCursorAWhite
: ToolCursor::FillCursorA;
else if (m_fillType.getValue() == FREEHANDFILL)
return (isBlackBG) ? ToolCursor::FillCursorAFWhite
: ToolCursor::FillCursorAF;
else if (m_fillType.getValue() == POLYLINEFILL)
return (isBlackBG) ? ToolCursor::FillCursorAPWhite
: ToolCursor::FillCursorAP;
else // Rect
return (isBlackBG) ? ToolCursor::FillCursorARWhite
: ToolCursor::FillCursorAR;
} else // line&areas
{
if (m_fillType.getValue() == NORMALFILL)
return (isBlackBG) ? ToolCursor::FillCursorWhite : ToolCursor::FillCursor;
else if (m_fillType.getValue() == FREEHANDFILL)
return (isBlackBG) ? ToolCursor::FillCursorFWhite
: ToolCursor::FillCursorF;
else if (m_fillType.getValue() == POLYLINEFILL)
return (isBlackBG) ? ToolCursor::FillCursorPWhite
: ToolCursor::FillCursorP;
else // Rect
return (isBlackBG) ? ToolCursor::FillCursorRWhite
: ToolCursor::FillCursorR;
int ret;
if (m_colorType.getValue() == LINES)
ret = ToolCursor::FillCursorL;
else {
ret = ToolCursor::FillCursor;
if (m_colorType.getValue() == AREAS) ret = ret | ToolCursor::Ex_Area;
}
if (m_fillType.getValue() == FREEHANDFILL)
ret = ret | ToolCursor::Ex_FreeHand;
else if (m_fillType.getValue() == POLYLINEFILL)
ret = ret | ToolCursor::Ex_PolyLine;
else if (m_fillType.getValue() == RECTFILL)
ret = ret | ToolCursor::Ex_Rectangle;
if (ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg)
ret = ret | ToolCursor::Ex_Negate;
return ret;
}
//-----------------------------------------------------------------------------

View file

@ -51,6 +51,8 @@ TEnv::DoubleVar FullcolorMinOpacity("FullcolorMinOpacity", 100);
TEnv::DoubleVar FullcolorMaxOpacity("FullcolorMaxOpacity", 100);
TEnv::DoubleVar FullcolorModifierSize("FullcolorModifierSize", 0);
TEnv::DoubleVar FullcolorModifierOpacity("FullcolorModifierOpacity", 100);
TEnv::IntVar FullcolorModifierEraser("FullcolorModifierEraser", 0);
TEnv::IntVar FullcolorModifierLockAlpha("FullcolorModifierLockAlpha", 0);
//----------------------------------------------------------------------------------
@ -115,6 +117,8 @@ FullColorBrushTool::FullColorBrushTool(std::string name)
, m_hardness("Hardness:", 0, 100, 100)
, m_modifierSize("ModifierSize", -3, 3, 0, true)
, m_modifierOpacity("ModifierOpacity", 0, 100, 100, true)
, m_modifierEraser("ModifierEraser", false)
, m_modifierLockAlpha("ModifierLockAlpha", false)
, m_preset("Preset:")
, m_minCursorThick(0)
, m_maxCursorThick(0)
@ -132,6 +136,8 @@ FullColorBrushTool::FullColorBrushTool(std::string name)
m_prop.bind(m_opacity);
m_prop.bind(m_modifierSize);
m_prop.bind(m_modifierOpacity);
m_prop.bind(m_modifierEraser);
m_prop.bind(m_modifierLockAlpha);
m_prop.bind(m_pressure);
m_prop.bind(m_preset);
@ -172,6 +178,8 @@ void FullColorBrushTool::updateTranslation() {
m_preset.setQStringName(tr("Preset:"));
m_modifierSize.setQStringName(tr("Size"));
m_modifierOpacity.setQStringName(tr("Opacity"));
m_modifierEraser.setQStringName(tr("Eraser"));
m_modifierLockAlpha.setQStringName(tr("Lock Alpha"));
}
//---------------------------------------------------------------------------------------------------
@ -191,6 +199,8 @@ void FullColorBrushTool::onActivate() {
m_hardness.setValue(FullcolorBrushHardness);
m_modifierSize.setValue(FullcolorModifierSize);
m_modifierOpacity.setValue(FullcolorModifierOpacity);
m_modifierEraser.setValue(FullcolorModifierEraser ? true : false);
m_modifierLockAlpha.setValue(FullcolorModifierLockAlpha ? true : false);
}
setWorkAndBackupImages();
@ -568,6 +578,8 @@ bool FullColorBrushTool::onPropertyChanged(std::string propertyName) {
FullcolorMaxOpacity = m_opacity.getValue().second;
FullcolorModifierSize = m_modifierSize.getValue();
FullcolorModifierOpacity = m_modifierOpacity.getValue();
FullcolorModifierEraser = m_modifierEraser.getValue() ? 1 : 0;
FullcolorModifierLockAlpha = m_modifierLockAlpha.getValue() ? 1 : 0;
updateCurrentStyle();
@ -625,6 +637,8 @@ void FullColorBrushTool::loadPreset() {
m_pressure.setValue(preset.m_pressure);
m_modifierSize.setValue(preset.m_modifierSize);
m_modifierOpacity.setValue(preset.m_modifierOpacity);
m_modifierEraser.setValue(preset.m_modifierEraser);
m_modifierLockAlpha.setValue(preset.m_modifierLockAlpha);
} catch (...) {
}
}
@ -643,6 +657,8 @@ void FullColorBrushTool::addPreset(QString name) {
preset.m_pressure = m_pressure.getValue();
preset.m_modifierSize = m_modifierSize.getValue();
preset.m_modifierOpacity = m_modifierOpacity.getValue();
preset.m_modifierEraser = m_modifierEraser.getValue();
preset.m_modifierLockAlpha = m_modifierLockAlpha.getValue();
// Pass the preset to the manager
m_presetsManager.addPreset(preset);
@ -821,6 +837,8 @@ void FullColorBrushTool::applyToonzBrushSettings(mypaint::Brush &mypaintBrush) {
double modifierSize = m_modifierSize.getValue() * log(2.0);
double modifierOpacity = 0.01 * m_modifierOpacity.getValue();
bool modifierEraser = m_modifierEraser.getValue();
bool modifierLockAlpha = m_modifierLockAlpha.getValue();
TPixelD color = PixelConverter<TPixelD>::from(m_currentColor);
double colorH = 0.0;
@ -841,6 +859,14 @@ void FullColorBrushTool::applyToonzBrushSettings(mypaint::Brush &mypaintBrush) {
mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_COLOR_H, colorH / 360.0);
mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_COLOR_S, colorS);
mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_COLOR_V, colorV);
if (modifierEraser) {
mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_ERASER, 1.0);
mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_LOCK_ALPHA, 0.0);
} else if (modifierLockAlpha) {
// lock-alpha already disables eraser
mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_LOCK_ALPHA, 1.0);
}
} else {
applyClassicToonzBrushSettings(mypaintBrush);
}

View file

@ -88,6 +88,8 @@ protected:
TDoubleProperty m_hardness;
TDoubleProperty m_modifierSize;
TDoubleProperty m_modifierOpacity;
TBoolProperty m_modifierEraser;
TBoolProperty m_modifierLockAlpha;
TEnumProperty m_preset;
TPixel32 m_currentColor;

View file

@ -690,12 +690,28 @@ void EraserTool::draw() {
//----------------------------------------------------------------------
int EraserTool::getCursorId() const {
int ret;
if (m_eraseType.getValue() == NORMALERASE)
return ToolCursor::NormalEraserCursor;
else if (ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg)
return ToolCursor::RectEraserCursorWhite;
else
return ToolCursor::RectEraserCursor;
ret = ToolCursor::NormalEraserCursor;
else {
ret = ToolCursor::RectEraserCursor;
if (m_eraseType.getValue() == FREEHANDERASE)
ret = ret | ToolCursor::Ex_FreeHand;
else if (m_eraseType.getValue() == POLYLINEERASE)
ret = ret | ToolCursor::Ex_PolyLine;
else if (m_eraseType.getValue() == RECTERASE)
ret = ret | ToolCursor::Ex_Rectangle;
}
if (m_colorType.getValue() == LINES)
ret = ret | ToolCursor::Ex_Line;
else if (m_colorType.getValue() == AREAS)
ret = ret | ToolCursor::Ex_Area;
if (ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg)
ret = ret | ToolCursor::Ex_Negate;
return ret;
}
//----------------------------------------------------------------------

View file

@ -671,10 +671,19 @@ public:
//----------------------------------------------------------------------
int getCursorId() const override {
int ret = ToolCursor::TapeCursor;
if (m_closeType.getValue() == FREEHAND_CLOSE)
ret = ret | ToolCursor::Ex_FreeHand;
else if (m_closeType.getValue() == POLYLINE_CLOSE)
ret = ret | ToolCursor::Ex_PolyLine;
else if (m_closeType.getValue() == RECT_CLOSE)
ret = ret | ToolCursor::Ex_Rectangle;
if (ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg)
return ToolCursor::TapeCursorWhite;
else
return ToolCursor::TapeCursor;
ret = ret | ToolCursor::Ex_Negate;
return ret;
}
//----------------------------------------------------------------------

View file

@ -212,22 +212,20 @@ void StylePickerTool::mouseMove(const TPointD &pos, const TMouseEvent &e) {
}
int StylePickerTool::getCursorId() const {
bool isBlackBG = ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg;
int ret;
/* in case the "organize palette" option is active */
if (m_organizePalette.getValue())
return (isBlackBG) ? ToolCursor::PickerCursorWhiteOrganize
: ToolCursor::PickerCursorOrganize;
if (m_colorType.getValue() == LINES)
return (isBlackBG) ? ToolCursor::PickerCursorWhiteLine
: ToolCursor::PickerCursorLine;
ret = ToolCursor::PickerCursorOrganize;
else if (m_colorType.getValue() == LINES)
ret = ToolCursor::PickerCursorLine;
else if (m_colorType.getValue() == AREAS)
return (isBlackBG) ? ToolCursor::PickerCursorWhiteArea
: ToolCursor::PickerCursorArea;
ret = ToolCursor::PickerCursorArea;
else // line&areas
return (isBlackBG) ? ToolCursor::PickerCursorWhite
: ToolCursor::PickerCursor;
ret = ToolCursor::PickerCursor;
if (ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg)
ret = ret | ToolCursor::Ex_Negate;
return ret;
}
bool StylePickerTool::onPropertyChanged(std::string propertyName) {

View file

@ -44,39 +44,16 @@
<file>Resources/scale_hv.png</file>
<file>Resources/normaleraser.png</file>
<file>Resources/recteraser.png</file>
<file>Resources/recteraser_white.png</file>
<file>Resources/fill_white.png</file>
<file>Resources/tape_white.png</file>
<file>Resources/picker_style_white_line.png</file>
<file>Resources/picker_style_white_area.png</file>
<file>Resources/picker_style_white.png</file>
<file>Resources/picker_style_organize.png</file>
<file>Resources/picker_style_white_organize.png</file>
<file>Resources/picker_rgb.png</file>
<file>Resources/picker_rgb_white.png</file>
<file>Resources/fill_f.png</file>
<file>Resources/fill_f_white.png</file>
<file>Resources/fill_p.png</file>
<file>Resources/fill_p_white.png</file>
<file>Resources/fill_r.png</file>
<file>Resources/fill_r_white.png</file>
<file>Resources/fill_a.png</file>
<file>Resources/fill_a_white.png</file>
<file>Resources/fill_a_f.png</file>
<file>Resources/fill_a_f_white.png</file>
<file>Resources/fill_a_p.png</file>
<file>Resources/fill_a_p_white.png</file>
<file>Resources/fill_a_r.png</file>
<file>Resources/fill_a_r_white.png</file>
<file>Resources/karasu.png</file>
<file>Resources/karasu_white.png</file>
<file>Resources/karasu_f.png</file>
<file>Resources/karasu_f_white.png</file>
<file>Resources/karasu_p.png</file>
<file>Resources/karasu_p_white.png</file>
<file>Resources/karasu_r.png</file>
<file>Resources/karasu_r_white.png</file>
<file>Resources/ruler_modify.png</file>
<file>Resources/ruler_new.png</file>
<file>Resources/ex_freehand.png</file>
<file>Resources/ex_polyline.png</file>
<file>Resources/ex_rectangle.png</file>
<file>Resources/ex_line.png</file>
<file>Resources/ex_area.png</file>
</qresource>
</RCC>

View file

@ -306,8 +306,10 @@ void ToolOptionControlBuilder::visit(TBoolProperty *p) {
std::string actionName = "A_ToolOption_" + p->getId();
QAction *a = CommandManager::instance()->getAction(actionName.c_str());
if (a) {
a->setCheckable(true);
control->addAction(a);
QObject::connect(a, SIGNAL(triggered()), control, SLOT(doClick()));
QObject::connect(a, SIGNAL(triggered(bool)), control,
SLOT(doClick(bool)));
}
}
hLayout()->addSpacing(5);
@ -553,10 +555,11 @@ ArrowToolOptionsBox::ArrowToolOptionsBox(
m_lockNSCenterCheckbox =
new ToolOptionCheckbox(m_tool, lockProp, toolHandle, this);
TBoolProperty *prop =
TBoolProperty *globalKeyProp =
dynamic_cast<TBoolProperty *>(m_pg->getProperty("Global Key"));
if (prop)
m_globalKey = new ToolOptionCheckbox(m_tool, prop, toolHandle, this);
if (globalKeyProp)
m_globalKey =
new ToolOptionCheckbox(m_tool, globalKeyProp, toolHandle, this);
m_lockEWPosCheckbox->setObjectName("EditToolLockButton");
m_lockNSPosCheckbox->setObjectName("EditToolLockButton");
@ -812,6 +815,16 @@ ArrowToolOptionsBox::ArrowToolOptionsBox(
connect(m_maintainCombo, SIGNAL(currentIndexChanged(int)), m_scaleVField,
SLOT(onScaleTypeChanged(int)));
}
if (globalKeyProp) {
std::string actionName = "A_ToolOption_" + globalKeyProp->getId();
QAction *a = CommandManager::instance()->getAction(actionName.c_str());
if (a) {
a->setCheckable(true);
m_globalKey->addAction(a);
connect(a, SIGNAL(triggered(bool)), m_globalKey, SLOT(doClick(bool)));
}
}
}
//-----------------------------------------------------------------------------

View file

@ -102,6 +102,11 @@ ToolOptionCheckbox::ToolOptionCheckbox(TTool *tool, TBoolProperty *property,
void ToolOptionCheckbox::updateStatus() {
bool check = m_property->getValue();
if (!actions().isEmpty() && actions()[0]->isCheckable() &&
actions()[0]->isChecked() != check)
actions()[0]->setChecked(check);
if (isChecked() == check) return;
setCheckState(check ? Qt::Checked : Qt::Unchecked);
@ -117,11 +122,16 @@ void ToolOptionCheckbox::nextCheckState() {
//-----------------------------------------------------------------------------
void ToolOptionCheckbox::doClick() {
void ToolOptionCheckbox::doClick(bool checked) {
if (m_toolHandle && m_toolHandle->getTool() != m_tool) return;
// active only if the belonging combo-viewer is visible
if (!isInVisibleViewer(this)) return;
click();
if (isChecked() == checked) return;
setChecked(checked);
m_property->setValue(checked);
notifyTool();
}
//=============================================================================

View file

@ -93,7 +93,7 @@ public:
ToolHandle *toolHandle = 0, QWidget *parent = 0);
void updateStatus() override;
public slots:
void doClick();
void doClick(bool);
protected:
void nextCheckState() override;

View file

@ -752,10 +752,11 @@ public:
}
int getCursorId() const override {
int ret = ToolCursor::TapeCursor;
if (m_type.getValue() == RECT) ret = ret | ToolCursor::Ex_Rectangle;
if (ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg)
return ToolCursor::TapeCursorWhite;
else
return ToolCursor::TapeCursor;
ret = ret | ToolCursor::Ex_Negate;
return ret;
}
} vectorTapeTool;

View file

@ -431,7 +431,7 @@ elseif(BUILD_ENV_UNIXLIKE)
set(EXTRA_LIBS ${EXTRA_LIBS} ${Boost_LIBRARIES} ${OPENBLAS_LIB})
if(BUILD_TARGET_WIN)
set(EXTRA_LIBS ${EXTRA_LIBS} Qt5::WinMain -lstrmiids)
set(EXTRA_LIBS ${EXTRA_LIBS} Qt5::WinMain -lstrmiids -mwindows)
endif()
target_link_libraries(

View file

@ -1326,40 +1326,18 @@ void TCellSelection::enableCommands() {
bool TCellSelection::isEnabledCommand(
std::string commandId) { // static function
static QList<std::string> commands = {MI_Autorenumber,
MI_Reverse,
MI_Swing,
MI_Random,
MI_Increment,
MI_ResetStep,
MI_IncreaseStep,
MI_DecreaseStep,
MI_Step2,
MI_Step3,
MI_Step4,
MI_Each2,
MI_Each3,
MI_Each4,
MI_Rollup,
MI_Rolldown,
MI_TimeStretch,
MI_CloneLevel,
MI_SetKeyframes,
MI_Copy,
MI_Paste,
MI_PasteInto,
MI_Cut,
MI_Clear,
MI_Insert,
MI_PasteInto,
MI_Reframe1,
MI_Reframe2,
MI_Reframe3,
MI_Reframe4,
MI_ReframeWithEmptyInbetweens,
MI_Undo,
MI_Redo,
MI_PasteNumbers};
static QList<std::string> commands = {
MI_Autorenumber, MI_Reverse, MI_Swing,
MI_Random, MI_Increment, MI_ResetStep,
MI_IncreaseStep, MI_DecreaseStep, MI_Step2,
MI_Step3, MI_Step4, MI_Each2,
MI_Each3, MI_Each4, MI_Rollup,
MI_Rolldown, MI_TimeStretch, MI_CloneLevel,
MI_SetKeyframes, MI_Copy, MI_Paste,
MI_PasteInto, MI_Cut, MI_Clear,
MI_Insert, MI_Reframe1, MI_Reframe2,
MI_Reframe3, MI_Reframe4, MI_ReframeWithEmptyInbetweens,
MI_Undo, MI_Redo, MI_PasteNumbers};
return commands.contains(commandId);
}

View file

@ -2582,9 +2582,9 @@ void CellArea::createCellMenu(QMenu &menu, bool isCellSelected) {
if (isCellSelected) {
menu.addAction(cmdManager->getAction(MI_LevelSettings));
menu.addSeparator();
if (!soundCellsSelected) {
//- force reframe
QMenu *reframeSubMenu = new QMenu(tr("Reframe"), this);
{
reframeSubMenu->addAction(cmdManager->getAction(MI_Reframe1));
@ -2614,22 +2614,32 @@ void CellArea::createCellMenu(QMenu &menu, bool isCellSelected) {
}
menu.addMenu(eachSubMenu);
menu.addSeparator();
QMenu *editCellNumbersMenu = new QMenu(tr("Edit Cell Numbers"), this);
{
editCellNumbersMenu->addAction(cmdManager->getAction(MI_Reverse));
editCellNumbersMenu->addAction(cmdManager->getAction(MI_Swing));
editCellNumbersMenu->addAction(cmdManager->getAction(MI_Random));
editCellNumbersMenu->addAction(cmdManager->getAction(MI_Dup));
editCellNumbersMenu->addAction(cmdManager->getAction(MI_Rollup));
editCellNumbersMenu->addAction(cmdManager->getAction(MI_Rolldown));
editCellNumbersMenu->addAction(cmdManager->getAction(MI_TimeStretch));
editCellNumbersMenu->addAction(
cmdManager->getAction(MI_AutoInputCellNumber));
}
menu.addMenu(editCellNumbersMenu);
menu.addAction(cmdManager->getAction(MI_Reverse));
menu.addAction(cmdManager->getAction(MI_Swing));
menu.addAction(cmdManager->getAction(MI_Random));
menu.addAction(cmdManager->getAction(MI_Dup));
menu.addAction(cmdManager->getAction(MI_Rollup));
menu.addAction(cmdManager->getAction(MI_Rolldown));
menu.addAction(cmdManager->getAction(MI_TimeStretch));
menu.addAction(cmdManager->getAction(MI_AutoInputCellNumber));
menu.addSeparator();
menu.addAction(cmdManager->getAction(MI_Autorenumber));
}
menu.addAction(cmdManager->getAction(MI_ReplaceLevel));
menu.addAction(cmdManager->getAction(MI_ReplaceParentDirectory));
QMenu *replaceLevelMenu = new QMenu(tr("Replace Level"), this);
menu.addMenu(replaceLevelMenu);
replaceLevelMenu->addAction(cmdManager->getAction(MI_ReplaceLevel));
replaceLevelMenu->addAction(
cmdManager->getAction(MI_ReplaceParentDirectory));
{
// replace with another level in scene cast
std::vector<TXshLevel *> levels;
@ -2639,7 +2649,7 @@ void CellArea::createCellMenu(QMenu &menu, bool isCellSelected) {
->getLevelSet()
->listLevels(levels);
if (!levels.empty()) {
QMenu *replaceMenu = menu.addMenu(tr("Replace"));
QMenu *replaceMenu = replaceLevelMenu->addMenu(tr("Replace with"));
connect(replaceMenu, SIGNAL(triggered(QAction *)), this,
SLOT(onReplaceByCastedLevel(QAction *)));
for (int i = 0; i < (int)levels.size(); i++) {
@ -2662,14 +2672,31 @@ void CellArea::createCellMenu(QMenu &menu, bool isCellSelected) {
if (!soundCellsSelected) {
if (selectionContainTlvImage(m_viewer->getCellSelection(),
m_viewer->getXsheet()))
menu.addAction(cmdManager->getAction(MI_RevertToCleanedUp));
replaceLevelMenu->addAction(
cmdManager->getAction(MI_RevertToCleanedUp));
if (selectionContainLevelImage(m_viewer->getCellSelection(),
m_viewer->getXsheet()))
menu.addAction(cmdManager->getAction(MI_RevertToLastSaved));
replaceLevelMenu->addAction(
cmdManager->getAction(MI_RevertToLastSaved));
menu.addAction(cmdManager->getAction(MI_SetKeyframes));
}
menu.addSeparator();
menu.addAction(cmdManager->getAction(MI_Cut));
menu.addAction(cmdManager->getAction(MI_Copy));
menu.addAction(cmdManager->getAction(MI_Paste));
QMenu *pasteSpecialMenu = new QMenu(tr("Paste Special"), this);
{
pasteSpecialMenu->addAction(cmdManager->getAction(MI_PasteInto));
pasteSpecialMenu->addAction(cmdManager->getAction(MI_PasteNumbers));
}
menu.addMenu(pasteSpecialMenu);
menu.addAction(cmdManager->getAction(MI_Clear));
menu.addAction(cmdManager->getAction(MI_Insert));
menu.addSeparator();
TXshSimpleLevel *sl = TApp::instance()->getCurrentLevel()->getSimpleLevel();
if (sl || soundCellsSelected)
menu.addAction(cmdManager->getAction(MI_FileInfo));
@ -2679,11 +2706,17 @@ void CellArea::createCellMenu(QMenu &menu, bool isCellSelected) {
menu.addSeparator();
if (selectionContainRasterImage(m_viewer->getCellSelection(),
m_viewer->getXsheet())) {
menu.addAction(cmdManager->getAction(MI_AdjustLevels));
menu.addAction(cmdManager->getAction(MI_LinesFade));
menu.addAction(cmdManager->getAction(MI_BrightnessAndContrast));
menu.addAction(cmdManager->getAction(MI_Antialias));
menu.addAction(cmdManager->getAction(MI_CanvasSize));
QMenu *editImageMenu = new QMenu(tr("Edit Image"), this);
{
editImageMenu->addAction(cmdManager->getAction(MI_AdjustLevels));
editImageMenu->addAction(cmdManager->getAction(MI_LinesFade));
editImageMenu->addAction(
cmdManager->getAction(MI_BrightnessAndContrast));
editImageMenu->addAction(cmdManager->getAction(MI_Antialias));
editImageMenu->addAction(cmdManager->getAction(MI_CanvasSize));
}
menu.addMenu(editImageMenu);
} else if (selectionContainTlvImage(m_viewer->getCellSelection(),
m_viewer->getXsheet()))
menu.addAction(cmdManager->getAction(MI_CanvasSize));
@ -2691,7 +2724,6 @@ void CellArea::createCellMenu(QMenu &menu, bool isCellSelected) {
menu.addSeparator();
if (!soundCellsSelected)
menu.addAction(cmdManager->getAction(MI_ImportMagpieFile));
menu.addAction(cmdManager->getAction(MI_PasteNumbers));
}
//-----------------------------------------------------------------------------
/*! replace level with another level in the cast

View file

@ -5,6 +5,7 @@
#include <QPainterPath>
#include <QBoxLayout>
#include <math.h>
#include <stdexcept>
using std::pair;