这是indexloc提供的服务,不要输入任何密码
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions app/src/toolbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ GNU General Public License for more details.
#include "toolmanager.h"
#include "layermanager.h"
#include "pencilsettings.h"
#include "selectionmanager.h"
#include "selecttool.h"

// ----------------------------------------------------------------------------------
QString GetToolTips(QString strCommandName)
Expand Down Expand Up @@ -137,6 +139,8 @@ void ToolBoxWidget::initUI()

connect(editor()->layers(), &LayerManager::currentLayerChanged, this, &ToolBoxWidget::onLayerDidChange);

//switch to move tool when selection changes
connect(editor()->select(), &SelectionManager::selectionChanged, this, &ToolBoxWidget::onSelectionChanged);

FlowLayout* flowlayout = new FlowLayout;

Expand Down Expand Up @@ -304,3 +308,18 @@ void ToolBoxWidget::onLayerDidChange(int)
moveOn();
}
}

void ToolBoxWidget::onSelectionChanged(){
BaseTool* currentTool = editor()->tools()->currentTool();
if (currentTool->type() == SELECT)
{
if (editor()->select()->somethingSelected())
{
SelectTool* selectTool = (SelectTool*) currentTool;
if (selectTool->properties.autoSwitchTool && !selectTool->selectChanging())
{
moveOn();
}
}
}
}
1 change: 1 addition & 0 deletions app/src/toolbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class ToolBoxWidget : public BaseDockWidget
public slots:
void onToolSetActive(ToolType toolType);
void onLayerDidChange(int index);
void onSelectionChanged();
void pencilOn();
void eraserOn();
void selectOn();
Expand Down
10 changes: 10 additions & 0 deletions app/src/tooloptionwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ void ToolOptionWidget::makeConnectionToEditor(Editor* editor)

connect(ui->fillContourBox, &QCheckBox::clicked, toolManager, &ToolManager::setUseFillContour);

connect(ui->autoSwitchToolCheckBox, &QCheckBox::clicked, toolManager, &ToolManager::setAutoSwitchTool);

connect(ui->showInfoBox, &QCheckBox::clicked, toolManager, &ToolManager::setShowSelectionInfo);

connect(toolManager, &ToolManager::toolChanged, this, &ToolOptionWidget::onToolChanged);
Expand All @@ -136,6 +138,7 @@ void ToolOptionWidget::onToolPropertyChanged(ToolType, ToolPropertyType ePropert
case ANTI_ALIASING: setAA(p.useAA); break;
case STABILIZATION: setStabilizerLevel(p.stabilizerLevel); break;
case FILLCONTOUR: setFillContour(p.useFillContour); break;
case AUTOSWITCHTOOL: setAutoSwitchTool(p.autoSwitchTool); break;
case SHOWSELECTIONINFO: setShowSelectionInfo(p.showSelectionInfo); break;
case BEZIER: setBezier(p.bezier_state); break;
case CAMERAPATH: { break; }
Expand Down Expand Up @@ -186,6 +189,7 @@ void ToolOptionWidget::setVisibility(BaseTool* tool)
ui->stabilizerLabel->setVisible(tool->isPropertyEnabled(STABILIZATION));
ui->inpolLevelsCombo->setVisible(tool->isPropertyEnabled(STABILIZATION));
ui->fillContourBox->setVisible(tool->isPropertyEnabled(FILLCONTOUR));
ui->autoSwitchToolCheckBox->setVisible(tool->isPropertyEnabled(AUTOSWITCHTOOL));
ui->showInfoBox->setVisible(tool->isPropertyEnabled(SHOWSELECTIONINFO));

auto currentLayerType = editor()->layers()->currentLayer()->type();
Expand Down Expand Up @@ -344,6 +348,12 @@ void ToolOptionWidget::setBezier(bool useBezier)
ui->useBezierBox->setChecked(useBezier);
}

void ToolOptionWidget::setAutoSwitchTool(bool autoSwitch)
{
QSignalBlocker b(ui->autoSwitchToolCheckBox);
ui->autoSwitchToolCheckBox->setChecked(autoSwitch);
}

void ToolOptionWidget::setShowSelectionInfo(bool showSelectionInfo)
{
QSignalBlocker b(ui->showInfoBox);
Expand Down
1 change: 1 addition & 0 deletions app/src/tooloptionwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public slots:
void setStabilizerLevel(int);
void setFillContour(int);
void setBezier(bool);
void setAutoSwitchTool(bool);
void setShowSelectionInfo(bool);

void disableAllOptions();
Expand Down
10 changes: 10 additions & 0 deletions app/ui/tooloptions.ui
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@
</widget>
</item>

<item>
<widget class="QCheckBox" name="autoSwitchToolCheckBox">
<property name="text">
<string>Auto-Switch to Move Tool</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="showInfoBox">
<property name="text">
Expand Down
5 changes: 5 additions & 0 deletions core_lib/src/managers/toolmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@ void ToolManager::setUseFillContour(bool useFillContour)
emit toolPropertyChanged(currentTool()->type(), FILLCONTOUR);
}

