cursor customize

This commit is contained in:
shun_iwasawa 2017-10-26 15:17:19 +09:00
parent 22f3c9edbd
commit 009457074f
46 changed files with 123 additions and 162 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

@ -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,22 +108,47 @@ 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);
data.x = cursorInfo[i].x;
data.y = cursorInfo[i].y;
it = m_cursors.insert(std::make_pair(cursorType, data)).first;
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;
return it->second;
}
// niente da fare. uso un default

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

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

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