diff --git a/libs/ui/forms/wdgpaintopsettings.ui b/libs/ui/forms/wdgpaintopsettings.ui --- a/libs/ui/forms/wdgpaintopsettings.ui +++ b/libs/ui/forms/wdgpaintopsettings.ui @@ -6,8 +6,8 @@ 0 0 - 1441 - 495 + 1134 + 431 @@ -17,7 +17,7 @@ - 5 + 9 1 @@ -74,63 +74,6 @@ - - - 5 - - - - - - 0 - 0 - - - - - 32 - 32 - - - - - 32 - 32 - - - - - - - - - - - - 0 - 0 - - - - - 32 - 32 - - - - - 32 - 32 - - - - - - - - - - @@ -155,6 +98,9 @@ false + + Qt::DefaultContextMenu + QFrame::StyledPanel @@ -173,6 +119,9 @@ true + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + QPainter::Antialiasing|QPainter::HighQualityAntialiasing|QPainter::SmoothPixmapTransform @@ -182,244 +131,255 @@ - + 0 - - 5 - - - - - 0 - 0 - - - - - 150 - 0 - - - - - 16777215 - 20 - - - - - 10 - 75 - true - - - - 0 - - - Current Brush Name - - - false - - - Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft - - - 0 - - - 5 - - - - - - - - 0 - 0 - - - - - 16777215 - 20 - - - - Current Brush Engine - - - false - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - 5 - - - - - - - - - - - - 0 - 0 - - - - - 32 - 32 - - - - - 32 - 32 - - - - - - - false + + + 10 - + + + + + 0 + 0 + + + + + 10 + 75 + true + + + + current brush + + + + + + + + 0 + 0 + + + + + 24 + 24 + + + + + 24 + 24 + + + + + + + + + + + + 180 + 0 + + + + + + + + + 0 + 0 + + + + + 16777215 + 28 + + + + Save + + + + + + + + 16777215 + 28 + + + + Cancel + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + - - - - 0 - 0 - - - - - 32 - 32 - - - - - 32 - 32 - - - - + + + 6 - + + + + Current Brush Engine + + + + + + + + 0 + 0 + + + + + 26 + 26 + + + + + 26 + 26 + + + + + + + + + + + + 0 + 0 + + + + + 30 + 30 + + + + + 30 + 30 + + + + + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + - + Qt::Horizontal + + QSizePolicy::MinimumExpanding + - 40 - 20 + 0 + 0 - - - Show: - - - - + + 0 + - - - - 0 - 0 - - - - - 35 - 20 - - - - - 16777215 - 20 - - - - Presets - - - - - + - + 0 0 - - - 35 - 20 - - 16777215 - 20 + 28 - - Settings + + Save New Brush Preset... - + - + 0 0 - - - 35 - 20 - - 16777215 - 20 + 28 - - Scratchpad - - - true + + Overwrite Brush @@ -432,6 +392,9 @@ + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + 5 @@ -443,17 +406,62 @@ 5 - 10 + 5 5 + + + + + + 24 + 24 + + + + + 24 + 24 + + + + + + + + 12 + 12 + + + + + + + + + + + + 0 + 0 + + + + Presets + + + + + + - + - + 0 0 @@ -466,7 +474,7 @@ - + 0 0 @@ -476,7 +484,7 @@ - + 0 0 @@ -491,7 +499,7 @@ - + 0 0 @@ -499,7 +507,7 @@ 0 - 350 + 120 @@ -510,6 +518,54 @@ + + + + Qt::Vertical + + + QSizePolicy::Preferred + + + + 5 + 5 + + + + + + + + + 0 + 0 + + + + Engine Default Preset + + + false + + + false + + + + + + + Qt::Vertical + + + + 20 + 10 + + + + @@ -547,7 +603,7 @@ - 120 + 100 0 @@ -677,93 +733,6 @@ - - - - - - - 0 - 0 - - - - Load Engine Defaults - - - - - - - - 0 - 0 - - - - Rename - - - - - - - - 250 - 0 - - - - - - - - - 0 - 0 - - - - Save - - - - - - - Cancel - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Overwrite Brush - - - - - - - Save New Brush Preset... - - - - - @@ -775,7 +744,7 @@ false - + 5 @@ -792,6 +761,42 @@ 5 + + + + + + 24 + 24 + + + + + 24 + 20 + + + + + + + + 12 + 12 + + + + + + + + Scratchpad + + + + + + QFrame::NoFrame @@ -829,7 +834,7 @@ 250 - 300 + 0 @@ -915,12 +920,6 @@
kis_lod_availability_widget.h
1 - - KisHighlightedToolButton - QWidget -
kis_highlighted_button.h
- 1 -
diff --git a/libs/ui/kis_paintop_box.cc b/libs/ui/kis_paintop_box.cc --- a/libs/ui/kis_paintop_box.cc +++ b/libs/ui/kis_paintop_box.cc @@ -878,6 +878,10 @@ KisPaintOpPresetSP preset = defaultPreset(m_resourceProvider->currentPreset()->paintOp()); preset->setOptionsWidget(m_optionWidget); m_resourceProvider->setPaintOpPreset(preset); + + // tell the brush editor that the resource has changed + // so it can update everything + m_presetsPopup->resourceSelected(preset.data()); } void KisPaintopBox::slotNodeChanged(const KisNodeSP node) diff --git a/libs/ui/kis_paintop_settings_widget.cpp b/libs/ui/kis_paintop_settings_widget.cpp --- a/libs/ui/kis_paintop_settings_widget.cpp +++ b/libs/ui/kis_paintop_settings_widget.cpp @@ -67,7 +67,7 @@ QSizePolicy policy = QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); m_d->optionsList->setSizePolicy(policy); - m_d->optionsList->setMinimumWidth(130); // this should be just big enough to show all of the setting names + m_d->optionsList->setMinimumWidth(140); // this should be just big enough to show all of the setting names m_d->optionsStack = new QStackedWidget(this); policy = QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); diff --git a/libs/ui/widgets/kis_paintop_presets_popup.h b/libs/ui/widgets/kis_paintop_presets_popup.h --- a/libs/ui/widgets/kis_paintop_presets_popup.h +++ b/libs/ui/widgets/kis_paintop_presets_popup.h @@ -87,8 +87,6 @@ public Q_SLOTS: void switchDetached(bool show = true); - void hideScratchPad(); - void showScratchPad(); void resourceSelected(KoResource* resource); void updateThemedIcons(); @@ -131,8 +129,6 @@ QString current_paintOpId; QList sortedBrushEnginesList; void toggleBrushRenameUIActive(bool isRenaming); - void calculateShowingTopArea(); - }; #endif diff --git a/libs/ui/widgets/kis_paintop_presets_popup.cpp b/libs/ui/widgets/kis_paintop_presets_popup.cpp --- a/libs/ui/widgets/kis_paintop_presets_popup.cpp +++ b/libs/ui/widgets/kis_paintop_presets_popup.cpp @@ -117,6 +117,10 @@ m_d->uiWdgPaintOpPresetSettings.dirtyPresetIndicatorButton->setIcon(KisIconUtils::loadIcon("warning")); m_d->uiWdgPaintOpPresetSettings.dirtyPresetIndicatorButton->setToolTip(i18n("The settings for this preset have changed from their default.")); + m_d->uiWdgPaintOpPresetSettings.showPresetsButton->setIcon(KisIconUtils::loadIcon("paintop_settings_02")); + m_d->uiWdgPaintOpPresetSettings.showPresetsButton->setToolTip(i18n("Toggle showing presets")); + + m_d->uiWdgPaintOpPresetSettings.showScratchpadButton->setToolTip(i18n("Toggle showing scratchpad")); m_d->uiWdgPaintOpPresetSettings.reloadPresetButton->setToolTip(i18n("Reload the brush preset")); m_d->uiWdgPaintOpPresetSettings.renameBrushPresetButton->setToolTip(i18n("Rename the brush preset")); @@ -182,17 +186,19 @@ m_d->uiWdgPaintOpPresetSettings.showScratchpadButton->setCheckable(true); m_d->uiWdgPaintOpPresetSettings.showScratchpadButton->setChecked(cfg.scratchpadVisible()); - m_d->uiWdgPaintOpPresetSettings.showEditorButton->setCheckable(true); - m_d->uiWdgPaintOpPresetSettings.showEditorButton->setChecked(true); - m_d->uiWdgPaintOpPresetSettings.showPresetsButton->setText(i18n("Presets")); + if (cfg.scratchpadVisible()) { + slotSwitchScratchpad(true); // show scratchpad + } else { + slotSwitchScratchpad(false); + } + m_d->uiWdgPaintOpPresetSettings.showPresetsButton->setCheckable(true); - m_d->uiWdgPaintOpPresetSettings.showPresetsButton->setChecked(false); // use a config to load/save this state + m_d->uiWdgPaintOpPresetSettings.showPresetsButton->setChecked(false); slotSwitchShowPresets(false); // hide presets by default // Connections - connect(m_d->uiWdgPaintOpPresetSettings.paintPresetIcon, SIGNAL(clicked()), m_d->uiWdgPaintOpPresetSettings.scratchPad, SLOT(paintPresetImage())); @@ -220,8 +226,6 @@ connect(m_d->uiWdgPaintOpPresetSettings.showScratchpadButton, SIGNAL(clicked(bool)), this, SLOT(slotSwitchScratchpad(bool))); - connect(m_d->uiWdgPaintOpPresetSettings.showEditorButton, SIGNAL(clicked(bool)), - this, SLOT(slotSwitchShowEditor(bool))); connect(m_d->uiWdgPaintOpPresetSettings.showPresetsButton, SIGNAL(clicked(bool)), this, SLOT(slotSwitchShowPresets(bool))); @@ -277,7 +281,7 @@ m_d->detached = false; m_d->ignoreHideEvents = false; m_d->minimumSettingsWidgetSize = QSize(0, 0); - m_d->uiWdgPaintOpPresetSettings.scratchpadControls->setVisible(cfg.scratchpadVisible()); + m_d->detachedGeometry = QRect(100, 100, 0, 0); m_d->uiWdgPaintOpPresetSettings.dirtyPresetCheckBox->setChecked(cfg.useDirtyPresets()); m_d->uiWdgPaintOpPresetSettings.eraserBrushSizeCheckBox->setChecked(cfg.useEraserBrushSize()); @@ -303,17 +307,6 @@ // setup things like the scene construct images, layers, etc that is a one-time thing m_d->uiWdgPaintOpPresetSettings.liveBrushPreviewView->setup(); - m_d->uiWdgPaintOpPresetSettings.zoomOutGraphicsViewButton->setIcon(KisIconUtils::loadIcon("view-fullscreen")); - connect(m_d->uiWdgPaintOpPresetSettings.zoomOutGraphicsViewButton, SIGNAL(clicked(bool)), - m_d->uiWdgPaintOpPresetSettings.liveBrushPreviewView, - SLOT(slotZoomToOneHundredPercent())); - - - m_d->uiWdgPaintOpPresetSettings.resetGraphicsViewButton->setIcon(KisIconUtils::loadIcon("view-refresh")); - connect(m_d->uiWdgPaintOpPresetSettings.resetGraphicsViewButton, SIGNAL(clicked(bool)), - m_d->uiWdgPaintOpPresetSettings.liveBrushPreviewView, - SLOT(slotResetViewZoom())); - } @@ -330,17 +323,27 @@ void KisPaintOpPresetsPopup::toggleBrushRenameUIActive(bool isRenaming) { // This function doesn't really do anything except get the UI in a state to rename a brush preset - - m_d->uiWdgPaintOpPresetSettings.renameBrushPresetButton->setVisible(!isRenaming); - m_d->uiWdgPaintOpPresetSettings.renameBrushNameTextField->setVisible(isRenaming); m_d->uiWdgPaintOpPresetSettings.updateBrushNameButton->setVisible(isRenaming); m_d->uiWdgPaintOpPresetSettings.cancelBrushNameUpdateButton->setVisible(isRenaming); + + // hide these below areas while renaming + m_d->uiWdgPaintOpPresetSettings.currentBrushNameLabel->setVisible(!isRenaming); + m_d->uiWdgPaintOpPresetSettings.renameBrushPresetButton->setVisible(!isRenaming); m_d->uiWdgPaintOpPresetSettings.saveBrushPresetButton->setEnabled(!isRenaming); + m_d->uiWdgPaintOpPresetSettings.saveBrushPresetButton->setVisible(!isRenaming); m_d->uiWdgPaintOpPresetSettings.saveNewBrushPresetButton->setEnabled(!isRenaming); + m_d->uiWdgPaintOpPresetSettings.saveNewBrushPresetButton->setVisible(!isRenaming); + + // if the presets area is shown, only then can you show/hide the load default brush + // need to think about weird state when you are in the middle of renaming a brush + // what happens if you try to change presets. maybe we should auto-hide (or disable) + // the presets area in this case + if (m_d->uiWdgPaintOpPresetSettings.presetWidget->isVisible()) { + m_d->uiWdgPaintOpPresetSettings.bnDefaultPreset->setVisible(!isRenaming); + } - m_d->uiWdgPaintOpPresetSettings.bnDefaultPreset->setVisible(!isRenaming); } @@ -434,10 +437,11 @@ m_d->settingsWidget = dynamic_cast(widget); KIS_ASSERT_RECOVER_RETURN(m_d->settingsWidget); - if (m_d->settingsWidget->supportScratchBox()) { - showScratchPad(); + KisConfig cfg; + if (m_d->settingsWidget->supportScratchBox() && cfg.scratchpadVisible()) { + slotSwitchScratchpad(true); } else { - hideScratchPad(); + slotSwitchScratchpad(false); } m_d->widgetConnections.addConnection(m_d->settingsWidget, SIGNAL(sigConfigurationItemChanged()), @@ -511,22 +515,6 @@ } } -void KisPaintOpPresetsPopup::hideScratchPad() -{ - m_d->uiWdgPaintOpPresetSettings.scratchPad->setEnabled(false); - m_d->uiWdgPaintOpPresetSettings.fillGradient->setEnabled(false); - m_d->uiWdgPaintOpPresetSettings.fillSolid->setEnabled(false); - m_d->uiWdgPaintOpPresetSettings.eraseScratchPad->setEnabled(false); -} - -void KisPaintOpPresetsPopup::showScratchPad() -{ - m_d->uiWdgPaintOpPresetSettings.scratchPad->setEnabled(true); - m_d->uiWdgPaintOpPresetSettings.fillGradient->setEnabled(true); - m_d->uiWdgPaintOpPresetSettings.fillSolid->setEnabled(true); - m_d->uiWdgPaintOpPresetSettings.eraseScratchPad->setEnabled(true); -} - void KisPaintOpPresetsPopup::resourceSelected(KoResource* resource) { // this gets called every time the brush editor window is opened @@ -640,6 +628,7 @@ if (m_d->detached) { window()->setGeometry(m_d->detachedGeometry); } + emit brushEditorShown(); } @@ -656,45 +645,52 @@ void KisPaintOpPresetsPopup::slotSwitchScratchpad(bool visible) { - m_d->uiWdgPaintOpPresetSettings.scratchpadControls->setVisible(visible); - KisConfig cfg; - cfg.setScratchpadVisible(visible); - calculateShowingTopArea(); -} - -void KisPaintOpPresetsPopup::calculateShowingTopArea() { - // if the scratchpad is the only area visible, we should hide the currently selected brush and settings - // so the top area doesn't - - bool shouldDisplayTopBar = true; - - if (m_d->uiWdgPaintOpPresetSettings.showScratchpadButton->isChecked() && !m_d->uiWdgPaintOpPresetSettings.showPresetsButton->isChecked() && - !m_d->uiWdgPaintOpPresetSettings.showEditorButton->isChecked() ) { - shouldDisplayTopBar = false; + // hide all the internal controls except the toggle button + m_d->uiWdgPaintOpPresetSettings.scratchPad->setVisible(visible); + m_d->uiWdgPaintOpPresetSettings.paintPresetIcon->setVisible(visible); + m_d->uiWdgPaintOpPresetSettings.fillGradient->setVisible(visible); + m_d->uiWdgPaintOpPresetSettings.fillLayer->setVisible(visible); + m_d->uiWdgPaintOpPresetSettings.fillSolid->setVisible(visible); + m_d->uiWdgPaintOpPresetSettings.eraseScratchPad->setVisible(visible); + m_d->uiWdgPaintOpPresetSettings.scratchpadSidebarLabel->setVisible(visible); + + if (visible) { + m_d->uiWdgPaintOpPresetSettings.showScratchpadButton->setIcon(KisIconUtils::loadIcon("arrow-left")); + } else { + m_d->uiWdgPaintOpPresetSettings.showScratchpadButton->setIcon(KisIconUtils::loadIcon("arrow-right")); } - m_d->uiWdgPaintOpPresetSettings.presetThumbnailicon->setVisible(shouldDisplayTopBar); - m_d->uiWdgPaintOpPresetSettings.currentBrushNameLabel->setVisible(shouldDisplayTopBar); - m_d->uiWdgPaintOpPresetSettings.renameBrushPresetButton->setVisible(shouldDisplayTopBar); - // always hide these since they are part of the brush renaming field and can make things get in a weird state - m_d->uiWdgPaintOpPresetSettings.renameBrushNameTextField->setVisible(false); - m_d->uiWdgPaintOpPresetSettings.updateBrushNameButton->setVisible(false); - m_d->uiWdgPaintOpPresetSettings.cancelBrushNameUpdateButton->setVisible(false); - slotUpdatePresetSettings(); // find out if the preset is dirty or not and update visibility + KisConfig cfg; + cfg.setScratchpadVisible(visible); } - void KisPaintOpPresetsPopup::slotSwitchShowEditor(bool visible) { m_d->uiWdgPaintOpPresetSettings.brushEditorSettingsControls->setVisible(visible); - calculateShowingTopArea(); } void KisPaintOpPresetsPopup::slotSwitchShowPresets(bool visible) { - m_d->uiWdgPaintOpPresetSettings.presetsContainer->setVisible(visible); - calculateShowingTopArea() ; + + m_d->uiWdgPaintOpPresetSettings.presetWidget->setVisible(visible); + m_d->uiWdgPaintOpPresetSettings.presetChangeViewToolButton->setVisible(visible); + m_d->uiWdgPaintOpPresetSettings.brushEgineComboBox->setVisible(visible); + m_d->uiWdgPaintOpPresetSettings.engineFilterLabel->setVisible(visible); + m_d->uiWdgPaintOpPresetSettings.bnDefaultPreset->setVisible(visible); + m_d->uiWdgPaintOpPresetSettings.presetsSidebarLabel->setVisible(visible); + + + // we only want a spacer to work when the toggle icon is present. Otherwise the list of presets will shrink + // which is something we don't want + if (visible) { + m_d->uiWdgPaintOpPresetSettings.presetsSpacer->changeSize(0,0, QSizePolicy::Ignored,QSizePolicy::Ignored); + m_d->uiWdgPaintOpPresetSettings.showPresetsButton->setIcon(KisIconUtils::loadIcon("arrow-right")); + } else { + m_d->uiWdgPaintOpPresetSettings.presetsSpacer->changeSize(0,0, QSizePolicy::MinimumExpanding,QSizePolicy::MinimumExpanding); + m_d->uiWdgPaintOpPresetSettings.showPresetsButton->setIcon(KisIconUtils::loadIcon("arrow-left")); + } + } void KisPaintOpPresetsPopup::slotUpdatePaintOpFilter() { @@ -727,7 +723,6 @@ saveDialog->showDialog(); } - void KisPaintOpPresetsPopup::updateViewSettings() { m_d->uiWdgPaintOpPresetSettings.presetWidget->smallPresetChooser->updateViewSettings(); diff --git a/libs/ui/widgets/kis_preset_live_preview_view.h b/libs/ui/widgets/kis_preset_live_preview_view.h --- a/libs/ui/widgets/kis_preset_live_preview_view.h +++ b/libs/ui/widgets/kis_preset_live_preview_view.h @@ -67,19 +67,6 @@ void updateStroke(); -public Q_SLOTS: - /** - * @brief scales the view to fit the brush stroke and moves it back to the center position - */ - void slotResetViewZoom(); - - /** - * @brief sets the zoom level to full size to get a close up of larger brushes - */ - void slotZoomToOneHundredPercent(); - - - private: /// internally sets the image area for brush preview @@ -146,12 +133,6 @@ /** - * @brief reads the brush size and scales the view out to fit it - * used internally when resetting the views or changing brush sizes - */ - void zoomToBrushSize(); - - /** * @brief works as both clearing the previous stroke, providing * striped backgrounds for smudging brushes, and text if there is no preview */ @@ -163,7 +144,6 @@ */ void setupAndPaintStroke(); - }; #endif diff --git a/libs/ui/widgets/kis_preset_live_preview_view.cpp b/libs/ui/widgets/kis_preset_live_preview_view.cpp --- a/libs/ui/widgets/kis_preset_live_preview_view.cpp +++ b/libs/ui/widgets/kis_preset_live_preview_view.cpp @@ -40,15 +40,13 @@ m_noPreviewText = 0; m_sceneImageItem = 0; - setCursor(Qt::SizeAllCursor); - setHorizontalScrollBarPolicy ( Qt::ScrollBarAlwaysOff ); setVerticalScrollBarPolicy ( Qt::ScrollBarAlwaysOff ); // layer image needs to be big enough to get an entire stroke of data - m_canvasSize.setWidth(1200); - m_canvasSize.setHeight(400); + m_canvasSize.setWidth(this->width()); + m_canvasSize.setHeight(this->height()); m_canvasCenterPoint.setX(m_canvasSize.width()*0.5); m_canvasCenterPoint.setY(m_canvasSize.height()*0.5); @@ -64,7 +62,6 @@ m_brushPreviewScene = new QGraphicsScene(); setScene(m_brushPreviewScene); - zoomToBrushSize(); } void KisPresetLivePreviewView::setCurrentPreset(KisPaintOpPresetSP preset) @@ -97,27 +94,13 @@ // only add the object once...then just update the pixmap so we can move the preview around if (!m_sceneImageItem) { m_sceneImageItem = m_brushPreviewScene->addPixmap(QPixmap::fromImage(m_temp_image)); - m_sceneImageItem->setFlag(QGraphicsItem::ItemIsSelectable); - m_sceneImageItem->setFlag(QGraphicsItem::ItemIsMovable); - m_sceneImageItem->setFlag(QGraphicsItem::ItemSendsGeometryChanges); - m_sceneImageItem->setPos(-m_canvasCenterPoint.x(), -m_canvasCenterPoint.y()); // center the object } else { m_sceneImageItem->setPixmap(QPixmap::fromImage(m_temp_image)); } } -void KisPresetLivePreviewView::slotResetViewZoom() -{ - zoomToBrushSize(); -} -void KisPresetLivePreviewView::slotZoomToOneHundredPercent() -{ - m_scaleFactor = 1.0; - resetMatrix(); - this->scale(m_scaleFactor, m_scaleFactor); -} void KisPresetLivePreviewView::paintBackground() { @@ -179,10 +162,8 @@ font.setPixelSize(14); font.setBold(false); - slotZoomToOneHundredPercent(); // 100% zoom if we are showing the text - m_noPreviewText = this->scene()->addText(i18n("No Preview for this engine"),font); - m_noPreviewText->setPos(-this->width()/3, -this->height()/4); // this mostly centers the text in the viewport + m_noPreviewText->setPos(50, this->height()/4); return; @@ -205,41 +186,16 @@ // we are making a proxy preset and setting it to the painter...otherwise setting the brush size of the original preset // will fire off signals that make this run in an infinite loop qreal originalPresetSize = m_currentPreset->settings()->paintOpSize(); - qreal previewSize = qBound(1.0, m_currentPreset->settings()->paintOpSize(), 150.0 ); // constrain live preview brush size + qreal previewSize = qBound(3.0, m_currentPreset->settings()->paintOpSize(), 25.0 ); // constrain live preview brush size KisPaintOpPresetSP proxy_preset = m_currentPreset->clone(); proxy_preset->settings()->setPaintOpSize(previewSize); m_brushPreviewPainter->setPaintOpPreset(proxy_preset, m_layer, m_image); - // slope-intercept is good for mapping two values. - // find the slope of the line (slope-intercept form) - float slope = (m_maxScale-m_maxStrokeScale) / (m_minScale-m_minStrokeScale); // y2-y1 / x2-x1 - float yIntercept = m_maxStrokeScale - slope * m_minStrokeScale; // y1 − m * x1 - - float strokeScaleAmount = m_scaleFactor * slope + yIntercept; // y = mx + b - strokeScaleAmount = qBound(m_minStrokeScale, strokeScaleAmount, m_maxStrokeScale); - - - - - // we only need to change the zoom amount if we are changing the brush size - if (m_currentBrushSize != m_currentPreset->settings()->paintOpSize()) { - m_currentBrushSize = m_currentPreset->settings()->paintOpSize(); - - zoomToBrushSize(); - - } - - - - // points for drawing an S curve - // we are going to paint the stroke right in the middle of the canvas to make sure - // everything is captured for big brush strokes + // paint the stroke. The sketchbrush gets a differnet shape than the others to show how it works if (m_currentPreset->paintOp().id() == "sketchbrush") { - slotZoomToOneHundredPercent(); // sketch brush is always scaled at 100% - KisPaintInformation pointOne; pointOne.setPressure(0.0); pointOne.setPos(QPointF(m_canvasCenterPoint.x() - (this->width() * 0.4), @@ -261,13 +217,14 @@ } else { - m_curvePointPI1.setPos(QPointF(m_canvasCenterPoint.x() - (this->width()*strokeScaleAmount), - m_canvasCenterPoint.y() + (this->height()*strokeScaleAmount))); + // paint an S curve + m_curvePointPI1.setPos(QPointF(m_canvasCenterPoint.x() - (this->width()*0.45), + m_canvasCenterPoint.y() + (this->height()*0.2))); m_curvePointPI1.setPressure(0.0); - m_curvePointPI2.setPos(QPointF(m_canvasCenterPoint.x() + (this->width()*strokeScaleAmount), - m_canvasCenterPoint.y())); + m_curvePointPI2.setPos(QPointF(m_canvasCenterPoint.x() + (this->width()*0.4), + m_canvasCenterPoint.y() - (this->height()*0.2) )); m_curvePointPI2.setPressure(1.0); @@ -287,23 +244,3 @@ } -void KisPresetLivePreviewView::zoomToBrushSize() -{ - // find the slope of the line (slope-intercept form) - float slope = (m_maxScale-m_minScale) / (m_maxBrushVal-m_minBrushVal); // y2-y1 / x2-x1 - float yIntercept = m_minScale - slope * m_minBrushVal; // y1 − m * x1 - - - // finally calculate our zoom level - float thresholdValue = qBound(m_minBrushVal, m_currentBrushSize, m_maxBrushVal); - m_scaleFactor = thresholdValue * slope + yIntercept; // y = mx + b - - resetMatrix(); - this->scale(m_scaleFactor,m_scaleFactor); - - // reset position of image preview in case we moved it - if(m_sceneImageItem) { - m_sceneImageItem->setPos(-m_canvasSize.width()/2, -m_canvasSize.height()/2 ); - } -} - diff --git a/plugins/paintops/libpaintop/CMakeLists.txt b/plugins/paintops/libpaintop/CMakeLists.txt --- a/plugins/paintops/libpaintop/CMakeLists.txt +++ b/plugins/paintops/libpaintop/CMakeLists.txt @@ -52,6 +52,7 @@ kis_brush_based_paintop_settings.cpp kis_compositeop_option.cpp kis_texture_option.cpp + kis_texture_chooser.cpp kis_pressure_texture_strength_option.cpp kis_embedded_pattern_manager.cpp sensors/kis_dynamic_sensors.cc @@ -76,6 +77,7 @@ forms/wdgcoloroptions.ui forms/wdgbrushchooser.ui forms/wdgpredefinedbrushchooser.ui + forms/wdgtexturechooser.ui forms/wdgCompositeOpOption.ui forms/wdgflowopacityoption.ui sensors/SensorDistanceConfiguration.ui diff --git a/plugins/paintops/libpaintop/forms/wdgbrushchooser.ui b/plugins/paintops/libpaintop/forms/wdgbrushchooser.ui --- a/plugins/paintops/libpaintop/forms/wdgbrushchooser.ui +++ b/plugins/paintops/libpaintop/forms/wdgbrushchooser.ui @@ -6,11 +6,11 @@ 0 0 - 537 - 300 + 504 + 270 - + 0 @@ -73,14 +73,14 @@ QFrame::StyledPanel - QFrame::Raised + QFrame::Plain + + + 0
- - - diff --git a/plugins/paintops/libpaintop/forms/wdgcurveoption.ui b/plugins/paintops/libpaintop/forms/wdgcurveoption.ui --- a/plugins/paintops/libpaintop/forms/wdgcurveoption.ui +++ b/plugins/paintops/libpaintop/forms/wdgcurveoption.ui @@ -6,8 +6,8 @@ 0 0 - 634 - 444 + 507 + 344 @@ -54,11 +54,189 @@ - - - Enable Pen Settings - - + + + + + + 190 + 0 + + + + Enable Pen Settings + + + + + + + + 24 + 24 + + + + + + + + 16 + 16 + + + + + + + + + 24 + 24 + + + + + + + + 16 + 16 + + + + + + + + + 24 + 24 + + + + + + + + 16 + 16 + + + + + + + + + 24 + 24 + + + + + + + + 16 + 16 + + + + + + + + + 24 + 24 + + + + + + + + 16 + 16 + + + + + + + + + 24 + 24 + + + + + + + + 16 + 16 + + + + + + + + + 24 + 24 + + + + + + + + 16 + 16 + + + + + + + + + 24 + 24 + + + + + + + + 16 + 16 + + + + Ctrl+S + + + + + + + Qt::Horizontal + + + + 2 + 2 + + + + + @@ -72,8 +250,8 @@ - 180 - 360 + 190 + 0 @@ -86,6 +264,32 @@ + + + + Qt::Horizontal + + + + 2 + 2 + + + + + + + + Qt::Vertical + + + + 2 + 2 + + + + @@ -134,15 +338,21 @@ - + 1 0 - 0 - 230 + 220 + 190 + + + + + 16777215 + 16777215 @@ -190,167 +400,17 @@ - - - - Share curve across all settings - - - true - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Vertical + + + + Share curve across all settings - - - 20 - 40 - + + true - - - - - - - - - - - - 16 - 16 - - - - - - - - - - - - 16 - 16 - - - - - - - - - - - - 16 - 16 - - - - - - - - - - - - 16 - 16 - - - - - - - - - - - - 16 - 16 - - - - - - - - - - - - 16 - 16 - - - - - - - - - - - - 16 - 16 - - - - - - - - - - - - 16 - 16 - - - - Ctrl+S - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - + diff --git a/plugins/paintops/libpaintop/forms/wdgpredefinedbrushchooser.ui b/plugins/paintops/libpaintop/forms/wdgpredefinedbrushchooser.ui --- a/plugins/paintops/libpaintop/forms/wdgpredefinedbrushchooser.ui +++ b/plugins/paintops/libpaintop/forms/wdgpredefinedbrushchooser.ui @@ -11,6 +11,21 @@ + + 6 + + + 0 + + + 0 + + + 0 + + + 0 + @@ -19,16 +34,16 @@ 0 - 5 + 0 - 5 + 0 - 5 + 0 - 5 + 0 diff --git a/plugins/paintops/libpaintop/forms/wdgtextbrush.ui b/plugins/paintops/libpaintop/forms/wdgtextbrush.ui --- a/plugins/paintops/libpaintop/forms/wdgtextbrush.ui +++ b/plugins/paintops/libpaintop/forms/wdgtextbrush.ui @@ -6,95 +6,174 @@ 0 0 - 458 - 262 + 381 + 182 - - - - - Text: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 120 - 0 - - - - - 50 - false - false - false - false - - - - The Quick Brown Fox Jumps Over The Lazy Dog - - - - - - - Font: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 350 - 150 - - - - - 350 - 150 - - - - QFrame::StyledPanel - - - -- - - - true - - + + + + + + + + 0 + 0 + + + + Font: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 10 + + + 5 + + + + + + + + 0 + 0 + + + + + 180 + 30 + + + + + 16777 + 40 + + + + QFrame::Box + + + QFrame::Plain + + + 1 + + + -- + + + true + + + 10 + + + + + + + + 0 + 0 + + + + ... + + + + + + + - - - - Spacing: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + + + 10 + + + + + Text: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 50 + false + false + false + false + + + + The Quick Brown Fox Jumps Over The Lazy Dog + + + + + + + + 0 + 0 + + + + Spacing: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + 0 + 0 + + + + use only one letter at a time + + + Pipe mode + + + + - + Qt::Vertical @@ -104,50 +183,20 @@ - 20 - 31 + 30 + 21 - - - - - 0 - 0 - - - - ... - - - - - - - - - - - - - use only one letter at a time - - - Pipe mode - - - + horizontalLayoutWidget + horizontalLayoutWidget + spacer2 + gridLayoutWidget - QLineEdit - QLineEdit -
klineedit.h
-
- KisDoubleSliderSpinBox QWidget
kis_slider_spin_box.h
diff --git a/plugins/paintops/libpaintop/forms/wdgtexturechooser.ui b/plugins/paintops/libpaintop/forms/wdgtexturechooser.ui new file mode 100644 --- /dev/null +++ b/plugins/paintops/libpaintop/forms/wdgtexturechooser.ui @@ -0,0 +1,343 @@ + + + KisWdgTextureChooser + + + + 0 + 0 + 548 + 391 + + + + + 0 + 0 + + + + + + + + 0 + 0 + + + + 1 + + + + Texture + + + + + + + 0 + 0 + + + + QFrame::StyledPanel + + + QFrame::Plain + + + 0 + + + + + + + + Options + + + + + + + + + + + 0 + 0 + + + + Contrast: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + 200 + 0 + + + + + + + + + 0 + 0 + + + + Cutoff + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + Brightness: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 200 + 0 + + + + + + + + + 0 + 0 + + + + Cutoff Policy: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + Texturing Mode: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + Scale: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + PushButton + + + + + + + + + + + + 0 + 0 + + + + Horizontal Offset: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + The border of the brush will be smoothed to avoid aliasing + + + Invert Pattern + + + + + + + + + + Random Offset + + + + + + + + 0 + 0 + + + + Vertical Offset: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + Random Offset + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + verticalLayoutWidget + verticalLayoutWidget + + + + + + + + KisSliderSpinBox + QWidget +
kis_slider_spin_box.h
+ 1 +
+ + KisPatternChooser + QFrame +
kis_pattern_chooser.h
+ 1 +
+ + KisDoubleSliderSpinBox + QWidget +
kis_slider_spin_box.h
+ 1 +
+ + KisGradientSlider + QWidget +
kis_gradient_slider.h
+ 1 +
+ + KisMultipliersDoubleSliderSpinBox + QWidget +
kis_multipliers_double_slider_spinbox.h
+ 1 +
+
+ + +
diff --git a/plugins/paintops/libpaintop/kis_texture_chooser.h b/plugins/paintops/libpaintop/kis_texture_chooser.h new file mode 100644 --- /dev/null +++ b/plugins/paintops/libpaintop/kis_texture_chooser.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017 Scott Petrovic + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef _KIS_TEXTURE_CHOOSER_H_ +#define _KIS_TEXTURE_CHOOSER_H_ + +#include "ui_wdgtexturechooser.h" + +class KisTextureChooser : public QWidget, public Ui::KisWdgTextureChooser +{ + Q_OBJECT + +public: + KisTextureChooser(QWidget *parent = 0); + ~KisTextureChooser(); +}; + +#endif diff --git a/plugins/paintops/libpaintop/kis_texture_chooser.cpp b/plugins/paintops/libpaintop/kis_texture_chooser.cpp new file mode 100644 --- /dev/null +++ b/plugins/paintops/libpaintop/kis_texture_chooser.cpp @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2017 Scott Petrovic + + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "kis_texture_chooser.h" +#include "kis_texture_option.h" + +KisTextureChooser::KisTextureChooser(QWidget *parent) + : QWidget(parent) +{ + setupUi(this); + + textureSelectorWidget->setGrayscalePreview(true); + textureSelectorWidget->setCurrentItem(0, 0); + + scaleSlider->setRange(0.0, 2.0, 2); + scaleSlider->setValue(1.0); + scaleSlider->addMultiplier(0.1); + scaleSlider->addMultiplier(2); + scaleSlider->addMultiplier(10); + + brightnessSlider->setRange(-1.0, 1.0, 2); + brightnessSlider->setValue(0.0); + brightnessSlider->setToolTip(i18n("Makes texture lighter or darker")); + + contrastSlider->setRange(0.0, 2.0, 2); + contrastSlider->setValue(1.0); + + offsetSliderX->setSuffix(i18n(" px")); + + offsetSliderY->setSuffix(i18n(" px")); + + + QStringList texturingModes; + texturingModes << i18n("Multiply") << i18n("Subtract"); + cmbTexturingMode->addItems(texturingModes); + cmbTexturingMode->setCurrentIndex(KisTextureProperties::SUBTRACT); + + QStringList cutOffPolicies; + cutOffPolicies << i18n("Cut Off Disabled") << i18n("Cut Off Brush") << i18n("Cut Off Pattern"); + cmbCutoffPolicy->addItems(cutOffPolicies); + + + cutoffSlider->setMinimumSize(256, 30); + cutoffSlider->enableGamma(false); + cutoffSlider->setToolTip(i18n("When pattern texture values are outside the range specified" + " by the slider, the cut-off policy will be applied.")); + + chkInvert->setChecked(false); +} + +KisTextureChooser::~KisTextureChooser() +{ + +} diff --git a/plugins/paintops/libpaintop/kis_texture_option.h b/plugins/paintops/libpaintop/kis_texture_option.h --- a/plugins/paintops/libpaintop/kis_texture_option.h +++ b/plugins/paintops/libpaintop/kis_texture_option.h @@ -29,6 +29,7 @@ #include +class KisTextureChooser; class KisTextureOptionWidget; class KoPattern; class KoResource; @@ -54,8 +55,8 @@ void resetGUI(KoResource*); /// called when a new pattern is selected private: - KisTextureOptionWidget *m_optionWidget; - + /// UI Widget that stores all the texture options + KisTextureChooser* m_textureOptions; }; diff --git a/plugins/paintops/libpaintop/kis_texture_option.cpp b/plugins/paintops/libpaintop/kis_texture_option.cpp --- a/plugins/paintops/libpaintop/kis_texture_option.cpp +++ b/plugins/paintops/libpaintop/kis_texture_option.cpp @@ -51,150 +51,46 @@ #include "kis_algebra_2d.h" #include "kis_lod_transform.h" #include - - +#include "kis_texture_chooser.h" #include -class KisTextureOptionWidget : public QWidget -{ -public: - - KisTextureOptionWidget(QWidget *parent = 0) - : QWidget(parent) { - QFormLayout *formLayout = new QFormLayout(this); - formLayout->setMargin(0); - - chooser = new KisPatternChooser(this); - chooser->setGrayscalePreview(true); - chooser->setMaximumHeight(250); - chooser->setCurrentItem(0, 0); - formLayout->addRow(chooser); - - scaleSlider = new KisMultipliersDoubleSliderSpinBox(this); - scaleSlider->setRange(0.0, 2.0, 2); - scaleSlider->setValue(1.0); - scaleSlider->addMultiplier(0.1); - scaleSlider->addMultiplier(2); - scaleSlider->addMultiplier(10); - - formLayout->addRow(i18n("Scale:"), scaleSlider); - - brightnessSlider = new KisDoubleSliderSpinBox(this); - brightnessSlider->setRange(-1.0, 1.0, 2); - brightnessSlider->setValue(0.0); - brightnessSlider->setToolTip(i18n("Makes texture lighter or darker")); - brightnessSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - - formLayout->addRow(i18n("Brightness:"), brightnessSlider); - - contrastSlider = new KisDoubleSliderSpinBox(this); - contrastSlider->setRange(0.0, 2.0, 2); - contrastSlider->setValue(1.0); - contrastSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - - formLayout->addRow(i18n("Contrast:"), contrastSlider); - - - QBoxLayout *offsetLayoutX = new QBoxLayout(QBoxLayout::LeftToRight); - offsetSliderX = new KisSliderSpinBox(this); - offsetSliderX->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - offsetSliderX->setSuffix(i18n(" px")); - randomOffsetX = new QCheckBox(i18n("Random Offset"),this); - offsetLayoutX->addWidget(offsetSliderX,1,0); - offsetLayoutX->addWidget(randomOffsetX,0,0); - formLayout->addRow(i18n("Horizontal Offset:"), offsetLayoutX); - - - QBoxLayout *offsetLayoutY = new QBoxLayout(QBoxLayout::LeftToRight); - offsetSliderY = new KisSliderSpinBox(this); - offsetSliderY->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - offsetSliderY->setSuffix(i18n(" px")); - randomOffsetY = new QCheckBox(i18n("Random Offset"),this); - offsetLayoutY->addWidget(offsetSliderY,1,0); - offsetLayoutY->addWidget(randomOffsetY,0,0); - formLayout->addRow(i18n("Vertical Offset:"), offsetLayoutY); - - cmbTexturingMode = new QComboBox(this); - cmbTexturingMode->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - QStringList texturingModes; - texturingModes << i18n("Multiply") << i18n("Subtract"); - cmbTexturingMode->addItems(texturingModes); - formLayout->addRow(i18n("Texturing Mode:"), cmbTexturingMode); - cmbTexturingMode->setCurrentIndex(KisTextureProperties::SUBTRACT); - - cmbCutoffPolicy = new QComboBox(this); - cmbCutoffPolicy->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - QStringList cutOffPolicies; - cutOffPolicies << i18n("Cut Off Disabled") << i18n("Cut Off Brush") << i18n("Cut Off Pattern"); - cmbCutoffPolicy->addItems(cutOffPolicies); - formLayout->addRow(i18n("Cutoff Policy:"), cmbCutoffPolicy); - - cutoffSlider = new KisGradientSlider(this); - cutoffSlider->setMinimumSize(256, 30); - cutoffSlider->enableGamma(false); - cutoffSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - cutoffSlider->setToolTip(i18n("When pattern texture values are outside the range specified" - " by the slider, the cut-off policy will be applied.")); - formLayout->addRow(i18n("Cutoff:"), cutoffSlider); - - chkInvert = new QCheckBox(this); - chkInvert->setChecked(false); - formLayout->addRow(i18n("Invert Pattern:"), chkInvert); - - setLayout(formLayout); - } - KisPatternChooser *chooser; - KisMultipliersDoubleSliderSpinBox *scaleSlider; - KisDoubleSliderSpinBox *brightnessSlider; - KisDoubleSliderSpinBox *contrastSlider; - KisSliderSpinBox *offsetSliderX; - QCheckBox *randomOffsetX; - KisSliderSpinBox *offsetSliderY; - QCheckBox *randomOffsetY; - QComboBox *cmbTexturingMode; - KisGradientSlider *cutoffSlider; - QComboBox *cmbCutoffPolicy; - QCheckBox *chkInvert; -}; KisTextureOption::KisTextureOption() : KisPaintOpOption(KisPaintOpOption::TEXTURE, true) + , m_textureOptions(new KisTextureChooser()) { setObjectName("KisTextureOption"); + setConfigurationPage(m_textureOptions); + + connect(m_textureOptions->textureSelectorWidget, SIGNAL(resourceSelected(KoResource*)), SLOT(resetGUI(KoResource*))); + connect(m_textureOptions->textureSelectorWidget, SIGNAL(resourceSelected(KoResource*)), SLOT(emitSettingChanged())); + connect(m_textureOptions->scaleSlider, SIGNAL(valueChanged(qreal)), SLOT(emitSettingChanged())); + connect(m_textureOptions->brightnessSlider, SIGNAL(valueChanged(qreal)), SLOT(emitSettingChanged())); + connect(m_textureOptions->contrastSlider, SIGNAL(valueChanged(qreal)), SLOT(emitSettingChanged())); + connect(m_textureOptions->offsetSliderX, SIGNAL(valueChanged(int)), SLOT(emitSettingChanged())); + connect(m_textureOptions->randomOffsetX, SIGNAL(toggled(bool)), SLOT(emitSettingChanged())); + connect(m_textureOptions->randomOffsetY, SIGNAL(toggled(bool)), SLOT(emitSettingChanged())); + connect(m_textureOptions->offsetSliderY, SIGNAL(valueChanged(int)), SLOT(emitSettingChanged())); + connect(m_textureOptions->cmbTexturingMode, SIGNAL(currentIndexChanged(int)), SLOT(emitSettingChanged())); + connect(m_textureOptions->cmbCutoffPolicy, SIGNAL(currentIndexChanged(int)), SLOT(emitSettingChanged())); + connect(m_textureOptions->cutoffSlider, SIGNAL(sigModifiedBlack(int)), SLOT(emitSettingChanged())); + connect(m_textureOptions->cutoffSlider, SIGNAL(sigModifiedWhite(int)), SLOT(emitSettingChanged())); + connect(m_textureOptions->chkInvert, SIGNAL(toggled(bool)), SLOT(emitSettingChanged())); + resetGUI(m_textureOptions->textureSelectorWidget->currentResource()); - setChecked(false); - m_optionWidget = new KisTextureOptionWidget; - m_optionWidget->hide(); - setConfigurationPage(m_optionWidget); - - connect(m_optionWidget->chooser, SIGNAL(resourceSelected(KoResource*)), SLOT(resetGUI(KoResource*))); - connect(m_optionWidget->chooser, SIGNAL(resourceSelected(KoResource*)), SLOT(emitSettingChanged())); - connect(m_optionWidget->scaleSlider, SIGNAL(valueChanged(qreal)), SLOT(emitSettingChanged())); - connect(m_optionWidget->brightnessSlider, SIGNAL(valueChanged(qreal)), SLOT(emitSettingChanged())); - connect(m_optionWidget->contrastSlider, SIGNAL(valueChanged(qreal)), SLOT(emitSettingChanged())); - connect(m_optionWidget->offsetSliderX, SIGNAL(valueChanged(int)), SLOT(emitSettingChanged())); - connect(m_optionWidget->randomOffsetX, SIGNAL(toggled(bool)), SLOT(emitSettingChanged())); - connect(m_optionWidget->randomOffsetY, SIGNAL(toggled(bool)), SLOT(emitSettingChanged())); - connect(m_optionWidget->offsetSliderY, SIGNAL(valueChanged(int)), SLOT(emitSettingChanged())); - connect(m_optionWidget->cmbTexturingMode, SIGNAL(currentIndexChanged(int)), SLOT(emitSettingChanged())); - connect(m_optionWidget->cmbCutoffPolicy, SIGNAL(currentIndexChanged(int)), SLOT(emitSettingChanged())); - connect(m_optionWidget->cutoffSlider, SIGNAL(sigModifiedBlack(int)), SLOT(emitSettingChanged())); - connect(m_optionWidget->cutoffSlider, SIGNAL(sigModifiedWhite(int)), SLOT(emitSettingChanged())); - connect(m_optionWidget->chkInvert, SIGNAL(toggled(bool)), SLOT(emitSettingChanged())); - resetGUI(m_optionWidget->chooser->currentResource()); } KisTextureOption::~KisTextureOption() { - delete m_optionWidget; + delete m_textureOptions; } void KisTextureOption::writeOptionSetting(KisPropertiesConfigurationSP setting) const { - m_optionWidget->chooser->blockSignals(true); // Checking - if (!m_optionWidget->chooser->currentResource()) return; - KoPattern *pattern = static_cast(m_optionWidget->chooser->currentResource()); - m_optionWidget->chooser->blockSignals(false); // Checking + m_textureOptions->textureSelectorWidget->blockSignals(true); // Checking + if (!m_textureOptions->textureSelectorWidget->currentResource()) return; + KoPattern *pattern = static_cast(m_textureOptions->textureSelectorWidget->currentResource()); + m_textureOptions->textureSelectorWidget->blockSignals(false); // Checking if (!pattern) return; setting->setProperty("Texture/Pattern/Enabled", isChecked()); @@ -202,38 +98,38 @@ return; } - qreal scale = m_optionWidget->scaleSlider->value(); + qreal scale = m_textureOptions->scaleSlider->value(); - qreal brightness = m_optionWidget->brightnessSlider->value(); + qreal brightness = m_textureOptions->brightnessSlider->value(); - qreal contrast = m_optionWidget->contrastSlider->value(); + qreal contrast = m_textureOptions->contrastSlider->value(); - int offsetX = m_optionWidget->offsetSliderX->value(); - if (m_optionWidget ->randomOffsetX->isChecked()) { + int offsetX = m_textureOptions->offsetSliderX->value(); + if (m_textureOptions ->randomOffsetX->isChecked()) { - m_optionWidget->offsetSliderX ->setEnabled(false); - m_optionWidget->offsetSliderX ->blockSignals(true); - m_optionWidget->offsetSliderX ->setValue(offsetX); - m_optionWidget->offsetSliderX ->blockSignals(false); + m_textureOptions->offsetSliderX ->setEnabled(false); + m_textureOptions->offsetSliderX ->blockSignals(true); + m_textureOptions->offsetSliderX ->setValue(offsetX); + m_textureOptions->offsetSliderX ->blockSignals(false); } else { - m_optionWidget->offsetSliderX ->setEnabled(true); + m_textureOptions->offsetSliderX ->setEnabled(true); } - int offsetY = m_optionWidget->offsetSliderY->value(); - if (m_optionWidget ->randomOffsetY->isChecked()) { + int offsetY = m_textureOptions->offsetSliderY->value(); + if (m_textureOptions ->randomOffsetY->isChecked()) { - m_optionWidget->offsetSliderY ->setEnabled(false); - m_optionWidget->offsetSliderY ->blockSignals(true); - m_optionWidget->offsetSliderY ->setValue(offsetY); - m_optionWidget->offsetSliderY ->blockSignals(false); + m_textureOptions->offsetSliderY ->setEnabled(false); + m_textureOptions->offsetSliderY ->blockSignals(true); + m_textureOptions->offsetSliderY ->setValue(offsetY); + m_textureOptions->offsetSliderY ->blockSignals(false); } else { - m_optionWidget->offsetSliderY ->setEnabled(true); + m_textureOptions->offsetSliderY ->setEnabled(true); } - int texturingMode = m_optionWidget->cmbTexturingMode->currentIndex(); - bool invert = (m_optionWidget->chkInvert->checkState() == Qt::Checked); + int texturingMode = m_textureOptions->cmbTexturingMode->currentIndex(); + bool invert = (m_textureOptions->chkInvert->checkState() == Qt::Checked); setting->setProperty("Texture/Pattern/Scale", scale); setting->setProperty("Texture/Pattern/Brightness", brightness); @@ -241,21 +137,22 @@ setting->setProperty("Texture/Pattern/OffsetX", offsetX); setting->setProperty("Texture/Pattern/OffsetY", offsetY); setting->setProperty("Texture/Pattern/TexturingMode", texturingMode); - setting->setProperty("Texture/Pattern/CutoffLeft", m_optionWidget->cutoffSlider->black()); - setting->setProperty("Texture/Pattern/CutoffRight", m_optionWidget->cutoffSlider->white()); - setting->setProperty("Texture/Pattern/CutoffPolicy", m_optionWidget->cmbCutoffPolicy->currentIndex()); + setting->setProperty("Texture/Pattern/CutoffLeft", m_textureOptions->cutoffSlider->black()); + setting->setProperty("Texture/Pattern/CutoffRight", m_textureOptions->cutoffSlider->white()); + setting->setProperty("Texture/Pattern/CutoffPolicy", m_textureOptions->cmbCutoffPolicy->currentIndex()); setting->setProperty("Texture/Pattern/Invert", invert); - setting->setProperty("Texture/Pattern/MaximumOffsetX",m_optionWidget->offsetSliderX ->maximum()); - setting->setProperty("Texture/Pattern/MaximumOffsetY",m_optionWidget->offsetSliderY ->maximum()); - setting->setProperty("Texture/Pattern/isRandomOffsetX",m_optionWidget ->randomOffsetX ->isChecked()); - setting->setProperty("Texture/Pattern/isRandomOffsetY",m_optionWidget ->randomOffsetY ->isChecked()); + setting->setProperty("Texture/Pattern/MaximumOffsetX",m_textureOptions->offsetSliderX ->maximum()); + setting->setProperty("Texture/Pattern/MaximumOffsetY",m_textureOptions->offsetSliderY ->maximum()); + setting->setProperty("Texture/Pattern/isRandomOffsetX",m_textureOptions ->randomOffsetX ->isChecked()); + setting->setProperty("Texture/Pattern/isRandomOffsetY",m_textureOptions ->randomOffsetY ->isChecked()); KisEmbeddedPatternManager::saveEmbeddedPattern(setting, pattern); } void KisTextureOption::readOptionSetting(const KisPropertiesConfigurationSP setting) { + setChecked(setting->getBool("Texture/Pattern/Enabled")); if (!isChecked()) { return; @@ -263,23 +160,24 @@ KoPattern *pattern = KisEmbeddedPatternManager::loadEmbeddedPattern(setting); if (!pattern) { - pattern = static_cast(m_optionWidget->chooser->currentResource()); + pattern = static_cast(m_textureOptions->textureSelectorWidget->currentResource()); } - m_optionWidget->chooser->setCurrentPattern(pattern); - - m_optionWidget->scaleSlider->setValue(setting->getDouble("Texture/Pattern/Scale", 1.0)); - m_optionWidget->brightnessSlider->setValue(setting->getDouble("Texture/Pattern/Brightness")); - m_optionWidget->contrastSlider->setValue(setting->getDouble("Texture/Pattern/Contrast", 1.0)); - m_optionWidget->offsetSliderX->setValue(setting->getInt("Texture/Pattern/OffsetX")); - m_optionWidget->offsetSliderY->setValue(setting->getInt("Texture/Pattern/OffsetY")); - m_optionWidget->randomOffsetX->setChecked(setting->getBool("Texture/Pattern/isRandomOffsetX")); - m_optionWidget->randomOffsetY->setChecked(setting->getBool("Texture/Pattern/isRandomOffsetY")); - m_optionWidget->cmbTexturingMode->setCurrentIndex(setting->getInt("Texture/Pattern/TexturingMode", KisTextureProperties::MULTIPLY)); - m_optionWidget->cmbCutoffPolicy->setCurrentIndex(setting->getInt("Texture/Pattern/CutoffPolicy")); - m_optionWidget->cutoffSlider->slotModifyBlack(setting->getInt("Texture/Pattern/CutoffLeft", 0)); - m_optionWidget->cutoffSlider->slotModifyWhite(setting->getInt("Texture/Pattern/CutoffRight", 255)); - m_optionWidget->chkInvert->setChecked(setting->getBool("Texture/Pattern/Invert")); + m_textureOptions->textureSelectorWidget->setCurrentPattern(pattern); + + m_textureOptions->scaleSlider->setValue(setting->getDouble("Texture/Pattern/Scale", 1.0)); + m_textureOptions->brightnessSlider->setValue(setting->getDouble("Texture/Pattern/Brightness")); + m_textureOptions->contrastSlider->setValue(setting->getDouble("Texture/Pattern/Contrast", 1.0)); + m_textureOptions->offsetSliderX->setValue(setting->getInt("Texture/Pattern/OffsetX")); + m_textureOptions->offsetSliderY->setValue(setting->getInt("Texture/Pattern/OffsetY")); + m_textureOptions->randomOffsetX->setChecked(setting->getBool("Texture/Pattern/isRandomOffsetX")); + m_textureOptions->randomOffsetY->setChecked(setting->getBool("Texture/Pattern/isRandomOffsetY")); + m_textureOptions->cmbTexturingMode->setCurrentIndex(setting->getInt("Texture/Pattern/TexturingMode", KisTextureProperties::MULTIPLY)); + m_textureOptions->cmbCutoffPolicy->setCurrentIndex(setting->getInt("Texture/Pattern/CutoffPolicy")); + m_textureOptions->cutoffSlider->slotModifyBlack(setting->getInt("Texture/Pattern/CutoffLeft", 0)); + m_textureOptions->cutoffSlider->slotModifyWhite(setting->getInt("Texture/Pattern/CutoffRight", 255)); + m_textureOptions->chkInvert->setChecked(setting->getBool("Texture/Pattern/Invert")); + } void KisTextureOption::lodLimitations(KisPaintopLodLimitations *l) const @@ -293,8 +191,8 @@ KoPattern *pattern = static_cast(res); if (!pattern) return; - m_optionWidget->offsetSliderX->setRange(0, pattern->pattern().width() / 2); - m_optionWidget->offsetSliderY->setRange(0, pattern->pattern().height() / 2); + m_textureOptions->offsetSliderX->setRange(0, pattern->pattern().width() / 2); + m_textureOptions->offsetSliderY->setRange(0, pattern->pattern().height() / 2); } KisTextureProperties::KisTextureProperties(int levelOfDetail) @@ -377,6 +275,7 @@ void KisTextureProperties::fillProperties(const KisPropertiesConfigurationSP setting) { + if (!setting->hasProperty("Texture/Pattern/PatternMD5")) { m_enabled = false; return;