Brush Size Shortcuts Change (#685)

* Changed brush size shortcut to Ctrl + Alt ( in considering ui consistency )
close #477
This commit is contained in:
Jeremy Bullock 2017-01-19 04:46:50 -07:00 committed by shun-iwasawa
parent 34b8160c90
commit 01e454e092
3 changed files with 63 additions and 41 deletions

View file

@ -1616,28 +1616,40 @@ void BrushTool::mouseMove(const TPointD &pos, const TMouseEvent &e) {
setValue(prop, value);
}
void addMinMaxSeparate(TDoublePairProperty &prop, double min, double max) {
if (min == 0.0 && max == 0.0) return;
const TDoublePairProperty::Range &range = prop.getRange();
TDoublePairProperty::Value value = prop.getValue();
value.first += min;
value.second += max;
if (value.first > value.second) value.first = value.second;
value.first = tcrop(value.first, range.first, range.second);
value.second = tcrop(value.second, range.first, range.second);
setValue(prop, value);
}
} locals = {this};
switch (e.getModifiersMask()) {
/*--
* Altキー+Min/MaxともCtrlやShiftでは誤操作の恐れがある
* --*/
case TMouseEvent::ALT_KEY: {
// User wants to alter the minimum brush size
// if (e.isAltPressed() && !e.isCtrlPressed()) {
// const TPointD &diff = pos - m_mousePos;
// double add = (fabs(diff.x) > fabs(diff.y)) ? diff.x : diff.y;
// locals.addMinMax(
// TToonzImageP(getImage(false, 1)) ? m_rasThickness : m_thickness, add);
//} else
if (e.isCtrlPressed() && e.isAltPressed()) {
const TPointD &diff = pos - m_mousePos;
double add = (fabs(diff.x) > fabs(diff.y)) ? diff.x : diff.y;
double max = diff.x / 2;
double min = diff.y / 2;
locals.addMinMax(
TToonzImageP(getImage(false, 1)) ? m_rasThickness : m_thickness, add);
break;
}
default:
locals.addMinMaxSeparate(
(m_targetType & TTool::ToonzImage) ? m_rasThickness : m_thickness, min,
max);
} else {
m_brushPos = pos;
break;
}
m_mousePos = pos;
invalidate();

View file

@ -130,9 +130,9 @@ public:
FullColorBrushTool::FullColorBrushTool(std::string name)
: TTool(name)
, m_thickness("Thickness", 1, 100, 1, 5, false)
, m_pressure("Pressure Sensitivity", true)
, m_opacity("Opacity:", 0, 100, 100, 100, true)
, m_thickness("Size", 1, 100, 1, 5, false)
, m_pressure("Pressure", true)
, m_opacity("Opacity", 0, 100, 100, 100, true)
, m_hardness("Hardness:", 0, 100, 100)
, m_preset("Preset:")
, m_styleId(0)
@ -172,9 +172,9 @@ void FullColorBrushTool::onCanvasSizeChanged() {
//---------------------------------------------------------------------------------------------------
void FullColorBrushTool::updateTranslation() {
m_thickness.setQStringName(tr("Thickness"));
m_pressure.setQStringName(tr("Pressure Sensitivity"));
m_opacity.setQStringName(tr("Opacity:"));
m_thickness.setQStringName(tr("Size"));
m_pressure.setQStringName(tr("Pressure"));
m_opacity.setQStringName(tr("Opacity"));
m_hardness.setQStringName(tr("Hardness:"));
m_preset.setQStringName(tr("Preset:"));
}
@ -452,25 +452,36 @@ void FullColorBrushTool::mouseMove(const TPointD &pos, const TMouseEvent &e) {
setValue(prop, value);
}
void addMinMaxSeparate(TIntPairProperty &prop, double min, double max) {
if (min == 0.0 && max == 0.0) return;
const TIntPairProperty::Range &range = prop.getRange();
TIntPairProperty::Value value = prop.getValue();
value.first += min;
value.second += max;
if (value.first > value.second) value.first = value.second;
value.first = tcrop<double>(value.first, range.first, range.second);
value.second = tcrop<double>(value.second, range.first, range.second);
setValue(prop, value);
}
} locals = {this};
switch (e.getModifiersMask()) {
/*--
* Altキー+Min/MaxともCtrlやShiftでは誤操作の恐れがある
* --*/
case TMouseEvent::ALT_KEY: {
// User wants to alter the minimum brush size
// if (e.isAltPressed() && !e.isCtrlPressed()) {
// const TPointD &diff = pos - m_mousePos;
// double add = (fabs(diff.x) > fabs(diff.y)) ? diff.x : diff.y;
// locals.addMinMax(m_thickness, int(add));
//} else
if (e.isCtrlPressed() && e.isAltPressed()) {
const TPointD &diff = pos - m_mousePos;
double add = (fabs(diff.x) > fabs(diff.y)) ? diff.x : diff.y;
double max = diff.x / 2;
double min = diff.y / 2;
locals.addMinMax(m_thickness, int(add));
break;
}
default:
locals.addMinMaxSeparate(m_thickness, int(min), int(max));
} else {
m_brushPos = pos;
break;
}
m_mousePos = pos;
@ -552,7 +563,8 @@ void FullColorBrushTool::setWorkAndBackupImages() {
bool FullColorBrushTool::onPropertyChanged(std::string propertyName) {
m_minThick = m_thickness.getValue().first;
m_maxThick = m_thickness.getValue().second;
if (propertyName == "Hardness:" || propertyName == "Thickness") {
if (propertyName == "Hardness:" || propertyName == "Thickness" ||
propertyName == "Size") {
m_brushPad = ToolUtils::getBrushPad(m_thickness.getValue().second,
m_hardness.getValue() * 0.01);
TRectD rect(m_brushPos - TPointD(m_maxThick + 2, m_maxThick + 2),

View file

@ -214,7 +214,6 @@ void ToolOptionControlBuilder::visit(TDoublePairProperty *p) {
m_tool, p, QObject::tr("Min:"), QObject::tr("Max:"), m_toolHandle);
hLayout()->addWidget(control, 150);
m_panel->addControl(control);
if (p->getName() == "Size:" || p->getName() == "Size") {
CommandManager *cm = CommandManager::instance();
QAction *a;
@ -244,8 +243,8 @@ void ToolOptionControlBuilder::visit(TIntPairProperty *p) {
m_tool, p, QObject::tr("Min:"), QObject::tr("Max:"), m_toolHandle);
hLayout()->addWidget(control, 100);
m_panel->addControl(control);
if (p->getName() == "Size:") {
if (p->getName() == "Size:" || p->getName() == "Thickness" ||
p->getName() == "Size") {
CommandManager *cm = CommandManager::instance();
QAction *a;
a = cm->getAction("A_IncreaseMaxBrushThickness");
@ -278,7 +277,6 @@ void ToolOptionControlBuilder::visit(TIntProperty *p) {
control->enableSlider(false);
control->setFixedWidth(45);
}
hLayout()->addWidget(control, 100);
m_panel->addControl(control);
if (p->getName() == "Size:") {