void KisBrushSelectionWidget::setCurrentBrush( KisBrushSP brush) { // XXX: clever code have brush plugins know their configuration // pane, so we don't have to have this if statement and // have an extensible set of brush types if ( dynamic_cast<KisAutoBrush*>(brush.data()) ) { m_brushesTab->setCurrentWidget( m_autoBrushWidget ); m_autoBrushWidget->setBrush(brush); } else if (dynamic_cast<KisTextBrush*>(brush.data())) { m_brushesTab->setCurrentWidget( m_textBrushWidget ); m_textBrushWidget->setBrush(brush); } else { m_brushesTab->setCurrentWidget( m_brushChooser ); m_brushChooser->setBrush(brush); } }
void KisAutoBrushWidget::setBrush(KisBrushSP brush) { m_autoBrush = brush; m_brush = brush->image(); // XXX: lock, set and unlock the widgets. KisAutoBrush* aBrush = dynamic_cast<KisAutoBrush*>(brush.data()); if (aBrush->maskGenerator()->type() == KisMaskGenerator::CIRCLE) { comboBoxShape->setCurrentIndex(0); } else if (aBrush->maskGenerator()->type() == KisMaskGenerator::RECTANGLE) { comboBoxShape->setCurrentIndex(1); } else { comboBoxShape->setCurrentIndex(2); } comboBoxMaskType->setCurrentIndex(comboBoxMaskType->findText(aBrush->maskGenerator()->name())); inputRadius->setValue(aBrush->maskGenerator()->diameter()); inputRatio->setValue(aBrush->maskGenerator()->ratio()); inputVFade->blockSignals(true); inputHFade->blockSignals(true); inputHFade->setValue(aBrush->maskGenerator()->horizontalFade()); inputVFade->setValue(aBrush->maskGenerator()->verticalFade()); inputVFade->blockSignals(false); inputHFade->blockSignals(false); inputAngle->setValue(aBrush->angle() * 180 / M_PI); inputSpikes->setValue(aBrush->maskGenerator()->spikes()); inputSpacing->setValue(aBrush->spacing()); inputSpacing->setExponentRatio(3.0); inputRandomness->setValue(aBrush->randomness() * 100); density->setValue(aBrush->density() * 100); if (!aBrush->maskGenerator()->curveString().isEmpty()) { KisCubicCurve curve; curve.fromString(aBrush->maskGenerator()->curveString()); softnessCurve->setCurve(curve); } }