void ToolManager::setAutoSwitchTool(bool autoSwitch)
{
currentTool()->setAutoSwitchTool(autoSwitch);
}

void ToolManager::setShowSelectionInfo(bool b)
{
currentTool()->setShowSelectionInfo(b);
Expand Down
1 change: 1 addition & 0 deletions core_lib/src/managers/toolmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public slots:
void setBucketFillReferenceMode(int referenceMode);
void setBucketFillExpand(int);
void setUseFillContour(bool);
void setAutoSwitchTool(bool autoSwitch);
void setShowSelectionInfo(bool b);
void setShowCameraPath(bool);
void resetCameraPath();
Expand Down
5 changes: 5 additions & 0 deletions core_lib/src/tool/basetool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,11 @@ void BaseTool::setUseFillContour(const bool useFillContour)
properties.useFillContour = useFillContour;
}

void BaseTool::setAutoSwitchTool(const bool autoSwitch)
{
properties.autoSwitchTool = autoSwitch;
}

void BaseTool::setShowSelectionInfo(const bool b)
{
properties.showSelectionInfo = b;
Expand Down
2 changes: 2 additions & 0 deletions core_lib/src/tool/basetool.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class Properties
bool bucketFillExpandEnabled = 0;
int bucketFillReferenceMode = 0;
bool useFillContour = false;
bool autoSwitchTool = true;
bool showSelectionInfo = true;
bool cameraShowPath = true;
DotColorType cameraPathDotColorType = DotColorType::RED;
Expand Down Expand Up @@ -128,6 +129,7 @@ class BaseTool : public QObject
virtual void setFillExpandEnabled(const bool enabled);
virtual void setFillReferenceMode(int referenceMode);
virtual void setUseFillContour(const bool useFillContour);
virtual void setAutoSwitchTool(const bool autoSwitch);
virtual void setShowSelectionInfo(const bool b);
virtual void setShowCameraPath(const bool showCameraPath);
virtual void setPathDotColorType(const DotColorType dotColorType);
Expand Down
12 changes: 12 additions & 0 deletions core_lib/src/tool/selecttool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ void SelectTool::loadSettings()
QSettings settings(PENCIL2D, PENCIL2D);
properties.showSelectionInfo = settings.value("ShowSelectionInfo").toBool();
mPropertyEnabled[SHOWSELECTIONINFO] = true;
properties.autoSwitchTool = true;
mPropertyEnabled[AUTOSWITCHTOOL] = true;
}

QCursor SelectTool::cursor()
Expand Down Expand Up @@ -95,6 +97,11 @@ void SelectTool::setShowSelectionInfo(const bool b)
settings.setValue("ShowSelectionInfo", b);
}

bool SelectTool::selectChanging()
{
return mSelectChanging;
}

void SelectTool::beginSelection()
{
auto selectMan = mEditor->select();
Expand All @@ -121,6 +128,8 @@ void SelectTool::beginSelection()

void SelectTool::pointerPressEvent(PointerEvent* event)
{
mSelectChanging = true;

mCurrentLayer = mEditor->layers()->currentLayer();
if (mCurrentLayer == nullptr) return;
if (!mCurrentLayer->isPaintable()) { return; }
Expand Down Expand Up @@ -165,6 +174,8 @@ void SelectTool::pointerMoveEvent(PointerEvent*)

void SelectTool::pointerReleaseEvent(PointerEvent* event)
{
mSelectChanging = false;

mCurrentLayer = mEditor->layers()->currentLayer();
if (mCurrentLayer == nullptr) return;
if (event->button() != Qt::LeftButton) return;
Expand All @@ -187,6 +198,7 @@ void SelectTool::pointerReleaseEvent(PointerEvent* event)

mStartMoveMode = MoveMode::NONE;
mSelectionRect = mEditor->select()->mapToSelection(mEditor->select()->mySelectionRect()).boundingRect();
editor()->select()->setSelection(mSelectionRect);

mScribbleArea->updateToolCursor();
mScribbleArea->updateFrame();
Expand Down
3 changes: 3 additions & 0 deletions core_lib/src/tool/selecttool.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class SelectTool : public BaseTool
void resetToDefault() override;
void setShowSelectionInfo(const bool b) override;

bool selectChanging();

private:

void pointerPressEvent(PointerEvent*) override;
Expand All @@ -65,6 +67,7 @@ class SelectTool : public BaseTool
MoveMode mStartMoveMode = MoveMode::NONE;
QRectF mSelectionRect;
Layer* mCurrentLayer = nullptr;
bool mSelectChanging = false;

QPixmap mCursorPixmap = QPixmap(24, 24);
};
Expand Down
1 change: 1 addition & 0 deletions core_lib/src/util/pencildef.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ enum ToolPropertyType
STABILIZATION,
TOLERANCE,
FILLCONTOUR,
AUTOSWITCHTOOL,
SHOWSELECTIONINFO,
USETOLERANCE,
BUCKETFILLEXPAND,
Expand Down