Skip to content

Commit

Permalink
Add "Pick Line Styles" button to ColorModelViewer
Browse files Browse the repository at this point in the history
  • Loading branch information
Abel You committed Feb 10, 2025
1 parent 5f0d923 commit 142b7b4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
38 changes: 33 additions & 5 deletions toonz/sources/toonz/colormodelviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include <QMouseEvent>
#include <QUrl>
#include <QMenu>
#include <qtoolbutton.h>

#define LINES "Lines"
#define AREAS "Areas"
Expand Down Expand Up @@ -94,9 +95,20 @@ ColorModelViewer::ColorModelViewer(QWidget *parent)
FlipConsole::eFlipVertical, FlipConsole::eResetView}),
eDontKeepFilesOpened, true)
, m_mode(0)
, m_currentRefImgPath(TFilePath()) {
, m_currentRefImgPath(TFilePath()),
m_alwaysPickLineStyle(false) {
setObjectName("colormodel");

pickLineStyles = new QToolButton(this);
QString tip("Pick Line Styles");
QIcon icon = createQIcon("centerline");
pickLineStyles->setIcon(icon);
pickLineStyles->setToolTip(tip);
pickLineStyles->setCheckable(true);

// TODO: add to right place
this->layout()->addWidget(pickLineStyles);

setToolCursor(m_imageViewer, ToolCursor::PickerCursor);

// Do not call the special procedure for flipbook closures...
Expand All @@ -105,6 +117,12 @@ ColorModelViewer::ColorModelViewer(QWidget *parent)

bool ret = connect(this, SIGNAL(refImageNotFound()), this,
SLOT(onRefImageNotFound()), Qt::QueuedConnection);
ret = ret && connect(pickLineStyles, &QToolButton::clicked, this,
[this](bool clicked) {
m_alwaysPickLineStyle = clicked;
changePickType();
});

assert(ret);

m_imageViewer->setMouseTracking(true);
Expand Down Expand Up @@ -414,6 +432,8 @@ void ColorModelViewer::changePickType() {
if (!propGroup) {
m_mode = 2;
setToolCursor(m_imageViewer, ToolCursor::PickerCursor);
pickLineStyles->setDisabled(true);
pickLineStyles->setChecked(true);
return;
}

Expand All @@ -422,23 +442,31 @@ void ColorModelViewer::changePickType() {
if (!modeProp) {
m_mode = 2;
setToolCursor(m_imageViewer, ToolCursor::PickerCursor);
pickLineStyles->setDisabled(true);
pickLineStyles->setChecked(true);
return;
}

else {//A a Temporary change, to always pick Lines and Areas
std::string var = modeProp->getValueAsString();
if (var == LINES) {
m_mode = 2;
setToolCursor(m_imageViewer, ToolCursor::PickerCursor);
m_mode = 1;
setToolCursor(m_imageViewer, ToolCursor::PickerCursorLine);
} else if (var == AREAS) {
m_mode = 2;
setToolCursor(m_imageViewer, ToolCursor::PickerCursor);
if (m_alwaysPickLineStyle)
m_mode = 2;// Areas & Line
else
m_mode = 0;
setToolCursor(m_imageViewer, ToolCursor::PickerCursorArea);
} else // Line & Areas
{
m_mode = 2;
setToolCursor(m_imageViewer, ToolCursor::PickerCursor);
}
pickLineStyles->setEnabled(var == AREAS);
pickLineStyles->setChecked(m_mode != 0);
}

}

//-----------------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions toonz/sources/toonz/colormodelviewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class ColorModelViewer final : public FlipBook {
/*-- ColorModelのファイルパスを覚えておいて、UseCurrentFrame間の移動に対応
* --*/
TFilePath m_currentRefImgPath;
/*-- Set m_mode to 2 after got m_mode --*/
bool m_alwaysPickLineStyle;
QToolButton *pickLineStyles;

public:
ColorModelViewer(QWidget *parent = 0);
Expand Down

0 comments on commit 142b7b4

Please sign in to comment.